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 | |
| 4117 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 4118 | } |
| 4119 | else |
| 4120 | { |
| 4121 | switch (attachment) |
| 4122 | { |
| 4123 | case GL_DEPTH_ATTACHMENT: |
| 4124 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 4125 | break; |
| 4126 | case GL_STENCIL_ATTACHMENT: |
| 4127 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 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 | |
| 4269 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4270 | } |
| 4271 | else |
| 4272 | { |
| 4273 | switch (attachment) |
| 4274 | { |
Geoff Lang | 55ba29c | 2013-07-11 16:57:53 -0400 | [diff] [blame] | 4275 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4276 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4277 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture); 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; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5050 | |
| 5051 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5052 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5053 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 5054 | |
| 5055 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 5056 | { |
| 5057 | return gl::error(GL_INVALID_ENUM); |
| 5058 | } |
| 5059 | |
| 5060 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 5061 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 5062 | } |
| 5063 | else |
| 5064 | { |
| 5065 | switch (attachment) |
| 5066 | { |
| 5067 | case GL_DEPTH_ATTACHMENT: |
| 5068 | attachmentType = framebuffer->getDepthbufferType(); |
| 5069 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 5070 | break; |
| 5071 | case GL_STENCIL_ATTACHMENT: |
| 5072 | attachmentType = framebuffer->getStencilbufferType(); |
| 5073 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 5074 | break; |
Geoff Lang | 55ba29c | 2013-07-11 16:57:53 -0400 | [diff] [blame] | 5075 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 5076 | if (context->getClientVersion() < 3) |
| 5077 | { |
| 5078 | return gl::error(GL_INVALID_ENUM); |
| 5079 | } |
| 5080 | if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle()) |
| 5081 | { |
| 5082 | return gl::error(GL_INVALID_OPERATION); |
| 5083 | } |
| 5084 | attachmentType = framebuffer->getDepthStencilbufferType(); |
| 5085 | attachmentHandle = framebuffer->getDepthStencilbufferHandle(); |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 5086 | default: return gl::error(GL_INVALID_ENUM); |
| 5087 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5088 | } |
| 5089 | |
| 5090 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 5091 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5092 | { |
| 5093 | attachmentObjectType = attachmentType; |
| 5094 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 5095 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5096 | { |
| 5097 | attachmentObjectType = GL_TEXTURE; |
| 5098 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 5099 | else |
| 5100 | { |
| 5101 | UNREACHABLE(); |
| 5102 | return; |
| 5103 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5104 | |
| 5105 | switch (pname) |
| 5106 | { |
| 5107 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 5108 | *params = attachmentObjectType; |
| 5109 | break; |
| 5110 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 5111 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 5112 | { |
| 5113 | *params = attachmentHandle; |
| 5114 | } |
| 5115 | else |
| 5116 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5117 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5118 | } |
| 5119 | break; |
| 5120 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 5121 | if (attachmentObjectType == GL_TEXTURE) |
| 5122 | { |
| 5123 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 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_CUBE_MAP_FACE: |
| 5131 | if (attachmentObjectType == GL_TEXTURE) |
| 5132 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 5133 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5134 | { |
| 5135 | *params = attachmentType; |
| 5136 | } |
| 5137 | else |
| 5138 | { |
| 5139 | *params = 0; |
| 5140 | } |
| 5141 | } |
| 5142 | else |
| 5143 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5144 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5145 | } |
| 5146 | break; |
| 5147 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5148 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 5149 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5150 | } |
| 5151 | } |
| 5152 | catch(std::bad_alloc&) |
| 5153 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5154 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5155 | } |
| 5156 | } |
| 5157 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 5158 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 5159 | { |
| 5160 | EVENT("()"); |
| 5161 | |
| 5162 | try |
| 5163 | { |
| 5164 | gl::Context *context = gl::getContext(); |
| 5165 | |
| 5166 | if (context) |
| 5167 | { |
| 5168 | return context->getResetStatus(); |
| 5169 | } |
| 5170 | |
| 5171 | return GL_NO_ERROR; |
| 5172 | } |
| 5173 | catch(std::bad_alloc&) |
| 5174 | { |
| 5175 | return GL_OUT_OF_MEMORY; |
| 5176 | } |
| 5177 | } |
| 5178 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5179 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 5180 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5181 | 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] | 5182 | |
| 5183 | try |
| 5184 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5185 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5186 | |
| 5187 | if (context) |
| 5188 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5189 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5190 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5191 | GLenum nativeType; |
| 5192 | unsigned int numParams = 0; |
| 5193 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5194 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5195 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5196 | if (numParams == 0) |
| 5197 | return; // it is known that pname is valid, but there are no parameters to return |
| 5198 | |
| 5199 | if (nativeType == GL_BOOL) |
| 5200 | { |
| 5201 | GLboolean *boolParams = NULL; |
| 5202 | boolParams = new GLboolean[numParams]; |
| 5203 | |
| 5204 | context->getBooleanv(pname, boolParams); |
| 5205 | |
| 5206 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5207 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5208 | if (boolParams[i] == GL_FALSE) |
| 5209 | params[i] = 0; |
| 5210 | else |
| 5211 | params[i] = 1; |
| 5212 | } |
| 5213 | |
| 5214 | delete [] boolParams; |
| 5215 | } |
| 5216 | else if (nativeType == GL_FLOAT) |
| 5217 | { |
| 5218 | GLfloat *floatParams = NULL; |
| 5219 | floatParams = new GLfloat[numParams]; |
| 5220 | |
| 5221 | context->getFloatv(pname, floatParams); |
| 5222 | |
| 5223 | for (unsigned int i = 0; i < numParams; ++i) |
| 5224 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5225 | // 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] | 5226 | 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] | 5227 | { |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5228 | 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] | 5229 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5230 | else |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5231 | { |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 5232 | params[i] = gl::iround<GLint>(floatParams[i]); |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5233 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5234 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5235 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 5236 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5237 | } |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 5238 | else if (nativeType == GL_INT_64_ANGLEX) |
| 5239 | { |
| 5240 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 5241 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 5242 | GLint64 *int64Params = NULL; |
| 5243 | int64Params = new GLint64[numParams]; |
| 5244 | |
| 5245 | context->getInteger64v(pname, int64Params); |
| 5246 | |
| 5247 | for (unsigned int i = 0; i < numParams; ++i) |
| 5248 | { |
| 5249 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 5250 | params[i] = static_cast<GLint>(clampedValue); |
| 5251 | } |
| 5252 | |
| 5253 | delete [] int64Params; |
| 5254 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5255 | } |
| 5256 | } |
| 5257 | } |
| 5258 | catch(std::bad_alloc&) |
| 5259 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5260 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5261 | } |
| 5262 | } |
| 5263 | |
| 5264 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 5265 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5266 | 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] | 5267 | |
| 5268 | try |
| 5269 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5270 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5271 | |
| 5272 | if (context) |
| 5273 | { |
| 5274 | gl::Program *programObject = context->getProgram(program); |
| 5275 | |
| 5276 | if (!programObject) |
| 5277 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5278 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5279 | } |
| 5280 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5281 | if (context->getClientVersion() < 3) |
| 5282 | { |
| 5283 | switch (pname) |
| 5284 | { |
| 5285 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5286 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5287 | return gl::error(GL_INVALID_ENUM); |
| 5288 | } |
| 5289 | } |
| 5290 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5291 | switch (pname) |
| 5292 | { |
| 5293 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5294 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5295 | return; |
| 5296 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5297 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5298 | return; |
| 5299 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5300 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5301 | return; |
| 5302 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5303 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5304 | return; |
| 5305 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5306 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5307 | return; |
| 5308 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5309 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5310 | return; |
| 5311 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5312 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5313 | return; |
| 5314 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5315 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5316 | return; |
| 5317 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5318 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5319 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5320 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5321 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5322 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5323 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5324 | *params = programObject->getActiveUniformBlockCount(); |
| 5325 | return; |
| 5326 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5327 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5328 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5329 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5330 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5331 | } |
| 5332 | } |
| 5333 | } |
| 5334 | catch(std::bad_alloc&) |
| 5335 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5336 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5337 | } |
| 5338 | } |
| 5339 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5340 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5341 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5342 | 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] | 5343 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5344 | |
| 5345 | try |
| 5346 | { |
| 5347 | if (bufsize < 0) |
| 5348 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5349 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5350 | } |
| 5351 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5352 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5353 | |
| 5354 | if (context) |
| 5355 | { |
| 5356 | gl::Program *programObject = context->getProgram(program); |
| 5357 | |
| 5358 | if (!programObject) |
| 5359 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5360 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5361 | } |
| 5362 | |
| 5363 | programObject->getInfoLog(bufsize, length, infolog); |
| 5364 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5365 | } |
| 5366 | catch(std::bad_alloc&) |
| 5367 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5368 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5369 | } |
| 5370 | } |
| 5371 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5372 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5373 | { |
| 5374 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5375 | |
| 5376 | try |
| 5377 | { |
| 5378 | switch (pname) |
| 5379 | { |
| 5380 | case GL_CURRENT_QUERY_EXT: |
| 5381 | break; |
| 5382 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5383 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5384 | } |
| 5385 | |
| 5386 | gl::Context *context = gl::getNonLostContext(); |
| 5387 | |
| 5388 | if (context) |
| 5389 | { |
| 5390 | params[0] = context->getActiveQuery(target); |
| 5391 | } |
| 5392 | } |
| 5393 | catch(std::bad_alloc&) |
| 5394 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5395 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5396 | } |
| 5397 | } |
| 5398 | |
| 5399 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5400 | { |
| 5401 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5402 | |
| 5403 | try |
| 5404 | { |
| 5405 | switch (pname) |
| 5406 | { |
| 5407 | case GL_QUERY_RESULT_EXT: |
| 5408 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5409 | break; |
| 5410 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5411 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5412 | } |
| 5413 | gl::Context *context = gl::getNonLostContext(); |
| 5414 | |
| 5415 | if (context) |
| 5416 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5417 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5418 | |
| 5419 | if (!queryObject) |
| 5420 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5421 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5422 | } |
| 5423 | |
| 5424 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5425 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5426 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5427 | } |
| 5428 | |
| 5429 | switch(pname) |
| 5430 | { |
| 5431 | case GL_QUERY_RESULT_EXT: |
| 5432 | params[0] = queryObject->getResult(); |
| 5433 | break; |
| 5434 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5435 | params[0] = queryObject->isResultAvailable(); |
| 5436 | break; |
| 5437 | default: |
| 5438 | ASSERT(false); |
| 5439 | } |
| 5440 | } |
| 5441 | } |
| 5442 | catch(std::bad_alloc&) |
| 5443 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5444 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5445 | } |
| 5446 | } |
| 5447 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5448 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5449 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5450 | 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] | 5451 | |
| 5452 | try |
| 5453 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5454 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5455 | |
| 5456 | if (context) |
| 5457 | { |
| 5458 | if (target != GL_RENDERBUFFER) |
| 5459 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5460 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5461 | } |
| 5462 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5463 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5464 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5465 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5466 | } |
| 5467 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5468 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5469 | |
| 5470 | switch (pname) |
| 5471 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5472 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5473 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5474 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5475 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5476 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5477 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5478 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5479 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5480 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5481 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5482 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5483 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5484 | *params = renderbuffer->getSamples(); |
| 5485 | } |
| 5486 | else |
| 5487 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5488 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5489 | } |
| 5490 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5491 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5492 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5493 | } |
| 5494 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5495 | } |
| 5496 | catch(std::bad_alloc&) |
| 5497 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5498 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5499 | } |
| 5500 | } |
| 5501 | |
| 5502 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5503 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5504 | 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] | 5505 | |
| 5506 | try |
| 5507 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5508 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5509 | |
| 5510 | if (context) |
| 5511 | { |
| 5512 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5513 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5514 | if (!shaderObject) |
| 5515 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5516 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5517 | } |
| 5518 | |
| 5519 | switch (pname) |
| 5520 | { |
| 5521 | case GL_SHADER_TYPE: |
| 5522 | *params = shaderObject->getType(); |
| 5523 | return; |
| 5524 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5525 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5526 | return; |
| 5527 | case GL_COMPILE_STATUS: |
| 5528 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5529 | return; |
| 5530 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5531 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5532 | return; |
| 5533 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5534 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5535 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5536 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5537 | *params = shaderObject->getTranslatedSourceLength(); |
| 5538 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5539 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5540 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5541 | } |
| 5542 | } |
| 5543 | } |
| 5544 | catch(std::bad_alloc&) |
| 5545 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5546 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5547 | } |
| 5548 | } |
| 5549 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5550 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5551 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5552 | 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] | 5553 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5554 | |
| 5555 | try |
| 5556 | { |
| 5557 | if (bufsize < 0) |
| 5558 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5559 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5560 | } |
| 5561 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5562 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5563 | |
| 5564 | if (context) |
| 5565 | { |
| 5566 | gl::Shader *shaderObject = context->getShader(shader); |
| 5567 | |
| 5568 | if (!shaderObject) |
| 5569 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5570 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5571 | } |
| 5572 | |
| 5573 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5574 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5575 | } |
| 5576 | catch(std::bad_alloc&) |
| 5577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5578 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5579 | } |
| 5580 | } |
| 5581 | |
| 5582 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5583 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5584 | 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] | 5585 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5586 | |
| 5587 | try |
| 5588 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5589 | switch (shadertype) |
| 5590 | { |
| 5591 | case GL_VERTEX_SHADER: |
| 5592 | case GL_FRAGMENT_SHADER: |
| 5593 | break; |
| 5594 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5595 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5596 | } |
| 5597 | |
| 5598 | switch (precisiontype) |
| 5599 | { |
| 5600 | case GL_LOW_FLOAT: |
| 5601 | case GL_MEDIUM_FLOAT: |
| 5602 | case GL_HIGH_FLOAT: |
| 5603 | // Assume IEEE 754 precision |
| 5604 | range[0] = 127; |
| 5605 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5606 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5607 | break; |
| 5608 | case GL_LOW_INT: |
| 5609 | case GL_MEDIUM_INT: |
| 5610 | case GL_HIGH_INT: |
| 5611 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5612 | // which can accurately represent integers up to +/-16777216 |
| 5613 | range[0] = 24; |
| 5614 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5615 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5616 | break; |
| 5617 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5618 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5619 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5620 | } |
| 5621 | catch(std::bad_alloc&) |
| 5622 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5623 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5624 | } |
| 5625 | } |
| 5626 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5627 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5628 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5629 | 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] | 5630 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5631 | |
| 5632 | try |
| 5633 | { |
| 5634 | if (bufsize < 0) |
| 5635 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5636 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5637 | } |
| 5638 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5639 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5640 | |
| 5641 | if (context) |
| 5642 | { |
| 5643 | gl::Shader *shaderObject = context->getShader(shader); |
| 5644 | |
| 5645 | if (!shaderObject) |
| 5646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5647 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5648 | } |
| 5649 | |
| 5650 | shaderObject->getSource(bufsize, length, source); |
| 5651 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5652 | } |
| 5653 | catch(std::bad_alloc&) |
| 5654 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5655 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5656 | } |
| 5657 | } |
| 5658 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5659 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5660 | { |
| 5661 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5662 | shader, bufsize, length, source); |
| 5663 | |
| 5664 | try |
| 5665 | { |
| 5666 | if (bufsize < 0) |
| 5667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5668 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5669 | } |
| 5670 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5671 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5672 | |
| 5673 | if (context) |
| 5674 | { |
| 5675 | gl::Shader *shaderObject = context->getShader(shader); |
| 5676 | |
| 5677 | if (!shaderObject) |
| 5678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5679 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5680 | } |
| 5681 | |
| 5682 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 5683 | } |
| 5684 | } |
| 5685 | catch(std::bad_alloc&) |
| 5686 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5687 | return gl::error(GL_OUT_OF_MEMORY); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5688 | } |
| 5689 | } |
| 5690 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5691 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5692 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5693 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5694 | |
| 5695 | try |
| 5696 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5697 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5698 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5699 | switch (name) |
| 5700 | { |
| 5701 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5702 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5703 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5704 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5705 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5706 | if (context->getClientVersion() == 2) |
| 5707 | { |
| 5708 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5709 | } |
| 5710 | else |
| 5711 | { |
| 5712 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5713 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5714 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5715 | if (context->getClientVersion() == 2) |
| 5716 | { |
| 5717 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5718 | } |
| 5719 | else |
| 5720 | { |
| 5721 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5722 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5723 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5724 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5725 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5726 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5727 | } |
| 5728 | } |
| 5729 | catch(std::bad_alloc&) |
| 5730 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5731 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5732 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5733 | } |
| 5734 | |
| 5735 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5736 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5737 | 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] | 5738 | |
| 5739 | try |
| 5740 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5741 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5742 | |
| 5743 | if (context) |
| 5744 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5745 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5746 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5747 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5748 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5749 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5750 | } |
| 5751 | |
| 5752 | switch (pname) |
| 5753 | { |
| 5754 | case GL_TEXTURE_MAG_FILTER: |
| 5755 | *params = (GLfloat)texture->getMagFilter(); |
| 5756 | break; |
| 5757 | case GL_TEXTURE_MIN_FILTER: |
| 5758 | *params = (GLfloat)texture->getMinFilter(); |
| 5759 | break; |
| 5760 | case GL_TEXTURE_WRAP_S: |
| 5761 | *params = (GLfloat)texture->getWrapS(); |
| 5762 | break; |
| 5763 | case GL_TEXTURE_WRAP_T: |
| 5764 | *params = (GLfloat)texture->getWrapT(); |
| 5765 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5766 | case GL_TEXTURE_WRAP_R: |
| 5767 | if (context->getClientVersion() < 3) |
| 5768 | { |
| 5769 | return gl::error(GL_INVALID_ENUM); |
| 5770 | } |
| 5771 | *params = (GLfloat)texture->getWrapR(); |
| 5772 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5773 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5774 | // 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] | 5775 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5776 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5777 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5778 | if (context->getClientVersion() < 3) |
| 5779 | { |
| 5780 | return gl::error(GL_INVALID_ENUM); |
| 5781 | } |
| 5782 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5783 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5784 | case GL_TEXTURE_USAGE_ANGLE: |
| 5785 | *params = (GLfloat)texture->getUsage(); |
| 5786 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5787 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5788 | if (!context->supportsTextureFilterAnisotropy()) |
| 5789 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5790 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5791 | } |
| 5792 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5793 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5794 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5795 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5796 | } |
| 5797 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5798 | } |
| 5799 | catch(std::bad_alloc&) |
| 5800 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5801 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5802 | } |
| 5803 | } |
| 5804 | |
| 5805 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5806 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5807 | 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] | 5808 | |
| 5809 | try |
| 5810 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5811 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5812 | |
| 5813 | if (context) |
| 5814 | { |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5815 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5816 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 5817 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5818 | { |
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 | |
| 5822 | switch (pname) |
| 5823 | { |
| 5824 | case GL_TEXTURE_MAG_FILTER: |
| 5825 | *params = texture->getMagFilter(); |
| 5826 | break; |
| 5827 | case GL_TEXTURE_MIN_FILTER: |
| 5828 | *params = texture->getMinFilter(); |
| 5829 | break; |
| 5830 | case GL_TEXTURE_WRAP_S: |
| 5831 | *params = texture->getWrapS(); |
| 5832 | break; |
| 5833 | case GL_TEXTURE_WRAP_T: |
| 5834 | *params = texture->getWrapT(); |
| 5835 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5836 | case GL_TEXTURE_WRAP_R: |
| 5837 | if (context->getClientVersion() < 3) |
| 5838 | { |
| 5839 | return gl::error(GL_INVALID_ENUM); |
| 5840 | } |
| 5841 | *params = texture->getWrapR(); |
| 5842 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5843 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5844 | // 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] | 5845 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5846 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5847 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5848 | if (context->getClientVersion() < 3) |
| 5849 | { |
| 5850 | return gl::error(GL_INVALID_ENUM); |
| 5851 | } |
| 5852 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5853 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5854 | case GL_TEXTURE_USAGE_ANGLE: |
| 5855 | *params = texture->getUsage(); |
| 5856 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5857 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5858 | if (!context->supportsTextureFilterAnisotropy()) |
| 5859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5860 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5861 | } |
| 5862 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5863 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5864 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5865 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5866 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5867 | } |
| 5868 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5869 | } |
| 5870 | catch(std::bad_alloc&) |
| 5871 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5872 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5873 | } |
| 5874 | } |
| 5875 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5876 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5877 | { |
| 5878 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5879 | program, location, bufSize, params); |
| 5880 | |
| 5881 | try |
| 5882 | { |
| 5883 | if (bufSize < 0) |
| 5884 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5885 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5886 | } |
| 5887 | |
| 5888 | gl::Context *context = gl::getNonLostContext(); |
| 5889 | |
| 5890 | if (context) |
| 5891 | { |
| 5892 | if (program == 0) |
| 5893 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5894 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5895 | } |
| 5896 | |
| 5897 | gl::Program *programObject = context->getProgram(program); |
| 5898 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5899 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5900 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5901 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5902 | } |
| 5903 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5904 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5905 | if (!programBinary) |
| 5906 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5907 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5908 | } |
| 5909 | |
| 5910 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5911 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5912 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5913 | } |
| 5914 | } |
| 5915 | } |
| 5916 | catch(std::bad_alloc&) |
| 5917 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5918 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5919 | } |
| 5920 | } |
| 5921 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5922 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5923 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5924 | 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] | 5925 | |
| 5926 | try |
| 5927 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5928 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5929 | |
| 5930 | if (context) |
| 5931 | { |
| 5932 | if (program == 0) |
| 5933 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5934 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5935 | } |
| 5936 | |
| 5937 | gl::Program *programObject = context->getProgram(program); |
| 5938 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5939 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5940 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5941 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5942 | } |
| 5943 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5944 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5945 | if (!programBinary) |
| 5946 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5947 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5948 | } |
| 5949 | |
| 5950 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5951 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5952 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5953 | } |
| 5954 | } |
| 5955 | } |
| 5956 | catch(std::bad_alloc&) |
| 5957 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5958 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5959 | } |
| 5960 | } |
| 5961 | |
| 5962 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5963 | { |
| 5964 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5965 | program, location, bufSize, params); |
| 5966 | |
| 5967 | try |
| 5968 | { |
| 5969 | if (bufSize < 0) |
| 5970 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5971 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5972 | } |
| 5973 | |
| 5974 | gl::Context *context = gl::getNonLostContext(); |
| 5975 | |
| 5976 | if (context) |
| 5977 | { |
| 5978 | if (program == 0) |
| 5979 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5980 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5981 | } |
| 5982 | |
| 5983 | gl::Program *programObject = context->getProgram(program); |
| 5984 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5985 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5987 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5988 | } |
| 5989 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5990 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5991 | if (!programBinary) |
| 5992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5993 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5994 | } |
| 5995 | |
| 5996 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5997 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5998 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5999 | } |
| 6000 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6001 | } |
| 6002 | catch(std::bad_alloc&) |
| 6003 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6004 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6005 | } |
| 6006 | } |
| 6007 | |
| 6008 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 6009 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6010 | 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] | 6011 | |
| 6012 | try |
| 6013 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6014 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6015 | |
| 6016 | if (context) |
| 6017 | { |
| 6018 | if (program == 0) |
| 6019 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6020 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6021 | } |
| 6022 | |
| 6023 | gl::Program *programObject = context->getProgram(program); |
| 6024 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6025 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6026 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6027 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6028 | } |
| 6029 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6030 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6031 | if (!programBinary) |
| 6032 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6033 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6034 | } |
| 6035 | |
| 6036 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6037 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6038 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 6039 | } |
| 6040 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6041 | } |
| 6042 | catch(std::bad_alloc&) |
| 6043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6044 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6045 | } |
| 6046 | } |
| 6047 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6048 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6049 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6050 | 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] | 6051 | |
| 6052 | try |
| 6053 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6054 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6055 | |
| 6056 | if (strstr(name, "gl_") == name) |
| 6057 | { |
| 6058 | return -1; |
| 6059 | } |
| 6060 | |
| 6061 | if (context) |
| 6062 | { |
| 6063 | gl::Program *programObject = context->getProgram(program); |
| 6064 | |
| 6065 | if (!programObject) |
| 6066 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6067 | if (context->getShader(program)) |
| 6068 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6069 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6070 | } |
| 6071 | else |
| 6072 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6073 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 6074 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6075 | } |
| 6076 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6077 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 6078 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6079 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6080 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6081 | } |
| 6082 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 6083 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6084 | } |
| 6085 | } |
| 6086 | catch(std::bad_alloc&) |
| 6087 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6088 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6089 | } |
| 6090 | |
| 6091 | return -1; |
| 6092 | } |
| 6093 | |
| 6094 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 6095 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6096 | 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] | 6097 | |
| 6098 | try |
| 6099 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6100 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6101 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6102 | if (context) |
| 6103 | { |
| 6104 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6105 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6106 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6107 | } |
| 6108 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6109 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6110 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6111 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6112 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6113 | return; |
| 6114 | } |
| 6115 | |
| 6116 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6117 | { |
| 6118 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6119 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6120 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6121 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6122 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6123 | } |
| 6124 | else |
| 6125 | { |
| 6126 | *params = attribState.querySingleParameter<GLfloat>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6127 | } |
| 6128 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6129 | } |
| 6130 | catch(std::bad_alloc&) |
| 6131 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6132 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6133 | } |
| 6134 | } |
| 6135 | |
| 6136 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 6137 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6138 | 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] | 6139 | |
| 6140 | try |
| 6141 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6142 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6143 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6144 | if (context) |
| 6145 | { |
| 6146 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6147 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6148 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6149 | } |
| 6150 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 6151 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6152 | |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6153 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6154 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6155 | return; |
| 6156 | } |
| 6157 | |
| 6158 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6159 | { |
| 6160 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 6161 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6162 | { |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6163 | float currentValue = currentValueData.FloatValues[i]; |
Jamie Madill | af49691 | 2013-07-19 16:36:54 -0400 | [diff] [blame] | 6164 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6165 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 6166 | } |
| 6167 | else |
| 6168 | { |
| 6169 | *params = attribState.querySingleParameter<GLint>(pname); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6170 | } |
| 6171 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6172 | } |
| 6173 | catch(std::bad_alloc&) |
| 6174 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6175 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6176 | } |
| 6177 | } |
| 6178 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6179 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6180 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6181 | 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] | 6182 | |
| 6183 | try |
| 6184 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6185 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6186 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6187 | if (context) |
| 6188 | { |
| 6189 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6190 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6191 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6192 | } |
| 6193 | |
| 6194 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 6195 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6196 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6197 | } |
| 6198 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6199 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 6200 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6201 | } |
| 6202 | catch(std::bad_alloc&) |
| 6203 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6204 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6205 | } |
| 6206 | } |
| 6207 | |
| 6208 | void __stdcall glHint(GLenum target, GLenum mode) |
| 6209 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6210 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6211 | |
| 6212 | try |
| 6213 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6214 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6215 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6216 | case GL_FASTEST: |
| 6217 | case GL_NICEST: |
| 6218 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6219 | break; |
| 6220 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6221 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6222 | } |
| 6223 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6224 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6225 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6226 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6227 | case GL_GENERATE_MIPMAP_HINT: |
| 6228 | if (context) context->setGenerateMipmapHint(mode); |
| 6229 | break; |
| 6230 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6231 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6232 | break; |
| 6233 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6234 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6235 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6236 | } |
| 6237 | catch(std::bad_alloc&) |
| 6238 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6239 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6240 | } |
| 6241 | } |
| 6242 | |
| 6243 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6244 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6245 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6246 | |
| 6247 | try |
| 6248 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6249 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6250 | |
| 6251 | if (context && buffer) |
| 6252 | { |
| 6253 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6254 | |
| 6255 | if (bufferObject) |
| 6256 | { |
| 6257 | return GL_TRUE; |
| 6258 | } |
| 6259 | } |
| 6260 | } |
| 6261 | catch(std::bad_alloc&) |
| 6262 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6263 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6264 | } |
| 6265 | |
| 6266 | return GL_FALSE; |
| 6267 | } |
| 6268 | |
| 6269 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6270 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6271 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6272 | |
| 6273 | try |
| 6274 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6275 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6276 | |
| 6277 | if (context) |
| 6278 | { |
| 6279 | switch (cap) |
| 6280 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6281 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6282 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6283 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6284 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6285 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6286 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6287 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6288 | case GL_BLEND: return context->isBlendEnabled(); |
| 6289 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6290 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6291 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6292 | } |
| 6293 | } |
| 6294 | } |
| 6295 | catch(std::bad_alloc&) |
| 6296 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6297 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6298 | } |
| 6299 | |
| 6300 | return false; |
| 6301 | } |
| 6302 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6303 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6304 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6305 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6306 | |
| 6307 | try |
| 6308 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6309 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6310 | |
| 6311 | if (context) |
| 6312 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 6313 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6314 | |
| 6315 | if (fenceObject == NULL) |
| 6316 | { |
| 6317 | return GL_FALSE; |
| 6318 | } |
| 6319 | |
| 6320 | return fenceObject->isFence(); |
| 6321 | } |
| 6322 | } |
| 6323 | catch(std::bad_alloc&) |
| 6324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6325 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6326 | } |
| 6327 | |
| 6328 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6329 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6330 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6331 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6332 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6333 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6334 | |
| 6335 | try |
| 6336 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6337 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6338 | |
| 6339 | if (context && framebuffer) |
| 6340 | { |
| 6341 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6342 | |
| 6343 | if (framebufferObject) |
| 6344 | { |
| 6345 | return GL_TRUE; |
| 6346 | } |
| 6347 | } |
| 6348 | } |
| 6349 | catch(std::bad_alloc&) |
| 6350 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6351 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6352 | } |
| 6353 | |
| 6354 | return GL_FALSE; |
| 6355 | } |
| 6356 | |
| 6357 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6358 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6359 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6360 | |
| 6361 | try |
| 6362 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6363 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6364 | |
| 6365 | if (context && program) |
| 6366 | { |
| 6367 | gl::Program *programObject = context->getProgram(program); |
| 6368 | |
| 6369 | if (programObject) |
| 6370 | { |
| 6371 | return GL_TRUE; |
| 6372 | } |
| 6373 | } |
| 6374 | } |
| 6375 | catch(std::bad_alloc&) |
| 6376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6377 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6378 | } |
| 6379 | |
| 6380 | return GL_FALSE; |
| 6381 | } |
| 6382 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6383 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6384 | { |
| 6385 | EVENT("(GLuint id = %d)", id); |
| 6386 | |
| 6387 | try |
| 6388 | { |
| 6389 | if (id == 0) |
| 6390 | { |
| 6391 | return GL_FALSE; |
| 6392 | } |
| 6393 | |
| 6394 | gl::Context *context = gl::getNonLostContext(); |
| 6395 | |
| 6396 | if (context) |
| 6397 | { |
| 6398 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6399 | |
| 6400 | if (queryObject) |
| 6401 | { |
| 6402 | return GL_TRUE; |
| 6403 | } |
| 6404 | } |
| 6405 | } |
| 6406 | catch(std::bad_alloc&) |
| 6407 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6408 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6409 | } |
| 6410 | |
| 6411 | return GL_FALSE; |
| 6412 | } |
| 6413 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6414 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6415 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6416 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6417 | |
| 6418 | try |
| 6419 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6420 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6421 | |
| 6422 | if (context && renderbuffer) |
| 6423 | { |
| 6424 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6425 | |
| 6426 | if (renderbufferObject) |
| 6427 | { |
| 6428 | return GL_TRUE; |
| 6429 | } |
| 6430 | } |
| 6431 | } |
| 6432 | catch(std::bad_alloc&) |
| 6433 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6434 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6435 | } |
| 6436 | |
| 6437 | return GL_FALSE; |
| 6438 | } |
| 6439 | |
| 6440 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6441 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6442 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6443 | |
| 6444 | try |
| 6445 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6446 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6447 | |
| 6448 | if (context && shader) |
| 6449 | { |
| 6450 | gl::Shader *shaderObject = context->getShader(shader); |
| 6451 | |
| 6452 | if (shaderObject) |
| 6453 | { |
| 6454 | return GL_TRUE; |
| 6455 | } |
| 6456 | } |
| 6457 | } |
| 6458 | catch(std::bad_alloc&) |
| 6459 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6460 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6461 | } |
| 6462 | |
| 6463 | return GL_FALSE; |
| 6464 | } |
| 6465 | |
| 6466 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6467 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6468 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6469 | |
| 6470 | try |
| 6471 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6472 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6473 | |
| 6474 | if (context && texture) |
| 6475 | { |
| 6476 | gl::Texture *textureObject = context->getTexture(texture); |
| 6477 | |
| 6478 | if (textureObject) |
| 6479 | { |
| 6480 | return GL_TRUE; |
| 6481 | } |
| 6482 | } |
| 6483 | } |
| 6484 | catch(std::bad_alloc&) |
| 6485 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6486 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6487 | } |
| 6488 | |
| 6489 | return GL_FALSE; |
| 6490 | } |
| 6491 | |
| 6492 | void __stdcall glLineWidth(GLfloat width) |
| 6493 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6494 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6495 | |
| 6496 | try |
| 6497 | { |
| 6498 | if (width <= 0.0f) |
| 6499 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6500 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6501 | } |
| 6502 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6503 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6504 | |
| 6505 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6506 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6507 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6508 | } |
| 6509 | } |
| 6510 | catch(std::bad_alloc&) |
| 6511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6512 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6513 | } |
| 6514 | } |
| 6515 | |
| 6516 | void __stdcall glLinkProgram(GLuint program) |
| 6517 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6518 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6519 | |
| 6520 | try |
| 6521 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6522 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6523 | |
| 6524 | if (context) |
| 6525 | { |
| 6526 | gl::Program *programObject = context->getProgram(program); |
| 6527 | |
| 6528 | if (!programObject) |
| 6529 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6530 | if (context->getShader(program)) |
| 6531 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6532 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6533 | } |
| 6534 | else |
| 6535 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6536 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6537 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6538 | } |
| 6539 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6540 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6541 | } |
| 6542 | } |
| 6543 | catch(std::bad_alloc&) |
| 6544 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6545 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6546 | } |
| 6547 | } |
| 6548 | |
| 6549 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6550 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6551 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6552 | |
| 6553 | try |
| 6554 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6555 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6556 | |
| 6557 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6558 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6559 | switch (pname) |
| 6560 | { |
| 6561 | case GL_UNPACK_ALIGNMENT: |
| 6562 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6563 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6564 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6565 | } |
| 6566 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6567 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6568 | break; |
| 6569 | |
| 6570 | case GL_PACK_ALIGNMENT: |
| 6571 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6572 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6573 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6574 | } |
| 6575 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6576 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6577 | break; |
| 6578 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6579 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6580 | context->setPackReverseRowOrder(param != 0); |
| 6581 | break; |
| 6582 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6583 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6584 | case GL_UNPACK_SKIP_IMAGES: |
| 6585 | case GL_UNPACK_ROW_LENGTH: |
| 6586 | case GL_UNPACK_SKIP_ROWS: |
| 6587 | case GL_UNPACK_SKIP_PIXELS: |
| 6588 | case GL_PACK_ROW_LENGTH: |
| 6589 | case GL_PACK_SKIP_ROWS: |
| 6590 | case GL_PACK_SKIP_PIXELS: |
| 6591 | if (context->getClientVersion() < 3) |
| 6592 | { |
| 6593 | return gl::error(GL_INVALID_ENUM); |
| 6594 | } |
| 6595 | UNIMPLEMENTED(); |
| 6596 | break; |
| 6597 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6598 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6599 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6600 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6601 | } |
| 6602 | } |
| 6603 | catch(std::bad_alloc&) |
| 6604 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6605 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6606 | } |
| 6607 | } |
| 6608 | |
| 6609 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6610 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6611 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6612 | |
| 6613 | try |
| 6614 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6615 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6616 | |
| 6617 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6618 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6619 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6620 | } |
| 6621 | } |
| 6622 | catch(std::bad_alloc&) |
| 6623 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6624 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6625 | } |
| 6626 | } |
| 6627 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6628 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6629 | GLenum format, GLenum type, GLsizei bufSize, |
| 6630 | GLvoid *data) |
| 6631 | { |
| 6632 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6633 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6634 | x, y, width, height, format, type, bufSize, data); |
| 6635 | |
| 6636 | try |
| 6637 | { |
| 6638 | if (width < 0 || height < 0 || bufSize < 0) |
| 6639 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6640 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6641 | } |
| 6642 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6643 | gl::Context *context = gl::getNonLostContext(); |
| 6644 | |
| 6645 | if (context) |
| 6646 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6647 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6648 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6649 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6650 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6651 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6652 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6653 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6654 | return; |
| 6655 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6656 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6657 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6658 | |
| 6659 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6660 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6661 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6662 | } |
| 6663 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6664 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6665 | } |
| 6666 | } |
| 6667 | catch(std::bad_alloc&) |
| 6668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6669 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6670 | } |
| 6671 | } |
| 6672 | |
| 6673 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6674 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6675 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6676 | EVENT("(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] | 6677 | "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] | 6678 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6679 | |
| 6680 | try |
| 6681 | { |
| 6682 | if (width < 0 || height < 0) |
| 6683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6684 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6685 | } |
| 6686 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6687 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6688 | |
| 6689 | if (context) |
| 6690 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6691 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6692 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6693 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6694 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6695 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6696 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6697 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6698 | return; |
| 6699 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6700 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6701 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6702 | |
| 6703 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6704 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6705 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6706 | } |
| 6707 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6708 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6709 | } |
| 6710 | } |
| 6711 | catch(std::bad_alloc&) |
| 6712 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6713 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6714 | } |
| 6715 | } |
| 6716 | |
| 6717 | void __stdcall glReleaseShaderCompiler(void) |
| 6718 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6719 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6720 | |
| 6721 | try |
| 6722 | { |
| 6723 | gl::Shader::releaseCompiler(); |
| 6724 | } |
| 6725 | catch(std::bad_alloc&) |
| 6726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6727 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6728 | } |
| 6729 | } |
| 6730 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6731 | 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] | 6732 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6733 | 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] | 6734 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6735 | |
| 6736 | try |
| 6737 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6738 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6739 | |
| 6740 | if (context) |
| 6741 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6742 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6743 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6744 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6745 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6746 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6747 | |
| 6748 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6749 | } |
| 6750 | } |
| 6751 | catch(std::bad_alloc&) |
| 6752 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6753 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6754 | } |
| 6755 | } |
| 6756 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6757 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6758 | { |
| 6759 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6760 | } |
| 6761 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6762 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6763 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6764 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6765 | |
| 6766 | try |
| 6767 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6768 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6769 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6770 | if (context) |
| 6771 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6772 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
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 | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6781 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6782 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6783 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6784 | |
| 6785 | try |
| 6786 | { |
| 6787 | if (condition != GL_ALL_COMPLETED_NV) |
| 6788 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6789 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6790 | } |
| 6791 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6792 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6793 | |
| 6794 | if (context) |
| 6795 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 6796 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6797 | |
| 6798 | if (fenceObject == NULL) |
| 6799 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6800 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6801 | } |
| 6802 | |
| 6803 | fenceObject->setFence(condition); |
| 6804 | } |
| 6805 | } |
| 6806 | catch(std::bad_alloc&) |
| 6807 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6808 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6809 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6810 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6811 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6812 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6813 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6814 | 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] | 6815 | |
| 6816 | try |
| 6817 | { |
| 6818 | if (width < 0 || height < 0) |
| 6819 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6820 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6821 | } |
| 6822 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6823 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6824 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6825 | if (context) |
| 6826 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6827 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6833 | } |
| 6834 | } |
| 6835 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6836 | 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] | 6837 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6838 | 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] | 6839 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6840 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6841 | |
| 6842 | try |
| 6843 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6844 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6845 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6846 | } |
| 6847 | catch(std::bad_alloc&) |
| 6848 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6849 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6850 | } |
| 6851 | } |
| 6852 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6853 | 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] | 6854 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6855 | 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] | 6856 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6857 | |
| 6858 | try |
| 6859 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6860 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6861 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6862 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6863 | } |
| 6864 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6865 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6866 | |
| 6867 | if (context) |
| 6868 | { |
| 6869 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6870 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6871 | if (!shaderObject) |
| 6872 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6873 | if (context->getProgram(shader)) |
| 6874 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6875 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6876 | } |
| 6877 | else |
| 6878 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6879 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6880 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6881 | } |
| 6882 | |
| 6883 | shaderObject->setSource(count, string, length); |
| 6884 | } |
| 6885 | } |
| 6886 | catch(std::bad_alloc&) |
| 6887 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6888 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6889 | } |
| 6890 | } |
| 6891 | |
| 6892 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6893 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6894 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6895 | } |
| 6896 | |
| 6897 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6898 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6899 | 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] | 6900 | |
| 6901 | try |
| 6902 | { |
| 6903 | switch (face) |
| 6904 | { |
| 6905 | case GL_FRONT: |
| 6906 | case GL_BACK: |
| 6907 | case GL_FRONT_AND_BACK: |
| 6908 | break; |
| 6909 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6910 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6911 | } |
| 6912 | |
| 6913 | switch (func) |
| 6914 | { |
| 6915 | case GL_NEVER: |
| 6916 | case GL_ALWAYS: |
| 6917 | case GL_LESS: |
| 6918 | case GL_LEQUAL: |
| 6919 | case GL_EQUAL: |
| 6920 | case GL_GEQUAL: |
| 6921 | case GL_GREATER: |
| 6922 | case GL_NOTEQUAL: |
| 6923 | break; |
| 6924 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6925 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6926 | } |
| 6927 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6928 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6929 | |
| 6930 | if (context) |
| 6931 | { |
| 6932 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6933 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6934 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6935 | } |
| 6936 | |
| 6937 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6938 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6939 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6940 | } |
| 6941 | } |
| 6942 | } |
| 6943 | catch(std::bad_alloc&) |
| 6944 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6945 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6946 | } |
| 6947 | } |
| 6948 | |
| 6949 | void __stdcall glStencilMask(GLuint mask) |
| 6950 | { |
| 6951 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6952 | } |
| 6953 | |
| 6954 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6956 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6957 | |
| 6958 | try |
| 6959 | { |
| 6960 | switch (face) |
| 6961 | { |
| 6962 | case GL_FRONT: |
| 6963 | case GL_BACK: |
| 6964 | case GL_FRONT_AND_BACK: |
| 6965 | break; |
| 6966 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6967 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6968 | } |
| 6969 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6970 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6971 | |
| 6972 | if (context) |
| 6973 | { |
| 6974 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6975 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6976 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6977 | } |
| 6978 | |
| 6979 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6980 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6981 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6982 | } |
| 6983 | } |
| 6984 | } |
| 6985 | catch(std::bad_alloc&) |
| 6986 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6987 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6988 | } |
| 6989 | } |
| 6990 | |
| 6991 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6992 | { |
| 6993 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6994 | } |
| 6995 | |
| 6996 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6997 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6998 | 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] | 6999 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7000 | |
| 7001 | try |
| 7002 | { |
| 7003 | switch (face) |
| 7004 | { |
| 7005 | case GL_FRONT: |
| 7006 | case GL_BACK: |
| 7007 | case GL_FRONT_AND_BACK: |
| 7008 | break; |
| 7009 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7010 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7011 | } |
| 7012 | |
| 7013 | switch (fail) |
| 7014 | { |
| 7015 | case GL_ZERO: |
| 7016 | case GL_KEEP: |
| 7017 | case GL_REPLACE: |
| 7018 | case GL_INCR: |
| 7019 | case GL_DECR: |
| 7020 | case GL_INVERT: |
| 7021 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7022 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7023 | break; |
| 7024 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7025 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7026 | } |
| 7027 | |
| 7028 | switch (zfail) |
| 7029 | { |
| 7030 | case GL_ZERO: |
| 7031 | case GL_KEEP: |
| 7032 | case GL_REPLACE: |
| 7033 | case GL_INCR: |
| 7034 | case GL_DECR: |
| 7035 | case GL_INVERT: |
| 7036 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7037 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7038 | break; |
| 7039 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7040 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7041 | } |
| 7042 | |
| 7043 | switch (zpass) |
| 7044 | { |
| 7045 | case GL_ZERO: |
| 7046 | case GL_KEEP: |
| 7047 | case GL_REPLACE: |
| 7048 | case GL_INCR: |
| 7049 | case GL_DECR: |
| 7050 | case GL_INVERT: |
| 7051 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 7052 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7053 | break; |
| 7054 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7055 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7056 | } |
| 7057 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7058 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7059 | |
| 7060 | if (context) |
| 7061 | { |
| 7062 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 7063 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7064 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7065 | } |
| 7066 | |
| 7067 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 7068 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 7069 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7070 | } |
| 7071 | } |
| 7072 | } |
| 7073 | catch(std::bad_alloc&) |
| 7074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7075 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7076 | } |
| 7077 | } |
| 7078 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7079 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 7080 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7081 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7082 | |
| 7083 | try |
| 7084 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7085 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7086 | |
| 7087 | if (context) |
| 7088 | { |
Jamie Madill | 33dc843 | 2013-07-26 11:55:05 -0400 | [diff] [blame] | 7089 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7090 | |
| 7091 | if (fenceObject == NULL) |
| 7092 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7093 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7094 | } |
| 7095 | |
Jamie Madill | fb9a740 | 2013-07-26 11:55:01 -0400 | [diff] [blame] | 7096 | if (fenceObject->isFence() != GL_TRUE) |
| 7097 | { |
| 7098 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
| 7099 | } |
| 7100 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7101 | return fenceObject->testFence(); |
| 7102 | } |
| 7103 | } |
| 7104 | catch(std::bad_alloc&) |
| 7105 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7106 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7107 | } |
| 7108 | |
| 7109 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 7110 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 7111 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7112 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 7113 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7114 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7115 | 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] | 7116 | "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] | 7117 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7118 | |
| 7119 | try |
| 7120 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7121 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7122 | |
| 7123 | if (context) |
| 7124 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7125 | if (context->getClientVersion() < 3 && |
| 7126 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 7127 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7128 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7129 | return; |
| 7130 | } |
| 7131 | |
| 7132 | if (context->getClientVersion() >= 3 && |
| 7133 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 7134 | 0, 0, 0, width, height, 1, border, format, type)) |
| 7135 | { |
| 7136 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 7137 | } |
| 7138 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7139 | switch (target) |
| 7140 | { |
| 7141 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7142 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7143 | gl::Texture2D *texture = context->getTexture2D(); |
| 7144 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7145 | } |
| 7146 | break; |
| 7147 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 7148 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7149 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 7150 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7151 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7152 | break; |
| 7153 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7154 | { |
| 7155 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7156 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7157 | } |
| 7158 | break; |
| 7159 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7160 | { |
| 7161 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7162 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7163 | } |
| 7164 | break; |
| 7165 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7166 | { |
| 7167 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7168 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7169 | } |
| 7170 | break; |
| 7171 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7172 | { |
| 7173 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7174 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7175 | } |
| 7176 | break; |
| 7177 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 7178 | { |
| 7179 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 7180 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 7181 | } |
| 7182 | break; |
| 7183 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7184 | } |
| 7185 | } |
| 7186 | } |
| 7187 | catch(std::bad_alloc&) |
| 7188 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7189 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7190 | } |
| 7191 | } |
| 7192 | |
| 7193 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 7194 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7195 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 7196 | |
| 7197 | try |
| 7198 | { |
| 7199 | gl::Context *context = gl::getNonLostContext(); |
| 7200 | |
| 7201 | if (context) |
| 7202 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7203 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7204 | { |
| 7205 | return; |
| 7206 | } |
| 7207 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7208 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7209 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7210 | if (!texture) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7212 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7213 | } |
| 7214 | |
| 7215 | switch (pname) |
| 7216 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7217 | case GL_TEXTURE_WRAP_S: texture->setWrapS(gl::uiround<GLenum>(param)); break; |
| 7218 | case GL_TEXTURE_WRAP_T: texture->setWrapT(gl::uiround<GLenum>(param)); break; |
| 7219 | case GL_TEXTURE_WRAP_R: texture->setWrapR(gl::uiround<GLenum>(param)); break; |
| 7220 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter(gl::uiround<GLenum>(param)); break; |
| 7221 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter(gl::uiround<GLenum>(param)); break; |
| 7222 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 7223 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy(static_cast<GLfloat>(param), context->getTextureMaxAnisotropy()); break; |
| 7224 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode(gl::uiround<GLenum>(param)); break; |
| 7225 | 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] | 7226 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7227 | case GL_TEXTURE_SWIZZLE_R: |
| 7228 | case GL_TEXTURE_SWIZZLE_G: |
| 7229 | case GL_TEXTURE_SWIZZLE_B: |
| 7230 | case GL_TEXTURE_SWIZZLE_A: |
| 7231 | case GL_TEXTURE_BASE_LEVEL: |
| 7232 | case GL_TEXTURE_MAX_LEVEL: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7233 | case GL_TEXTURE_MIN_LOD: |
| 7234 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7235 | UNIMPLEMENTED(); |
| 7236 | break; |
| 7237 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7238 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7239 | } |
| 7240 | } |
| 7241 | } |
| 7242 | catch(std::bad_alloc&) |
| 7243 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7244 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7245 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7246 | } |
| 7247 | |
| 7248 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7249 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7250 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7251 | } |
| 7252 | |
| 7253 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7254 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7255 | 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] | 7256 | |
| 7257 | try |
| 7258 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7259 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7260 | |
| 7261 | if (context) |
| 7262 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7263 | if (!validateTexParamParameters(context, pname, param)) |
| 7264 | { |
| 7265 | return; |
| 7266 | } |
| 7267 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7268 | gl::Texture *texture = getTargetTexture(context, target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7269 | |
Jamie Madill | fb8a830 | 2013-07-03 14:24:12 -0400 | [diff] [blame] | 7270 | if (!texture) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7271 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7272 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7273 | } |
| 7274 | |
| 7275 | switch (pname) |
| 7276 | { |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7277 | case GL_TEXTURE_WRAP_S: texture->setWrapS((GLenum)param); break; |
| 7278 | case GL_TEXTURE_WRAP_T: texture->setWrapT((GLenum)param); break; |
| 7279 | case GL_TEXTURE_WRAP_R: texture->setWrapR((GLenum)param); break; |
| 7280 | case GL_TEXTURE_MIN_FILTER: texture->setMinFilter((GLenum)param); break; |
| 7281 | case GL_TEXTURE_MAG_FILTER: texture->setMagFilter((GLenum)param); break; |
| 7282 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 7283 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy()); break; |
| 7284 | case GL_TEXTURE_COMPARE_MODE: texture->setCompareMode((GLenum)param); break; |
| 7285 | case GL_TEXTURE_COMPARE_FUNC: texture->setCompareFunc((GLenum)param); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7286 | |
| 7287 | case GL_TEXTURE_SWIZZLE_R: |
| 7288 | case GL_TEXTURE_SWIZZLE_G: |
| 7289 | case GL_TEXTURE_SWIZZLE_B: |
| 7290 | case GL_TEXTURE_SWIZZLE_A: |
| 7291 | case GL_TEXTURE_BASE_LEVEL: |
| 7292 | case GL_TEXTURE_MAX_LEVEL: |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7293 | case GL_TEXTURE_MIN_LOD: |
| 7294 | case GL_TEXTURE_MAX_LOD: |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7295 | UNIMPLEMENTED(); |
| 7296 | break; |
| 7297 | |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 7298 | default: UNREACHABLE(); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7299 | } |
| 7300 | } |
| 7301 | } |
| 7302 | catch(std::bad_alloc&) |
| 7303 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7304 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7305 | } |
| 7306 | } |
| 7307 | |
| 7308 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7309 | { |
| 7310 | glTexParameteri(target, pname, *params); |
| 7311 | } |
| 7312 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7313 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7314 | { |
| 7315 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7316 | target, levels, internalformat, width, height); |
| 7317 | |
| 7318 | try |
| 7319 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7320 | gl::Context *context = gl::getNonLostContext(); |
| 7321 | |
| 7322 | if (context) |
| 7323 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7324 | if (context->getClientVersion() < 3 && |
| 7325 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7326 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7327 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7328 | } |
| 7329 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7330 | if (context->getClientVersion() >= 3 && |
| 7331 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7332 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7333 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7334 | } |
| 7335 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7336 | switch (target) |
| 7337 | { |
| 7338 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7339 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7340 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7341 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7342 | } |
| 7343 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7344 | |
| 7345 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7346 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7347 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7348 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7349 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7350 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7351 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7352 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7353 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7354 | } |
| 7355 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7356 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7357 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7358 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7359 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7360 | } |
| 7361 | } |
| 7362 | catch(std::bad_alloc&) |
| 7363 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7364 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7365 | } |
| 7366 | } |
| 7367 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7368 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7369 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7370 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7371 | 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] | 7372 | "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] | 7373 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7374 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7375 | |
| 7376 | try |
| 7377 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7378 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7379 | |
| 7380 | if (context) |
| 7381 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7382 | if (context->getClientVersion() < 3 && |
| 7383 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7384 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7385 | { |
| 7386 | return; |
| 7387 | } |
| 7388 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7389 | if (context->getClientVersion() >= 3 && |
| 7390 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7391 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7392 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7393 | return; |
| 7394 | } |
| 7395 | |
| 7396 | switch (target) |
| 7397 | { |
| 7398 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7399 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7400 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7401 | 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] | 7402 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7403 | break; |
| 7404 | |
| 7405 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7406 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7407 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7408 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7409 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7410 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7411 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7412 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7413 | 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] | 7414 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7415 | break; |
| 7416 | |
| 7417 | default: |
| 7418 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7419 | } |
| 7420 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7421 | } |
| 7422 | catch(std::bad_alloc&) |
| 7423 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7424 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7425 | } |
| 7426 | } |
| 7427 | |
| 7428 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7429 | { |
| 7430 | glUniform1fv(location, 1, &x); |
| 7431 | } |
| 7432 | |
| 7433 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7434 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7435 | 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] | 7436 | |
| 7437 | try |
| 7438 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7439 | if (count < 0) |
| 7440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7441 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7442 | } |
| 7443 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7444 | if (location == -1) |
| 7445 | { |
| 7446 | return; |
| 7447 | } |
| 7448 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7449 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7450 | |
| 7451 | if (context) |
| 7452 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7453 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7454 | if (!programBinary) |
| 7455 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7456 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7457 | } |
| 7458 | |
| 7459 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7460 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7461 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7462 | } |
| 7463 | } |
| 7464 | } |
| 7465 | catch(std::bad_alloc&) |
| 7466 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7467 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7468 | } |
| 7469 | } |
| 7470 | |
| 7471 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7472 | { |
| 7473 | glUniform1iv(location, 1, &x); |
| 7474 | } |
| 7475 | |
| 7476 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7477 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7478 | 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] | 7479 | |
| 7480 | try |
| 7481 | { |
| 7482 | if (count < 0) |
| 7483 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7484 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7485 | } |
| 7486 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7487 | if (location == -1) |
| 7488 | { |
| 7489 | return; |
| 7490 | } |
| 7491 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7492 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7493 | |
| 7494 | if (context) |
| 7495 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7496 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7497 | if (!programBinary) |
| 7498 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7499 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7500 | } |
| 7501 | |
| 7502 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7503 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7504 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7505 | } |
| 7506 | } |
| 7507 | } |
| 7508 | catch(std::bad_alloc&) |
| 7509 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7510 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7511 | } |
| 7512 | } |
| 7513 | |
| 7514 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7515 | { |
| 7516 | GLfloat xy[2] = {x, y}; |
| 7517 | |
| 7518 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7519 | } |
| 7520 | |
| 7521 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7522 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7523 | 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] | 7524 | |
| 7525 | try |
| 7526 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7527 | if (count < 0) |
| 7528 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7529 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7530 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7531 | |
| 7532 | if (location == -1) |
| 7533 | { |
| 7534 | return; |
| 7535 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7536 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7537 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7538 | |
| 7539 | if (context) |
| 7540 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7541 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7542 | if (!programBinary) |
| 7543 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7544 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7545 | } |
| 7546 | |
| 7547 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7548 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7549 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7550 | } |
| 7551 | } |
| 7552 | } |
| 7553 | catch(std::bad_alloc&) |
| 7554 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7555 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7556 | } |
| 7557 | } |
| 7558 | |
| 7559 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7560 | { |
| 7561 | GLint xy[4] = {x, y}; |
| 7562 | |
| 7563 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7564 | } |
| 7565 | |
| 7566 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7567 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7568 | 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] | 7569 | |
| 7570 | try |
| 7571 | { |
| 7572 | if (count < 0) |
| 7573 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7574 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7575 | } |
| 7576 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7577 | if (location == -1) |
| 7578 | { |
| 7579 | return; |
| 7580 | } |
| 7581 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7582 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7583 | |
| 7584 | if (context) |
| 7585 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7586 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7587 | if (!programBinary) |
| 7588 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7589 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7590 | } |
| 7591 | |
| 7592 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7593 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7594 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7595 | } |
| 7596 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7597 | } |
| 7598 | catch(std::bad_alloc&) |
| 7599 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7600 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7601 | } |
| 7602 | } |
| 7603 | |
| 7604 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7605 | { |
| 7606 | GLfloat xyz[3] = {x, y, z}; |
| 7607 | |
| 7608 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7609 | } |
| 7610 | |
| 7611 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7612 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7613 | 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] | 7614 | |
| 7615 | try |
| 7616 | { |
| 7617 | if (count < 0) |
| 7618 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7619 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7620 | } |
| 7621 | |
| 7622 | if (location == -1) |
| 7623 | { |
| 7624 | return; |
| 7625 | } |
| 7626 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7627 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7628 | |
| 7629 | if (context) |
| 7630 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7631 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7632 | if (!programBinary) |
| 7633 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7634 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7635 | } |
| 7636 | |
| 7637 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7638 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7639 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7640 | } |
| 7641 | } |
| 7642 | } |
| 7643 | catch(std::bad_alloc&) |
| 7644 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7645 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7646 | } |
| 7647 | } |
| 7648 | |
| 7649 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7650 | { |
| 7651 | GLint xyz[3] = {x, y, z}; |
| 7652 | |
| 7653 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7654 | } |
| 7655 | |
| 7656 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7657 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7658 | 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] | 7659 | |
| 7660 | try |
| 7661 | { |
| 7662 | if (count < 0) |
| 7663 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7664 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7665 | } |
| 7666 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7667 | if (location == -1) |
| 7668 | { |
| 7669 | return; |
| 7670 | } |
| 7671 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7672 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7673 | |
| 7674 | if (context) |
| 7675 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7676 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7677 | if (!programBinary) |
| 7678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7679 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7680 | } |
| 7681 | |
| 7682 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7684 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7685 | } |
| 7686 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7687 | } |
| 7688 | catch(std::bad_alloc&) |
| 7689 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7690 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7691 | } |
| 7692 | } |
| 7693 | |
| 7694 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7695 | { |
| 7696 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7697 | |
| 7698 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7699 | } |
| 7700 | |
| 7701 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7702 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7703 | 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] | 7704 | |
| 7705 | try |
| 7706 | { |
| 7707 | if (count < 0) |
| 7708 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7709 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7710 | } |
| 7711 | |
| 7712 | if (location == -1) |
| 7713 | { |
| 7714 | return; |
| 7715 | } |
| 7716 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7717 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7718 | |
| 7719 | if (context) |
| 7720 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7721 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7722 | if (!programBinary) |
| 7723 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7724 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7725 | } |
| 7726 | |
| 7727 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7728 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7729 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7730 | } |
| 7731 | } |
| 7732 | } |
| 7733 | catch(std::bad_alloc&) |
| 7734 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7735 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7736 | } |
| 7737 | } |
| 7738 | |
| 7739 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7740 | { |
| 7741 | GLint xyzw[4] = {x, y, z, w}; |
| 7742 | |
| 7743 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7744 | } |
| 7745 | |
| 7746 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7747 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7748 | 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] | 7749 | |
| 7750 | try |
| 7751 | { |
| 7752 | if (count < 0) |
| 7753 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7754 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7755 | } |
| 7756 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7757 | if (location == -1) |
| 7758 | { |
| 7759 | return; |
| 7760 | } |
| 7761 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7762 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7763 | |
| 7764 | if (context) |
| 7765 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7766 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7767 | if (!programBinary) |
| 7768 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7769 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7770 | } |
| 7771 | |
| 7772 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7773 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7774 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7775 | } |
| 7776 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7777 | } |
| 7778 | catch(std::bad_alloc&) |
| 7779 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7780 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7781 | } |
| 7782 | } |
| 7783 | |
| 7784 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7785 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7786 | 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] | 7787 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7788 | |
| 7789 | try |
| 7790 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7791 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7792 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7793 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7794 | } |
| 7795 | |
| 7796 | if (location == -1) |
| 7797 | { |
| 7798 | return; |
| 7799 | } |
| 7800 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7801 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7802 | |
| 7803 | if (context) |
| 7804 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7805 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7806 | { |
| 7807 | return gl::error(GL_INVALID_VALUE); |
| 7808 | } |
| 7809 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7810 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7811 | if (!programBinary) |
| 7812 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7813 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7814 | } |
| 7815 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7816 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7818 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7819 | } |
| 7820 | } |
| 7821 | } |
| 7822 | catch(std::bad_alloc&) |
| 7823 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7824 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7825 | } |
| 7826 | } |
| 7827 | |
| 7828 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7829 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7830 | 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] | 7831 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7832 | |
| 7833 | try |
| 7834 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7835 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7836 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7837 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7838 | } |
| 7839 | |
| 7840 | if (location == -1) |
| 7841 | { |
| 7842 | return; |
| 7843 | } |
| 7844 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7845 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7846 | |
| 7847 | if (context) |
| 7848 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7849 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7850 | { |
| 7851 | return gl::error(GL_INVALID_VALUE); |
| 7852 | } |
| 7853 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7854 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7855 | if (!programBinary) |
| 7856 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7857 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7858 | } |
| 7859 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7860 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7861 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7862 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7863 | } |
| 7864 | } |
| 7865 | } |
| 7866 | catch(std::bad_alloc&) |
| 7867 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7868 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7869 | } |
| 7870 | } |
| 7871 | |
| 7872 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7873 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7874 | 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] | 7875 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7876 | |
| 7877 | try |
| 7878 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7879 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7880 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7881 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7882 | } |
| 7883 | |
| 7884 | if (location == -1) |
| 7885 | { |
| 7886 | return; |
| 7887 | } |
| 7888 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7889 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7890 | |
| 7891 | if (context) |
| 7892 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7893 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7894 | { |
| 7895 | return gl::error(GL_INVALID_VALUE); |
| 7896 | } |
| 7897 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7898 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7899 | if (!programBinary) |
| 7900 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7901 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7902 | } |
| 7903 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7904 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7905 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7906 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7907 | } |
| 7908 | } |
| 7909 | } |
| 7910 | catch(std::bad_alloc&) |
| 7911 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7912 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7913 | } |
| 7914 | } |
| 7915 | |
| 7916 | void __stdcall glUseProgram(GLuint program) |
| 7917 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7918 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7919 | |
| 7920 | try |
| 7921 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7922 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7923 | |
| 7924 | if (context) |
| 7925 | { |
| 7926 | gl::Program *programObject = context->getProgram(program); |
| 7927 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7928 | if (!programObject && program != 0) |
| 7929 | { |
| 7930 | if (context->getShader(program)) |
| 7931 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7932 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7933 | } |
| 7934 | else |
| 7935 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7936 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7937 | } |
| 7938 | } |
| 7939 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7940 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7941 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7942 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7943 | } |
| 7944 | |
| 7945 | context->useProgram(program); |
| 7946 | } |
| 7947 | } |
| 7948 | catch(std::bad_alloc&) |
| 7949 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7950 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7951 | } |
| 7952 | } |
| 7953 | |
| 7954 | void __stdcall glValidateProgram(GLuint program) |
| 7955 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7956 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7957 | |
| 7958 | try |
| 7959 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7960 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7961 | |
| 7962 | if (context) |
| 7963 | { |
| 7964 | gl::Program *programObject = context->getProgram(program); |
| 7965 | |
| 7966 | if (!programObject) |
| 7967 | { |
| 7968 | if (context->getShader(program)) |
| 7969 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7970 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7971 | } |
| 7972 | else |
| 7973 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7974 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7975 | } |
| 7976 | } |
| 7977 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7978 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7979 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7980 | } |
| 7981 | catch(std::bad_alloc&) |
| 7982 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7983 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7984 | } |
| 7985 | } |
| 7986 | |
| 7987 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7988 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7989 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7990 | |
| 7991 | try |
| 7992 | { |
| 7993 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7994 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7995 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7996 | } |
| 7997 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7998 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7999 | |
| 8000 | if (context) |
| 8001 | { |
| 8002 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8003 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8004 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8005 | } |
| 8006 | catch(std::bad_alloc&) |
| 8007 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8008 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8009 | } |
| 8010 | } |
| 8011 | |
| 8012 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 8013 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8014 | 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] | 8015 | |
| 8016 | try |
| 8017 | { |
| 8018 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8019 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8020 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8021 | } |
| 8022 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8023 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8024 | |
| 8025 | if (context) |
| 8026 | { |
| 8027 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8028 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8029 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8030 | } |
| 8031 | catch(std::bad_alloc&) |
| 8032 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8033 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8034 | } |
| 8035 | } |
| 8036 | |
| 8037 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 8038 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8039 | 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] | 8040 | |
| 8041 | try |
| 8042 | { |
| 8043 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8044 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8045 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8046 | } |
| 8047 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8048 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8049 | |
| 8050 | if (context) |
| 8051 | { |
| 8052 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8053 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8054 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8055 | } |
| 8056 | catch(std::bad_alloc&) |
| 8057 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8058 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8059 | } |
| 8060 | } |
| 8061 | |
| 8062 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 8063 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8064 | 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] | 8065 | |
| 8066 | try |
| 8067 | { |
| 8068 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8069 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8070 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8071 | } |
| 8072 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8073 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8074 | |
| 8075 | if (context) |
| 8076 | { |
| 8077 | 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] | 8078 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8079 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8080 | } |
| 8081 | catch(std::bad_alloc&) |
| 8082 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8083 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8084 | } |
| 8085 | } |
| 8086 | |
| 8087 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 8088 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8089 | 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] | 8090 | |
| 8091 | try |
| 8092 | { |
| 8093 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8094 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8095 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8096 | } |
| 8097 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8098 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8099 | |
| 8100 | if (context) |
| 8101 | { |
| 8102 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8103 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8104 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8105 | } |
| 8106 | catch(std::bad_alloc&) |
| 8107 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8108 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8109 | } |
| 8110 | } |
| 8111 | |
| 8112 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 8113 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8114 | 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] | 8115 | |
| 8116 | try |
| 8117 | { |
| 8118 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8119 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8120 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8121 | } |
| 8122 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8123 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8124 | |
| 8125 | if (context) |
| 8126 | { |
| 8127 | 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] | 8128 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8129 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8130 | } |
| 8131 | catch(std::bad_alloc&) |
| 8132 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8133 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8134 | } |
| 8135 | } |
| 8136 | |
| 8137 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8139 | 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] | 8140 | |
| 8141 | try |
| 8142 | { |
| 8143 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8144 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8145 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8146 | } |
| 8147 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8148 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8149 | |
| 8150 | if (context) |
| 8151 | { |
| 8152 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8153 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8154 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8155 | } |
| 8156 | catch(std::bad_alloc&) |
| 8157 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8158 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8159 | } |
| 8160 | } |
| 8161 | |
| 8162 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8163 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8164 | 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] | 8165 | |
| 8166 | try |
| 8167 | { |
| 8168 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8170 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8171 | } |
| 8172 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8173 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8174 | |
| 8175 | if (context) |
| 8176 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8177 | context->setVertexAttribf(index, values); |
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 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8186 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8187 | { |
| 8188 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 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 | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8195 | } |
| 8196 | |
| 8197 | gl::Context *context = gl::getNonLostContext(); |
| 8198 | |
| 8199 | if (context) |
| 8200 | { |
| 8201 | context->setVertexAttribDivisor(index, divisor); |
| 8202 | } |
| 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 | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8207 | } |
| 8208 | } |
| 8209 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8210 | 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] | 8211 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8212 | 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] | 8213 | "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] | 8214 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8215 | |
| 8216 | try |
| 8217 | { |
| 8218 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8219 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8220 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8221 | } |
| 8222 | |
| 8223 | if (size < 1 || size > 4) |
| 8224 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8225 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8226 | } |
| 8227 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8228 | gl::Context *context = gl::getNonLostContext(); |
| 8229 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8230 | switch (type) |
| 8231 | { |
| 8232 | case GL_BYTE: |
| 8233 | case GL_UNSIGNED_BYTE: |
| 8234 | case GL_SHORT: |
| 8235 | case GL_UNSIGNED_SHORT: |
| 8236 | case GL_FIXED: |
| 8237 | case GL_FLOAT: |
| 8238 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8239 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8240 | case GL_INT: |
| 8241 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8242 | case GL_INT_2_10_10_10_REV: |
| 8243 | 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] | 8244 | if (context && context->getClientVersion() < 3) |
| 8245 | { |
| 8246 | return gl::error(GL_INVALID_ENUM); |
| 8247 | } |
| 8248 | else |
| 8249 | { |
| 8250 | break; |
| 8251 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8252 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8253 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8254 | } |
| 8255 | |
| 8256 | if (stride < 0) |
| 8257 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8258 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8259 | } |
| 8260 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8261 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8262 | { |
| 8263 | return gl::error(GL_INVALID_OPERATION); |
| 8264 | } |
| 8265 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8266 | if (context) |
| 8267 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 8268 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 8269 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 8270 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 8271 | // and the pointer argument is not NULL. |
| 8272 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL) |
| 8273 | { |
| 8274 | return gl::error(GL_INVALID_OPERATION); |
| 8275 | } |
| 8276 | |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8277 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8278 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8279 | } |
| 8280 | } |
| 8281 | catch(std::bad_alloc&) |
| 8282 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8283 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8284 | } |
| 8285 | } |
| 8286 | |
| 8287 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8288 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8289 | 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] | 8290 | |
| 8291 | try |
| 8292 | { |
| 8293 | if (width < 0 || height < 0) |
| 8294 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8295 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8296 | } |
| 8297 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8298 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8299 | |
| 8300 | if (context) |
| 8301 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8302 | context->setViewportParams(x, y, width, height); |
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 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8311 | // OpenGL ES 3.0 functions |
| 8312 | |
| 8313 | void __stdcall glReadBuffer(GLenum mode) |
| 8314 | { |
| 8315 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8316 | |
| 8317 | try |
| 8318 | { |
| 8319 | gl::Context *context = gl::getNonLostContext(); |
| 8320 | |
| 8321 | if (context) |
| 8322 | { |
| 8323 | if (context->getClientVersion() < 3) |
| 8324 | { |
| 8325 | return gl::error(GL_INVALID_OPERATION); |
| 8326 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8327 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8328 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8329 | UNIMPLEMENTED(); |
| 8330 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8331 | } |
| 8332 | catch(std::bad_alloc&) |
| 8333 | { |
| 8334 | return gl::error(GL_OUT_OF_MEMORY); |
| 8335 | } |
| 8336 | } |
| 8337 | |
| 8338 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8339 | { |
| 8340 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8341 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8342 | |
| 8343 | try |
| 8344 | { |
| 8345 | gl::Context *context = gl::getNonLostContext(); |
| 8346 | |
| 8347 | if (context) |
| 8348 | { |
| 8349 | if (context->getClientVersion() < 3) |
| 8350 | { |
| 8351 | return gl::error(GL_INVALID_OPERATION); |
| 8352 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8353 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8354 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8355 | UNIMPLEMENTED(); |
| 8356 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8357 | } |
| 8358 | catch(std::bad_alloc&) |
| 8359 | { |
| 8360 | return gl::error(GL_OUT_OF_MEMORY); |
| 8361 | } |
| 8362 | } |
| 8363 | |
| 8364 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8365 | { |
| 8366 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8367 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8368 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8369 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8370 | |
| 8371 | try |
| 8372 | { |
| 8373 | gl::Context *context = gl::getNonLostContext(); |
| 8374 | |
| 8375 | if (context) |
| 8376 | { |
| 8377 | if (context->getClientVersion() < 3) |
| 8378 | { |
| 8379 | return gl::error(GL_INVALID_OPERATION); |
| 8380 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8381 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8382 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8383 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8384 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8385 | { |
| 8386 | return; |
| 8387 | } |
| 8388 | |
| 8389 | switch(target) |
| 8390 | { |
| 8391 | case GL_TEXTURE_3D: |
| 8392 | { |
| 8393 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8394 | 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] | 8395 | } |
| 8396 | break; |
| 8397 | |
| 8398 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8399 | { |
| 8400 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8401 | 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] | 8402 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8403 | break; |
| 8404 | |
| 8405 | default: |
| 8406 | return gl::error(GL_INVALID_ENUM); |
| 8407 | } |
| 8408 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8409 | } |
| 8410 | catch(std::bad_alloc&) |
| 8411 | { |
| 8412 | return gl::error(GL_OUT_OF_MEMORY); |
| 8413 | } |
| 8414 | } |
| 8415 | |
| 8416 | 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) |
| 8417 | { |
| 8418 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8419 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8420 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8421 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8422 | |
| 8423 | try |
| 8424 | { |
| 8425 | gl::Context *context = gl::getNonLostContext(); |
| 8426 | |
| 8427 | if (context) |
| 8428 | { |
| 8429 | if (context->getClientVersion() < 3) |
| 8430 | { |
| 8431 | return gl::error(GL_INVALID_OPERATION); |
| 8432 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8433 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8434 | if (!pixels) |
| 8435 | { |
| 8436 | return gl::error(GL_INVALID_VALUE); |
| 8437 | } |
| 8438 | |
| 8439 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8440 | 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] | 8441 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8442 | format, type)) |
| 8443 | { |
| 8444 | return; |
| 8445 | } |
| 8446 | |
| 8447 | switch(target) |
| 8448 | { |
| 8449 | case GL_TEXTURE_3D: |
| 8450 | { |
| 8451 | gl::Texture3D *texture = context->getTexture3D(); |
| 8452 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8453 | } |
| 8454 | break; |
| 8455 | |
| 8456 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8457 | { |
| 8458 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8459 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8460 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8461 | break; |
| 8462 | |
| 8463 | default: |
| 8464 | return gl::error(GL_INVALID_ENUM); |
| 8465 | } |
| 8466 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8467 | } |
| 8468 | catch(std::bad_alloc&) |
| 8469 | { |
| 8470 | return gl::error(GL_OUT_OF_MEMORY); |
| 8471 | } |
| 8472 | } |
| 8473 | |
| 8474 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8475 | { |
| 8476 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8477 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8478 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8479 | |
| 8480 | try |
| 8481 | { |
| 8482 | gl::Context *context = gl::getNonLostContext(); |
| 8483 | |
| 8484 | if (context) |
| 8485 | { |
| 8486 | if (context->getClientVersion() < 3) |
| 8487 | { |
| 8488 | return gl::error(GL_INVALID_OPERATION); |
| 8489 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8490 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8491 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8492 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8493 | { |
| 8494 | return; |
| 8495 | } |
| 8496 | |
| 8497 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8498 | gl::Texture *texture = NULL; |
| 8499 | switch (target) |
| 8500 | { |
| 8501 | case GL_TEXTURE_3D: |
| 8502 | texture = context->getTexture3D(); |
| 8503 | break; |
| 8504 | |
| 8505 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8506 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8507 | break; |
| 8508 | |
| 8509 | default: |
| 8510 | return gl::error(GL_INVALID_ENUM); |
| 8511 | } |
| 8512 | |
| 8513 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8514 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8515 | } |
| 8516 | catch(std::bad_alloc&) |
| 8517 | { |
| 8518 | return gl::error(GL_OUT_OF_MEMORY); |
| 8519 | } |
| 8520 | } |
| 8521 | |
| 8522 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8523 | { |
| 8524 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8525 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8526 | "const GLvoid* data = 0x%0.8p)", |
| 8527 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8528 | |
| 8529 | try |
| 8530 | { |
| 8531 | gl::Context *context = gl::getNonLostContext(); |
| 8532 | |
| 8533 | if (context) |
| 8534 | { |
| 8535 | if (context->getClientVersion() < 3) |
| 8536 | { |
| 8537 | return gl::error(GL_INVALID_OPERATION); |
| 8538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8539 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8540 | 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] | 8541 | { |
| 8542 | return gl::error(GL_INVALID_VALUE); |
| 8543 | } |
| 8544 | |
| 8545 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8546 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8547 | 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] | 8548 | { |
| 8549 | return; |
| 8550 | } |
| 8551 | |
| 8552 | switch(target) |
| 8553 | { |
| 8554 | case GL_TEXTURE_3D: |
| 8555 | { |
| 8556 | gl::Texture3D *texture = context->getTexture3D(); |
| 8557 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8558 | } |
| 8559 | break; |
| 8560 | |
| 8561 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8562 | { |
| 8563 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8564 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8565 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8566 | break; |
| 8567 | |
| 8568 | default: |
| 8569 | return gl::error(GL_INVALID_ENUM); |
| 8570 | } |
| 8571 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8572 | } |
| 8573 | catch(std::bad_alloc&) |
| 8574 | { |
| 8575 | return gl::error(GL_OUT_OF_MEMORY); |
| 8576 | } |
| 8577 | } |
| 8578 | |
| 8579 | 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) |
| 8580 | { |
| 8581 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8582 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8583 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8584 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8585 | |
| 8586 | try |
| 8587 | { |
| 8588 | gl::Context *context = gl::getNonLostContext(); |
| 8589 | |
| 8590 | if (context) |
| 8591 | { |
| 8592 | if (context->getClientVersion() < 3) |
| 8593 | { |
| 8594 | return gl::error(GL_INVALID_OPERATION); |
| 8595 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8596 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8597 | 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] | 8598 | { |
| 8599 | return gl::error(GL_INVALID_VALUE); |
| 8600 | } |
| 8601 | |
| 8602 | if (!data) |
| 8603 | { |
| 8604 | return gl::error(GL_INVALID_VALUE); |
| 8605 | } |
| 8606 | |
| 8607 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8608 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8609 | 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] | 8610 | { |
| 8611 | return; |
| 8612 | } |
| 8613 | |
| 8614 | switch(target) |
| 8615 | { |
| 8616 | case GL_TEXTURE_3D: |
| 8617 | { |
| 8618 | gl::Texture3D *texture = context->getTexture3D(); |
| 8619 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8620 | format, imageSize, data); |
| 8621 | } |
| 8622 | break; |
| 8623 | |
| 8624 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8625 | { |
| 8626 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8627 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8628 | format, imageSize, data); |
| 8629 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8630 | break; |
| 8631 | |
| 8632 | default: |
| 8633 | return gl::error(GL_INVALID_ENUM); |
| 8634 | } |
| 8635 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8636 | } |
| 8637 | catch(std::bad_alloc&) |
| 8638 | { |
| 8639 | return gl::error(GL_OUT_OF_MEMORY); |
| 8640 | } |
| 8641 | } |
| 8642 | |
| 8643 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8644 | { |
| 8645 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8646 | |
| 8647 | try |
| 8648 | { |
| 8649 | gl::Context *context = gl::getNonLostContext(); |
| 8650 | |
| 8651 | if (context) |
| 8652 | { |
| 8653 | if (context->getClientVersion() < 3) |
| 8654 | { |
| 8655 | return gl::error(GL_INVALID_OPERATION); |
| 8656 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8657 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8658 | glGenQueriesEXT(n, ids); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 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 glDeleteQueries(GLsizei n, const 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 | glDeleteQueriesEXT(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 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8692 | { |
| 8693 | EVENT("(GLuint id = %u)", id); |
| 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, GL_FALSE); |
| 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 | // TODO: XFB queries |
| 8707 | return glIsQueryEXT(id); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8708 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8709 | } |
| 8710 | catch(std::bad_alloc&) |
| 8711 | { |
| 8712 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8713 | } |
| 8714 | |
| 8715 | return GL_FALSE; |
| 8716 | } |
| 8717 | |
| 8718 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8719 | { |
| 8720 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8721 | |
| 8722 | try |
| 8723 | { |
| 8724 | gl::Context *context = gl::getNonLostContext(); |
| 8725 | |
| 8726 | if (context) |
| 8727 | { |
| 8728 | if (context->getClientVersion() < 3) |
| 8729 | { |
| 8730 | return gl::error(GL_INVALID_OPERATION); |
| 8731 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8732 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8733 | switch (target) |
| 8734 | { |
| 8735 | case GL_ANY_SAMPLES_PASSED: |
| 8736 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: |
| 8737 | case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: |
| 8738 | break; |
| 8739 | default: |
| 8740 | return gl::error(GL_INVALID_ENUM); |
| 8741 | } |
| 8742 | |
| 8743 | if (id == 0) |
| 8744 | { |
| 8745 | return gl::error(GL_INVALID_OPERATION); |
| 8746 | } |
| 8747 | |
| 8748 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 8749 | { |
| 8750 | // TODO: XFB queries |
| 8751 | UNIMPLEMENTED(); |
| 8752 | } |
| 8753 | else |
| 8754 | { |
| 8755 | context->beginQuery(target, id); |
| 8756 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8757 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8758 | } |
| 8759 | catch(std::bad_alloc&) |
| 8760 | { |
| 8761 | return gl::error(GL_OUT_OF_MEMORY); |
| 8762 | } |
| 8763 | } |
| 8764 | |
| 8765 | void __stdcall glEndQuery(GLenum target) |
| 8766 | { |
| 8767 | EVENT("(GLenum target = 0x%X)", target); |
| 8768 | |
| 8769 | try |
| 8770 | { |
| 8771 | gl::Context *context = gl::getNonLostContext(); |
| 8772 | |
| 8773 | if (context) |
| 8774 | { |
| 8775 | if (context->getClientVersion() < 3) |
| 8776 | { |
| 8777 | return gl::error(GL_INVALID_OPERATION); |
| 8778 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8779 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8780 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 8781 | { |
| 8782 | // TODO: XFB queries |
| 8783 | UNIMPLEMENTED(); |
| 8784 | } |
| 8785 | else |
| 8786 | { |
| 8787 | glEndQueryEXT(target); |
| 8788 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8789 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8790 | } |
| 8791 | catch(std::bad_alloc&) |
| 8792 | { |
| 8793 | return gl::error(GL_OUT_OF_MEMORY); |
| 8794 | } |
| 8795 | } |
| 8796 | |
| 8797 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8798 | { |
| 8799 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8800 | |
| 8801 | try |
| 8802 | { |
| 8803 | gl::Context *context = gl::getNonLostContext(); |
| 8804 | |
| 8805 | if (context) |
| 8806 | { |
| 8807 | if (context->getClientVersion() < 3) |
| 8808 | { |
| 8809 | return gl::error(GL_INVALID_OPERATION); |
| 8810 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8811 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8812 | if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) |
| 8813 | { |
| 8814 | // TODO: XFB queries |
| 8815 | UNIMPLEMENTED(); |
| 8816 | } |
| 8817 | else |
| 8818 | { |
| 8819 | glGetQueryivEXT(target, pname, params); |
| 8820 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8821 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8822 | } |
| 8823 | catch(std::bad_alloc&) |
| 8824 | { |
| 8825 | return gl::error(GL_OUT_OF_MEMORY); |
| 8826 | } |
| 8827 | } |
| 8828 | |
| 8829 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8830 | { |
| 8831 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8832 | |
| 8833 | try |
| 8834 | { |
| 8835 | gl::Context *context = gl::getNonLostContext(); |
| 8836 | |
| 8837 | if (context) |
| 8838 | { |
| 8839 | if (context->getClientVersion() < 3) |
| 8840 | { |
| 8841 | return gl::error(GL_INVALID_OPERATION); |
| 8842 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8843 | |
Jamie Madill | 3641b4b | 2013-07-26 12:54:59 -0400 | [diff] [blame] | 8844 | // TODO: XFB queries |
| 8845 | glGetQueryObjectuivEXT(id, pname, params); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8846 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8847 | } |
| 8848 | catch(std::bad_alloc&) |
| 8849 | { |
| 8850 | return gl::error(GL_OUT_OF_MEMORY); |
| 8851 | } |
| 8852 | } |
| 8853 | |
| 8854 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8855 | { |
| 8856 | EVENT("(GLenum target = 0x%X)", target); |
| 8857 | |
| 8858 | try |
| 8859 | { |
| 8860 | gl::Context *context = gl::getNonLostContext(); |
| 8861 | |
| 8862 | if (context) |
| 8863 | { |
| 8864 | if (context->getClientVersion() < 3) |
| 8865 | { |
| 8866 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8867 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8868 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8869 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8870 | UNIMPLEMENTED(); |
| 8871 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8872 | } |
| 8873 | catch(std::bad_alloc&) |
| 8874 | { |
| 8875 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8876 | } |
| 8877 | |
| 8878 | return GL_FALSE; |
| 8879 | } |
| 8880 | |
| 8881 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8882 | { |
| 8883 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8884 | |
| 8885 | try |
| 8886 | { |
| 8887 | gl::Context *context = gl::getNonLostContext(); |
| 8888 | |
| 8889 | if (context) |
| 8890 | { |
| 8891 | if (context->getClientVersion() < 3) |
| 8892 | { |
| 8893 | return gl::error(GL_INVALID_OPERATION); |
| 8894 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8895 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8896 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8897 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8898 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8899 | } |
| 8900 | catch(std::bad_alloc&) |
| 8901 | { |
| 8902 | return gl::error(GL_OUT_OF_MEMORY); |
| 8903 | } |
| 8904 | } |
| 8905 | |
| 8906 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8907 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8908 | try |
| 8909 | { |
| 8910 | gl::Context *context = gl::getNonLostContext(); |
| 8911 | |
| 8912 | if (context) |
| 8913 | { |
| 8914 | if (context->getClientVersion() < 3) |
| 8915 | { |
| 8916 | return gl::error(GL_INVALID_OPERATION); |
| 8917 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8918 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8919 | glDrawBuffersEXT(n, bufs); |
| 8920 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8921 | } |
| 8922 | catch(std::bad_alloc&) |
| 8923 | { |
| 8924 | return gl::error(GL_OUT_OF_MEMORY); |
| 8925 | } |
| 8926 | } |
| 8927 | |
| 8928 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8929 | { |
| 8930 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8931 | location, count, transpose, value); |
| 8932 | |
| 8933 | try |
| 8934 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8935 | if (count < 0) |
| 8936 | { |
| 8937 | return gl::error(GL_INVALID_VALUE); |
| 8938 | } |
| 8939 | |
| 8940 | if (location == -1) |
| 8941 | { |
| 8942 | return; |
| 8943 | } |
| 8944 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8945 | gl::Context *context = gl::getNonLostContext(); |
| 8946 | |
| 8947 | if (context) |
| 8948 | { |
| 8949 | if (context->getClientVersion() < 3) |
| 8950 | { |
| 8951 | return gl::error(GL_INVALID_OPERATION); |
| 8952 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8953 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8954 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8955 | if (!programBinary) |
| 8956 | { |
| 8957 | return gl::error(GL_INVALID_OPERATION); |
| 8958 | } |
| 8959 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8960 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8961 | { |
| 8962 | return gl::error(GL_INVALID_OPERATION); |
| 8963 | } |
| 8964 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8965 | } |
| 8966 | catch(std::bad_alloc&) |
| 8967 | { |
| 8968 | return gl::error(GL_OUT_OF_MEMORY); |
| 8969 | } |
| 8970 | } |
| 8971 | |
| 8972 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8973 | { |
| 8974 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8975 | location, count, transpose, value); |
| 8976 | |
| 8977 | try |
| 8978 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8979 | if (count < 0) |
| 8980 | { |
| 8981 | return gl::error(GL_INVALID_VALUE); |
| 8982 | } |
| 8983 | |
| 8984 | if (location == -1) |
| 8985 | { |
| 8986 | return; |
| 8987 | } |
| 8988 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8989 | gl::Context *context = gl::getNonLostContext(); |
| 8990 | |
| 8991 | if (context) |
| 8992 | { |
| 8993 | if (context->getClientVersion() < 3) |
| 8994 | { |
| 8995 | return gl::error(GL_INVALID_OPERATION); |
| 8996 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8997 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8998 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8999 | if (!programBinary) |
| 9000 | { |
| 9001 | return gl::error(GL_INVALID_OPERATION); |
| 9002 | } |
| 9003 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9004 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9005 | { |
| 9006 | return gl::error(GL_INVALID_OPERATION); |
| 9007 | } |
| 9008 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9009 | } |
| 9010 | catch(std::bad_alloc&) |
| 9011 | { |
| 9012 | return gl::error(GL_OUT_OF_MEMORY); |
| 9013 | } |
| 9014 | } |
| 9015 | |
| 9016 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9017 | { |
| 9018 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9019 | location, count, transpose, value); |
| 9020 | |
| 9021 | try |
| 9022 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9023 | if (count < 0) |
| 9024 | { |
| 9025 | return gl::error(GL_INVALID_VALUE); |
| 9026 | } |
| 9027 | |
| 9028 | if (location == -1) |
| 9029 | { |
| 9030 | return; |
| 9031 | } |
| 9032 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9033 | gl::Context *context = gl::getNonLostContext(); |
| 9034 | |
| 9035 | if (context) |
| 9036 | { |
| 9037 | if (context->getClientVersion() < 3) |
| 9038 | { |
| 9039 | return gl::error(GL_INVALID_OPERATION); |
| 9040 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9041 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9042 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9043 | if (!programBinary) |
| 9044 | { |
| 9045 | return gl::error(GL_INVALID_OPERATION); |
| 9046 | } |
| 9047 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9048 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9049 | { |
| 9050 | return gl::error(GL_INVALID_OPERATION); |
| 9051 | } |
| 9052 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9053 | } |
| 9054 | catch(std::bad_alloc&) |
| 9055 | { |
| 9056 | return gl::error(GL_OUT_OF_MEMORY); |
| 9057 | } |
| 9058 | } |
| 9059 | |
| 9060 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9061 | { |
| 9062 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9063 | location, count, transpose, value); |
| 9064 | |
| 9065 | try |
| 9066 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9067 | if (count < 0) |
| 9068 | { |
| 9069 | return gl::error(GL_INVALID_VALUE); |
| 9070 | } |
| 9071 | |
| 9072 | if (location == -1) |
| 9073 | { |
| 9074 | return; |
| 9075 | } |
| 9076 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9077 | gl::Context *context = gl::getNonLostContext(); |
| 9078 | |
| 9079 | if (context) |
| 9080 | { |
| 9081 | if (context->getClientVersion() < 3) |
| 9082 | { |
| 9083 | return gl::error(GL_INVALID_OPERATION); |
| 9084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9085 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9086 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9087 | if (!programBinary) |
| 9088 | { |
| 9089 | return gl::error(GL_INVALID_OPERATION); |
| 9090 | } |
| 9091 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9092 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9093 | { |
| 9094 | return gl::error(GL_INVALID_OPERATION); |
| 9095 | } |
| 9096 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9097 | } |
| 9098 | catch(std::bad_alloc&) |
| 9099 | { |
| 9100 | return gl::error(GL_OUT_OF_MEMORY); |
| 9101 | } |
| 9102 | } |
| 9103 | |
| 9104 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9105 | { |
| 9106 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9107 | location, count, transpose, value); |
| 9108 | |
| 9109 | try |
| 9110 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9111 | if (count < 0) |
| 9112 | { |
| 9113 | return gl::error(GL_INVALID_VALUE); |
| 9114 | } |
| 9115 | |
| 9116 | if (location == -1) |
| 9117 | { |
| 9118 | return; |
| 9119 | } |
| 9120 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9121 | gl::Context *context = gl::getNonLostContext(); |
| 9122 | |
| 9123 | if (context) |
| 9124 | { |
| 9125 | if (context->getClientVersion() < 3) |
| 9126 | { |
| 9127 | return gl::error(GL_INVALID_OPERATION); |
| 9128 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9129 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9130 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9131 | if (!programBinary) |
| 9132 | { |
| 9133 | return gl::error(GL_INVALID_OPERATION); |
| 9134 | } |
| 9135 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9136 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9137 | { |
| 9138 | return gl::error(GL_INVALID_OPERATION); |
| 9139 | } |
| 9140 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9141 | } |
| 9142 | catch(std::bad_alloc&) |
| 9143 | { |
| 9144 | return gl::error(GL_OUT_OF_MEMORY); |
| 9145 | } |
| 9146 | } |
| 9147 | |
| 9148 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 9149 | { |
| 9150 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9151 | location, count, transpose, value); |
| 9152 | |
| 9153 | try |
| 9154 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9155 | if (count < 0) |
| 9156 | { |
| 9157 | return gl::error(GL_INVALID_VALUE); |
| 9158 | } |
| 9159 | |
| 9160 | if (location == -1) |
| 9161 | { |
| 9162 | return; |
| 9163 | } |
| 9164 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9165 | gl::Context *context = gl::getNonLostContext(); |
| 9166 | |
| 9167 | if (context) |
| 9168 | { |
| 9169 | if (context->getClientVersion() < 3) |
| 9170 | { |
| 9171 | return gl::error(GL_INVALID_OPERATION); |
| 9172 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9173 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9174 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9175 | if (!programBinary) |
| 9176 | { |
| 9177 | return gl::error(GL_INVALID_OPERATION); |
| 9178 | } |
| 9179 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9180 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9181 | { |
| 9182 | return gl::error(GL_INVALID_OPERATION); |
| 9183 | } |
| 9184 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9185 | } |
| 9186 | catch(std::bad_alloc&) |
| 9187 | { |
| 9188 | return gl::error(GL_OUT_OF_MEMORY); |
| 9189 | } |
| 9190 | } |
| 9191 | |
| 9192 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9193 | { |
| 9194 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9195 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9196 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9197 | |
| 9198 | try |
| 9199 | { |
| 9200 | gl::Context *context = gl::getNonLostContext(); |
| 9201 | |
| 9202 | if (context) |
| 9203 | { |
| 9204 | if (context->getClientVersion() < 3) |
| 9205 | { |
| 9206 | return gl::error(GL_INVALID_OPERATION); |
| 9207 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9208 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9209 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9210 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9211 | false)) |
| 9212 | { |
| 9213 | return; |
| 9214 | } |
| 9215 | |
| 9216 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9217 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9219 | } |
| 9220 | catch(std::bad_alloc&) |
| 9221 | { |
| 9222 | return gl::error(GL_OUT_OF_MEMORY); |
| 9223 | } |
| 9224 | } |
| 9225 | |
| 9226 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9227 | { |
| 9228 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9229 | target, samples, internalformat, width, height); |
| 9230 | |
| 9231 | try |
| 9232 | { |
| 9233 | gl::Context *context = gl::getNonLostContext(); |
| 9234 | |
| 9235 | if (context) |
| 9236 | { |
| 9237 | if (context->getClientVersion() < 3) |
| 9238 | { |
| 9239 | return gl::error(GL_INVALID_OPERATION); |
| 9240 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9241 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9242 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9243 | width, height, false)) |
| 9244 | { |
| 9245 | return; |
| 9246 | } |
| 9247 | |
| 9248 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9249 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9250 | } |
| 9251 | catch(std::bad_alloc&) |
| 9252 | { |
| 9253 | return gl::error(GL_OUT_OF_MEMORY); |
| 9254 | } |
| 9255 | } |
| 9256 | |
| 9257 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9258 | { |
| 9259 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9260 | target, attachment, texture, level, layer); |
| 9261 | |
| 9262 | try |
| 9263 | { |
| 9264 | gl::Context *context = gl::getNonLostContext(); |
| 9265 | |
| 9266 | if (context) |
| 9267 | { |
| 9268 | if (context->getClientVersion() < 3) |
| 9269 | { |
| 9270 | return gl::error(GL_INVALID_OPERATION); |
| 9271 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9272 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9273 | // glFramebufferTextureLayer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9274 | UNIMPLEMENTED(); |
| 9275 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9276 | } |
| 9277 | catch(std::bad_alloc&) |
| 9278 | { |
| 9279 | return gl::error(GL_OUT_OF_MEMORY); |
| 9280 | } |
| 9281 | } |
| 9282 | |
| 9283 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9284 | { |
| 9285 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9286 | target, offset, length, access); |
| 9287 | |
| 9288 | try |
| 9289 | { |
| 9290 | gl::Context *context = gl::getNonLostContext(); |
| 9291 | |
| 9292 | if (context) |
| 9293 | { |
| 9294 | if (context->getClientVersion() < 3) |
| 9295 | { |
| 9296 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9297 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9298 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9299 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9300 | UNIMPLEMENTED(); |
| 9301 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9302 | } |
| 9303 | catch(std::bad_alloc&) |
| 9304 | { |
| 9305 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9306 | } |
| 9307 | |
| 9308 | return NULL; |
| 9309 | } |
| 9310 | |
| 9311 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9312 | { |
| 9313 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9314 | |
| 9315 | try |
| 9316 | { |
| 9317 | gl::Context *context = gl::getNonLostContext(); |
| 9318 | |
| 9319 | if (context) |
| 9320 | { |
| 9321 | if (context->getClientVersion() < 3) |
| 9322 | { |
| 9323 | return gl::error(GL_INVALID_OPERATION); |
| 9324 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9325 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9326 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9327 | UNIMPLEMENTED(); |
| 9328 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9329 | } |
| 9330 | catch(std::bad_alloc&) |
| 9331 | { |
| 9332 | return gl::error(GL_OUT_OF_MEMORY); |
| 9333 | } |
| 9334 | } |
| 9335 | |
| 9336 | void __stdcall glBindVertexArray(GLuint array) |
| 9337 | { |
| 9338 | EVENT("(GLuint array = %u)", array); |
| 9339 | |
| 9340 | try |
| 9341 | { |
| 9342 | gl::Context *context = gl::getNonLostContext(); |
| 9343 | |
| 9344 | if (context) |
| 9345 | { |
| 9346 | if (context->getClientVersion() < 3) |
| 9347 | { |
| 9348 | return gl::error(GL_INVALID_OPERATION); |
| 9349 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9350 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9351 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9352 | |
| 9353 | if (!vao) |
| 9354 | { |
| 9355 | // The default VAO should always exist |
| 9356 | ASSERT(array != 0); |
| 9357 | return gl::error(GL_INVALID_OPERATION); |
| 9358 | } |
| 9359 | |
| 9360 | context->bindVertexArray(array); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9361 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9362 | } |
| 9363 | catch(std::bad_alloc&) |
| 9364 | { |
| 9365 | return gl::error(GL_OUT_OF_MEMORY); |
| 9366 | } |
| 9367 | } |
| 9368 | |
| 9369 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9370 | { |
| 9371 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9372 | |
| 9373 | try |
| 9374 | { |
| 9375 | gl::Context *context = gl::getNonLostContext(); |
| 9376 | |
| 9377 | if (context) |
| 9378 | { |
| 9379 | if (context->getClientVersion() < 3) |
| 9380 | { |
| 9381 | return gl::error(GL_INVALID_OPERATION); |
| 9382 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9383 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9384 | if (n < 0) |
| 9385 | { |
| 9386 | return gl::error(GL_INVALID_VALUE); |
| 9387 | } |
| 9388 | |
| 9389 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9390 | { |
| 9391 | if (arrays[arrayIndex] != 0) |
| 9392 | { |
| 9393 | context->deleteVertexArray(arrays[arrayIndex]); |
| 9394 | } |
| 9395 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9396 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9397 | } |
| 9398 | catch(std::bad_alloc&) |
| 9399 | { |
| 9400 | return gl::error(GL_OUT_OF_MEMORY); |
| 9401 | } |
| 9402 | } |
| 9403 | |
| 9404 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9405 | { |
| 9406 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9407 | |
| 9408 | try |
| 9409 | { |
| 9410 | gl::Context *context = gl::getNonLostContext(); |
| 9411 | |
| 9412 | if (context) |
| 9413 | { |
| 9414 | if (context->getClientVersion() < 3) |
| 9415 | { |
| 9416 | return gl::error(GL_INVALID_OPERATION); |
| 9417 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9418 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9419 | if (n < 0) |
| 9420 | { |
| 9421 | return gl::error(GL_INVALID_VALUE); |
| 9422 | } |
| 9423 | |
| 9424 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 9425 | { |
| 9426 | arrays[arrayIndex] = context->createVertexArray(); |
| 9427 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9429 | } |
| 9430 | catch(std::bad_alloc&) |
| 9431 | { |
| 9432 | return gl::error(GL_OUT_OF_MEMORY); |
| 9433 | } |
| 9434 | } |
| 9435 | |
| 9436 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9437 | { |
| 9438 | EVENT("(GLuint array = %u)", array); |
| 9439 | |
| 9440 | try |
| 9441 | { |
| 9442 | gl::Context *context = gl::getNonLostContext(); |
| 9443 | |
| 9444 | if (context) |
| 9445 | { |
| 9446 | if (context->getClientVersion() < 3) |
| 9447 | { |
| 9448 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9449 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9450 | |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9451 | if (array == 0) |
| 9452 | { |
| 9453 | return GL_FALSE; |
| 9454 | } |
| 9455 | |
| 9456 | gl::VertexArray *vao = context->getVertexArray(array); |
| 9457 | |
| 9458 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9459 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9460 | } |
| 9461 | catch(std::bad_alloc&) |
| 9462 | { |
| 9463 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9464 | } |
| 9465 | |
| 9466 | return GL_FALSE; |
| 9467 | } |
| 9468 | |
| 9469 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9470 | { |
| 9471 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9472 | target, index, data); |
| 9473 | |
| 9474 | try |
| 9475 | { |
| 9476 | gl::Context *context = gl::getNonLostContext(); |
| 9477 | |
| 9478 | if (context) |
| 9479 | { |
| 9480 | if (context->getClientVersion() < 3) |
| 9481 | { |
| 9482 | return gl::error(GL_INVALID_OPERATION); |
| 9483 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9484 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9485 | // glGetIntegeri_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9486 | UNIMPLEMENTED(); |
| 9487 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9488 | } |
| 9489 | catch(std::bad_alloc&) |
| 9490 | { |
| 9491 | return gl::error(GL_OUT_OF_MEMORY); |
| 9492 | } |
| 9493 | } |
| 9494 | |
| 9495 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9496 | { |
| 9497 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9498 | |
| 9499 | try |
| 9500 | { |
| 9501 | gl::Context *context = gl::getNonLostContext(); |
| 9502 | |
| 9503 | if (context) |
| 9504 | { |
| 9505 | if (context->getClientVersion() < 3) |
| 9506 | { |
| 9507 | return gl::error(GL_INVALID_OPERATION); |
| 9508 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9509 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9510 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9511 | UNIMPLEMENTED(); |
| 9512 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9513 | } |
| 9514 | catch(std::bad_alloc&) |
| 9515 | { |
| 9516 | return gl::error(GL_OUT_OF_MEMORY); |
| 9517 | } |
| 9518 | } |
| 9519 | |
| 9520 | void __stdcall glEndTransformFeedback(void) |
| 9521 | { |
| 9522 | EVENT("(void)"); |
| 9523 | |
| 9524 | try |
| 9525 | { |
| 9526 | gl::Context *context = gl::getNonLostContext(); |
| 9527 | |
| 9528 | if (context) |
| 9529 | { |
| 9530 | if (context->getClientVersion() < 3) |
| 9531 | { |
| 9532 | return gl::error(GL_INVALID_OPERATION); |
| 9533 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9534 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9535 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9536 | UNIMPLEMENTED(); |
| 9537 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9538 | } |
| 9539 | catch(std::bad_alloc&) |
| 9540 | { |
| 9541 | return gl::error(GL_OUT_OF_MEMORY); |
| 9542 | } |
| 9543 | } |
| 9544 | |
| 9545 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9546 | { |
| 9547 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9548 | target, index, buffer, offset, size); |
| 9549 | |
| 9550 | try |
| 9551 | { |
| 9552 | gl::Context *context = gl::getNonLostContext(); |
| 9553 | |
| 9554 | if (context) |
| 9555 | { |
| 9556 | if (context->getClientVersion() < 3) |
| 9557 | { |
| 9558 | return gl::error(GL_INVALID_OPERATION); |
| 9559 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9560 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9561 | switch (target) |
| 9562 | { |
| 9563 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9564 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9565 | { |
| 9566 | return gl::error(GL_INVALID_VALUE); |
| 9567 | } |
| 9568 | break; |
| 9569 | |
| 9570 | case GL_UNIFORM_BUFFER: |
| 9571 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9572 | { |
| 9573 | return gl::error(GL_INVALID_VALUE); |
| 9574 | } |
| 9575 | break; |
| 9576 | |
| 9577 | default: |
| 9578 | return gl::error(GL_INVALID_ENUM); |
| 9579 | } |
| 9580 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9581 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9582 | { |
| 9583 | return gl::error(GL_INVALID_VALUE); |
| 9584 | } |
| 9585 | |
| 9586 | switch (target) |
| 9587 | { |
| 9588 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9589 | |
| 9590 | // size and offset must be a multiple of 4 |
| 9591 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9592 | { |
| 9593 | return gl::error(GL_INVALID_VALUE); |
| 9594 | } |
| 9595 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9596 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9597 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9598 | break; |
| 9599 | |
| 9600 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9601 | |
| 9602 | // it is an error to bind an offset not a multiple of the alignment |
| 9603 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9604 | { |
| 9605 | return gl::error(GL_INVALID_VALUE); |
| 9606 | } |
| 9607 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9608 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9609 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9610 | break; |
| 9611 | |
| 9612 | default: |
| 9613 | UNREACHABLE(); |
| 9614 | } |
| 9615 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9616 | } |
| 9617 | catch(std::bad_alloc&) |
| 9618 | { |
| 9619 | return gl::error(GL_OUT_OF_MEMORY); |
| 9620 | } |
| 9621 | } |
| 9622 | |
| 9623 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9624 | { |
| 9625 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9626 | target, index, buffer); |
| 9627 | |
| 9628 | try |
| 9629 | { |
| 9630 | gl::Context *context = gl::getNonLostContext(); |
| 9631 | |
| 9632 | if (context) |
| 9633 | { |
| 9634 | if (context->getClientVersion() < 3) |
| 9635 | { |
| 9636 | return gl::error(GL_INVALID_OPERATION); |
| 9637 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9638 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9639 | switch (target) |
| 9640 | { |
| 9641 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9642 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9643 | { |
| 9644 | return gl::error(GL_INVALID_VALUE); |
| 9645 | } |
| 9646 | break; |
| 9647 | |
| 9648 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9649 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9650 | { |
| 9651 | return gl::error(GL_INVALID_VALUE); |
| 9652 | } |
| 9653 | break; |
| 9654 | |
| 9655 | default: |
| 9656 | return gl::error(GL_INVALID_ENUM); |
| 9657 | } |
| 9658 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9659 | switch (target) |
| 9660 | { |
| 9661 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9662 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9663 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9664 | break; |
| 9665 | |
| 9666 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9667 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9668 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9669 | break; |
| 9670 | |
| 9671 | default: |
| 9672 | UNREACHABLE(); |
| 9673 | } |
| 9674 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9675 | } |
| 9676 | catch(std::bad_alloc&) |
| 9677 | { |
| 9678 | return gl::error(GL_OUT_OF_MEMORY); |
| 9679 | } |
| 9680 | } |
| 9681 | |
| 9682 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9683 | { |
| 9684 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9685 | program, count, varyings, bufferMode); |
| 9686 | |
| 9687 | try |
| 9688 | { |
| 9689 | gl::Context *context = gl::getNonLostContext(); |
| 9690 | |
| 9691 | if (context) |
| 9692 | { |
| 9693 | if (context->getClientVersion() < 3) |
| 9694 | { |
| 9695 | return gl::error(GL_INVALID_OPERATION); |
| 9696 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9697 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9698 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9699 | UNIMPLEMENTED(); |
| 9700 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9701 | } |
| 9702 | catch(std::bad_alloc&) |
| 9703 | { |
| 9704 | return gl::error(GL_OUT_OF_MEMORY); |
| 9705 | } |
| 9706 | } |
| 9707 | |
| 9708 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9709 | { |
| 9710 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9711 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9712 | program, index, bufSize, length, size, type, name); |
| 9713 | |
| 9714 | try |
| 9715 | { |
| 9716 | gl::Context *context = gl::getNonLostContext(); |
| 9717 | |
| 9718 | if (context) |
| 9719 | { |
| 9720 | if (context->getClientVersion() < 3) |
| 9721 | { |
| 9722 | return gl::error(GL_INVALID_OPERATION); |
| 9723 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9724 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9725 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9726 | UNIMPLEMENTED(); |
| 9727 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9728 | } |
| 9729 | catch(std::bad_alloc&) |
| 9730 | { |
| 9731 | return gl::error(GL_OUT_OF_MEMORY); |
| 9732 | } |
| 9733 | } |
| 9734 | |
| 9735 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9736 | { |
| 9737 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9738 | index, size, type, stride, pointer); |
| 9739 | |
| 9740 | try |
| 9741 | { |
| 9742 | gl::Context *context = gl::getNonLostContext(); |
| 9743 | |
| 9744 | if (context) |
| 9745 | { |
| 9746 | if (context->getClientVersion() < 3) |
| 9747 | { |
| 9748 | return gl::error(GL_INVALID_OPERATION); |
| 9749 | } |
| 9750 | } |
| 9751 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9752 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9753 | { |
| 9754 | return gl::error(GL_INVALID_VALUE); |
| 9755 | } |
| 9756 | |
| 9757 | if (size < 1 || size > 4) |
| 9758 | { |
| 9759 | return gl::error(GL_INVALID_VALUE); |
| 9760 | } |
| 9761 | |
| 9762 | switch (type) |
| 9763 | { |
| 9764 | case GL_BYTE: |
| 9765 | case GL_UNSIGNED_BYTE: |
| 9766 | case GL_SHORT: |
| 9767 | case GL_UNSIGNED_SHORT: |
| 9768 | case GL_INT: |
| 9769 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9770 | case GL_INT_2_10_10_10_REV: |
| 9771 | 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] | 9772 | break; |
| 9773 | default: |
| 9774 | return gl::error(GL_INVALID_ENUM); |
| 9775 | } |
| 9776 | |
| 9777 | if (stride < 0) |
| 9778 | { |
| 9779 | return gl::error(GL_INVALID_VALUE); |
| 9780 | } |
| 9781 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9782 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9783 | { |
| 9784 | return gl::error(GL_INVALID_OPERATION); |
| 9785 | } |
| 9786 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9787 | if (context) |
| 9788 | { |
Jamie Madill | d8db866 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 9789 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 9790 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 9791 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 9792 | // and the pointer argument is not NULL. |
| 9793 | if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL) |
| 9794 | { |
| 9795 | return gl::error(GL_INVALID_OPERATION); |
| 9796 | } |
| 9797 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9798 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9799 | stride, pointer); |
| 9800 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9801 | } |
| 9802 | catch(std::bad_alloc&) |
| 9803 | { |
| 9804 | return gl::error(GL_OUT_OF_MEMORY); |
| 9805 | } |
| 9806 | } |
| 9807 | |
| 9808 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9809 | { |
| 9810 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9811 | index, pname, params); |
| 9812 | |
| 9813 | try |
| 9814 | { |
| 9815 | gl::Context *context = gl::getNonLostContext(); |
| 9816 | |
| 9817 | if (context) |
| 9818 | { |
| 9819 | if (context->getClientVersion() < 3) |
| 9820 | { |
| 9821 | return gl::error(GL_INVALID_OPERATION); |
| 9822 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9823 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9824 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9825 | { |
| 9826 | return gl::error(GL_INVALID_VALUE); |
| 9827 | } |
| 9828 | |
| 9829 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9830 | |
| 9831 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9832 | { |
| 9833 | return; |
| 9834 | } |
| 9835 | |
| 9836 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9837 | { |
| 9838 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9839 | for (int i = 0; i < 4; ++i) |
| 9840 | { |
| 9841 | params[i] = currentValueData.IntValues[i]; |
| 9842 | } |
| 9843 | } |
| 9844 | else |
| 9845 | { |
| 9846 | *params = attribState.querySingleParameter<GLint>(pname); |
| 9847 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9848 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9849 | } |
| 9850 | catch(std::bad_alloc&) |
| 9851 | { |
| 9852 | return gl::error(GL_OUT_OF_MEMORY); |
| 9853 | } |
| 9854 | } |
| 9855 | |
| 9856 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9857 | { |
| 9858 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9859 | index, pname, params); |
| 9860 | |
| 9861 | try |
| 9862 | { |
| 9863 | gl::Context *context = gl::getNonLostContext(); |
| 9864 | |
| 9865 | if (context) |
| 9866 | { |
| 9867 | if (context->getClientVersion() < 3) |
| 9868 | { |
| 9869 | return gl::error(GL_INVALID_OPERATION); |
| 9870 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9871 | |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 9872 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9873 | { |
| 9874 | return gl::error(GL_INVALID_VALUE); |
| 9875 | } |
| 9876 | |
| 9877 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
| 9878 | |
| 9879 | if (!validateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 9880 | { |
| 9881 | return; |
| 9882 | } |
| 9883 | |
| 9884 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 9885 | { |
| 9886 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 9887 | for (int i = 0; i < 4; ++i) |
| 9888 | { |
| 9889 | params[i] = currentValueData.UnsignedIntValues[i]; |
| 9890 | } |
| 9891 | } |
| 9892 | else |
| 9893 | { |
| 9894 | *params = attribState.querySingleParameter<GLuint>(pname); |
| 9895 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9896 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9897 | } |
| 9898 | catch(std::bad_alloc&) |
| 9899 | { |
| 9900 | return gl::error(GL_OUT_OF_MEMORY); |
| 9901 | } |
| 9902 | } |
| 9903 | |
| 9904 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9905 | { |
| 9906 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9907 | index, x, y, z, w); |
| 9908 | |
| 9909 | try |
| 9910 | { |
| 9911 | gl::Context *context = gl::getNonLostContext(); |
| 9912 | |
| 9913 | if (context) |
| 9914 | { |
| 9915 | if (context->getClientVersion() < 3) |
| 9916 | { |
| 9917 | return gl::error(GL_INVALID_OPERATION); |
| 9918 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9919 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9920 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9921 | { |
| 9922 | return gl::error(GL_INVALID_VALUE); |
| 9923 | } |
| 9924 | |
| 9925 | GLint vals[4] = { x, y, z, w }; |
| 9926 | context->setVertexAttribi(index, vals); |
| 9927 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9928 | } |
| 9929 | catch(std::bad_alloc&) |
| 9930 | { |
| 9931 | return gl::error(GL_OUT_OF_MEMORY); |
| 9932 | } |
| 9933 | } |
| 9934 | |
| 9935 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9936 | { |
| 9937 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9938 | index, x, y, z, w); |
| 9939 | |
| 9940 | try |
| 9941 | { |
| 9942 | gl::Context *context = gl::getNonLostContext(); |
| 9943 | |
| 9944 | if (context) |
| 9945 | { |
| 9946 | if (context->getClientVersion() < 3) |
| 9947 | { |
| 9948 | return gl::error(GL_INVALID_OPERATION); |
| 9949 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9950 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9951 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9952 | { |
| 9953 | return gl::error(GL_INVALID_VALUE); |
| 9954 | } |
| 9955 | |
| 9956 | GLuint vals[4] = { x, y, z, w }; |
| 9957 | context->setVertexAttribu(index, vals); |
| 9958 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9959 | } |
| 9960 | catch(std::bad_alloc&) |
| 9961 | { |
| 9962 | return gl::error(GL_OUT_OF_MEMORY); |
| 9963 | } |
| 9964 | } |
| 9965 | |
| 9966 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9967 | { |
| 9968 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9969 | |
| 9970 | try |
| 9971 | { |
| 9972 | gl::Context *context = gl::getNonLostContext(); |
| 9973 | |
| 9974 | if (context) |
| 9975 | { |
| 9976 | if (context->getClientVersion() < 3) |
| 9977 | { |
| 9978 | return gl::error(GL_INVALID_OPERATION); |
| 9979 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9980 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9981 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9982 | { |
| 9983 | return gl::error(GL_INVALID_VALUE); |
| 9984 | } |
| 9985 | |
| 9986 | context->setVertexAttribi(index, v); |
| 9987 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9988 | } |
| 9989 | catch(std::bad_alloc&) |
| 9990 | { |
| 9991 | return gl::error(GL_OUT_OF_MEMORY); |
| 9992 | } |
| 9993 | } |
| 9994 | |
| 9995 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9996 | { |
| 9997 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9998 | |
| 9999 | try |
| 10000 | { |
| 10001 | gl::Context *context = gl::getNonLostContext(); |
| 10002 | |
| 10003 | if (context) |
| 10004 | { |
| 10005 | if (context->getClientVersion() < 3) |
| 10006 | { |
| 10007 | return gl::error(GL_INVALID_OPERATION); |
| 10008 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10009 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 10010 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 10011 | { |
| 10012 | return gl::error(GL_INVALID_VALUE); |
| 10013 | } |
| 10014 | |
| 10015 | context->setVertexAttribu(index, v); |
| 10016 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10017 | } |
| 10018 | catch(std::bad_alloc&) |
| 10019 | { |
| 10020 | return gl::error(GL_OUT_OF_MEMORY); |
| 10021 | } |
| 10022 | } |
| 10023 | |
| 10024 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 10025 | { |
| 10026 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 10027 | program, location, params); |
| 10028 | |
| 10029 | try |
| 10030 | { |
| 10031 | gl::Context *context = gl::getNonLostContext(); |
| 10032 | |
| 10033 | if (context) |
| 10034 | { |
| 10035 | if (context->getClientVersion() < 3) |
| 10036 | { |
| 10037 | return gl::error(GL_INVALID_OPERATION); |
| 10038 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10039 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 10040 | if (program == 0) |
| 10041 | { |
| 10042 | return gl::error(GL_INVALID_VALUE); |
| 10043 | } |
| 10044 | |
| 10045 | gl::Program *programObject = context->getProgram(program); |
| 10046 | |
| 10047 | if (!programObject || !programObject->isLinked()) |
| 10048 | { |
| 10049 | return gl::error(GL_INVALID_OPERATION); |
| 10050 | } |
| 10051 | |
| 10052 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10053 | if (!programBinary) |
| 10054 | { |
| 10055 | return gl::error(GL_INVALID_OPERATION); |
| 10056 | } |
| 10057 | |
| 10058 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 10059 | { |
| 10060 | return gl::error(GL_INVALID_OPERATION); |
| 10061 | } |
| 10062 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10063 | } |
| 10064 | catch(std::bad_alloc&) |
| 10065 | { |
| 10066 | return gl::error(GL_OUT_OF_MEMORY); |
| 10067 | } |
| 10068 | } |
| 10069 | |
| 10070 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 10071 | { |
| 10072 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 10073 | program, name); |
| 10074 | |
| 10075 | try |
| 10076 | { |
| 10077 | gl::Context *context = gl::getNonLostContext(); |
| 10078 | |
| 10079 | if (context) |
| 10080 | { |
| 10081 | if (context->getClientVersion() < 3) |
| 10082 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10083 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10085 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 10086 | if (program == 0) |
| 10087 | { |
| 10088 | return gl::error(GL_INVALID_VALUE, -1); |
| 10089 | } |
| 10090 | |
| 10091 | gl::Program *programObject = context->getProgram(program); |
| 10092 | |
| 10093 | if (!programObject || !programObject->isLinked()) |
| 10094 | { |
| 10095 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10096 | } |
| 10097 | |
| 10098 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10099 | if (!programBinary) |
| 10100 | { |
| 10101 | return gl::error(GL_INVALID_OPERATION, -1); |
| 10102 | } |
| 10103 | |
| 10104 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10105 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10106 | } |
| 10107 | catch(std::bad_alloc&) |
| 10108 | { |
| 10109 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10110 | } |
| 10111 | |
| 10112 | return 0; |
| 10113 | } |
| 10114 | |
| 10115 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 10116 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10117 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10118 | } |
| 10119 | |
| 10120 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 10121 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10122 | const GLuint xy[] = { v0, v1 }; |
| 10123 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10124 | } |
| 10125 | |
| 10126 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 10127 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10128 | const GLuint xyz[] = { v0, v1, v2 }; |
| 10129 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10130 | } |
| 10131 | |
| 10132 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 10133 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 10134 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 10135 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10136 | } |
| 10137 | |
| 10138 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 10139 | { |
| 10140 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10141 | location, count, value); |
| 10142 | |
| 10143 | try |
| 10144 | { |
| 10145 | gl::Context *context = gl::getNonLostContext(); |
| 10146 | |
| 10147 | if (context) |
| 10148 | { |
| 10149 | if (context->getClientVersion() < 3) |
| 10150 | { |
| 10151 | return gl::error(GL_INVALID_OPERATION); |
| 10152 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10153 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10154 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10155 | if (!programBinary) |
| 10156 | { |
| 10157 | return gl::error(GL_INVALID_OPERATION); |
| 10158 | } |
| 10159 | |
| 10160 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 10161 | { |
| 10162 | return gl::error(GL_INVALID_OPERATION); |
| 10163 | } |
| 10164 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10165 | } |
| 10166 | catch(std::bad_alloc&) |
| 10167 | { |
| 10168 | return gl::error(GL_OUT_OF_MEMORY); |
| 10169 | } |
| 10170 | } |
| 10171 | |
| 10172 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 10173 | { |
| 10174 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10175 | location, count, value); |
| 10176 | |
| 10177 | try |
| 10178 | { |
| 10179 | gl::Context *context = gl::getNonLostContext(); |
| 10180 | |
| 10181 | if (context) |
| 10182 | { |
| 10183 | if (context->getClientVersion() < 3) |
| 10184 | { |
| 10185 | return gl::error(GL_INVALID_OPERATION); |
| 10186 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10187 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10188 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10189 | if (!programBinary) |
| 10190 | { |
| 10191 | return gl::error(GL_INVALID_OPERATION); |
| 10192 | } |
| 10193 | |
| 10194 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 10195 | { |
| 10196 | return gl::error(GL_INVALID_OPERATION); |
| 10197 | } |
| 10198 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10199 | } |
| 10200 | catch(std::bad_alloc&) |
| 10201 | { |
| 10202 | return gl::error(GL_OUT_OF_MEMORY); |
| 10203 | } |
| 10204 | } |
| 10205 | |
| 10206 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 10207 | { |
| 10208 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 10209 | location, count, value); |
| 10210 | |
| 10211 | try |
| 10212 | { |
| 10213 | gl::Context *context = gl::getNonLostContext(); |
| 10214 | |
| 10215 | if (context) |
| 10216 | { |
| 10217 | if (context->getClientVersion() < 3) |
| 10218 | { |
| 10219 | return gl::error(GL_INVALID_OPERATION); |
| 10220 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10221 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10222 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10223 | if (!programBinary) |
| 10224 | { |
| 10225 | return gl::error(GL_INVALID_OPERATION); |
| 10226 | } |
| 10227 | |
| 10228 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 10229 | { |
| 10230 | return gl::error(GL_INVALID_OPERATION); |
| 10231 | } |
| 10232 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10233 | } |
| 10234 | catch(std::bad_alloc&) |
| 10235 | { |
| 10236 | return gl::error(GL_OUT_OF_MEMORY); |
| 10237 | } |
| 10238 | } |
| 10239 | |
| 10240 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 10241 | { |
| 10242 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10243 | location, count, value); |
| 10244 | |
| 10245 | try |
| 10246 | { |
| 10247 | gl::Context *context = gl::getNonLostContext(); |
| 10248 | |
| 10249 | if (context) |
| 10250 | { |
| 10251 | if (context->getClientVersion() < 3) |
| 10252 | { |
| 10253 | return gl::error(GL_INVALID_OPERATION); |
| 10254 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10255 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10256 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10257 | if (!programBinary) |
| 10258 | { |
| 10259 | return gl::error(GL_INVALID_OPERATION); |
| 10260 | } |
| 10261 | |
| 10262 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 10263 | { |
| 10264 | return gl::error(GL_INVALID_OPERATION); |
| 10265 | } |
| 10266 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10267 | } |
| 10268 | catch(std::bad_alloc&) |
| 10269 | { |
| 10270 | return gl::error(GL_OUT_OF_MEMORY); |
| 10271 | } |
| 10272 | } |
| 10273 | |
| 10274 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10275 | { |
| 10276 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10277 | buffer, drawbuffer, value); |
| 10278 | |
| 10279 | try |
| 10280 | { |
| 10281 | gl::Context *context = gl::getNonLostContext(); |
| 10282 | |
| 10283 | if (context) |
| 10284 | { |
| 10285 | if (context->getClientVersion() < 3) |
| 10286 | { |
| 10287 | return gl::error(GL_INVALID_OPERATION); |
| 10288 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10289 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10290 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10291 | UNIMPLEMENTED(); |
| 10292 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10293 | } |
| 10294 | catch(std::bad_alloc&) |
| 10295 | { |
| 10296 | return gl::error(GL_OUT_OF_MEMORY); |
| 10297 | } |
| 10298 | } |
| 10299 | |
| 10300 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10301 | { |
| 10302 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10303 | buffer, drawbuffer, value); |
| 10304 | |
| 10305 | try |
| 10306 | { |
| 10307 | gl::Context *context = gl::getNonLostContext(); |
| 10308 | |
| 10309 | if (context) |
| 10310 | { |
| 10311 | if (context->getClientVersion() < 3) |
| 10312 | { |
| 10313 | return gl::error(GL_INVALID_OPERATION); |
| 10314 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10315 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10316 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10317 | UNIMPLEMENTED(); |
| 10318 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10319 | } |
| 10320 | catch(std::bad_alloc&) |
| 10321 | { |
| 10322 | return gl::error(GL_OUT_OF_MEMORY); |
| 10323 | } |
| 10324 | } |
| 10325 | |
| 10326 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10327 | { |
| 10328 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10329 | buffer, drawbuffer, value); |
| 10330 | |
| 10331 | try |
| 10332 | { |
| 10333 | gl::Context *context = gl::getNonLostContext(); |
| 10334 | |
| 10335 | if (context) |
| 10336 | { |
| 10337 | if (context->getClientVersion() < 3) |
| 10338 | { |
| 10339 | return gl::error(GL_INVALID_OPERATION); |
| 10340 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10341 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10342 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10343 | UNIMPLEMENTED(); |
| 10344 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10345 | } |
| 10346 | catch(std::bad_alloc&) |
| 10347 | { |
| 10348 | return gl::error(GL_OUT_OF_MEMORY); |
| 10349 | } |
| 10350 | } |
| 10351 | |
| 10352 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10353 | { |
| 10354 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10355 | buffer, drawbuffer, depth, stencil); |
| 10356 | |
| 10357 | try |
| 10358 | { |
| 10359 | gl::Context *context = gl::getNonLostContext(); |
| 10360 | |
| 10361 | if (context) |
| 10362 | { |
| 10363 | if (context->getClientVersion() < 3) |
| 10364 | { |
| 10365 | return gl::error(GL_INVALID_OPERATION); |
| 10366 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10367 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10368 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10369 | UNIMPLEMENTED(); |
| 10370 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10371 | } |
| 10372 | catch(std::bad_alloc&) |
| 10373 | { |
| 10374 | return gl::error(GL_OUT_OF_MEMORY); |
| 10375 | } |
| 10376 | } |
| 10377 | |
| 10378 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10379 | { |
| 10380 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10381 | |
| 10382 | try |
| 10383 | { |
| 10384 | gl::Context *context = gl::getNonLostContext(); |
| 10385 | |
| 10386 | if (context) |
| 10387 | { |
| 10388 | if (context->getClientVersion() < 3) |
| 10389 | { |
| 10390 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10391 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10392 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10393 | if (name != GL_EXTENSIONS) |
| 10394 | { |
| 10395 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10396 | } |
| 10397 | |
| 10398 | if (index >= context->getNumExtensions()) |
| 10399 | { |
| 10400 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10401 | } |
| 10402 | |
| 10403 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10404 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10405 | } |
| 10406 | catch(std::bad_alloc&) |
| 10407 | { |
| 10408 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10409 | } |
| 10410 | |
| 10411 | return NULL; |
| 10412 | } |
| 10413 | |
| 10414 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10415 | { |
| 10416 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10417 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10418 | |
| 10419 | try |
| 10420 | { |
| 10421 | gl::Context *context = gl::getNonLostContext(); |
| 10422 | |
| 10423 | if (context) |
| 10424 | { |
| 10425 | if (context->getClientVersion() < 3) |
| 10426 | { |
| 10427 | return gl::error(GL_INVALID_OPERATION); |
| 10428 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10429 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10430 | gl::Buffer *readBuffer = NULL; |
| 10431 | switch (readTarget) |
| 10432 | { |
| 10433 | case GL_ARRAY_BUFFER: |
| 10434 | readBuffer = context->getArrayBuffer(); |
| 10435 | break; |
| 10436 | case GL_COPY_READ_BUFFER: |
| 10437 | readBuffer = context->getCopyReadBuffer(); |
| 10438 | break; |
| 10439 | case GL_COPY_WRITE_BUFFER: |
| 10440 | readBuffer = context->getCopyWriteBuffer(); |
| 10441 | break; |
| 10442 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10443 | readBuffer = context->getElementArrayBuffer(); |
| 10444 | break; |
| 10445 | case GL_PIXEL_PACK_BUFFER: |
| 10446 | readBuffer = context->getPixelPackBuffer(); |
| 10447 | break; |
| 10448 | case GL_PIXEL_UNPACK_BUFFER: |
| 10449 | readBuffer = context->getPixelUnpackBuffer(); |
| 10450 | break; |
| 10451 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10452 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10453 | break; |
| 10454 | case GL_UNIFORM_BUFFER: |
| 10455 | readBuffer = context->getGenericUniformBuffer(); |
| 10456 | break; |
| 10457 | default: |
| 10458 | return gl::error(GL_INVALID_ENUM); |
| 10459 | } |
| 10460 | |
| 10461 | gl::Buffer *writeBuffer = NULL; |
| 10462 | switch (writeTarget) |
| 10463 | { |
| 10464 | case GL_ARRAY_BUFFER: |
| 10465 | writeBuffer = context->getArrayBuffer(); |
| 10466 | break; |
| 10467 | case GL_COPY_READ_BUFFER: |
| 10468 | writeBuffer = context->getCopyReadBuffer(); |
| 10469 | break; |
| 10470 | case GL_COPY_WRITE_BUFFER: |
| 10471 | writeBuffer = context->getCopyWriteBuffer(); |
| 10472 | break; |
| 10473 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10474 | writeBuffer = context->getElementArrayBuffer(); |
| 10475 | break; |
| 10476 | case GL_PIXEL_PACK_BUFFER: |
| 10477 | writeBuffer = context->getPixelPackBuffer(); |
| 10478 | break; |
| 10479 | case GL_PIXEL_UNPACK_BUFFER: |
| 10480 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10481 | break; |
| 10482 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10483 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10484 | break; |
| 10485 | case GL_UNIFORM_BUFFER: |
| 10486 | writeBuffer = context->getGenericUniformBuffer(); |
| 10487 | break; |
| 10488 | default: |
| 10489 | return gl::error(GL_INVALID_ENUM); |
| 10490 | } |
| 10491 | |
| 10492 | if (!readBuffer || !writeBuffer) |
| 10493 | { |
| 10494 | return gl::error(GL_INVALID_OPERATION); |
| 10495 | } |
| 10496 | |
| 10497 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10498 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10499 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10500 | { |
| 10501 | return gl::error(GL_INVALID_VALUE); |
| 10502 | } |
| 10503 | |
| 10504 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10505 | { |
| 10506 | return gl::error(GL_INVALID_VALUE); |
| 10507 | } |
| 10508 | |
| 10509 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10510 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10511 | // if size is zero, the copy is a successful no-op |
| 10512 | if (size > 0) |
| 10513 | { |
| 10514 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10515 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10516 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10517 | } |
| 10518 | catch(std::bad_alloc&) |
| 10519 | { |
| 10520 | return gl::error(GL_OUT_OF_MEMORY); |
| 10521 | } |
| 10522 | } |
| 10523 | |
| 10524 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10525 | { |
| 10526 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10527 | program, uniformCount, uniformNames, uniformIndices); |
| 10528 | |
| 10529 | try |
| 10530 | { |
| 10531 | gl::Context *context = gl::getNonLostContext(); |
| 10532 | |
| 10533 | if (context) |
| 10534 | { |
| 10535 | if (context->getClientVersion() < 3) |
| 10536 | { |
| 10537 | return gl::error(GL_INVALID_OPERATION); |
| 10538 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10539 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10540 | if (uniformCount < 0) |
| 10541 | { |
| 10542 | return gl::error(GL_INVALID_VALUE); |
| 10543 | } |
| 10544 | |
| 10545 | gl::Program *programObject = context->getProgram(program); |
| 10546 | |
| 10547 | if (!programObject) |
| 10548 | { |
| 10549 | if (context->getShader(program)) |
| 10550 | { |
| 10551 | return gl::error(GL_INVALID_OPERATION); |
| 10552 | } |
| 10553 | else |
| 10554 | { |
| 10555 | return gl::error(GL_INVALID_VALUE); |
| 10556 | } |
| 10557 | } |
| 10558 | |
| 10559 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10560 | if (!programObject->isLinked() || !programBinary) |
| 10561 | { |
| 10562 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10563 | { |
| 10564 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10565 | } |
| 10566 | } |
| 10567 | else |
| 10568 | { |
| 10569 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10570 | { |
| 10571 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10572 | } |
| 10573 | } |
| 10574 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10575 | } |
| 10576 | catch(std::bad_alloc&) |
| 10577 | { |
| 10578 | return gl::error(GL_OUT_OF_MEMORY); |
| 10579 | } |
| 10580 | } |
| 10581 | |
| 10582 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10583 | { |
| 10584 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10585 | program, uniformCount, uniformIndices, pname, params); |
| 10586 | |
| 10587 | try |
| 10588 | { |
| 10589 | gl::Context *context = gl::getNonLostContext(); |
| 10590 | |
| 10591 | if (context) |
| 10592 | { |
| 10593 | if (context->getClientVersion() < 3) |
| 10594 | { |
| 10595 | return gl::error(GL_INVALID_OPERATION); |
| 10596 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10597 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10598 | if (uniformCount < 0) |
| 10599 | { |
| 10600 | return gl::error(GL_INVALID_VALUE); |
| 10601 | } |
| 10602 | |
| 10603 | gl::Program *programObject = context->getProgram(program); |
| 10604 | |
| 10605 | if (!programObject) |
| 10606 | { |
| 10607 | if (context->getShader(program)) |
| 10608 | { |
| 10609 | return gl::error(GL_INVALID_OPERATION); |
| 10610 | } |
| 10611 | else |
| 10612 | { |
| 10613 | return gl::error(GL_INVALID_VALUE); |
| 10614 | } |
| 10615 | } |
| 10616 | |
| 10617 | switch (pname) |
| 10618 | { |
| 10619 | case GL_UNIFORM_TYPE: |
| 10620 | case GL_UNIFORM_SIZE: |
| 10621 | case GL_UNIFORM_NAME_LENGTH: |
| 10622 | case GL_UNIFORM_BLOCK_INDEX: |
| 10623 | case GL_UNIFORM_OFFSET: |
| 10624 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10625 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10626 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10627 | break; |
| 10628 | default: |
| 10629 | return gl::error(GL_INVALID_ENUM); |
| 10630 | } |
| 10631 | |
| 10632 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10633 | |
| 10634 | if (!programBinary && uniformCount > 0) |
| 10635 | { |
| 10636 | return gl::error(GL_INVALID_VALUE); |
| 10637 | } |
| 10638 | |
| 10639 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10640 | { |
| 10641 | const GLuint index = uniformIndices[uniformId]; |
| 10642 | |
| 10643 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10644 | { |
| 10645 | return gl::error(GL_INVALID_VALUE); |
| 10646 | } |
| 10647 | } |
| 10648 | |
| 10649 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10650 | { |
| 10651 | const GLuint index = uniformIndices[uniformId]; |
| 10652 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10653 | } |
| 10654 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10655 | } |
| 10656 | catch(std::bad_alloc&) |
| 10657 | { |
| 10658 | return gl::error(GL_OUT_OF_MEMORY); |
| 10659 | } |
| 10660 | } |
| 10661 | |
| 10662 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10663 | { |
| 10664 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10665 | |
| 10666 | try |
| 10667 | { |
| 10668 | gl::Context *context = gl::getNonLostContext(); |
| 10669 | |
| 10670 | if (context) |
| 10671 | { |
| 10672 | if (context->getClientVersion() < 3) |
| 10673 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10674 | 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] | 10675 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10676 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10677 | gl::Program *programObject = context->getProgram(program); |
| 10678 | |
| 10679 | if (!programObject) |
| 10680 | { |
| 10681 | if (context->getShader(program)) |
| 10682 | { |
| 10683 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10684 | } |
| 10685 | else |
| 10686 | { |
| 10687 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10688 | } |
| 10689 | } |
| 10690 | |
| 10691 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10692 | if (!programBinary) |
| 10693 | { |
| 10694 | return GL_INVALID_INDEX; |
| 10695 | } |
| 10696 | |
| 10697 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10698 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10699 | } |
| 10700 | catch(std::bad_alloc&) |
| 10701 | { |
| 10702 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10703 | } |
| 10704 | |
| 10705 | return 0; |
| 10706 | } |
| 10707 | |
| 10708 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10709 | { |
| 10710 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10711 | program, uniformBlockIndex, pname, params); |
| 10712 | |
| 10713 | try |
| 10714 | { |
| 10715 | gl::Context *context = gl::getNonLostContext(); |
| 10716 | |
| 10717 | if (context) |
| 10718 | { |
| 10719 | if (context->getClientVersion() < 3) |
| 10720 | { |
| 10721 | return gl::error(GL_INVALID_OPERATION); |
| 10722 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10723 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10724 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10725 | if (!programObject) |
| 10726 | { |
| 10727 | if (context->getShader(program)) |
| 10728 | { |
| 10729 | return gl::error(GL_INVALID_OPERATION); |
| 10730 | } |
| 10731 | else |
| 10732 | { |
| 10733 | return gl::error(GL_INVALID_VALUE); |
| 10734 | } |
| 10735 | } |
| 10736 | |
| 10737 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10738 | |
| 10739 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10740 | { |
| 10741 | return gl::error(GL_INVALID_VALUE); |
| 10742 | } |
| 10743 | |
| 10744 | switch (pname) |
| 10745 | { |
| 10746 | case GL_UNIFORM_BLOCK_BINDING: |
| 10747 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10748 | break; |
| 10749 | |
| 10750 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10751 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10752 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10753 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10754 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10755 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10756 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10757 | break; |
| 10758 | |
| 10759 | default: |
| 10760 | return gl::error(GL_INVALID_ENUM); |
| 10761 | } |
| 10762 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10763 | } |
| 10764 | catch(std::bad_alloc&) |
| 10765 | { |
| 10766 | return gl::error(GL_OUT_OF_MEMORY); |
| 10767 | } |
| 10768 | } |
| 10769 | |
| 10770 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10771 | { |
| 10772 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10773 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10774 | |
| 10775 | try |
| 10776 | { |
| 10777 | gl::Context *context = gl::getNonLostContext(); |
| 10778 | |
| 10779 | if (context) |
| 10780 | { |
| 10781 | if (context->getClientVersion() < 3) |
| 10782 | { |
| 10783 | return gl::error(GL_INVALID_OPERATION); |
| 10784 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10785 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10786 | gl::Program *programObject = context->getProgram(program); |
| 10787 | |
| 10788 | if (!programObject) |
| 10789 | { |
| 10790 | if (context->getShader(program)) |
| 10791 | { |
| 10792 | return gl::error(GL_INVALID_OPERATION); |
| 10793 | } |
| 10794 | else |
| 10795 | { |
| 10796 | return gl::error(GL_INVALID_VALUE); |
| 10797 | } |
| 10798 | } |
| 10799 | |
| 10800 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10801 | |
| 10802 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10803 | { |
| 10804 | return gl::error(GL_INVALID_VALUE); |
| 10805 | } |
| 10806 | |
| 10807 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10808 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10809 | } |
| 10810 | catch(std::bad_alloc&) |
| 10811 | { |
| 10812 | return gl::error(GL_OUT_OF_MEMORY); |
| 10813 | } |
| 10814 | } |
| 10815 | |
| 10816 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10817 | { |
| 10818 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10819 | program, uniformBlockIndex, uniformBlockBinding); |
| 10820 | |
| 10821 | try |
| 10822 | { |
| 10823 | gl::Context *context = gl::getNonLostContext(); |
| 10824 | |
| 10825 | if (context) |
| 10826 | { |
| 10827 | if (context->getClientVersion() < 3) |
| 10828 | { |
| 10829 | return gl::error(GL_INVALID_OPERATION); |
| 10830 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10831 | |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10832 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 10833 | { |
| 10834 | return gl::error(GL_INVALID_VALUE); |
| 10835 | } |
| 10836 | |
| 10837 | gl::Program *programObject = context->getProgram(program); |
| 10838 | |
| 10839 | if (!programObject) |
| 10840 | { |
| 10841 | if (context->getShader(program)) |
| 10842 | { |
| 10843 | return gl::error(GL_INVALID_OPERATION); |
| 10844 | } |
| 10845 | else |
| 10846 | { |
| 10847 | return gl::error(GL_INVALID_VALUE); |
| 10848 | } |
| 10849 | } |
| 10850 | |
| 10851 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10852 | |
| 10853 | // if never linked, there won't be any uniform blocks |
| 10854 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10855 | { |
| 10856 | return gl::error(GL_INVALID_VALUE); |
| 10857 | } |
| 10858 | |
| 10859 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10860 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10861 | } |
| 10862 | catch(std::bad_alloc&) |
| 10863 | { |
| 10864 | return gl::error(GL_OUT_OF_MEMORY); |
| 10865 | } |
| 10866 | } |
| 10867 | |
| 10868 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10869 | { |
| 10870 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10871 | mode, first, count, instanceCount); |
| 10872 | |
| 10873 | try |
| 10874 | { |
| 10875 | gl::Context *context = gl::getNonLostContext(); |
| 10876 | |
| 10877 | if (context) |
| 10878 | { |
| 10879 | if (context->getClientVersion() < 3) |
| 10880 | { |
| 10881 | return gl::error(GL_INVALID_OPERATION); |
| 10882 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10883 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10884 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10885 | UNIMPLEMENTED(); |
| 10886 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10887 | } |
| 10888 | catch(std::bad_alloc&) |
| 10889 | { |
| 10890 | return gl::error(GL_OUT_OF_MEMORY); |
| 10891 | } |
| 10892 | } |
| 10893 | |
| 10894 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10895 | { |
| 10896 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10897 | mode, count, type, indices, instanceCount); |
| 10898 | |
| 10899 | try |
| 10900 | { |
| 10901 | gl::Context *context = gl::getNonLostContext(); |
| 10902 | |
| 10903 | if (context) |
| 10904 | { |
| 10905 | if (context->getClientVersion() < 3) |
| 10906 | { |
| 10907 | return gl::error(GL_INVALID_OPERATION); |
| 10908 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10909 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10910 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10911 | UNIMPLEMENTED(); |
| 10912 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10913 | } |
| 10914 | catch(std::bad_alloc&) |
| 10915 | { |
| 10916 | return gl::error(GL_OUT_OF_MEMORY); |
| 10917 | } |
| 10918 | } |
| 10919 | |
| 10920 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10921 | { |
| 10922 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10923 | |
| 10924 | try |
| 10925 | { |
| 10926 | gl::Context *context = gl::getNonLostContext(); |
| 10927 | |
| 10928 | if (context) |
| 10929 | { |
| 10930 | if (context->getClientVersion() < 3) |
| 10931 | { |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10932 | 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] | 10933 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10934 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10935 | if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) |
| 10936 | { |
| 10937 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLsync>(0)); |
| 10938 | } |
| 10939 | |
| 10940 | if (flags != 0) |
| 10941 | { |
| 10942 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLsync>(0)); |
| 10943 | } |
| 10944 | |
| 10945 | return context->createFenceSync(condition); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10946 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10947 | } |
| 10948 | catch(std::bad_alloc&) |
| 10949 | { |
| 10950 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10951 | } |
| 10952 | |
| 10953 | return NULL; |
| 10954 | } |
| 10955 | |
| 10956 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10957 | { |
| 10958 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10959 | |
| 10960 | try |
| 10961 | { |
| 10962 | gl::Context *context = gl::getNonLostContext(); |
| 10963 | |
| 10964 | if (context) |
| 10965 | { |
| 10966 | if (context->getClientVersion() < 3) |
| 10967 | { |
| 10968 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10969 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10970 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10971 | return (context->getFenceSync(sync) != NULL); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10972 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10973 | } |
| 10974 | catch(std::bad_alloc&) |
| 10975 | { |
| 10976 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10977 | } |
| 10978 | |
| 10979 | return GL_FALSE; |
| 10980 | } |
| 10981 | |
| 10982 | void __stdcall glDeleteSync(GLsync sync) |
| 10983 | { |
| 10984 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10985 | |
| 10986 | try |
| 10987 | { |
| 10988 | gl::Context *context = gl::getNonLostContext(); |
| 10989 | |
| 10990 | if (context) |
| 10991 | { |
| 10992 | if (context->getClientVersion() < 3) |
| 10993 | { |
| 10994 | return gl::error(GL_INVALID_OPERATION); |
| 10995 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10996 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 10997 | if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync)) |
| 10998 | { |
| 10999 | return gl::error(GL_INVALID_VALUE); |
| 11000 | } |
| 11001 | |
| 11002 | context->deleteFenceSync(sync); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11003 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11004 | } |
| 11005 | catch(std::bad_alloc&) |
| 11006 | { |
| 11007 | return gl::error(GL_OUT_OF_MEMORY); |
| 11008 | } |
| 11009 | } |
| 11010 | |
| 11011 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 11012 | { |
| 11013 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 11014 | sync, flags, timeout); |
| 11015 | |
| 11016 | try |
| 11017 | { |
| 11018 | gl::Context *context = gl::getNonLostContext(); |
| 11019 | |
| 11020 | if (context) |
| 11021 | { |
| 11022 | if (context->getClientVersion() < 3) |
| 11023 | { |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11024 | 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] | 11025 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11026 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11027 | if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) |
| 11028 | { |
| 11029 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 11030 | } |
| 11031 | |
| 11032 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 11033 | |
| 11034 | if (!fenceSync) |
| 11035 | { |
| 11036 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 11037 | } |
| 11038 | |
| 11039 | return fenceSync->clientWait(flags, timeout); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11040 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11041 | } |
| 11042 | catch(std::bad_alloc&) |
| 11043 | { |
| 11044 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11045 | } |
| 11046 | |
| 11047 | return GL_FALSE; |
| 11048 | } |
| 11049 | |
| 11050 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 11051 | { |
| 11052 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 11053 | sync, flags, timeout); |
| 11054 | |
| 11055 | try |
| 11056 | { |
| 11057 | gl::Context *context = gl::getNonLostContext(); |
| 11058 | |
| 11059 | if (context) |
| 11060 | { |
| 11061 | if (context->getClientVersion() < 3) |
| 11062 | { |
| 11063 | return gl::error(GL_INVALID_OPERATION); |
| 11064 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11065 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11066 | if (flags != 0) |
| 11067 | { |
| 11068 | return gl::error(GL_INVALID_VALUE); |
| 11069 | } |
| 11070 | |
| 11071 | if (timeout != GL_TIMEOUT_IGNORED) |
| 11072 | { |
| 11073 | return gl::error(GL_INVALID_VALUE); |
| 11074 | } |
| 11075 | |
| 11076 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 11077 | |
| 11078 | if (!fenceSync) |
| 11079 | { |
| 11080 | return gl::error(GL_INVALID_VALUE); |
| 11081 | } |
| 11082 | |
| 11083 | fenceSync->serverWait(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11085 | } |
| 11086 | catch(std::bad_alloc&) |
| 11087 | { |
| 11088 | return gl::error(GL_OUT_OF_MEMORY); |
| 11089 | } |
| 11090 | } |
| 11091 | |
| 11092 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 11093 | { |
| 11094 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11095 | pname, params); |
| 11096 | |
| 11097 | try |
| 11098 | { |
| 11099 | gl::Context *context = gl::getNonLostContext(); |
| 11100 | |
| 11101 | if (context) |
| 11102 | { |
| 11103 | if (context->getClientVersion() < 3) |
| 11104 | { |
| 11105 | return gl::error(GL_INVALID_OPERATION); |
| 11106 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11107 | |
Jamie Madill | 71fbd60 | 2013-07-19 16:36:55 -0400 | [diff] [blame] | 11108 | if (!(context->getInteger64v(pname, params))) |
| 11109 | { |
| 11110 | GLenum nativeType; |
| 11111 | unsigned int numParams = 0; |
| 11112 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
| 11113 | return gl::error(GL_INVALID_ENUM); |
| 11114 | |
| 11115 | if (numParams == 0) |
| 11116 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 11117 | |
| 11118 | if (nativeType == GL_BOOL) |
| 11119 | { |
| 11120 | GLboolean *boolParams = NULL; |
| 11121 | boolParams = new GLboolean[numParams]; |
| 11122 | |
| 11123 | context->getBooleanv(pname, boolParams); |
| 11124 | |
| 11125 | for (unsigned int i = 0; i < numParams; ++i) |
| 11126 | { |
| 11127 | if (boolParams[i] == GL_FALSE) |
| 11128 | params[i] = 0; |
| 11129 | else |
| 11130 | params[i] = 1; |
| 11131 | } |
| 11132 | |
| 11133 | delete [] boolParams; |
| 11134 | } |
| 11135 | else if (nativeType == GL_INT) |
| 11136 | { |
| 11137 | GLint *intParams = NULL; |
| 11138 | intParams = new GLint[numParams]; |
| 11139 | |
| 11140 | context->getIntegerv(pname, intParams); |
| 11141 | |
| 11142 | for (unsigned int i = 0; i < numParams; ++i) |
| 11143 | { |
| 11144 | params[i] = static_cast<GLint64>(intParams[i]); |
| 11145 | } |
| 11146 | |
| 11147 | delete [] intParams; |
| 11148 | } |
| 11149 | else if (nativeType == GL_FLOAT) |
| 11150 | { |
| 11151 | GLfloat *floatParams = NULL; |
| 11152 | floatParams = new GLfloat[numParams]; |
| 11153 | |
| 11154 | context->getFloatv(pname, floatParams); |
| 11155 | |
| 11156 | for (unsigned int i = 0; i < numParams; ++i) |
| 11157 | { |
| 11158 | // RGBA color values and DepthRangeF values are converted to integer using Equation 2.4 from Table 4.5 |
| 11159 | if (pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR) |
| 11160 | { |
| 11161 | params[i] = static_cast<GLint64>((static_cast<GLfloat>(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
| 11162 | } |
| 11163 | else |
| 11164 | { |
| 11165 | params[i] = gl::iround<GLint64>(floatParams[i]); |
| 11166 | } |
| 11167 | } |
| 11168 | |
| 11169 | delete [] floatParams; |
| 11170 | } |
| 11171 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11172 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11173 | } |
| 11174 | catch(std::bad_alloc&) |
| 11175 | { |
| 11176 | return gl::error(GL_OUT_OF_MEMORY); |
| 11177 | } |
| 11178 | } |
| 11179 | |
| 11180 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 11181 | { |
| 11182 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 11183 | sync, pname, bufSize, length, values); |
| 11184 | |
| 11185 | try |
| 11186 | { |
| 11187 | gl::Context *context = gl::getNonLostContext(); |
| 11188 | |
| 11189 | if (context) |
| 11190 | { |
| 11191 | if (context->getClientVersion() < 3) |
| 11192 | { |
| 11193 | return gl::error(GL_INVALID_OPERATION); |
| 11194 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11195 | |
Jamie Madill | 5215e1a | 2013-07-26 11:55:19 -0400 | [diff] [blame] | 11196 | if (bufSize < 0) |
| 11197 | { |
| 11198 | return gl::error(GL_INVALID_VALUE); |
| 11199 | } |
| 11200 | |
| 11201 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 11202 | |
| 11203 | if (!fenceSync) |
| 11204 | { |
| 11205 | return gl::error(GL_INVALID_VALUE); |
| 11206 | } |
| 11207 | |
| 11208 | switch (pname) |
| 11209 | { |
| 11210 | case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break; |
| 11211 | case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break; |
| 11212 | case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break; |
| 11213 | case GL_SYNC_FLAGS: values[0] = 0; break; |
| 11214 | |
| 11215 | default: |
| 11216 | return gl::error(GL_INVALID_ENUM); |
| 11217 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11219 | } |
| 11220 | catch(std::bad_alloc&) |
| 11221 | { |
| 11222 | return gl::error(GL_OUT_OF_MEMORY); |
| 11223 | } |
| 11224 | } |
| 11225 | |
| 11226 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 11227 | { |
| 11228 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 11229 | target, index, data); |
| 11230 | |
| 11231 | try |
| 11232 | { |
| 11233 | gl::Context *context = gl::getNonLostContext(); |
| 11234 | |
| 11235 | if (context) |
| 11236 | { |
| 11237 | if (context->getClientVersion() < 3) |
| 11238 | { |
| 11239 | return gl::error(GL_INVALID_OPERATION); |
| 11240 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11241 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11242 | // glGetInteger64i_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11243 | UNIMPLEMENTED(); |
| 11244 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11245 | } |
| 11246 | catch(std::bad_alloc&) |
| 11247 | { |
| 11248 | return gl::error(GL_OUT_OF_MEMORY); |
| 11249 | } |
| 11250 | } |
| 11251 | |
| 11252 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 11253 | { |
| 11254 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 11255 | target, pname, params); |
| 11256 | |
| 11257 | try |
| 11258 | { |
| 11259 | gl::Context *context = gl::getNonLostContext(); |
| 11260 | |
| 11261 | if (context) |
| 11262 | { |
| 11263 | if (context->getClientVersion() < 3) |
| 11264 | { |
| 11265 | return gl::error(GL_INVALID_OPERATION); |
| 11266 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11267 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11268 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11269 | UNIMPLEMENTED(); |
| 11270 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11271 | } |
| 11272 | catch(std::bad_alloc&) |
| 11273 | { |
| 11274 | return gl::error(GL_OUT_OF_MEMORY); |
| 11275 | } |
| 11276 | } |
| 11277 | |
| 11278 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 11279 | { |
| 11280 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11281 | |
| 11282 | try |
| 11283 | { |
| 11284 | gl::Context *context = gl::getNonLostContext(); |
| 11285 | |
| 11286 | if (context) |
| 11287 | { |
| 11288 | if (context->getClientVersion() < 3) |
| 11289 | { |
| 11290 | return gl::error(GL_INVALID_OPERATION); |
| 11291 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11292 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11293 | if (count < 0) |
| 11294 | { |
| 11295 | return gl::error(GL_INVALID_VALUE); |
| 11296 | } |
| 11297 | |
| 11298 | for (int i = 0; i < count; i++) |
| 11299 | { |
| 11300 | samplers[i] = context->createSampler(); |
| 11301 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11302 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11303 | } |
| 11304 | catch(std::bad_alloc&) |
| 11305 | { |
| 11306 | return gl::error(GL_OUT_OF_MEMORY); |
| 11307 | } |
| 11308 | } |
| 11309 | |
| 11310 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 11311 | { |
| 11312 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 11313 | |
| 11314 | try |
| 11315 | { |
| 11316 | gl::Context *context = gl::getNonLostContext(); |
| 11317 | |
| 11318 | if (context) |
| 11319 | { |
| 11320 | if (context->getClientVersion() < 3) |
| 11321 | { |
| 11322 | return gl::error(GL_INVALID_OPERATION); |
| 11323 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11324 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11325 | if (count < 0) |
| 11326 | { |
| 11327 | return gl::error(GL_INVALID_VALUE); |
| 11328 | } |
| 11329 | |
| 11330 | for (int i = 0; i < count; i++) |
| 11331 | { |
| 11332 | context->deleteSampler(samplers[i]); |
| 11333 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11334 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11335 | } |
| 11336 | catch(std::bad_alloc&) |
| 11337 | { |
| 11338 | return gl::error(GL_OUT_OF_MEMORY); |
| 11339 | } |
| 11340 | } |
| 11341 | |
| 11342 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 11343 | { |
| 11344 | EVENT("(GLuint sampler = %u)", sampler); |
| 11345 | |
| 11346 | try |
| 11347 | { |
| 11348 | gl::Context *context = gl::getNonLostContext(); |
| 11349 | |
| 11350 | if (context) |
| 11351 | { |
| 11352 | if (context->getClientVersion() < 3) |
| 11353 | { |
| 11354 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11355 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11356 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11357 | return context->isSampler(sampler); |
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, GL_FALSE); |
| 11363 | } |
| 11364 | |
| 11365 | return GL_FALSE; |
| 11366 | } |
| 11367 | |
| 11368 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 11369 | { |
| 11370 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 11371 | |
| 11372 | try |
| 11373 | { |
| 11374 | gl::Context *context = gl::getNonLostContext(); |
| 11375 | |
| 11376 | if (context) |
| 11377 | { |
| 11378 | if (context->getClientVersion() < 3) |
| 11379 | { |
| 11380 | return gl::error(GL_INVALID_OPERATION); |
| 11381 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11382 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11383 | if (sampler != 0 && !context->isSampler(sampler)) |
| 11384 | { |
| 11385 | return gl::error(GL_INVALID_OPERATION); |
| 11386 | } |
| 11387 | |
| 11388 | if (unit >= context->getMaximumCombinedTextureImageUnits()) |
| 11389 | { |
| 11390 | return gl::error(GL_INVALID_VALUE); |
| 11391 | } |
| 11392 | |
| 11393 | context->bindSampler(unit, sampler); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11394 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11395 | } |
| 11396 | catch(std::bad_alloc&) |
| 11397 | { |
| 11398 | return gl::error(GL_OUT_OF_MEMORY); |
| 11399 | } |
| 11400 | } |
| 11401 | |
| 11402 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 11403 | { |
| 11404 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 11405 | |
| 11406 | try |
| 11407 | { |
| 11408 | gl::Context *context = gl::getNonLostContext(); |
| 11409 | |
| 11410 | if (context) |
| 11411 | { |
| 11412 | if (context->getClientVersion() < 3) |
| 11413 | { |
| 11414 | return gl::error(GL_INVALID_OPERATION); |
| 11415 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11416 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11417 | if (!validateSamplerObjectParameter(pname)) |
| 11418 | { |
| 11419 | return; |
| 11420 | } |
| 11421 | |
| 11422 | if (!validateTexParamParameters(context, pname, param)) |
| 11423 | { |
| 11424 | return; |
| 11425 | } |
| 11426 | |
| 11427 | if (!context->isSampler(sampler)) |
| 11428 | { |
| 11429 | return gl::error(GL_INVALID_OPERATION); |
| 11430 | } |
| 11431 | |
| 11432 | context->samplerParameteri(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11433 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11434 | } |
| 11435 | catch(std::bad_alloc&) |
| 11436 | { |
| 11437 | return gl::error(GL_OUT_OF_MEMORY); |
| 11438 | } |
| 11439 | } |
| 11440 | |
| 11441 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 11442 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11443 | glSamplerParameteri(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11444 | } |
| 11445 | |
| 11446 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11447 | { |
| 11448 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11449 | |
| 11450 | try |
| 11451 | { |
| 11452 | gl::Context *context = gl::getNonLostContext(); |
| 11453 | |
| 11454 | if (context) |
| 11455 | { |
| 11456 | if (context->getClientVersion() < 3) |
| 11457 | { |
| 11458 | return gl::error(GL_INVALID_OPERATION); |
| 11459 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11460 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11461 | if (!validateSamplerObjectParameter(pname)) |
| 11462 | { |
| 11463 | return; |
| 11464 | } |
| 11465 | |
| 11466 | if (!validateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 11467 | { |
| 11468 | return; |
| 11469 | } |
| 11470 | |
| 11471 | if (!context->isSampler(sampler)) |
| 11472 | { |
| 11473 | return gl::error(GL_INVALID_OPERATION); |
| 11474 | } |
| 11475 | |
| 11476 | context->samplerParameterf(sampler, pname, param); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11477 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11478 | } |
| 11479 | catch(std::bad_alloc&) |
| 11480 | { |
| 11481 | return gl::error(GL_OUT_OF_MEMORY); |
| 11482 | } |
| 11483 | } |
| 11484 | |
| 11485 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11486 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11487 | glSamplerParameterf(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11488 | } |
| 11489 | |
| 11490 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11491 | { |
| 11492 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11493 | |
| 11494 | try |
| 11495 | { |
| 11496 | gl::Context *context = gl::getNonLostContext(); |
| 11497 | |
| 11498 | if (context) |
| 11499 | { |
| 11500 | if (context->getClientVersion() < 3) |
| 11501 | { |
| 11502 | return gl::error(GL_INVALID_OPERATION); |
| 11503 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11504 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11505 | if (!validateSamplerObjectParameter(pname)) |
| 11506 | { |
| 11507 | return; |
| 11508 | } |
| 11509 | |
| 11510 | if (!context->isSampler(sampler)) |
| 11511 | { |
| 11512 | return gl::error(GL_INVALID_OPERATION); |
| 11513 | } |
| 11514 | |
| 11515 | *params = context->getSamplerParameteri(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11516 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11517 | } |
| 11518 | catch(std::bad_alloc&) |
| 11519 | { |
| 11520 | return gl::error(GL_OUT_OF_MEMORY); |
| 11521 | } |
| 11522 | } |
| 11523 | |
| 11524 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11525 | { |
| 11526 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11527 | |
| 11528 | try |
| 11529 | { |
| 11530 | gl::Context *context = gl::getNonLostContext(); |
| 11531 | |
| 11532 | if (context) |
| 11533 | { |
| 11534 | if (context->getClientVersion() < 3) |
| 11535 | { |
| 11536 | return gl::error(GL_INVALID_OPERATION); |
| 11537 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11538 | |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 11539 | if (!validateSamplerObjectParameter(pname)) |
| 11540 | { |
| 11541 | return; |
| 11542 | } |
| 11543 | |
| 11544 | if (!context->isSampler(sampler)) |
| 11545 | { |
| 11546 | return gl::error(GL_INVALID_OPERATION); |
| 11547 | } |
| 11548 | |
| 11549 | *params = context->getSamplerParameterf(sampler, pname); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11550 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11551 | } |
| 11552 | catch(std::bad_alloc&) |
| 11553 | { |
| 11554 | return gl::error(GL_OUT_OF_MEMORY); |
| 11555 | } |
| 11556 | } |
| 11557 | |
| 11558 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11559 | { |
| 11560 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11561 | |
| 11562 | try |
| 11563 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11564 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11565 | { |
| 11566 | return gl::error(GL_INVALID_VALUE); |
| 11567 | } |
| 11568 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11569 | gl::Context *context = gl::getNonLostContext(); |
| 11570 | |
| 11571 | if (context) |
| 11572 | { |
| 11573 | if (context->getClientVersion() < 3) |
| 11574 | { |
| 11575 | return gl::error(GL_INVALID_OPERATION); |
| 11576 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11577 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11578 | context->setVertexAttribDivisor(index, divisor); |
| 11579 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11580 | } |
| 11581 | catch(std::bad_alloc&) |
| 11582 | { |
| 11583 | return gl::error(GL_OUT_OF_MEMORY); |
| 11584 | } |
| 11585 | } |
| 11586 | |
| 11587 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11588 | { |
| 11589 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11590 | |
| 11591 | try |
| 11592 | { |
| 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 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11602 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11603 | UNIMPLEMENTED(); |
| 11604 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11605 | } |
| 11606 | catch(std::bad_alloc&) |
| 11607 | { |
| 11608 | return gl::error(GL_OUT_OF_MEMORY); |
| 11609 | } |
| 11610 | } |
| 11611 | |
| 11612 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11613 | { |
| 11614 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11615 | |
| 11616 | try |
| 11617 | { |
| 11618 | gl::Context *context = gl::getNonLostContext(); |
| 11619 | |
| 11620 | if (context) |
| 11621 | { |
| 11622 | if (context->getClientVersion() < 3) |
| 11623 | { |
| 11624 | return gl::error(GL_INVALID_OPERATION); |
| 11625 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11626 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11627 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11628 | UNIMPLEMENTED(); |
| 11629 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11630 | } |
| 11631 | catch(std::bad_alloc&) |
| 11632 | { |
| 11633 | return gl::error(GL_OUT_OF_MEMORY); |
| 11634 | } |
| 11635 | } |
| 11636 | |
| 11637 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11638 | { |
| 11639 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11640 | |
| 11641 | try |
| 11642 | { |
| 11643 | gl::Context *context = gl::getNonLostContext(); |
| 11644 | |
| 11645 | if (context) |
| 11646 | { |
| 11647 | if (context->getClientVersion() < 3) |
| 11648 | { |
| 11649 | return gl::error(GL_INVALID_OPERATION); |
| 11650 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11651 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11652 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11653 | UNIMPLEMENTED(); |
| 11654 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11655 | } |
| 11656 | catch(std::bad_alloc&) |
| 11657 | { |
| 11658 | return gl::error(GL_OUT_OF_MEMORY); |
| 11659 | } |
| 11660 | } |
| 11661 | |
| 11662 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11663 | { |
| 11664 | EVENT("(GLuint id = %u)", id); |
| 11665 | |
| 11666 | try |
| 11667 | { |
| 11668 | gl::Context *context = gl::getNonLostContext(); |
| 11669 | |
| 11670 | if (context) |
| 11671 | { |
| 11672 | if (context->getClientVersion() < 3) |
| 11673 | { |
| 11674 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11675 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11676 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11677 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11678 | UNIMPLEMENTED(); |
| 11679 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11680 | } |
| 11681 | catch(std::bad_alloc&) |
| 11682 | { |
| 11683 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11684 | } |
| 11685 | |
| 11686 | return GL_FALSE; |
| 11687 | } |
| 11688 | |
| 11689 | void __stdcall glPauseTransformFeedback(void) |
| 11690 | { |
| 11691 | EVENT("(void)"); |
| 11692 | |
| 11693 | try |
| 11694 | { |
| 11695 | gl::Context *context = gl::getNonLostContext(); |
| 11696 | |
| 11697 | if (context) |
| 11698 | { |
| 11699 | if (context->getClientVersion() < 3) |
| 11700 | { |
| 11701 | return gl::error(GL_INVALID_OPERATION); |
| 11702 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11703 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11704 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11705 | UNIMPLEMENTED(); |
| 11706 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11707 | } |
| 11708 | catch(std::bad_alloc&) |
| 11709 | { |
| 11710 | return gl::error(GL_OUT_OF_MEMORY); |
| 11711 | } |
| 11712 | } |
| 11713 | |
| 11714 | void __stdcall glResumeTransformFeedback(void) |
| 11715 | { |
| 11716 | EVENT("(void)"); |
| 11717 | |
| 11718 | try |
| 11719 | { |
| 11720 | gl::Context *context = gl::getNonLostContext(); |
| 11721 | |
| 11722 | if (context) |
| 11723 | { |
| 11724 | if (context->getClientVersion() < 3) |
| 11725 | { |
| 11726 | return gl::error(GL_INVALID_OPERATION); |
| 11727 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11728 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11729 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11730 | UNIMPLEMENTED(); |
| 11731 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11732 | } |
| 11733 | catch(std::bad_alloc&) |
| 11734 | { |
| 11735 | return gl::error(GL_OUT_OF_MEMORY); |
| 11736 | } |
| 11737 | } |
| 11738 | |
| 11739 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11740 | { |
| 11741 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11742 | program, bufSize, length, binaryFormat, binary); |
| 11743 | |
| 11744 | try |
| 11745 | { |
| 11746 | gl::Context *context = gl::getNonLostContext(); |
| 11747 | |
| 11748 | if (context) |
| 11749 | { |
| 11750 | if (context->getClientVersion() < 3) |
| 11751 | { |
| 11752 | return gl::error(GL_INVALID_OPERATION); |
| 11753 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11754 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11755 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11756 | UNIMPLEMENTED(); |
| 11757 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11758 | } |
| 11759 | catch(std::bad_alloc&) |
| 11760 | { |
| 11761 | return gl::error(GL_OUT_OF_MEMORY); |
| 11762 | } |
| 11763 | } |
| 11764 | |
| 11765 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11766 | { |
| 11767 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11768 | program, binaryFormat, binary, length); |
| 11769 | |
| 11770 | try |
| 11771 | { |
| 11772 | gl::Context *context = gl::getNonLostContext(); |
| 11773 | |
| 11774 | if (context) |
| 11775 | { |
| 11776 | if (context->getClientVersion() < 3) |
| 11777 | { |
| 11778 | return gl::error(GL_INVALID_OPERATION); |
| 11779 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11780 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11781 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11782 | UNIMPLEMENTED(); |
| 11783 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11784 | } |
| 11785 | catch(std::bad_alloc&) |
| 11786 | { |
| 11787 | return gl::error(GL_OUT_OF_MEMORY); |
| 11788 | } |
| 11789 | } |
| 11790 | |
| 11791 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11792 | { |
| 11793 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11794 | program, pname, value); |
| 11795 | |
| 11796 | try |
| 11797 | { |
| 11798 | gl::Context *context = gl::getNonLostContext(); |
| 11799 | |
| 11800 | if (context) |
| 11801 | { |
| 11802 | if (context->getClientVersion() < 3) |
| 11803 | { |
| 11804 | return gl::error(GL_INVALID_OPERATION); |
| 11805 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11806 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11807 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11808 | UNIMPLEMENTED(); |
| 11809 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11810 | } |
| 11811 | catch(std::bad_alloc&) |
| 11812 | { |
| 11813 | return gl::error(GL_OUT_OF_MEMORY); |
| 11814 | } |
| 11815 | } |
| 11816 | |
| 11817 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11818 | { |
| 11819 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11820 | target, numAttachments, attachments); |
| 11821 | |
| 11822 | try |
| 11823 | { |
| 11824 | gl::Context *context = gl::getNonLostContext(); |
| 11825 | |
| 11826 | if (context) |
| 11827 | { |
| 11828 | if (context->getClientVersion() < 3) |
| 11829 | { |
| 11830 | return gl::error(GL_INVALID_OPERATION); |
| 11831 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11832 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11833 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11834 | { |
| 11835 | return; |
| 11836 | } |
| 11837 | |
| 11838 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11839 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11840 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11841 | } |
| 11842 | catch(std::bad_alloc&) |
| 11843 | { |
| 11844 | return gl::error(GL_OUT_OF_MEMORY); |
| 11845 | } |
| 11846 | } |
| 11847 | |
| 11848 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11849 | { |
| 11850 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11851 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11852 | target, numAttachments, attachments, x, y, width, height); |
| 11853 | |
| 11854 | try |
| 11855 | { |
| 11856 | gl::Context *context = gl::getNonLostContext(); |
| 11857 | |
| 11858 | if (context) |
| 11859 | { |
| 11860 | if (context->getClientVersion() < 3) |
| 11861 | { |
| 11862 | return gl::error(GL_INVALID_OPERATION); |
| 11863 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11864 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11865 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11866 | { |
| 11867 | return; |
| 11868 | } |
| 11869 | |
| 11870 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11871 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11872 | } |
| 11873 | catch(std::bad_alloc&) |
| 11874 | { |
| 11875 | return gl::error(GL_OUT_OF_MEMORY); |
| 11876 | } |
| 11877 | } |
| 11878 | |
| 11879 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11880 | { |
| 11881 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11882 | target, levels, internalformat, width, height); |
| 11883 | |
| 11884 | try |
| 11885 | { |
| 11886 | gl::Context *context = gl::getNonLostContext(); |
| 11887 | |
| 11888 | if (context) |
| 11889 | { |
| 11890 | if (context->getClientVersion() < 3) |
| 11891 | { |
| 11892 | return gl::error(GL_INVALID_OPERATION); |
| 11893 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11894 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11895 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11896 | { |
| 11897 | return; |
| 11898 | } |
| 11899 | |
| 11900 | switch (target) |
| 11901 | { |
| 11902 | case GL_TEXTURE_2D: |
| 11903 | { |
| 11904 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11905 | texture2d->storage(levels, internalformat, width, height); |
| 11906 | } |
| 11907 | break; |
| 11908 | |
| 11909 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11910 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11911 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11912 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11913 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11914 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11915 | { |
| 11916 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11917 | textureCube->storage(levels, internalformat, width); |
| 11918 | } |
| 11919 | break; |
| 11920 | |
| 11921 | default: |
| 11922 | return gl::error(GL_INVALID_ENUM); |
| 11923 | } |
| 11924 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11925 | } |
| 11926 | catch(std::bad_alloc&) |
| 11927 | { |
| 11928 | return gl::error(GL_OUT_OF_MEMORY); |
| 11929 | } |
| 11930 | } |
| 11931 | |
| 11932 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11933 | { |
| 11934 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11935 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11936 | target, levels, internalformat, width, height, depth); |
| 11937 | |
| 11938 | try |
| 11939 | { |
| 11940 | gl::Context *context = gl::getNonLostContext(); |
| 11941 | |
| 11942 | if (context) |
| 11943 | { |
| 11944 | if (context->getClientVersion() < 3) |
| 11945 | { |
| 11946 | return gl::error(GL_INVALID_OPERATION); |
| 11947 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11948 | |
| 11949 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11950 | { |
| 11951 | return; |
| 11952 | } |
| 11953 | |
| 11954 | switch (target) |
| 11955 | { |
| 11956 | case GL_TEXTURE_3D: |
| 11957 | { |
| 11958 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11959 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11960 | } |
| 11961 | break; |
| 11962 | |
| 11963 | case GL_TEXTURE_2D_ARRAY: |
| 11964 | { |
| 11965 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11966 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11967 | } |
| 11968 | break; |
| 11969 | |
| 11970 | default: |
| 11971 | return gl::error(GL_INVALID_ENUM); |
| 11972 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11973 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11974 | } |
| 11975 | catch(std::bad_alloc&) |
| 11976 | { |
| 11977 | return gl::error(GL_OUT_OF_MEMORY); |
| 11978 | } |
| 11979 | } |
| 11980 | |
| 11981 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11982 | { |
| 11983 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11984 | "GLint* params = 0x%0.8p)", |
| 11985 | target, internalformat, pname, bufSize, params); |
| 11986 | |
| 11987 | try |
| 11988 | { |
| 11989 | gl::Context *context = gl::getNonLostContext(); |
| 11990 | |
| 11991 | if (context) |
| 11992 | { |
| 11993 | if (context->getClientVersion() < 3) |
| 11994 | { |
| 11995 | return gl::error(GL_INVALID_OPERATION); |
| 11996 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11997 | |
Shannon Woods | 809d250 | 2013-07-08 10:32:18 -0400 | [diff] [blame] | 11998 | if (!gl::IsColorRenderingSupported(internalformat, context) && |
| 11999 | !gl::IsDepthRenderingSupported(internalformat, context) && |
| 12000 | !gl::IsStencilRenderingSupported(internalformat, context)) |
| 12001 | { |
| 12002 | return gl::error(GL_INVALID_ENUM); |
| 12003 | } |
| 12004 | |
| 12005 | if (target != GL_RENDERBUFFER) |
| 12006 | { |
| 12007 | return gl::error(GL_INVALID_ENUM); |
| 12008 | } |
| 12009 | |
| 12010 | if (bufSize < 0) |
| 12011 | { |
| 12012 | return gl::error(GL_INVALID_VALUE); |
| 12013 | } |
| 12014 | |
| 12015 | switch (pname) |
| 12016 | { |
| 12017 | case GL_NUM_SAMPLE_COUNTS: |
| 12018 | if (bufSize != 0) |
| 12019 | *params = context->getNumSampleCounts(internalformat); |
| 12020 | break; |
| 12021 | case GL_SAMPLES: |
| 12022 | context->getSampleCounts(internalformat, bufSize, params); |
| 12023 | break; |
| 12024 | default: |
| 12025 | return gl::error(GL_INVALID_ENUM); |
| 12026 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 12027 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 12028 | } |
| 12029 | catch(std::bad_alloc&) |
| 12030 | { |
| 12031 | return gl::error(GL_OUT_OF_MEMORY); |
| 12032 | } |
| 12033 | } |
| 12034 | |
| 12035 | // Extension functions |
| 12036 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12037 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 12038 | GLbitfield mask, GLenum filter) |
| 12039 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 12040 | 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] | 12041 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 12042 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 12043 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 12044 | |
| 12045 | try |
| 12046 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12047 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12048 | |
| 12049 | if (context) |
| 12050 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 12051 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 12052 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 12053 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12054 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 12055 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12056 | } |
| 12057 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 12058 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 12059 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12060 | } |
| 12061 | } |
| 12062 | catch(std::bad_alloc&) |
| 12063 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12064 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 12065 | } |
| 12066 | } |
| 12067 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 12068 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 12069 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12070 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 12071 | 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] | 12072 | "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] | 12073 | "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] | 12074 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 12075 | |
| 12076 | try |
| 12077 | { |
| 12078 | UNIMPLEMENTED(); // FIXME |
| 12079 | } |
| 12080 | catch(std::bad_alloc&) |
| 12081 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12082 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12083 | } |
| 12084 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12085 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12086 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 12087 | GLenum *binaryFormat, void *binary) |
| 12088 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 12089 | 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] | 12090 | program, bufSize, length, binaryFormat, binary); |
| 12091 | |
| 12092 | try |
| 12093 | { |
| 12094 | gl::Context *context = gl::getNonLostContext(); |
| 12095 | |
| 12096 | if (context) |
| 12097 | { |
| 12098 | gl::Program *programObject = context->getProgram(program); |
| 12099 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 12100 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12101 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12102 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12103 | } |
| 12104 | |
| 12105 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 12106 | |
| 12107 | if (!programBinary) |
| 12108 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12109 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12110 | } |
| 12111 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 12112 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12114 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12115 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 12116 | |
| 12117 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12118 | } |
| 12119 | } |
| 12120 | catch(std::bad_alloc&) |
| 12121 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12122 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12123 | } |
| 12124 | } |
| 12125 | |
| 12126 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 12127 | const void *binary, GLint length) |
| 12128 | { |
| 12129 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 12130 | program, binaryFormat, binary, length); |
| 12131 | |
| 12132 | try |
| 12133 | { |
| 12134 | gl::Context *context = gl::getNonLostContext(); |
| 12135 | |
| 12136 | if (context) |
| 12137 | { |
| 12138 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 12139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12140 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12141 | } |
| 12142 | |
| 12143 | gl::Program *programObject = context->getProgram(program); |
| 12144 | |
| 12145 | if (!programObject) |
| 12146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12147 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12148 | } |
| 12149 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 12150 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12151 | } |
| 12152 | } |
| 12153 | catch(std::bad_alloc&) |
| 12154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12155 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12156 | } |
| 12157 | } |
| 12158 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12159 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 12160 | { |
| 12161 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 12162 | |
| 12163 | try |
| 12164 | { |
| 12165 | gl::Context *context = gl::getNonLostContext(); |
| 12166 | |
| 12167 | if (context) |
| 12168 | { |
| 12169 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 12170 | { |
| 12171 | return gl::error(GL_INVALID_VALUE); |
| 12172 | } |
| 12173 | |
| 12174 | if (context->getDrawFramebufferHandle() == 0) |
| 12175 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12176 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12177 | { |
| 12178 | return gl::error(GL_INVALID_OPERATION); |
| 12179 | } |
| 12180 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12181 | 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] | 12182 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12183 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12184 | } |
| 12185 | } |
| 12186 | else |
| 12187 | { |
| 12188 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12189 | { |
| 12190 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 12191 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 12192 | { |
| 12193 | return gl::error(GL_INVALID_OPERATION); |
| 12194 | } |
| 12195 | } |
| 12196 | } |
| 12197 | |
| 12198 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 12199 | |
| 12200 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 12201 | { |
| 12202 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 12203 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 12204 | |
| 12205 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 12206 | { |
| 12207 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 12208 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 12209 | } |
| 12210 | } |
| 12211 | catch (std::bad_alloc&) |
| 12212 | { |
| 12213 | return gl::error(GL_OUT_OF_MEMORY); |
| 12214 | } |
| 12215 | } |
| 12216 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12217 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 12218 | { |
| 12219 | struct Extension |
| 12220 | { |
| 12221 | const char *name; |
| 12222 | __eglMustCastToProperFunctionPointerType address; |
| 12223 | }; |
| 12224 | |
| 12225 | static const Extension glExtensions[] = |
| 12226 | { |
| 12227 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 12228 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 12229 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 12230 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 12231 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 12232 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 12233 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 12234 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 12235 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 12236 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 12237 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 12238 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 12239 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 12240 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 12241 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 12242 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 12243 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 12244 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 12245 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 12246 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 12247 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 12248 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 12249 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 12250 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 12251 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 12252 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 12253 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 12254 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 12255 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12256 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 12257 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 12258 | { |
| 12259 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 12260 | { |
| 12261 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 12262 | } |
| 12263 | } |
| 12264 | |
| 12265 | return NULL; |
| 12266 | } |
| 12267 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 12268 | // Non-public functions used by EGL |
| 12269 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12270 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12271 | { |
| 12272 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 12273 | surface); |
| 12274 | |
| 12275 | try |
| 12276 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 12277 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12278 | |
| 12279 | if (context) |
| 12280 | { |
| 12281 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 12282 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12283 | if (textureObject->isImmutable()) |
| 12284 | { |
| 12285 | return false; |
| 12286 | } |
| 12287 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12288 | if (textureObject) |
| 12289 | { |
| 12290 | textureObject->bindTexImage(surface); |
| 12291 | } |
| 12292 | } |
| 12293 | } |
| 12294 | catch(std::bad_alloc&) |
| 12295 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 12296 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12297 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 12298 | |
| 12299 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 12300 | } |
| 12301 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12302 | } |