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 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1926 | extern "C" |
| 1927 | { |
| 1928 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1929 | // OpenGL ES 2.0 functions |
| 1930 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1931 | void __stdcall glActiveTexture(GLenum texture) |
| 1932 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1933 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1934 | |
| 1935 | try |
| 1936 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1937 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1938 | |
| 1939 | if (context) |
| 1940 | { |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1941 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
| 1942 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1943 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f74c7a | 2011-05-11 15:36:51 +0000 | [diff] [blame] | 1944 | } |
| 1945 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 1946 | context->setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1947 | } |
| 1948 | } |
| 1949 | catch(std::bad_alloc&) |
| 1950 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1951 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1952 | } |
| 1953 | } |
| 1954 | |
| 1955 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 1956 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1957 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1958 | |
| 1959 | try |
| 1960 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 1961 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1962 | |
| 1963 | if (context) |
| 1964 | { |
| 1965 | gl::Program *programObject = context->getProgram(program); |
| 1966 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 1967 | |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1968 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1969 | { |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1970 | if (context->getShader(program)) |
| 1971 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1972 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1973 | } |
| 1974 | else |
| 1975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1976 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1977 | } |
| 1978 | } |
| 1979 | |
| 1980 | if (!shaderObject) |
| 1981 | { |
| 1982 | if (context->getProgram(shader)) |
| 1983 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1984 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1985 | } |
| 1986 | else |
| 1987 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1988 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e9d6ed0 | 2010-04-13 03:26:23 +0000 | [diff] [blame] | 1989 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1990 | } |
| 1991 | |
| 1992 | if (!programObject->attachShader(shaderObject)) |
| 1993 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1994 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1995 | } |
| 1996 | } |
| 1997 | } |
| 1998 | catch(std::bad_alloc&) |
| 1999 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2000 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2001 | } |
| 2002 | } |
| 2003 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2004 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 2005 | { |
| 2006 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 2007 | |
| 2008 | try |
| 2009 | { |
| 2010 | switch (target) |
| 2011 | { |
| 2012 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 2013 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 2014 | break; |
| 2015 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2016 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | if (id == 0) |
| 2020 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2021 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | gl::Context *context = gl::getNonLostContext(); |
| 2025 | |
| 2026 | if (context) |
| 2027 | { |
| 2028 | context->beginQuery(target, id); |
| 2029 | } |
| 2030 | } |
| 2031 | catch(std::bad_alloc&) |
| 2032 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2033 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2034 | } |
| 2035 | } |
| 2036 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2037 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2038 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2039 | 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] | 2040 | |
| 2041 | try |
| 2042 | { |
| 2043 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 2044 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2045 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2046 | } |
| 2047 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2048 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2049 | |
| 2050 | if (context) |
| 2051 | { |
| 2052 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2053 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2054 | if (!programObject) |
| 2055 | { |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2056 | if (context->getShader(program)) |
| 2057 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2058 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2059 | } |
| 2060 | else |
| 2061 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2062 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 2063 | } |
| 2064 | } |
| 2065 | |
| 2066 | if (strncmp(name, "gl_", 3) == 0) |
| 2067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2068 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2069 | } |
| 2070 | |
| 2071 | programObject->bindAttributeLocation(index, name); |
| 2072 | } |
| 2073 | } |
| 2074 | catch(std::bad_alloc&) |
| 2075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2076 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2077 | } |
| 2078 | } |
| 2079 | |
| 2080 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 2081 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2082 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2083 | |
| 2084 | try |
| 2085 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2086 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2087 | |
| 2088 | if (context) |
| 2089 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2090 | // Check ES3 specific targets |
| 2091 | switch (target) |
| 2092 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2093 | case GL_COPY_READ_BUFFER: |
| 2094 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2095 | case GL_PIXEL_PACK_BUFFER: |
| 2096 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2097 | case GL_UNIFORM_BUFFER: |
| 2098 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2099 | if (context->getClientVersion() < 3) |
| 2100 | { |
| 2101 | return gl::error(GL_INVALID_ENUM); |
| 2102 | } |
| 2103 | } |
| 2104 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2105 | switch (target) |
| 2106 | { |
| 2107 | case GL_ARRAY_BUFFER: |
| 2108 | context->bindArrayBuffer(buffer); |
| 2109 | return; |
| 2110 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2111 | context->bindElementArrayBuffer(buffer); |
| 2112 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2113 | case GL_COPY_READ_BUFFER: |
| 2114 | context->bindCopyReadBuffer(buffer); |
| 2115 | return; |
| 2116 | case GL_COPY_WRITE_BUFFER: |
| 2117 | context->bindCopyWriteBuffer(buffer); |
| 2118 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2119 | case GL_PIXEL_PACK_BUFFER: |
| 2120 | context->bindPixelPackBuffer(buffer); |
| 2121 | return; |
| 2122 | case GL_PIXEL_UNPACK_BUFFER: |
| 2123 | context->bindPixelUnpackBuffer(buffer); |
| 2124 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2125 | case GL_UNIFORM_BUFFER: |
| 2126 | context->bindGenericUniformBuffer(buffer); |
| 2127 | return; |
| 2128 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 7a1ebad | 2013-05-30 00:05:20 +0000 | [diff] [blame] | 2129 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2130 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2131 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2132 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2133 | } |
| 2134 | } |
| 2135 | } |
| 2136 | catch(std::bad_alloc&) |
| 2137 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2138 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2139 | } |
| 2140 | } |
| 2141 | |
| 2142 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 2143 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2144 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2145 | |
| 2146 | try |
| 2147 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2148 | 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] | 2149 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2150 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2151 | } |
| 2152 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2153 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2154 | |
| 2155 | if (context) |
| 2156 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2157 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2158 | { |
| 2159 | context->bindReadFramebuffer(framebuffer); |
| 2160 | } |
| 2161 | |
| 2162 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 2163 | { |
| 2164 | context->bindDrawFramebuffer(framebuffer); |
| 2165 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2166 | } |
| 2167 | } |
| 2168 | catch(std::bad_alloc&) |
| 2169 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2170 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2171 | } |
| 2172 | } |
| 2173 | |
| 2174 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 2175 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2176 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2177 | |
| 2178 | try |
| 2179 | { |
| 2180 | if (target != GL_RENDERBUFFER) |
| 2181 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2182 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2183 | } |
| 2184 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2185 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2186 | |
| 2187 | if (context) |
| 2188 | { |
| 2189 | context->bindRenderbuffer(renderbuffer); |
| 2190 | } |
| 2191 | } |
| 2192 | catch(std::bad_alloc&) |
| 2193 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2194 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2195 | } |
| 2196 | } |
| 2197 | |
| 2198 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 2199 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2200 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2201 | |
| 2202 | try |
| 2203 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2204 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2205 | |
| 2206 | if (context) |
| 2207 | { |
| 2208 | gl::Texture *textureObject = context->getTexture(texture); |
| 2209 | |
| 2210 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
| 2211 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2212 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2213 | } |
| 2214 | |
| 2215 | switch (target) |
| 2216 | { |
| 2217 | case GL_TEXTURE_2D: |
| 2218 | context->bindTexture2D(texture); |
| 2219 | return; |
| 2220 | case GL_TEXTURE_CUBE_MAP: |
| 2221 | context->bindTextureCubeMap(texture); |
| 2222 | return; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 2223 | case GL_TEXTURE_3D: |
| 2224 | if (context->getClientVersion() < 3) |
| 2225 | { |
| 2226 | return gl::error(GL_INVALID_ENUM); |
| 2227 | } |
| 2228 | context->bindTexture3D(texture); |
| 2229 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 2230 | case GL_TEXTURE_2D_ARRAY: |
| 2231 | if (context->getClientVersion() < 3) |
| 2232 | { |
| 2233 | return gl::error(GL_INVALID_ENUM); |
| 2234 | } |
| 2235 | context->bindTexture2DArray(texture); |
| 2236 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2237 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2238 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2239 | } |
| 2240 | } |
| 2241 | } |
| 2242 | catch(std::bad_alloc&) |
| 2243 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2244 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2245 | } |
| 2246 | } |
| 2247 | |
| 2248 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2249 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2250 | 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] | 2251 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2252 | |
| 2253 | try |
| 2254 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2255 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2256 | |
| 2257 | if (context) |
| 2258 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2259 | 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] | 2260 | } |
| 2261 | } |
| 2262 | catch(std::bad_alloc&) |
| 2263 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2264 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2265 | } |
| 2266 | } |
| 2267 | |
| 2268 | void __stdcall glBlendEquation(GLenum mode) |
| 2269 | { |
| 2270 | glBlendEquationSeparate(mode, mode); |
| 2271 | } |
| 2272 | |
| 2273 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 2274 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2275 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2276 | |
| 2277 | try |
| 2278 | { |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2279 | gl::Context *context = gl::getNonLostContext(); |
| 2280 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2281 | switch (modeRGB) |
| 2282 | { |
| 2283 | case GL_FUNC_ADD: |
| 2284 | case GL_FUNC_SUBTRACT: |
| 2285 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2286 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2287 | |
| 2288 | case GL_MIN: |
| 2289 | case GL_MAX: |
| 2290 | if (context && context->getClientVersion() < 3) |
| 2291 | { |
| 2292 | return gl::error(GL_INVALID_ENUM); |
| 2293 | } |
| 2294 | break; |
| 2295 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2296 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2297 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | switch (modeAlpha) |
| 2301 | { |
| 2302 | case GL_FUNC_ADD: |
| 2303 | case GL_FUNC_SUBTRACT: |
| 2304 | case GL_FUNC_REVERSE_SUBTRACT: |
| 2305 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 2306 | |
| 2307 | case GL_MIN: |
| 2308 | case GL_MAX: |
| 2309 | if (context && context->getClientVersion() < 3) |
| 2310 | { |
| 2311 | return gl::error(GL_INVALID_ENUM); |
| 2312 | } |
| 2313 | break; |
| 2314 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2315 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2316 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2317 | } |
| 2318 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2319 | if (context) |
| 2320 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2321 | context->setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2322 | } |
| 2323 | } |
| 2324 | catch(std::bad_alloc&) |
| 2325 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2326 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2327 | } |
| 2328 | } |
| 2329 | |
| 2330 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 2331 | { |
| 2332 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 2333 | } |
| 2334 | |
| 2335 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 2336 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2337 | 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] | 2338 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2339 | |
| 2340 | try |
| 2341 | { |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2342 | gl::Context *context = gl::getNonLostContext(); |
| 2343 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2344 | switch (srcRGB) |
| 2345 | { |
| 2346 | case GL_ZERO: |
| 2347 | case GL_ONE: |
| 2348 | case GL_SRC_COLOR: |
| 2349 | case GL_ONE_MINUS_SRC_COLOR: |
| 2350 | case GL_DST_COLOR: |
| 2351 | case GL_ONE_MINUS_DST_COLOR: |
| 2352 | case GL_SRC_ALPHA: |
| 2353 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2354 | case GL_DST_ALPHA: |
| 2355 | case GL_ONE_MINUS_DST_ALPHA: |
| 2356 | case GL_CONSTANT_COLOR: |
| 2357 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2358 | case GL_CONSTANT_ALPHA: |
| 2359 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2360 | case GL_SRC_ALPHA_SATURATE: |
| 2361 | break; |
| 2362 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2363 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2364 | } |
| 2365 | |
| 2366 | switch (dstRGB) |
| 2367 | { |
| 2368 | case GL_ZERO: |
| 2369 | case GL_ONE: |
| 2370 | case GL_SRC_COLOR: |
| 2371 | case GL_ONE_MINUS_SRC_COLOR: |
| 2372 | case GL_DST_COLOR: |
| 2373 | case GL_ONE_MINUS_DST_COLOR: |
| 2374 | case GL_SRC_ALPHA: |
| 2375 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2376 | case GL_DST_ALPHA: |
| 2377 | case GL_ONE_MINUS_DST_ALPHA: |
| 2378 | case GL_CONSTANT_COLOR: |
| 2379 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2380 | case GL_CONSTANT_ALPHA: |
| 2381 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2382 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2383 | |
| 2384 | case GL_SRC_ALPHA_SATURATE: |
| 2385 | if (!context || context->getClientVersion() < 3) |
| 2386 | { |
| 2387 | return gl::error(GL_INVALID_ENUM); |
| 2388 | } |
| 2389 | break; |
| 2390 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2391 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2392 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2393 | } |
| 2394 | |
| 2395 | switch (srcAlpha) |
| 2396 | { |
| 2397 | case GL_ZERO: |
| 2398 | case GL_ONE: |
| 2399 | case GL_SRC_COLOR: |
| 2400 | case GL_ONE_MINUS_SRC_COLOR: |
| 2401 | case GL_DST_COLOR: |
| 2402 | case GL_ONE_MINUS_DST_COLOR: |
| 2403 | case GL_SRC_ALPHA: |
| 2404 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2405 | case GL_DST_ALPHA: |
| 2406 | case GL_ONE_MINUS_DST_ALPHA: |
| 2407 | case GL_CONSTANT_COLOR: |
| 2408 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2409 | case GL_CONSTANT_ALPHA: |
| 2410 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2411 | case GL_SRC_ALPHA_SATURATE: |
| 2412 | break; |
| 2413 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2414 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2415 | } |
| 2416 | |
| 2417 | switch (dstAlpha) |
| 2418 | { |
| 2419 | case GL_ZERO: |
| 2420 | case GL_ONE: |
| 2421 | case GL_SRC_COLOR: |
| 2422 | case GL_ONE_MINUS_SRC_COLOR: |
| 2423 | case GL_DST_COLOR: |
| 2424 | case GL_ONE_MINUS_DST_COLOR: |
| 2425 | case GL_SRC_ALPHA: |
| 2426 | case GL_ONE_MINUS_SRC_ALPHA: |
| 2427 | case GL_DST_ALPHA: |
| 2428 | case GL_ONE_MINUS_DST_ALPHA: |
| 2429 | case GL_CONSTANT_COLOR: |
| 2430 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 2431 | case GL_CONSTANT_ALPHA: |
| 2432 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 2433 | break; |
shannonwoods@chromium.org | 48ae025 | 2013-05-30 00:13:22 +0000 | [diff] [blame] | 2434 | |
| 2435 | case GL_SRC_ALPHA_SATURATE: |
| 2436 | if (!context || context->getClientVersion() < 3) |
| 2437 | { |
| 2438 | return gl::error(GL_INVALID_ENUM); |
| 2439 | } |
| 2440 | break; |
| 2441 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2442 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2443 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2444 | } |
| 2445 | |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2446 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 2447 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 2448 | |
| 2449 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 2450 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 2451 | |
| 2452 | if (constantColorUsed && constantAlphaUsed) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2453 | { |
daniel@transgaming.com | fe45365 | 2010-03-16 06:23:28 +0000 | [diff] [blame] | 2454 | 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] | 2455 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2456 | } |
| 2457 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2458 | if (context) |
| 2459 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 2460 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2461 | } |
| 2462 | } |
| 2463 | catch(std::bad_alloc&) |
| 2464 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2465 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2466 | } |
| 2467 | } |
| 2468 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2469 | 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] | 2470 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2471 | 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] | 2472 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2473 | |
| 2474 | try |
| 2475 | { |
| 2476 | if (size < 0) |
| 2477 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2478 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2479 | } |
| 2480 | |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2481 | gl::Context *context = gl::getNonLostContext(); |
| 2482 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2483 | switch (usage) |
| 2484 | { |
| 2485 | case GL_STREAM_DRAW: |
| 2486 | case GL_STATIC_DRAW: |
| 2487 | case GL_DYNAMIC_DRAW: |
| 2488 | break; |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 2489 | |
| 2490 | case GL_STREAM_READ: |
| 2491 | case GL_STREAM_COPY: |
| 2492 | case GL_STATIC_READ: |
| 2493 | case GL_STATIC_COPY: |
| 2494 | case GL_DYNAMIC_READ: |
| 2495 | case GL_DYNAMIC_COPY: |
| 2496 | if (context && context->getClientVersion() < 3) |
| 2497 | { |
| 2498 | return gl::error(GL_INVALID_ENUM); |
| 2499 | } |
| 2500 | break; |
| 2501 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2502 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2503 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2504 | } |
| 2505 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2506 | if (context) |
| 2507 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2508 | // Check ES3 specific targets |
| 2509 | switch (target) |
| 2510 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2511 | case GL_COPY_READ_BUFFER: |
| 2512 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2513 | case GL_PIXEL_PACK_BUFFER: |
| 2514 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2515 | case GL_UNIFORM_BUFFER: |
| 2516 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2517 | if (context->getClientVersion() < 3) |
| 2518 | { |
| 2519 | return gl::error(GL_INVALID_ENUM); |
| 2520 | } |
| 2521 | } |
| 2522 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2523 | gl::Buffer *buffer; |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2524 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2525 | switch (target) |
| 2526 | { |
| 2527 | case GL_ARRAY_BUFFER: |
| 2528 | buffer = context->getArrayBuffer(); |
| 2529 | break; |
| 2530 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2531 | buffer = context->getElementArrayBuffer(); |
| 2532 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2533 | case GL_COPY_READ_BUFFER: |
| 2534 | buffer = context->getCopyReadBuffer(); |
| 2535 | break; |
| 2536 | case GL_COPY_WRITE_BUFFER: |
| 2537 | buffer = context->getCopyWriteBuffer(); |
| 2538 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2539 | case GL_PIXEL_PACK_BUFFER: |
| 2540 | buffer = context->getPixelPackBuffer(); |
| 2541 | break; |
| 2542 | case GL_PIXEL_UNPACK_BUFFER: |
| 2543 | buffer = context->getPixelUnpackBuffer(); |
| 2544 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2545 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2546 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2547 | break; |
| 2548 | case GL_UNIFORM_BUFFER: |
| 2549 | buffer = context->getGenericUniformBuffer(); |
| 2550 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2551 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2552 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2553 | } |
| 2554 | |
| 2555 | if (!buffer) |
| 2556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2557 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2558 | } |
| 2559 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2560 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2561 | } |
| 2562 | } |
| 2563 | catch(std::bad_alloc&) |
| 2564 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2565 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2566 | } |
| 2567 | } |
| 2568 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2569 | 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] | 2570 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2571 | 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] | 2572 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2573 | |
| 2574 | try |
| 2575 | { |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2576 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2578 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2579 | } |
| 2580 | |
daniel@transgaming.com | d4620a3 | 2010-03-21 04:31:28 +0000 | [diff] [blame] | 2581 | if (data == NULL) |
| 2582 | { |
| 2583 | return; |
| 2584 | } |
| 2585 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2586 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2587 | |
| 2588 | if (context) |
| 2589 | { |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2590 | // Check ES3 specific targets |
| 2591 | switch (target) |
| 2592 | { |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2593 | case GL_COPY_READ_BUFFER: |
| 2594 | case GL_COPY_WRITE_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2595 | case GL_PIXEL_PACK_BUFFER: |
| 2596 | case GL_PIXEL_UNPACK_BUFFER: |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2597 | case GL_UNIFORM_BUFFER: |
| 2598 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2599 | if (context->getClientVersion() < 3) |
| 2600 | { |
| 2601 | return gl::error(GL_INVALID_ENUM); |
| 2602 | } |
| 2603 | } |
| 2604 | |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2605 | gl::Buffer *buffer; |
| 2606 | |
| 2607 | switch (target) |
| 2608 | { |
| 2609 | case GL_ARRAY_BUFFER: |
| 2610 | buffer = context->getArrayBuffer(); |
| 2611 | break; |
| 2612 | case GL_ELEMENT_ARRAY_BUFFER: |
| 2613 | buffer = context->getElementArrayBuffer(); |
| 2614 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 5117188 | 2013-04-13 03:39:10 +0000 | [diff] [blame] | 2615 | case GL_COPY_READ_BUFFER: |
| 2616 | buffer = context->getCopyReadBuffer(); |
| 2617 | break; |
| 2618 | case GL_COPY_WRITE_BUFFER: |
| 2619 | buffer = context->getCopyWriteBuffer(); |
| 2620 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c926e5f | 2013-04-13 03:39:18 +0000 | [diff] [blame] | 2621 | case GL_PIXEL_PACK_BUFFER: |
| 2622 | buffer = context->getPixelPackBuffer(); |
| 2623 | break; |
| 2624 | case GL_PIXEL_UNPACK_BUFFER: |
| 2625 | buffer = context->getPixelUnpackBuffer(); |
| 2626 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 2627 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 2628 | buffer = context->getGenericTransformFeedbackBuffer(); |
| 2629 | break; |
| 2630 | case GL_UNIFORM_BUFFER: |
| 2631 | buffer = context->getGenericUniformBuffer(); |
| 2632 | break; |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2633 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2634 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2635 | } |
| 2636 | |
| 2637 | if (!buffer) |
| 2638 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2639 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2640 | } |
| 2641 | |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2642 | if ((size_t)size + offset > buffer->size()) |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2644 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2645 | } |
daniel@transgaming.com | defa1c3 | 2010-05-18 18:51:45 +0000 | [diff] [blame] | 2646 | |
| 2647 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 0f7aaf5 | 2010-03-11 19:41:38 +0000 | [diff] [blame] | 2648 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2649 | } |
| 2650 | catch(std::bad_alloc&) |
| 2651 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2652 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2653 | } |
| 2654 | } |
| 2655 | |
| 2656 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 2657 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2658 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2659 | |
| 2660 | try |
| 2661 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2662 | 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] | 2663 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2664 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2665 | } |
| 2666 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2667 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2668 | |
| 2669 | if (context) |
| 2670 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2671 | gl::Framebuffer *framebuffer = NULL; |
| 2672 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 2673 | { |
| 2674 | framebuffer = context->getReadFramebuffer(); |
| 2675 | } |
| 2676 | else |
| 2677 | { |
| 2678 | framebuffer = context->getDrawFramebuffer(); |
| 2679 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2680 | |
| 2681 | return framebuffer->completeness(); |
| 2682 | } |
| 2683 | } |
| 2684 | catch(std::bad_alloc&) |
| 2685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2686 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2687 | } |
| 2688 | |
| 2689 | return 0; |
| 2690 | } |
| 2691 | |
| 2692 | void __stdcall glClear(GLbitfield mask) |
| 2693 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2694 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2695 | |
| 2696 | try |
| 2697 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2698 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2699 | |
| 2700 | if (context) |
| 2701 | { |
| 2702 | context->clear(mask); |
| 2703 | } |
| 2704 | } |
| 2705 | catch(std::bad_alloc&) |
| 2706 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2707 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2708 | } |
| 2709 | } |
| 2710 | |
| 2711 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 2712 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2713 | 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] | 2714 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2715 | |
| 2716 | try |
| 2717 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2718 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2719 | |
| 2720 | if (context) |
| 2721 | { |
| 2722 | context->setClearColor(red, green, blue, alpha); |
| 2723 | } |
| 2724 | } |
| 2725 | catch(std::bad_alloc&) |
| 2726 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2727 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | void __stdcall glClearDepthf(GLclampf depth) |
| 2732 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2733 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2734 | |
| 2735 | try |
| 2736 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2737 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2738 | |
| 2739 | if (context) |
| 2740 | { |
| 2741 | context->setClearDepth(depth); |
| 2742 | } |
| 2743 | } |
| 2744 | catch(std::bad_alloc&) |
| 2745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2746 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2747 | } |
| 2748 | } |
| 2749 | |
| 2750 | void __stdcall glClearStencil(GLint s) |
| 2751 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2752 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2753 | |
| 2754 | try |
| 2755 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2756 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2757 | |
| 2758 | if (context) |
| 2759 | { |
| 2760 | context->setClearStencil(s); |
| 2761 | } |
| 2762 | } |
| 2763 | catch(std::bad_alloc&) |
| 2764 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2765 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2766 | } |
| 2767 | } |
| 2768 | |
| 2769 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 2770 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 2771 | 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] | 2772 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2773 | |
| 2774 | try |
| 2775 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2776 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2777 | |
| 2778 | if (context) |
| 2779 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 2780 | 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] | 2781 | } |
| 2782 | } |
| 2783 | catch(std::bad_alloc&) |
| 2784 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2785 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2786 | } |
| 2787 | } |
| 2788 | |
| 2789 | void __stdcall glCompileShader(GLuint shader) |
| 2790 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2791 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2792 | |
| 2793 | try |
| 2794 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2795 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2796 | |
| 2797 | if (context) |
| 2798 | { |
| 2799 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 2800 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2801 | if (!shaderObject) |
| 2802 | { |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2803 | if (context->getProgram(shader)) |
| 2804 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2805 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2806 | } |
| 2807 | else |
| 2808 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2809 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 0cefaf4 | 2010-04-13 03:26:36 +0000 | [diff] [blame] | 2810 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2811 | } |
| 2812 | |
| 2813 | shaderObject->compile(); |
| 2814 | } |
| 2815 | } |
| 2816 | catch(std::bad_alloc&) |
| 2817 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2818 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2819 | } |
| 2820 | } |
| 2821 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2822 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 2823 | GLint border, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2824 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2825 | 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] | 2826 | "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] | 2827 | target, level, internalformat, width, height, border, imageSize, data); |
| 2828 | |
| 2829 | try |
| 2830 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2831 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2832 | |
| 2833 | if (context) |
| 2834 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2835 | if (context->getClientVersion() < 3 && |
| 2836 | !validateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 2837 | 0, 0, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2838 | { |
| 2839 | return; |
| 2840 | } |
| 2841 | |
| 2842 | if (context->getClientVersion() >= 3 && |
| 2843 | !validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 2844 | 0, 0, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2845 | { |
| 2846 | return; |
| 2847 | } |
| 2848 | |
| 2849 | 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] | 2850 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2851 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2852 | } |
| 2853 | |
| 2854 | switch (target) |
| 2855 | { |
| 2856 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2857 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2858 | gl::Texture2D *texture = context->getTexture2D(); |
| 2859 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2860 | } |
| 2861 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2862 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2863 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2864 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2865 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2866 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2867 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2868 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2869 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2870 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2871 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2872 | } |
| 2873 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2874 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2875 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2876 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2877 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2878 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2879 | } |
| 2880 | catch(std::bad_alloc&) |
| 2881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2882 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2883 | } |
| 2884 | } |
| 2885 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2886 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 2887 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2888 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2889 | 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] | 2890 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2891 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2892 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 2893 | |
| 2894 | try |
| 2895 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2896 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2897 | |
| 2898 | if (context) |
| 2899 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2900 | if (context->getClientVersion() < 3 && |
| 2901 | !validateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2902 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
| 2903 | { |
| 2904 | return; |
| 2905 | } |
| 2906 | |
| 2907 | if (context->getClientVersion() >= 3 && |
| 2908 | !validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 2909 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE)) |
| 2910 | { |
| 2911 | return; |
| 2912 | } |
| 2913 | |
| 2914 | 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] | 2915 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2916 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2917 | } |
| 2918 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2919 | switch (target) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2920 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2921 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2922 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2923 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2924 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2925 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2926 | break; |
| 2927 | |
| 2928 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2929 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2930 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2931 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2932 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2933 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2934 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2935 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 2936 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2937 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2938 | break; |
| 2939 | |
| 2940 | default: |
| 2941 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 2942 | } |
| 2943 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2944 | } |
| 2945 | catch(std::bad_alloc&) |
| 2946 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2947 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2948 | } |
| 2949 | } |
| 2950 | |
| 2951 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 2952 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2953 | 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] | 2954 | "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] | 2955 | target, level, internalformat, x, y, width, height, border); |
| 2956 | |
| 2957 | try |
| 2958 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 2959 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 2960 | |
| 2961 | if (context) |
| 2962 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2963 | if (context->getClientVersion() < 3 && |
| 2964 | !validateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 2965 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2966 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2967 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 2968 | } |
| 2969 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2970 | if (context->getClientVersion() >= 3 && |
| 2971 | !validateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 2972 | 0, 0, 0, x, y, width, height, border)) |
| 2973 | { |
| 2974 | return; |
| 2975 | } |
| 2976 | |
| 2977 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 2978 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2979 | switch (target) |
| 2980 | { |
| 2981 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2982 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2983 | gl::Texture2D *texture = context->getTexture2D(); |
| 2984 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2985 | } |
| 2986 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2987 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2988 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 2989 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 2990 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 2991 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 2992 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 2993 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2994 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2995 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 2996 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 2997 | } |
| 2998 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 2999 | |
| 3000 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3001 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3002 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3003 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3004 | } |
| 3005 | catch(std::bad_alloc&) |
| 3006 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3007 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3008 | } |
| 3009 | } |
| 3010 | |
| 3011 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 3012 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3013 | 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] | 3014 | "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] | 3015 | target, level, xoffset, yoffset, x, y, width, height); |
| 3016 | |
| 3017 | try |
| 3018 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3019 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3020 | |
| 3021 | if (context) |
| 3022 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3023 | if (context->getClientVersion() < 3 && |
| 3024 | !validateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3025 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3026 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3027 | return; |
| 3028 | } |
| 3029 | |
| 3030 | if (context->getClientVersion() >= 3 && |
| 3031 | !validateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 3032 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 3033 | { |
| 3034 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 3035 | } |
| 3036 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3037 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3038 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3039 | switch (target) |
daniel@transgaming.com | bbc5779 | 2010-07-28 19:21:05 +0000 | [diff] [blame] | 3040 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3041 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 2ccbbef | 2012-05-09 15:49:00 +0000 | [diff] [blame] | 3042 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3043 | gl::Texture2D *texture = context->getTexture2D(); |
| 3044 | 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] | 3045 | } |
| 3046 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3047 | |
| 3048 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3049 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3050 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3051 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3052 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3053 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 6452adf | 2012-10-17 18:22:35 +0000 | [diff] [blame] | 3054 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3055 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3056 | 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] | 3057 | } |
| 3058 | break; |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3059 | |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3060 | default: |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 3061 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3f85fbb | 2010-10-15 17:58:05 +0000 | [diff] [blame] | 3062 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3063 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3064 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 3065 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3066 | catch(std::bad_alloc&) |
| 3067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3068 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3069 | } |
| 3070 | } |
| 3071 | |
| 3072 | GLuint __stdcall glCreateProgram(void) |
| 3073 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3074 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3075 | |
| 3076 | try |
| 3077 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3078 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3079 | |
| 3080 | if (context) |
| 3081 | { |
| 3082 | return context->createProgram(); |
| 3083 | } |
| 3084 | } |
| 3085 | catch(std::bad_alloc&) |
| 3086 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3087 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3088 | } |
| 3089 | |
| 3090 | return 0; |
| 3091 | } |
| 3092 | |
| 3093 | GLuint __stdcall glCreateShader(GLenum type) |
| 3094 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3095 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3096 | |
| 3097 | try |
| 3098 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3099 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3100 | |
| 3101 | if (context) |
| 3102 | { |
| 3103 | switch (type) |
| 3104 | { |
| 3105 | case GL_FRAGMENT_SHADER: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3106 | case GL_VERTEX_SHADER: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3107 | return context->createShader(type); |
| 3108 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3109 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3110 | } |
| 3111 | } |
| 3112 | } |
| 3113 | catch(std::bad_alloc&) |
| 3114 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3115 | return gl::error(GL_OUT_OF_MEMORY, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3116 | } |
| 3117 | |
| 3118 | return 0; |
| 3119 | } |
| 3120 | |
| 3121 | void __stdcall glCullFace(GLenum mode) |
| 3122 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3123 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3124 | |
| 3125 | try |
| 3126 | { |
| 3127 | switch (mode) |
| 3128 | { |
| 3129 | case GL_FRONT: |
| 3130 | case GL_BACK: |
| 3131 | case GL_FRONT_AND_BACK: |
| 3132 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3133 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3134 | |
| 3135 | if (context) |
| 3136 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3137 | context->setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3138 | } |
| 3139 | } |
| 3140 | break; |
| 3141 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3142 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3143 | } |
| 3144 | } |
| 3145 | catch(std::bad_alloc&) |
| 3146 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3147 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3148 | } |
| 3149 | } |
| 3150 | |
| 3151 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 3152 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3153 | 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] | 3154 | |
| 3155 | try |
| 3156 | { |
| 3157 | if (n < 0) |
| 3158 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3159 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3160 | } |
| 3161 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3162 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3163 | |
| 3164 | if (context) |
| 3165 | { |
| 3166 | for (int i = 0; i < n; i++) |
| 3167 | { |
| 3168 | context->deleteBuffer(buffers[i]); |
| 3169 | } |
| 3170 | } |
| 3171 | } |
| 3172 | catch(std::bad_alloc&) |
| 3173 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3174 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3175 | } |
| 3176 | } |
| 3177 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3178 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 3179 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3180 | 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] | 3181 | |
| 3182 | try |
| 3183 | { |
| 3184 | if (n < 0) |
| 3185 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3186 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3187 | } |
| 3188 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3189 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3190 | |
| 3191 | if (context) |
| 3192 | { |
| 3193 | for (int i = 0; i < n; i++) |
| 3194 | { |
| 3195 | context->deleteFence(fences[i]); |
| 3196 | } |
| 3197 | } |
| 3198 | } |
| 3199 | catch(std::bad_alloc&) |
| 3200 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3201 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3202 | } |
| 3203 | } |
| 3204 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3205 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 3206 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3207 | 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] | 3208 | |
| 3209 | try |
| 3210 | { |
| 3211 | if (n < 0) |
| 3212 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3213 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3214 | } |
| 3215 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3216 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3217 | |
| 3218 | if (context) |
| 3219 | { |
| 3220 | for (int i = 0; i < n; i++) |
| 3221 | { |
| 3222 | if (framebuffers[i] != 0) |
| 3223 | { |
| 3224 | context->deleteFramebuffer(framebuffers[i]); |
| 3225 | } |
| 3226 | } |
| 3227 | } |
| 3228 | } |
| 3229 | catch(std::bad_alloc&) |
| 3230 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3231 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3232 | } |
| 3233 | } |
| 3234 | |
| 3235 | void __stdcall glDeleteProgram(GLuint program) |
| 3236 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3237 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3238 | |
| 3239 | try |
| 3240 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3241 | if (program == 0) |
| 3242 | { |
| 3243 | return; |
| 3244 | } |
| 3245 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3246 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3247 | |
| 3248 | if (context) |
| 3249 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3250 | if (!context->getProgram(program)) |
| 3251 | { |
| 3252 | if(context->getShader(program)) |
| 3253 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3254 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3255 | } |
| 3256 | else |
| 3257 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3258 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3259 | } |
| 3260 | } |
| 3261 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3262 | context->deleteProgram(program); |
| 3263 | } |
| 3264 | } |
| 3265 | catch(std::bad_alloc&) |
| 3266 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3267 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3268 | } |
| 3269 | } |
| 3270 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3271 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 3272 | { |
| 3273 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 3274 | |
| 3275 | try |
| 3276 | { |
| 3277 | if (n < 0) |
| 3278 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3279 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3280 | } |
| 3281 | |
| 3282 | gl::Context *context = gl::getNonLostContext(); |
| 3283 | |
| 3284 | if (context) |
| 3285 | { |
| 3286 | for (int i = 0; i < n; i++) |
| 3287 | { |
| 3288 | context->deleteQuery(ids[i]); |
| 3289 | } |
| 3290 | } |
| 3291 | } |
| 3292 | catch(std::bad_alloc&) |
| 3293 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3294 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3295 | } |
| 3296 | } |
| 3297 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3298 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 3299 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3300 | 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] | 3301 | |
| 3302 | try |
| 3303 | { |
| 3304 | if (n < 0) |
| 3305 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3306 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3307 | } |
| 3308 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3309 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3310 | |
| 3311 | if (context) |
| 3312 | { |
daniel@transgaming.com | e2b2212 | 2010-03-11 19:22:14 +0000 | [diff] [blame] | 3313 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3314 | { |
| 3315 | context->deleteRenderbuffer(renderbuffers[i]); |
| 3316 | } |
| 3317 | } |
| 3318 | } |
| 3319 | catch(std::bad_alloc&) |
| 3320 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3321 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3322 | } |
| 3323 | } |
| 3324 | |
| 3325 | void __stdcall glDeleteShader(GLuint shader) |
| 3326 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3327 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | |
| 3329 | try |
| 3330 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3331 | if (shader == 0) |
| 3332 | { |
| 3333 | return; |
| 3334 | } |
| 3335 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3336 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3337 | |
| 3338 | if (context) |
| 3339 | { |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3340 | if (!context->getShader(shader)) |
| 3341 | { |
| 3342 | if(context->getProgram(shader)) |
| 3343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3344 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3345 | } |
| 3346 | else |
| 3347 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3348 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 75401e6 | 2010-04-13 03:26:39 +0000 | [diff] [blame] | 3349 | } |
| 3350 | } |
| 3351 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3352 | context->deleteShader(shader); |
| 3353 | } |
| 3354 | } |
| 3355 | catch(std::bad_alloc&) |
| 3356 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3357 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3358 | } |
| 3359 | } |
| 3360 | |
| 3361 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 3362 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3363 | 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] | 3364 | |
| 3365 | try |
| 3366 | { |
| 3367 | if (n < 0) |
| 3368 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3369 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3370 | } |
| 3371 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3372 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3373 | |
| 3374 | if (context) |
| 3375 | { |
| 3376 | for (int i = 0; i < n; i++) |
| 3377 | { |
| 3378 | if (textures[i] != 0) |
| 3379 | { |
| 3380 | context->deleteTexture(textures[i]); |
| 3381 | } |
| 3382 | } |
| 3383 | } |
| 3384 | } |
| 3385 | catch(std::bad_alloc&) |
| 3386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3387 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3388 | } |
| 3389 | } |
| 3390 | |
| 3391 | void __stdcall glDepthFunc(GLenum func) |
| 3392 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3393 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3394 | |
| 3395 | try |
| 3396 | { |
| 3397 | switch (func) |
| 3398 | { |
| 3399 | case GL_NEVER: |
| 3400 | case GL_ALWAYS: |
| 3401 | case GL_LESS: |
| 3402 | case GL_LEQUAL: |
| 3403 | case GL_EQUAL: |
| 3404 | case GL_GREATER: |
| 3405 | case GL_GEQUAL: |
| 3406 | case GL_NOTEQUAL: |
| 3407 | break; |
| 3408 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3409 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3410 | } |
| 3411 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3412 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3413 | |
| 3414 | if (context) |
| 3415 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3416 | context->setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3417 | } |
| 3418 | } |
| 3419 | catch(std::bad_alloc&) |
| 3420 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3421 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3422 | } |
| 3423 | } |
| 3424 | |
| 3425 | void __stdcall glDepthMask(GLboolean flag) |
| 3426 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3427 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3428 | |
| 3429 | try |
| 3430 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3431 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3432 | |
| 3433 | if (context) |
| 3434 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3435 | context->setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3436 | } |
| 3437 | } |
| 3438 | catch(std::bad_alloc&) |
| 3439 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3440 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3441 | } |
| 3442 | } |
| 3443 | |
| 3444 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 3445 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3446 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3447 | |
| 3448 | try |
| 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 | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3454 | context->setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3455 | } |
| 3456 | } |
| 3457 | catch(std::bad_alloc&) |
| 3458 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3459 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3460 | } |
| 3461 | } |
| 3462 | |
| 3463 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 3464 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3465 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3466 | |
| 3467 | try |
| 3468 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3469 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3470 | |
| 3471 | if (context) |
| 3472 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3473 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3474 | gl::Program *programObject = context->getProgram(program); |
| 3475 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3476 | |
| 3477 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3478 | { |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3479 | gl::Shader *shaderByProgramHandle; |
| 3480 | shaderByProgramHandle = context->getShader(program); |
| 3481 | if (!shaderByProgramHandle) |
| 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 | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3484 | } |
| 3485 | else |
| 3486 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3487 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3488 | } |
| 3489 | } |
| 3490 | |
| 3491 | if (!shaderObject) |
| 3492 | { |
| 3493 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 3494 | if (!programByShaderHandle) |
| 3495 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3496 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3497 | } |
| 3498 | else |
| 3499 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3500 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 3501 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3502 | } |
| 3503 | |
| 3504 | if (!programObject->detachShader(shaderObject)) |
| 3505 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3506 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3507 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3508 | } |
| 3509 | } |
| 3510 | catch(std::bad_alloc&) |
| 3511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3512 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3513 | } |
| 3514 | } |
| 3515 | |
| 3516 | void __stdcall glDisable(GLenum cap) |
| 3517 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3518 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3519 | |
| 3520 | try |
| 3521 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3522 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3523 | |
| 3524 | if (context) |
| 3525 | { |
| 3526 | switch (cap) |
| 3527 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3528 | case GL_CULL_FACE: context->setCullFace(false); break; |
| 3529 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break; |
| 3530 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break; |
| 3531 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break; |
| 3532 | case GL_SCISSOR_TEST: context->setScissorTest(false); break; |
| 3533 | case GL_STENCIL_TEST: context->setStencilTest(false); break; |
| 3534 | case GL_DEPTH_TEST: context->setDepthTest(false); break; |
| 3535 | case GL_BLEND: context->setBlend(false); break; |
| 3536 | case GL_DITHER: context->setDither(false); break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 3537 | |
| 3538 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: |
| 3539 | case GL_RASTERIZER_DISCARD: |
| 3540 | if (context->getClientVersion() < 3) |
| 3541 | { |
| 3542 | return gl::error(GL_INVALID_ENUM); |
| 3543 | } |
| 3544 | UNIMPLEMENTED(); |
| 3545 | break; |
| 3546 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3547 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3548 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3549 | } |
| 3550 | } |
| 3551 | } |
| 3552 | catch(std::bad_alloc&) |
| 3553 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3554 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3555 | } |
| 3556 | } |
| 3557 | |
| 3558 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 3559 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3560 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3561 | |
| 3562 | try |
| 3563 | { |
| 3564 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3566 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3567 | } |
| 3568 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3569 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3570 | |
| 3571 | if (context) |
| 3572 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3573 | context->setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3574 | } |
| 3575 | } |
| 3576 | catch(std::bad_alloc&) |
| 3577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3578 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3579 | } |
| 3580 | } |
| 3581 | |
| 3582 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 3583 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3584 | 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] | 3585 | |
| 3586 | try |
| 3587 | { |
| 3588 | if (count < 0 || first < 0) |
| 3589 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3590 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3591 | } |
| 3592 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3593 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3594 | |
| 3595 | if (context) |
| 3596 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3597 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3598 | } |
| 3599 | } |
| 3600 | catch(std::bad_alloc&) |
| 3601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3602 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3603 | } |
| 3604 | } |
| 3605 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3606 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 3607 | { |
| 3608 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 3609 | |
| 3610 | try |
| 3611 | { |
| 3612 | if (count < 0 || first < 0 || primcount < 0) |
| 3613 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3614 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3615 | } |
| 3616 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3617 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3618 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3619 | gl::Context *context = gl::getNonLostContext(); |
| 3620 | |
| 3621 | if (context) |
| 3622 | { |
| 3623 | context->drawArrays(mode, first, count, primcount); |
| 3624 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3625 | } |
| 3626 | } |
| 3627 | catch(std::bad_alloc&) |
| 3628 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3629 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3630 | } |
| 3631 | } |
| 3632 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3633 | 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] | 3634 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3635 | 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] | 3636 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3637 | |
| 3638 | try |
| 3639 | { |
| 3640 | if (count < 0) |
| 3641 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3642 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3643 | } |
| 3644 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3645 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3646 | |
| 3647 | if (context) |
| 3648 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3649 | switch (type) |
| 3650 | { |
| 3651 | case GL_UNSIGNED_BYTE: |
| 3652 | case GL_UNSIGNED_SHORT: |
| 3653 | break; |
| 3654 | case GL_UNSIGNED_INT: |
| 3655 | if (!context->supports32bitIndices()) |
| 3656 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3657 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3658 | } |
| 3659 | break; |
| 3660 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3661 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3662 | } |
| 3663 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3664 | context->drawElements(mode, count, type, indices, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3665 | } |
| 3666 | } |
| 3667 | catch(std::bad_alloc&) |
| 3668 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3669 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3670 | } |
| 3671 | } |
| 3672 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3673 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 3674 | { |
| 3675 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 3676 | mode, count, type, indices, primcount); |
| 3677 | |
| 3678 | try |
| 3679 | { |
| 3680 | if (count < 0 || primcount < 0) |
| 3681 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3682 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3683 | } |
| 3684 | |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3685 | if (primcount > 0) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3686 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3687 | gl::Context *context = gl::getNonLostContext(); |
| 3688 | |
| 3689 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3690 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3691 | switch (type) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3692 | { |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3693 | case GL_UNSIGNED_BYTE: |
| 3694 | case GL_UNSIGNED_SHORT: |
| 3695 | break; |
| 3696 | case GL_UNSIGNED_INT: |
| 3697 | if (!context->supports32bitIndices()) |
| 3698 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3699 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3700 | } |
| 3701 | break; |
| 3702 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3703 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3704 | } |
daniel@transgaming.com | 8ca9c6e | 2012-01-27 15:38:54 +0000 | [diff] [blame] | 3705 | |
| 3706 | context->drawElements(mode, count, type, indices, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3707 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3708 | } |
| 3709 | } |
| 3710 | catch(std::bad_alloc&) |
| 3711 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3712 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 3713 | } |
| 3714 | } |
| 3715 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3716 | void __stdcall glEnable(GLenum cap) |
| 3717 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3718 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3719 | |
| 3720 | try |
| 3721 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3722 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3723 | |
| 3724 | if (context) |
| 3725 | { |
| 3726 | switch (cap) |
| 3727 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3728 | case GL_CULL_FACE: context->setCullFace(true); break; |
| 3729 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break; |
| 3730 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break; |
| 3731 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break; |
| 3732 | case GL_SCISSOR_TEST: context->setScissorTest(true); break; |
| 3733 | case GL_STENCIL_TEST: context->setStencilTest(true); break; |
| 3734 | case GL_DEPTH_TEST: context->setDepthTest(true); break; |
| 3735 | case GL_BLEND: context->setBlend(true); break; |
| 3736 | case GL_DITHER: context->setDither(true); break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3737 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3738 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3739 | } |
| 3740 | } |
| 3741 | } |
| 3742 | catch(std::bad_alloc&) |
| 3743 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3744 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3745 | } |
| 3746 | } |
| 3747 | |
| 3748 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 3749 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3750 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3751 | |
| 3752 | try |
| 3753 | { |
| 3754 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 3755 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3756 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3757 | } |
| 3758 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3759 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3760 | |
| 3761 | if (context) |
| 3762 | { |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 3763 | context->setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3764 | } |
| 3765 | } |
| 3766 | catch(std::bad_alloc&) |
| 3767 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3768 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3769 | } |
| 3770 | } |
| 3771 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3772 | void __stdcall glEndQueryEXT(GLenum target) |
| 3773 | { |
| 3774 | EVENT("GLenum target = 0x%X)", target); |
| 3775 | |
| 3776 | try |
| 3777 | { |
| 3778 | switch (target) |
| 3779 | { |
| 3780 | case GL_ANY_SAMPLES_PASSED_EXT: |
| 3781 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT: |
| 3782 | break; |
| 3783 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3784 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3785 | } |
| 3786 | |
| 3787 | gl::Context *context = gl::getNonLostContext(); |
| 3788 | |
| 3789 | if (context) |
| 3790 | { |
| 3791 | context->endQuery(target); |
| 3792 | } |
| 3793 | } |
| 3794 | catch(std::bad_alloc&) |
| 3795 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3796 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3797 | } |
| 3798 | } |
| 3799 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3800 | void __stdcall glFinishFenceNV(GLuint fence) |
| 3801 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3802 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3803 | |
| 3804 | try |
| 3805 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3806 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3807 | |
| 3808 | if (context) |
| 3809 | { |
| 3810 | gl::Fence* fenceObject = context->getFence(fence); |
| 3811 | |
| 3812 | if (fenceObject == NULL) |
| 3813 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3814 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3815 | } |
| 3816 | |
| 3817 | fenceObject->finishFence(); |
| 3818 | } |
| 3819 | } |
| 3820 | catch(std::bad_alloc&) |
| 3821 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3822 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3823 | } |
| 3824 | } |
| 3825 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3826 | void __stdcall glFinish(void) |
| 3827 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3828 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3829 | |
| 3830 | try |
| 3831 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3832 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3833 | |
| 3834 | if (context) |
| 3835 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3836 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3837 | } |
| 3838 | } |
| 3839 | catch(std::bad_alloc&) |
| 3840 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3841 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3842 | } |
| 3843 | } |
| 3844 | |
| 3845 | void __stdcall glFlush(void) |
| 3846 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3847 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3848 | |
| 3849 | try |
| 3850 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3851 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3852 | |
| 3853 | if (context) |
| 3854 | { |
daniel@transgaming.com | 0d86aa7 | 2011-10-26 02:35:10 +0000 | [diff] [blame] | 3855 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3856 | } |
| 3857 | } |
| 3858 | catch(std::bad_alloc&) |
| 3859 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3860 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3861 | } |
| 3862 | } |
| 3863 | |
| 3864 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 3865 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3866 | 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] | 3867 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3868 | |
| 3869 | try |
| 3870 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3871 | 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] | 3872 | || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3873 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3874 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3875 | } |
| 3876 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3877 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3878 | |
| 3879 | if (context) |
| 3880 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3881 | gl::Framebuffer *framebuffer = NULL; |
| 3882 | GLuint framebufferHandle = 0; |
| 3883 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 3884 | { |
| 3885 | framebuffer = context->getReadFramebuffer(); |
| 3886 | framebufferHandle = context->getReadFramebufferHandle(); |
| 3887 | } |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3888 | else |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3889 | { |
| 3890 | framebuffer = context->getDrawFramebuffer(); |
| 3891 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 3892 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3893 | |
daniel@transgaming.com | 2fa4551 | 2011-10-04 18:43:18 +0000 | [diff] [blame] | 3894 | if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3895 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3896 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3897 | } |
| 3898 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3899 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3900 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3901 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3902 | |
| 3903 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3904 | { |
| 3905 | return gl::error(GL_INVALID_VALUE); |
| 3906 | } |
| 3907 | |
| 3908 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer); |
| 3909 | } |
| 3910 | else |
| 3911 | { |
| 3912 | switch (attachment) |
| 3913 | { |
| 3914 | case GL_DEPTH_ATTACHMENT: |
| 3915 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3916 | break; |
| 3917 | case GL_STENCIL_ATTACHMENT: |
| 3918 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer); |
| 3919 | break; |
| 3920 | default: |
| 3921 | return gl::error(GL_INVALID_ENUM); |
| 3922 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3923 | } |
| 3924 | } |
| 3925 | } |
| 3926 | catch(std::bad_alloc&) |
| 3927 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3928 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3929 | } |
| 3930 | } |
| 3931 | |
| 3932 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 3933 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3934 | 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] | 3935 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3936 | |
| 3937 | try |
| 3938 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 3939 | 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] | 3940 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3941 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3942 | } |
| 3943 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 3944 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3945 | |
| 3946 | if (context) |
| 3947 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 3948 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 3949 | { |
| 3950 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 3951 | |
| 3952 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 3953 | { |
| 3954 | return gl::error(GL_INVALID_VALUE); |
| 3955 | } |
| 3956 | } |
| 3957 | else |
| 3958 | { |
| 3959 | switch (attachment) |
| 3960 | { |
| 3961 | case GL_DEPTH_ATTACHMENT: |
| 3962 | case GL_STENCIL_ATTACHMENT: |
| 3963 | break; |
| 3964 | default: |
| 3965 | return gl::error(GL_INVALID_ENUM); |
| 3966 | } |
| 3967 | } |
| 3968 | |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3969 | if (texture == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3970 | { |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3971 | textarget = GL_NONE; |
| 3972 | } |
| 3973 | else |
| 3974 | { |
| 3975 | gl::Texture *tex = context->getTexture(texture); |
| 3976 | |
| 3977 | if (tex == NULL) |
| 3978 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3979 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3980 | } |
| 3981 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3982 | switch (textarget) |
| 3983 | { |
| 3984 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3985 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3986 | if (tex->getTarget() != GL_TEXTURE_2D) |
| 3987 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3988 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3989 | } |
| 3990 | gl::Texture2D *tex2d = static_cast<gl::Texture2D *>(tex); |
daniel@transgaming.com | 92f4992 | 2012-05-09 15:49:19 +0000 | [diff] [blame] | 3991 | if (tex2d->isCompressed(0)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3993 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 3994 | } |
| 3995 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3996 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 3997 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3998 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3999 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4000 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4001 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4002 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4003 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4004 | { |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4005 | if (tex->getTarget() != GL_TEXTURE_CUBE_MAP) |
| 4006 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4007 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4008 | } |
| 4009 | gl::TextureCubeMap *texcube = static_cast<gl::TextureCubeMap *>(tex); |
daniel@transgaming.com | 4df88e8 | 2012-05-09 15:49:24 +0000 | [diff] [blame] | 4010 | if (texcube->isCompressed(textarget, level)) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4011 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4012 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4013 | } |
| 4014 | break; |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4015 | } |
daniel@transgaming.com | 93a8147 | 2010-04-20 18:52:58 +0000 | [diff] [blame] | 4016 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4017 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4018 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4019 | } |
| 4020 | |
| 4021 | if (level != 0) |
| 4022 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4023 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4024 | } |
| 4025 | } |
| 4026 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4027 | gl::Framebuffer *framebuffer = NULL; |
| 4028 | GLuint framebufferHandle = 0; |
| 4029 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4030 | { |
| 4031 | framebuffer = context->getReadFramebuffer(); |
| 4032 | framebufferHandle = context->getReadFramebufferHandle(); |
| 4033 | } |
| 4034 | else |
| 4035 | { |
| 4036 | framebuffer = context->getDrawFramebuffer(); |
| 4037 | framebufferHandle = context->getDrawFramebufferHandle(); |
| 4038 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4039 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4040 | if (framebufferHandle == 0 || !framebuffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4041 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4042 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4043 | } |
| 4044 | |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4045 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4046 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4047 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4048 | |
| 4049 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4050 | { |
| 4051 | return gl::error(GL_INVALID_VALUE); |
| 4052 | } |
| 4053 | |
| 4054 | framebuffer->setColorbuffer(colorAttachment, textarget, texture); |
| 4055 | } |
| 4056 | else |
| 4057 | { |
| 4058 | switch (attachment) |
| 4059 | { |
| 4060 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break; |
| 4061 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break; |
| 4062 | } |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4063 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4064 | } |
| 4065 | } |
| 4066 | catch(std::bad_alloc&) |
| 4067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4068 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4069 | } |
| 4070 | } |
| 4071 | |
| 4072 | void __stdcall glFrontFace(GLenum mode) |
| 4073 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4074 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4075 | |
| 4076 | try |
| 4077 | { |
| 4078 | switch (mode) |
| 4079 | { |
| 4080 | case GL_CW: |
| 4081 | case GL_CCW: |
| 4082 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4083 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4084 | |
| 4085 | if (context) |
| 4086 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 4087 | context->setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4088 | } |
| 4089 | } |
| 4090 | break; |
| 4091 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4092 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4093 | } |
| 4094 | } |
| 4095 | catch(std::bad_alloc&) |
| 4096 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4097 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4098 | } |
| 4099 | } |
| 4100 | |
| 4101 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 4102 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4103 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4104 | |
| 4105 | try |
| 4106 | { |
| 4107 | if (n < 0) |
| 4108 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4109 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4110 | } |
| 4111 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4112 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4113 | |
| 4114 | if (context) |
| 4115 | { |
| 4116 | for (int i = 0; i < n; i++) |
| 4117 | { |
| 4118 | buffers[i] = context->createBuffer(); |
| 4119 | } |
| 4120 | } |
| 4121 | } |
| 4122 | catch(std::bad_alloc&) |
| 4123 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4124 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4125 | } |
| 4126 | } |
| 4127 | |
| 4128 | void __stdcall glGenerateMipmap(GLenum target) |
| 4129 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4130 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4131 | |
| 4132 | try |
| 4133 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4134 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4135 | |
| 4136 | if (context) |
| 4137 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4138 | gl::Texture *texture = NULL; |
| 4139 | GLint internalFormat = GL_NONE; |
| 4140 | bool isCompressed = false; |
| 4141 | bool isDepth = false; |
| 4142 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4143 | switch (target) |
| 4144 | { |
| 4145 | case GL_TEXTURE_2D: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4146 | { |
| 4147 | gl::Texture2D *tex2d = context->getTexture2D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4148 | if (tex2d) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4149 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4150 | internalFormat = tex2d->getInternalFormat(0); |
| 4151 | isCompressed = tex2d->isCompressed(0); |
| 4152 | isDepth = tex2d->isDepth(0); |
| 4153 | texture = tex2d; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4154 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4155 | break; |
| 4156 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4157 | |
| 4158 | case GL_TEXTURE_CUBE_MAP: |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4159 | { |
| 4160 | gl::TextureCubeMap *texcube = context->getTextureCubeMap(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4161 | if (texcube) |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4162 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4163 | internalFormat = texcube->getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4164 | isCompressed = texcube->isCompressed(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0); |
| 4165 | isDepth = false; |
| 4166 | texture = texcube; |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4167 | } |
daniel@transgaming.com | eb3c01a | 2012-05-09 15:49:12 +0000 | [diff] [blame] | 4168 | break; |
| 4169 | } |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4170 | |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4171 | case GL_TEXTURE_3D: |
| 4172 | { |
| 4173 | if (context->getClientVersion() < 3) |
| 4174 | { |
| 4175 | return gl::error(GL_INVALID_ENUM); |
| 4176 | } |
| 4177 | |
| 4178 | gl::Texture3D *tex3D = context->getTexture3D(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4179 | if (tex3D) |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4180 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4181 | internalFormat = tex3D->getInternalFormat(0); |
| 4182 | isCompressed = tex3D->isCompressed(0); |
| 4183 | isDepth = tex3D->isDepth(0); |
| 4184 | texture = tex3D; |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4185 | } |
shannon.woods%transgaming.com@gtempaccount.com | 86740a9 | 2013-04-13 03:45:24 +0000 | [diff] [blame] | 4186 | break; |
| 4187 | } |
| 4188 | |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4189 | case GL_TEXTURE_2D_ARRAY: |
| 4190 | { |
| 4191 | if (context->getClientVersion() < 3) |
| 4192 | { |
| 4193 | return gl::error(GL_INVALID_ENUM); |
| 4194 | } |
| 4195 | |
| 4196 | gl::Texture2DArray *tex2darr = context->getTexture2DArray(); |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4197 | if (tex2darr) |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4198 | { |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4199 | internalFormat = tex2darr->getInternalFormat(0); |
| 4200 | isCompressed = tex2darr->isCompressed(0); |
| 4201 | isDepth = tex2darr->isDepth(0); |
| 4202 | texture = tex2darr; |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4203 | } |
shannonwoods@chromium.org | 30aa1a9 | 2013-05-30 00:03:13 +0000 | [diff] [blame] | 4204 | break; |
| 4205 | } |
| 4206 | |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4207 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4208 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4209 | } |
Geoff Lang | ae4852a | 2013-06-05 15:00:34 -0400 | [diff] [blame] | 4210 | |
| 4211 | if (!texture) |
| 4212 | { |
| 4213 | return gl::error(GL_INVALID_OPERATION); |
| 4214 | } |
| 4215 | |
| 4216 | // Internally, all texture formats are sized so checking if the format |
| 4217 | // is color renderable and filterable will not fail. |
| 4218 | if (isDepth || isCompressed || |
| 4219 | !gl::IsColorRenderingSupported(internalFormat, context) || |
| 4220 | !gl::IsTextureFilteringSupported(internalFormat, context)) |
| 4221 | { |
| 4222 | return gl::error(GL_INVALID_OPERATION); |
| 4223 | } |
| 4224 | |
| 4225 | texture->generateMipmaps(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 4226 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4227 | } |
| 4228 | catch(std::bad_alloc&) |
| 4229 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4230 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4231 | } |
| 4232 | } |
| 4233 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4234 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 4235 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4236 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4237 | |
| 4238 | try |
| 4239 | { |
| 4240 | if (n < 0) |
| 4241 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4242 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4243 | } |
| 4244 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4245 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4246 | |
| 4247 | if (context) |
| 4248 | { |
| 4249 | for (int i = 0; i < n; i++) |
| 4250 | { |
| 4251 | fences[i] = context->createFence(); |
| 4252 | } |
| 4253 | } |
| 4254 | } |
| 4255 | catch(std::bad_alloc&) |
| 4256 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4257 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4258 | } |
| 4259 | } |
| 4260 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4261 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 4262 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4263 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4264 | |
| 4265 | try |
| 4266 | { |
| 4267 | if (n < 0) |
| 4268 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4269 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4270 | } |
| 4271 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4272 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4273 | |
| 4274 | if (context) |
| 4275 | { |
| 4276 | for (int i = 0; i < n; i++) |
| 4277 | { |
| 4278 | framebuffers[i] = context->createFramebuffer(); |
| 4279 | } |
| 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 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4288 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 4289 | { |
| 4290 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 4291 | |
| 4292 | try |
| 4293 | { |
| 4294 | if (n < 0) |
| 4295 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4296 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4297 | } |
| 4298 | |
| 4299 | gl::Context *context = gl::getNonLostContext(); |
| 4300 | |
| 4301 | if (context) |
| 4302 | { |
| 4303 | for (int i = 0; i < n; i++) |
| 4304 | { |
| 4305 | ids[i] = context->createQuery(); |
| 4306 | } |
| 4307 | } |
| 4308 | } |
| 4309 | catch(std::bad_alloc&) |
| 4310 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4311 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 4312 | } |
| 4313 | } |
| 4314 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4315 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 4316 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4317 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4318 | |
| 4319 | try |
| 4320 | { |
| 4321 | if (n < 0) |
| 4322 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4323 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4324 | } |
| 4325 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4326 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4327 | |
| 4328 | if (context) |
| 4329 | { |
| 4330 | for (int i = 0; i < n; i++) |
| 4331 | { |
| 4332 | renderbuffers[i] = context->createRenderbuffer(); |
| 4333 | } |
| 4334 | } |
| 4335 | } |
| 4336 | catch(std::bad_alloc&) |
| 4337 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4338 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4339 | } |
| 4340 | } |
| 4341 | |
| 4342 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 4343 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4344 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4345 | |
| 4346 | try |
| 4347 | { |
| 4348 | if (n < 0) |
| 4349 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4350 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4351 | } |
| 4352 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4353 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4354 | |
| 4355 | if (context) |
| 4356 | { |
| 4357 | for (int i = 0; i < n; i++) |
| 4358 | { |
| 4359 | textures[i] = context->createTexture(); |
| 4360 | } |
| 4361 | } |
| 4362 | } |
| 4363 | catch(std::bad_alloc&) |
| 4364 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4365 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4366 | } |
| 4367 | } |
| 4368 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4369 | 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] | 4370 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4371 | 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] | 4372 | "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] | 4373 | program, index, bufsize, length, size, type, name); |
| 4374 | |
| 4375 | try |
| 4376 | { |
| 4377 | if (bufsize < 0) |
| 4378 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4379 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4380 | } |
| 4381 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4382 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4383 | |
| 4384 | if (context) |
| 4385 | { |
| 4386 | gl::Program *programObject = context->getProgram(program); |
| 4387 | |
| 4388 | if (!programObject) |
| 4389 | { |
| 4390 | if (context->getShader(program)) |
| 4391 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4392 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4393 | } |
| 4394 | else |
| 4395 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4396 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4397 | } |
| 4398 | } |
| 4399 | |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4400 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4401 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4402 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 4403 | } |
| 4404 | |
| 4405 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
| 4406 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4407 | } |
| 4408 | catch(std::bad_alloc&) |
| 4409 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4410 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4411 | } |
| 4412 | } |
| 4413 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4414 | 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] | 4415 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4416 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4417 | "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] | 4418 | program, index, bufsize, length, size, type, name); |
| 4419 | |
| 4420 | try |
| 4421 | { |
| 4422 | if (bufsize < 0) |
| 4423 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4424 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4425 | } |
| 4426 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4427 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4428 | |
| 4429 | if (context) |
| 4430 | { |
| 4431 | gl::Program *programObject = context->getProgram(program); |
| 4432 | |
| 4433 | if (!programObject) |
| 4434 | { |
| 4435 | if (context->getShader(program)) |
| 4436 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4437 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4438 | } |
| 4439 | else |
| 4440 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4441 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4442 | } |
| 4443 | } |
| 4444 | |
| 4445 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
| 4446 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4447 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 4448 | } |
| 4449 | |
| 4450 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
| 4451 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4452 | } |
| 4453 | catch(std::bad_alloc&) |
| 4454 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4455 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4456 | } |
| 4457 | } |
| 4458 | |
| 4459 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 4460 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4461 | 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] | 4462 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4463 | |
| 4464 | try |
| 4465 | { |
| 4466 | if (maxcount < 0) |
| 4467 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4468 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4469 | } |
| 4470 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4471 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4472 | |
| 4473 | if (context) |
| 4474 | { |
| 4475 | gl::Program *programObject = context->getProgram(program); |
| 4476 | |
| 4477 | if (!programObject) |
| 4478 | { |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4479 | if (context->getShader(program)) |
| 4480 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4481 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4482 | } |
| 4483 | else |
| 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 | 23953e3 | 2010-04-13 19:53:31 +0000 | [diff] [blame] | 4486 | } |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 4487 | } |
| 4488 | |
| 4489 | return programObject->getAttachedShaders(maxcount, count, shaders); |
| 4490 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4491 | } |
| 4492 | catch(std::bad_alloc&) |
| 4493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4494 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4495 | } |
| 4496 | } |
| 4497 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4498 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4499 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4500 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4501 | |
| 4502 | try |
| 4503 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4504 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4505 | |
| 4506 | if (context) |
| 4507 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4508 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4509 | gl::Program *programObject = context->getProgram(program); |
| 4510 | |
| 4511 | if (!programObject) |
| 4512 | { |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4513 | if (context->getShader(program)) |
| 4514 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4515 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4516 | } |
| 4517 | else |
| 4518 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4519 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | bb274c3 | 2010-04-13 03:26:21 +0000 | [diff] [blame] | 4520 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4521 | } |
| 4522 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4523 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 4524 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4525 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4526 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 4527 | } |
| 4528 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 4529 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4530 | } |
| 4531 | } |
| 4532 | catch(std::bad_alloc&) |
| 4533 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4534 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4535 | } |
| 4536 | |
| 4537 | return -1; |
| 4538 | } |
| 4539 | |
| 4540 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 4541 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4542 | 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] | 4543 | |
| 4544 | try |
| 4545 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4546 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4547 | |
| 4548 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4549 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4550 | if (!(context->getBooleanv(pname, params))) |
| 4551 | { |
| 4552 | GLenum nativeType; |
| 4553 | unsigned int numParams = 0; |
| 4554 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4555 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4556 | |
| 4557 | if (numParams == 0) |
| 4558 | return; // it is known that the pname is valid, but there are no parameters to return |
| 4559 | |
| 4560 | if (nativeType == GL_FLOAT) |
| 4561 | { |
| 4562 | GLfloat *floatParams = NULL; |
| 4563 | floatParams = new GLfloat[numParams]; |
| 4564 | |
| 4565 | context->getFloatv(pname, floatParams); |
| 4566 | |
| 4567 | for (unsigned int i = 0; i < numParams; ++i) |
| 4568 | { |
| 4569 | if (floatParams[i] == 0.0f) |
| 4570 | params[i] = GL_FALSE; |
| 4571 | else |
| 4572 | params[i] = GL_TRUE; |
| 4573 | } |
| 4574 | |
| 4575 | delete [] floatParams; |
| 4576 | } |
| 4577 | else if (nativeType == GL_INT) |
| 4578 | { |
| 4579 | GLint *intParams = NULL; |
| 4580 | intParams = new GLint[numParams]; |
| 4581 | |
| 4582 | context->getIntegerv(pname, intParams); |
| 4583 | |
| 4584 | for (unsigned int i = 0; i < numParams; ++i) |
| 4585 | { |
| 4586 | if (intParams[i] == 0) |
| 4587 | params[i] = GL_FALSE; |
| 4588 | else |
| 4589 | params[i] = GL_TRUE; |
| 4590 | } |
| 4591 | |
| 4592 | delete [] intParams; |
| 4593 | } |
| 4594 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4595 | } |
| 4596 | } |
| 4597 | catch(std::bad_alloc&) |
| 4598 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4599 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4600 | } |
| 4601 | } |
| 4602 | |
| 4603 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 4604 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4605 | 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] | 4606 | |
| 4607 | try |
| 4608 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4609 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4610 | |
| 4611 | if (context) |
| 4612 | { |
| 4613 | gl::Buffer *buffer; |
| 4614 | |
| 4615 | switch (target) |
| 4616 | { |
| 4617 | case GL_ARRAY_BUFFER: |
| 4618 | buffer = context->getArrayBuffer(); |
| 4619 | break; |
| 4620 | case GL_ELEMENT_ARRAY_BUFFER: |
| 4621 | buffer = context->getElementArrayBuffer(); |
| 4622 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4623 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4624 | } |
| 4625 | |
| 4626 | if (!buffer) |
| 4627 | { |
| 4628 | // 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] | 4629 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4630 | } |
| 4631 | |
| 4632 | switch (pname) |
| 4633 | { |
| 4634 | case GL_BUFFER_USAGE: |
| 4635 | *params = buffer->usage(); |
| 4636 | break; |
| 4637 | case GL_BUFFER_SIZE: |
| 4638 | *params = buffer->size(); |
| 4639 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4640 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 4641 | } |
| 4642 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4643 | } |
| 4644 | catch(std::bad_alloc&) |
| 4645 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4646 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4647 | } |
| 4648 | } |
| 4649 | |
| 4650 | GLenum __stdcall glGetError(void) |
| 4651 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4652 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4653 | |
| 4654 | gl::Context *context = gl::getContext(); |
| 4655 | |
| 4656 | if (context) |
| 4657 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 4658 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | return GL_NO_ERROR; |
| 4662 | } |
| 4663 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4664 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 4665 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4666 | 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] | 4667 | |
| 4668 | try |
| 4669 | { |
| 4670 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4671 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4672 | |
| 4673 | if (context) |
| 4674 | { |
| 4675 | gl::Fence *fenceObject = context->getFence(fence); |
| 4676 | |
| 4677 | if (fenceObject == NULL) |
| 4678 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4679 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4680 | } |
| 4681 | |
| 4682 | fenceObject->getFenceiv(pname, params); |
| 4683 | } |
| 4684 | } |
| 4685 | catch(std::bad_alloc&) |
| 4686 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4687 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4688 | } |
| 4689 | } |
| 4690 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4691 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 4692 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4693 | 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] | 4694 | |
| 4695 | try |
| 4696 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4697 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4698 | |
| 4699 | if (context) |
| 4700 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4701 | if (!(context->getFloatv(pname, params))) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4702 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4703 | GLenum nativeType; |
| 4704 | unsigned int numParams = 0; |
| 4705 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4706 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4707 | |
| 4708 | if (numParams == 0) |
| 4709 | return; // it is known that the pname is valid, but that there are no parameters to return. |
| 4710 | |
| 4711 | if (nativeType == GL_BOOL) |
| 4712 | { |
| 4713 | GLboolean *boolParams = NULL; |
| 4714 | boolParams = new GLboolean[numParams]; |
| 4715 | |
| 4716 | context->getBooleanv(pname, boolParams); |
| 4717 | |
| 4718 | for (unsigned int i = 0; i < numParams; ++i) |
| 4719 | { |
| 4720 | if (boolParams[i] == GL_FALSE) |
| 4721 | params[i] = 0.0f; |
| 4722 | else |
| 4723 | params[i] = 1.0f; |
| 4724 | } |
| 4725 | |
| 4726 | delete [] boolParams; |
| 4727 | } |
| 4728 | else if (nativeType == GL_INT) |
| 4729 | { |
| 4730 | GLint *intParams = NULL; |
| 4731 | intParams = new GLint[numParams]; |
| 4732 | |
| 4733 | context->getIntegerv(pname, intParams); |
| 4734 | |
| 4735 | for (unsigned int i = 0; i < numParams; ++i) |
| 4736 | { |
| 4737 | params[i] = (GLfloat)intParams[i]; |
| 4738 | } |
| 4739 | |
| 4740 | delete [] intParams; |
| 4741 | } |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 4742 | } |
| 4743 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4744 | } |
| 4745 | catch(std::bad_alloc&) |
| 4746 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4747 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4748 | } |
| 4749 | } |
| 4750 | |
| 4751 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 4752 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4753 | 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] | 4754 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4755 | |
| 4756 | try |
| 4757 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4758 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4759 | |
| 4760 | if (context) |
| 4761 | { |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4762 | 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] | 4763 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4764 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4765 | } |
| 4766 | |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4767 | gl::Framebuffer *framebuffer = NULL; |
| 4768 | if (target == GL_READ_FRAMEBUFFER_ANGLE) |
| 4769 | { |
| 4770 | if(context->getReadFramebufferHandle() == 0) |
| 4771 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4772 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4773 | } |
| 4774 | |
| 4775 | framebuffer = context->getReadFramebuffer(); |
| 4776 | } |
| 4777 | else |
| 4778 | { |
| 4779 | if (context->getDrawFramebufferHandle() == 0) |
| 4780 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4781 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 4782 | } |
| 4783 | |
| 4784 | framebuffer = context->getDrawFramebuffer(); |
| 4785 | } |
| 4786 | |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4787 | GLenum attachmentType; |
| 4788 | GLuint attachmentHandle; |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4789 | |
| 4790 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4791 | { |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 4792 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 4793 | |
| 4794 | if (colorAttachment >= context->getMaximumRenderTargets()) |
| 4795 | { |
| 4796 | return gl::error(GL_INVALID_ENUM); |
| 4797 | } |
| 4798 | |
| 4799 | attachmentType = framebuffer->getColorbufferType(colorAttachment); |
| 4800 | attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment); |
| 4801 | } |
| 4802 | else |
| 4803 | { |
| 4804 | switch (attachment) |
| 4805 | { |
| 4806 | case GL_DEPTH_ATTACHMENT: |
| 4807 | attachmentType = framebuffer->getDepthbufferType(); |
| 4808 | attachmentHandle = framebuffer->getDepthbufferHandle(); |
| 4809 | break; |
| 4810 | case GL_STENCIL_ATTACHMENT: |
| 4811 | attachmentType = framebuffer->getStencilbufferType(); |
| 4812 | attachmentHandle = framebuffer->getStencilbufferHandle(); |
| 4813 | break; |
| 4814 | default: return gl::error(GL_INVALID_ENUM); |
| 4815 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4816 | } |
| 4817 | |
| 4818 | GLenum attachmentObjectType; // Type category |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 4819 | if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4820 | { |
| 4821 | attachmentObjectType = attachmentType; |
| 4822 | } |
apatrick@chromium.org | 551022e | 2012-01-23 19:56:54 +0000 | [diff] [blame] | 4823 | else if (gl::IsInternalTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4824 | { |
| 4825 | attachmentObjectType = GL_TEXTURE; |
| 4826 | } |
apatrick@chromium.org | a1d8059 | 2012-01-25 21:52:10 +0000 | [diff] [blame] | 4827 | else |
| 4828 | { |
| 4829 | UNREACHABLE(); |
| 4830 | return; |
| 4831 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4832 | |
| 4833 | switch (pname) |
| 4834 | { |
| 4835 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 4836 | *params = attachmentObjectType; |
| 4837 | break; |
| 4838 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 4839 | if (attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE) |
| 4840 | { |
| 4841 | *params = attachmentHandle; |
| 4842 | } |
| 4843 | else |
| 4844 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4845 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4846 | } |
| 4847 | break; |
| 4848 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 4849 | if (attachmentObjectType == GL_TEXTURE) |
| 4850 | { |
| 4851 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0 |
| 4852 | } |
| 4853 | else |
| 4854 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4855 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4856 | } |
| 4857 | break; |
| 4858 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 4859 | if (attachmentObjectType == GL_TEXTURE) |
| 4860 | { |
daniel@transgaming.com | 19ffc24 | 2010-05-04 03:35:21 +0000 | [diff] [blame] | 4861 | if (gl::IsCubemapTextureTarget(attachmentType)) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4862 | { |
| 4863 | *params = attachmentType; |
| 4864 | } |
| 4865 | else |
| 4866 | { |
| 4867 | *params = 0; |
| 4868 | } |
| 4869 | } |
| 4870 | else |
| 4871 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4872 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4873 | } |
| 4874 | break; |
| 4875 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4876 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 4877 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4878 | } |
| 4879 | } |
| 4880 | catch(std::bad_alloc&) |
| 4881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4882 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4883 | } |
| 4884 | } |
| 4885 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 4886 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 4887 | { |
| 4888 | EVENT("()"); |
| 4889 | |
| 4890 | try |
| 4891 | { |
| 4892 | gl::Context *context = gl::getContext(); |
| 4893 | |
| 4894 | if (context) |
| 4895 | { |
| 4896 | return context->getResetStatus(); |
| 4897 | } |
| 4898 | |
| 4899 | return GL_NO_ERROR; |
| 4900 | } |
| 4901 | catch(std::bad_alloc&) |
| 4902 | { |
| 4903 | return GL_OUT_OF_MEMORY; |
| 4904 | } |
| 4905 | } |
| 4906 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4907 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 4908 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4909 | 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] | 4910 | |
| 4911 | try |
| 4912 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4913 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4914 | |
| 4915 | if (context) |
| 4916 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4917 | if (!(context->getIntegerv(pname, params))) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4918 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4919 | GLenum nativeType; |
| 4920 | unsigned int numParams = 0; |
| 4921 | if (!context->getQueryParameterInfo(pname, &nativeType, &numParams)) |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4922 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4923 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4924 | if (numParams == 0) |
| 4925 | return; // it is known that pname is valid, but there are no parameters to return |
| 4926 | |
| 4927 | if (nativeType == GL_BOOL) |
| 4928 | { |
| 4929 | GLboolean *boolParams = NULL; |
| 4930 | boolParams = new GLboolean[numParams]; |
| 4931 | |
| 4932 | context->getBooleanv(pname, boolParams); |
| 4933 | |
| 4934 | for (unsigned int i = 0; i < numParams; ++i) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4935 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4936 | if (boolParams[i] == GL_FALSE) |
| 4937 | params[i] = 0; |
| 4938 | else |
| 4939 | params[i] = 1; |
| 4940 | } |
| 4941 | |
| 4942 | delete [] boolParams; |
| 4943 | } |
| 4944 | else if (nativeType == GL_FLOAT) |
| 4945 | { |
| 4946 | GLfloat *floatParams = NULL; |
| 4947 | floatParams = new GLfloat[numParams]; |
| 4948 | |
| 4949 | context->getFloatv(pname, floatParams); |
| 4950 | |
| 4951 | for (unsigned int i = 0; i < numParams; ++i) |
| 4952 | { |
daniel@transgaming.com | c164135 | 2010-04-26 15:33:36 +0000 | [diff] [blame] | 4953 | 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] | 4954 | { |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4955 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4956 | } |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4957 | else |
| 4958 | params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4959 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4960 | |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 4961 | delete [] floatParams; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4962 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4963 | } |
| 4964 | } |
| 4965 | } |
| 4966 | catch(std::bad_alloc&) |
| 4967 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4968 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4969 | } |
| 4970 | } |
| 4971 | |
| 4972 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 4973 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4974 | 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] | 4975 | |
| 4976 | try |
| 4977 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 4978 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4979 | |
| 4980 | if (context) |
| 4981 | { |
| 4982 | gl::Program *programObject = context->getProgram(program); |
| 4983 | |
| 4984 | if (!programObject) |
| 4985 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4986 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4987 | } |
| 4988 | |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 4989 | if (context->getClientVersion() < 3) |
| 4990 | { |
| 4991 | switch (pname) |
| 4992 | { |
| 4993 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 4994 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 4995 | return gl::error(GL_INVALID_ENUM); |
| 4996 | } |
| 4997 | } |
| 4998 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4999 | switch (pname) |
| 5000 | { |
| 5001 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5002 | *params = programObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5003 | return; |
| 5004 | case GL_LINK_STATUS: |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5005 | *params = programObject->isLinked(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5006 | return; |
| 5007 | case GL_VALIDATE_STATUS: |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 5008 | *params = programObject->isValidated(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5009 | return; |
| 5010 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5011 | *params = programObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5012 | return; |
| 5013 | case GL_ATTACHED_SHADERS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5014 | *params = programObject->getAttachedShadersCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5015 | return; |
| 5016 | case GL_ACTIVE_ATTRIBUTES: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5017 | *params = programObject->getActiveAttributeCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5018 | return; |
| 5019 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 5020 | *params = programObject->getActiveAttributeMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5021 | return; |
| 5022 | case GL_ACTIVE_UNIFORMS: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5023 | *params = programObject->getActiveUniformCount(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5024 | return; |
| 5025 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
daniel@transgaming.com | 09fbfef | 2010-04-22 13:35:31 +0000 | [diff] [blame] | 5026 | *params = programObject->getActiveUniformMaxLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5027 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5028 | case GL_PROGRAM_BINARY_LENGTH_OES: |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 5029 | *params = programObject->getProgramBinaryLength(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 5030 | return; |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 5031 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 5032 | *params = programObject->getActiveUniformBlockCount(); |
| 5033 | return; |
| 5034 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 5035 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 5036 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5037 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5038 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5039 | } |
| 5040 | } |
| 5041 | } |
| 5042 | catch(std::bad_alloc&) |
| 5043 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5044 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5045 | } |
| 5046 | } |
| 5047 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5048 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5049 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5050 | 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] | 5051 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5052 | |
| 5053 | try |
| 5054 | { |
| 5055 | if (bufsize < 0) |
| 5056 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5057 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5058 | } |
| 5059 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5060 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5061 | |
| 5062 | if (context) |
| 5063 | { |
| 5064 | gl::Program *programObject = context->getProgram(program); |
| 5065 | |
| 5066 | if (!programObject) |
| 5067 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5068 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5069 | } |
| 5070 | |
| 5071 | programObject->getInfoLog(bufsize, length, infolog); |
| 5072 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5073 | } |
| 5074 | catch(std::bad_alloc&) |
| 5075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5076 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5077 | } |
| 5078 | } |
| 5079 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5080 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 5081 | { |
| 5082 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 5083 | |
| 5084 | try |
| 5085 | { |
| 5086 | switch (pname) |
| 5087 | { |
| 5088 | case GL_CURRENT_QUERY_EXT: |
| 5089 | break; |
| 5090 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5091 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5092 | } |
| 5093 | |
| 5094 | gl::Context *context = gl::getNonLostContext(); |
| 5095 | |
| 5096 | if (context) |
| 5097 | { |
| 5098 | params[0] = context->getActiveQuery(target); |
| 5099 | } |
| 5100 | } |
| 5101 | catch(std::bad_alloc&) |
| 5102 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5103 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5104 | } |
| 5105 | } |
| 5106 | |
| 5107 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 5108 | { |
| 5109 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 5110 | |
| 5111 | try |
| 5112 | { |
| 5113 | switch (pname) |
| 5114 | { |
| 5115 | case GL_QUERY_RESULT_EXT: |
| 5116 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5117 | break; |
| 5118 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5119 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5120 | } |
| 5121 | gl::Context *context = gl::getNonLostContext(); |
| 5122 | |
| 5123 | if (context) |
| 5124 | { |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5125 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5126 | |
| 5127 | if (!queryObject) |
| 5128 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5129 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5130 | } |
| 5131 | |
| 5132 | if (context->getActiveQuery(queryObject->getType()) == id) |
| 5133 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5134 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5135 | } |
| 5136 | |
| 5137 | switch(pname) |
| 5138 | { |
| 5139 | case GL_QUERY_RESULT_EXT: |
| 5140 | params[0] = queryObject->getResult(); |
| 5141 | break; |
| 5142 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5143 | params[0] = queryObject->isResultAvailable(); |
| 5144 | break; |
| 5145 | default: |
| 5146 | ASSERT(false); |
| 5147 | } |
| 5148 | } |
| 5149 | } |
| 5150 | catch(std::bad_alloc&) |
| 5151 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5152 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 5153 | } |
| 5154 | } |
| 5155 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5156 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5157 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5158 | 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] | 5159 | |
| 5160 | try |
| 5161 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5162 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5163 | |
| 5164 | if (context) |
| 5165 | { |
| 5166 | if (target != GL_RENDERBUFFER) |
| 5167 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5168 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5169 | } |
| 5170 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5171 | if (context->getRenderbufferHandle() == 0) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5172 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5173 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5174 | } |
| 5175 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5176 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle()); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5177 | |
| 5178 | switch (pname) |
| 5179 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5180 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 5181 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 5182 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 5183 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 5184 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 5185 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 5186 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 5187 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 5188 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5189 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5190 | if (context->getMaxSupportedSamples() != 0) |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5191 | { |
daniel@transgaming.com | d2fd4f2 | 2011-02-01 18:49:11 +0000 | [diff] [blame] | 5192 | *params = renderbuffer->getSamples(); |
| 5193 | } |
| 5194 | else |
| 5195 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5196 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 5197 | } |
| 5198 | break; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5199 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5200 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 5201 | } |
| 5202 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5203 | } |
| 5204 | catch(std::bad_alloc&) |
| 5205 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5206 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5207 | } |
| 5208 | } |
| 5209 | |
| 5210 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 5211 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5212 | 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] | 5213 | |
| 5214 | try |
| 5215 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5216 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5217 | |
| 5218 | if (context) |
| 5219 | { |
| 5220 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 5221 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5222 | if (!shaderObject) |
| 5223 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5224 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5225 | } |
| 5226 | |
| 5227 | switch (pname) |
| 5228 | { |
| 5229 | case GL_SHADER_TYPE: |
| 5230 | *params = shaderObject->getType(); |
| 5231 | return; |
| 5232 | case GL_DELETE_STATUS: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5233 | *params = shaderObject->isFlaggedForDeletion(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5234 | return; |
| 5235 | case GL_COMPILE_STATUS: |
| 5236 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 5237 | return; |
| 5238 | case GL_INFO_LOG_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5239 | *params = shaderObject->getInfoLogLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5240 | return; |
| 5241 | case GL_SHADER_SOURCE_LENGTH: |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5242 | *params = shaderObject->getSourceLength(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5243 | return; |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5244 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 5245 | *params = shaderObject->getTranslatedSourceLength(); |
| 5246 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5247 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5248 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5249 | } |
| 5250 | } |
| 5251 | } |
| 5252 | catch(std::bad_alloc&) |
| 5253 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5254 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5255 | } |
| 5256 | } |
| 5257 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5258 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5259 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5260 | 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] | 5261 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5262 | |
| 5263 | try |
| 5264 | { |
| 5265 | if (bufsize < 0) |
| 5266 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5267 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5268 | } |
| 5269 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5270 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5271 | |
| 5272 | if (context) |
| 5273 | { |
| 5274 | gl::Shader *shaderObject = context->getShader(shader); |
| 5275 | |
| 5276 | if (!shaderObject) |
| 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 | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5279 | } |
| 5280 | |
| 5281 | shaderObject->getInfoLog(bufsize, length, infolog); |
| 5282 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5283 | } |
| 5284 | catch(std::bad_alloc&) |
| 5285 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5286 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5287 | } |
| 5288 | } |
| 5289 | |
| 5290 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 5291 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5292 | 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] | 5293 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5294 | |
| 5295 | try |
| 5296 | { |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5297 | switch (shadertype) |
| 5298 | { |
| 5299 | case GL_VERTEX_SHADER: |
| 5300 | case GL_FRAGMENT_SHADER: |
| 5301 | break; |
| 5302 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5303 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5304 | } |
| 5305 | |
| 5306 | switch (precisiontype) |
| 5307 | { |
| 5308 | case GL_LOW_FLOAT: |
| 5309 | case GL_MEDIUM_FLOAT: |
| 5310 | case GL_HIGH_FLOAT: |
| 5311 | // Assume IEEE 754 precision |
| 5312 | range[0] = 127; |
| 5313 | range[1] = 127; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5314 | *precision = 23; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5315 | break; |
| 5316 | case GL_LOW_INT: |
| 5317 | case GL_MEDIUM_INT: |
| 5318 | case GL_HIGH_INT: |
| 5319 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 5320 | // which can accurately represent integers up to +/-16777216 |
| 5321 | range[0] = 24; |
| 5322 | range[1] = 24; |
daniel@transgaming.com | c5c1538 | 2010-04-23 18:34:49 +0000 | [diff] [blame] | 5323 | *precision = 0; |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5324 | break; |
| 5325 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5326 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 6c78521 | 2010-03-30 03:36:17 +0000 | [diff] [blame] | 5327 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5328 | } |
| 5329 | catch(std::bad_alloc&) |
| 5330 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5331 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5332 | } |
| 5333 | } |
| 5334 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5335 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5336 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5337 | 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] | 5338 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5339 | |
| 5340 | try |
| 5341 | { |
| 5342 | if (bufsize < 0) |
| 5343 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5344 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5345 | } |
| 5346 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5347 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5348 | |
| 5349 | if (context) |
| 5350 | { |
| 5351 | gl::Shader *shaderObject = context->getShader(shader); |
| 5352 | |
| 5353 | if (!shaderObject) |
| 5354 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5355 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | cba5057 | 2010-03-28 19:36:09 +0000 | [diff] [blame] | 5356 | } |
| 5357 | |
| 5358 | shaderObject->getSource(bufsize, length, source); |
| 5359 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5360 | } |
| 5361 | catch(std::bad_alloc&) |
| 5362 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5363 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5364 | } |
| 5365 | } |
| 5366 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5367 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 5368 | { |
| 5369 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 5370 | shader, bufsize, length, source); |
| 5371 | |
| 5372 | try |
| 5373 | { |
| 5374 | if (bufsize < 0) |
| 5375 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5376 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5377 | } |
| 5378 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5379 | gl::Context *context = gl::getNonLostContext(); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5380 | |
| 5381 | if (context) |
| 5382 | { |
| 5383 | gl::Shader *shaderObject = context->getShader(shader); |
| 5384 | |
| 5385 | if (!shaderObject) |
| 5386 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5387 | return gl::error(GL_INVALID_OPERATION); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5388 | } |
| 5389 | |
| 5390 | shaderObject->getTranslatedSource(bufsize, length, source); |
| 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); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 5396 | } |
| 5397 | } |
| 5398 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5399 | const GLubyte* __stdcall glGetString(GLenum name) |
| 5400 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5401 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5402 | |
| 5403 | try |
| 5404 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5405 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 5406 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5407 | switch (name) |
| 5408 | { |
| 5409 | case GL_VENDOR: |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 5410 | return (GLubyte*)"Google Inc."; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5411 | case GL_RENDERER: |
daniel@transgaming.com | c23ff64 | 2011-08-16 20:28:45 +0000 | [diff] [blame] | 5412 | return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5413 | case GL_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5414 | if (context->getClientVersion() == 2) |
| 5415 | { |
| 5416 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " VERSION_STRING ")"; |
| 5417 | } |
| 5418 | else |
| 5419 | { |
| 5420 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " VERSION_STRING ")"; |
| 5421 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5422 | case GL_SHADING_LANGUAGE_VERSION: |
shannonwoods@chromium.org | e2865d0 | 2013-05-30 00:06:01 +0000 | [diff] [blame] | 5423 | if (context->getClientVersion() == 2) |
| 5424 | { |
| 5425 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " VERSION_STRING ")"; |
| 5426 | } |
| 5427 | else |
| 5428 | { |
| 5429 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " VERSION_STRING ")"; |
| 5430 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5431 | case GL_EXTENSIONS: |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 5432 | return (GLubyte*)((context != NULL) ? context->getCombinedExtensionsString() : ""); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5433 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5434 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5435 | } |
| 5436 | } |
| 5437 | catch(std::bad_alloc&) |
| 5438 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5439 | return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5440 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5441 | } |
| 5442 | |
| 5443 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 5444 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5445 | 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] | 5446 | |
| 5447 | try |
| 5448 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5449 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5450 | |
| 5451 | if (context) |
| 5452 | { |
| 5453 | gl::Texture *texture; |
| 5454 | |
| 5455 | switch (target) |
| 5456 | { |
| 5457 | case GL_TEXTURE_2D: |
| 5458 | texture = context->getTexture2D(); |
| 5459 | break; |
| 5460 | case GL_TEXTURE_CUBE_MAP: |
| 5461 | texture = context->getTextureCubeMap(); |
| 5462 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5463 | case GL_TEXTURE_3D: |
| 5464 | if (context->getClientVersion() < 3) |
| 5465 | { |
| 5466 | return gl::error(GL_INVALID_ENUM); |
| 5467 | } |
| 5468 | texture = context->getTexture3D(); |
| 5469 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5470 | case GL_TEXTURE_2D_ARRAY: |
| 5471 | if (context->getClientVersion() < 3) |
| 5472 | { |
| 5473 | return gl::error(GL_INVALID_ENUM); |
| 5474 | } |
| 5475 | texture = context->getTexture2DArray(); |
| 5476 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5477 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5478 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5479 | } |
| 5480 | |
| 5481 | switch (pname) |
| 5482 | { |
| 5483 | case GL_TEXTURE_MAG_FILTER: |
| 5484 | *params = (GLfloat)texture->getMagFilter(); |
| 5485 | break; |
| 5486 | case GL_TEXTURE_MIN_FILTER: |
| 5487 | *params = (GLfloat)texture->getMinFilter(); |
| 5488 | break; |
| 5489 | case GL_TEXTURE_WRAP_S: |
| 5490 | *params = (GLfloat)texture->getWrapS(); |
| 5491 | break; |
| 5492 | case GL_TEXTURE_WRAP_T: |
| 5493 | *params = (GLfloat)texture->getWrapT(); |
| 5494 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5495 | case GL_TEXTURE_WRAP_R: |
| 5496 | if (context->getClientVersion() < 3) |
| 5497 | { |
| 5498 | return gl::error(GL_INVALID_ENUM); |
| 5499 | } |
| 5500 | *params = (GLfloat)texture->getWrapR(); |
| 5501 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5502 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5503 | // 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] | 5504 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 5505 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5506 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5507 | if (context->getClientVersion() < 3) |
| 5508 | { |
| 5509 | return gl::error(GL_INVALID_ENUM); |
| 5510 | } |
| 5511 | *params = (GLfloat)(texture->isImmutable() ? texture->levelCount() : 0); |
| 5512 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5513 | case GL_TEXTURE_USAGE_ANGLE: |
| 5514 | *params = (GLfloat)texture->getUsage(); |
| 5515 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5516 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5517 | if (!context->supportsTextureFilterAnisotropy()) |
| 5518 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5519 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5520 | } |
| 5521 | *params = (GLfloat)texture->getMaxAnisotropy(); |
| 5522 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5523 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5524 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5525 | } |
| 5526 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5527 | } |
| 5528 | catch(std::bad_alloc&) |
| 5529 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5530 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5531 | } |
| 5532 | } |
| 5533 | |
| 5534 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 5535 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5536 | 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] | 5537 | |
| 5538 | try |
| 5539 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5540 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5541 | |
| 5542 | if (context) |
| 5543 | { |
| 5544 | gl::Texture *texture; |
| 5545 | |
| 5546 | switch (target) |
| 5547 | { |
| 5548 | case GL_TEXTURE_2D: |
| 5549 | texture = context->getTexture2D(); |
| 5550 | break; |
| 5551 | case GL_TEXTURE_CUBE_MAP: |
| 5552 | texture = context->getTextureCubeMap(); |
| 5553 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 5554 | case GL_TEXTURE_3D: |
| 5555 | if (context->getClientVersion() < 3) |
| 5556 | { |
| 5557 | return gl::error(GL_INVALID_ENUM); |
| 5558 | } |
| 5559 | texture = context->getTexture3D(); |
| 5560 | break; |
shannonwoods@chromium.org | 0c611d1 | 2013-05-30 00:15:05 +0000 | [diff] [blame] | 5561 | case GL_TEXTURE_2D_ARRAY: |
| 5562 | if (context->getClientVersion() < 3) |
| 5563 | { |
| 5564 | return gl::error(GL_INVALID_ENUM); |
| 5565 | } |
| 5566 | texture = context->getTexture2DArray(); |
| 5567 | break; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5568 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5569 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5570 | } |
| 5571 | |
| 5572 | switch (pname) |
| 5573 | { |
| 5574 | case GL_TEXTURE_MAG_FILTER: |
| 5575 | *params = texture->getMagFilter(); |
| 5576 | break; |
| 5577 | case GL_TEXTURE_MIN_FILTER: |
| 5578 | *params = texture->getMinFilter(); |
| 5579 | break; |
| 5580 | case GL_TEXTURE_WRAP_S: |
| 5581 | *params = texture->getWrapS(); |
| 5582 | break; |
| 5583 | case GL_TEXTURE_WRAP_T: |
| 5584 | *params = texture->getWrapT(); |
| 5585 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 5586 | case GL_TEXTURE_WRAP_R: |
| 5587 | if (context->getClientVersion() < 3) |
| 5588 | { |
| 5589 | return gl::error(GL_INVALID_ENUM); |
| 5590 | } |
| 5591 | *params = texture->getWrapR(); |
| 5592 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5593 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 5594 | // 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] | 5595 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 5596 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 5597 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 5598 | if (context->getClientVersion() < 3) |
| 5599 | { |
| 5600 | return gl::error(GL_INVALID_ENUM); |
| 5601 | } |
| 5602 | *params = texture->isImmutable() ? texture->levelCount() : 0; |
| 5603 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 5604 | case GL_TEXTURE_USAGE_ANGLE: |
| 5605 | *params = texture->getUsage(); |
| 5606 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5607 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 5608 | if (!context->supportsTextureFilterAnisotropy()) |
| 5609 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5610 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 5611 | } |
| 5612 | *params = (GLint)texture->getMaxAnisotropy(); |
| 5613 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 5614 | |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5615 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5616 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 5617 | } |
| 5618 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5619 | } |
| 5620 | catch(std::bad_alloc&) |
| 5621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5622 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5623 | } |
| 5624 | } |
| 5625 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5626 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 5627 | { |
| 5628 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 5629 | program, location, bufSize, params); |
| 5630 | |
| 5631 | try |
| 5632 | { |
| 5633 | if (bufSize < 0) |
| 5634 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5635 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5636 | } |
| 5637 | |
| 5638 | gl::Context *context = gl::getNonLostContext(); |
| 5639 | |
| 5640 | if (context) |
| 5641 | { |
| 5642 | if (program == 0) |
| 5643 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5644 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5645 | } |
| 5646 | |
| 5647 | gl::Program *programObject = context->getProgram(program); |
| 5648 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5649 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5651 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5652 | } |
| 5653 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5654 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5655 | if (!programBinary) |
| 5656 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5657 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5658 | } |
| 5659 | |
| 5660 | if (!programBinary->getUniformfv(location, &bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5661 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5662 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5663 | } |
| 5664 | } |
| 5665 | } |
| 5666 | catch(std::bad_alloc&) |
| 5667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5668 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5669 | } |
| 5670 | } |
| 5671 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5672 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 5673 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5674 | 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] | 5675 | |
| 5676 | try |
| 5677 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5678 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5679 | |
| 5680 | if (context) |
| 5681 | { |
| 5682 | if (program == 0) |
| 5683 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5684 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5685 | } |
| 5686 | |
| 5687 | gl::Program *programObject = context->getProgram(program); |
| 5688 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5689 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5690 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5691 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5692 | } |
| 5693 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5694 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5695 | if (!programBinary) |
| 5696 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5697 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5698 | } |
| 5699 | |
| 5700 | if (!programBinary->getUniformfv(location, NULL, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5701 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5702 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5703 | } |
| 5704 | } |
| 5705 | } |
| 5706 | catch(std::bad_alloc&) |
| 5707 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5708 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5709 | } |
| 5710 | } |
| 5711 | |
| 5712 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 5713 | { |
| 5714 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
| 5715 | program, location, bufSize, params); |
| 5716 | |
| 5717 | try |
| 5718 | { |
| 5719 | if (bufSize < 0) |
| 5720 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5721 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5722 | } |
| 5723 | |
| 5724 | gl::Context *context = gl::getNonLostContext(); |
| 5725 | |
| 5726 | if (context) |
| 5727 | { |
| 5728 | if (program == 0) |
| 5729 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5730 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5731 | } |
| 5732 | |
| 5733 | gl::Program *programObject = context->getProgram(program); |
| 5734 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5735 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5736 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5737 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 5738 | } |
| 5739 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5740 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5741 | if (!programBinary) |
| 5742 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5743 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5744 | } |
| 5745 | |
| 5746 | if (!programBinary->getUniformiv(location, &bufSize, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5747 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5748 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5749 | } |
| 5750 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5751 | } |
| 5752 | catch(std::bad_alloc&) |
| 5753 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5754 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5755 | } |
| 5756 | } |
| 5757 | |
| 5758 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 5759 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5760 | 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] | 5761 | |
| 5762 | try |
| 5763 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5764 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5765 | |
| 5766 | if (context) |
| 5767 | { |
| 5768 | if (program == 0) |
| 5769 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5770 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5771 | } |
| 5772 | |
| 5773 | gl::Program *programObject = context->getProgram(program); |
| 5774 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5775 | if (!programObject || !programObject->isLinked()) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5776 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5777 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5778 | } |
| 5779 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5780 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 5781 | if (!programBinary) |
| 5782 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5783 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5784 | } |
| 5785 | |
| 5786 | if (!programBinary->getUniformiv(location, NULL, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5787 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5788 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 5789 | } |
| 5790 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5791 | } |
| 5792 | catch(std::bad_alloc&) |
| 5793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5794 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5795 | } |
| 5796 | } |
| 5797 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5798 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5799 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5800 | 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] | 5801 | |
| 5802 | try |
| 5803 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5804 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5805 | |
| 5806 | if (strstr(name, "gl_") == name) |
| 5807 | { |
| 5808 | return -1; |
| 5809 | } |
| 5810 | |
| 5811 | if (context) |
| 5812 | { |
| 5813 | gl::Program *programObject = context->getProgram(program); |
| 5814 | |
| 5815 | if (!programObject) |
| 5816 | { |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5817 | if (context->getShader(program)) |
| 5818 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5819 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5820 | } |
| 5821 | else |
| 5822 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5823 | return gl::error(GL_INVALID_VALUE, -1); |
daniel@transgaming.com | d1abe5b | 2010-04-13 19:53:33 +0000 | [diff] [blame] | 5824 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5825 | } |
| 5826 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5827 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 5828 | if (!programObject->isLinked() || !programBinary) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5829 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5830 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5831 | } |
| 5832 | |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 5833 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5834 | } |
| 5835 | } |
| 5836 | catch(std::bad_alloc&) |
| 5837 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5838 | return gl::error(GL_OUT_OF_MEMORY, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5839 | } |
| 5840 | |
| 5841 | return -1; |
| 5842 | } |
| 5843 | |
| 5844 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 5845 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5846 | 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] | 5847 | |
| 5848 | try |
| 5849 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5850 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5851 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5852 | if (context) |
| 5853 | { |
| 5854 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5855 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5856 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5857 | } |
| 5858 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5859 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5860 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5861 | switch (pname) |
| 5862 | { |
| 5863 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5864 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5865 | break; |
| 5866 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5867 | *params = (GLfloat)attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5868 | break; |
| 5869 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5870 | *params = (GLfloat)attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5871 | break; |
| 5872 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5873 | *params = (GLfloat)attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5874 | break; |
| 5875 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5876 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5877 | break; |
| 5878 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5879 | *params = (GLfloat)attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5880 | break; |
| 5881 | case GL_CURRENT_VERTEX_ATTRIB: |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5882 | { |
Jamie Madill | a857c36 | 2013-07-02 11:57:02 -0400 | [diff] [blame] | 5883 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 5884 | for (int i = 0; i < 4; ++i) |
| 5885 | { |
| 5886 | params[i] = currentValueData.FloatValues[i]; |
| 5887 | } |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5888 | } |
| 5889 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5890 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5891 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5892 | // the same constant. |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5893 | *params = (GLfloat)attribState.mDivisor; |
| 5894 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5895 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5896 | } |
| 5897 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5898 | } |
| 5899 | catch(std::bad_alloc&) |
| 5900 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5901 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5902 | } |
| 5903 | } |
| 5904 | |
| 5905 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 5906 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5907 | 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] | 5908 | |
| 5909 | try |
| 5910 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5911 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5912 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5913 | if (context) |
| 5914 | { |
| 5915 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5916 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5917 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5918 | } |
| 5919 | |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5920 | const gl::VertexAttribute &attribState = context->getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5921 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5922 | switch (pname) |
| 5923 | { |
| 5924 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
daniel@transgaming.com | 8392138 | 2011-01-08 05:46:00 +0000 | [diff] [blame] | 5925 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5926 | break; |
| 5927 | case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5928 | *params = attribState.mSize; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5929 | break; |
| 5930 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5931 | *params = attribState.mStride; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5932 | break; |
| 5933 | case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5934 | *params = attribState.mType; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5935 | break; |
| 5936 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5937 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5938 | break; |
| 5939 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 5940 | *params = attribState.mBoundBuffer.id(); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5941 | break; |
| 5942 | case GL_CURRENT_VERTEX_ATTRIB: |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5943 | { |
Jamie Madill | a857c36 | 2013-07-02 11:57:02 -0400 | [diff] [blame] | 5944 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getVertexAttribCurrentValue(index); |
| 5945 | for (int i = 0; i < 4; ++i) |
| 5946 | { |
| 5947 | float currentValue = currentValueData.FloatValues[i]; |
| 5948 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f)); |
| 5949 | } |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5950 | } |
| 5951 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 5952 | case GL_VERTEX_ATTRIB_ARRAY_DIVISOR: |
| 5953 | // Don't verify ES3 context because GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE uses |
| 5954 | // the same constant. |
| 5955 | META_ASSERT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 5956 | *params = (GLint)attribState.mDivisor; |
| 5957 | break; |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5958 | default: return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5959 | } |
| 5960 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5961 | } |
| 5962 | catch(std::bad_alloc&) |
| 5963 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5964 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5965 | } |
| 5966 | } |
| 5967 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 5968 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5969 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5970 | 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] | 5971 | |
| 5972 | try |
| 5973 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 5974 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5975 | |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5976 | if (context) |
| 5977 | { |
| 5978 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 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 | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5981 | } |
| 5982 | |
| 5983 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 5984 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5985 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5986 | } |
| 5987 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 5988 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index)); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 5989 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5990 | } |
| 5991 | catch(std::bad_alloc&) |
| 5992 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 5993 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 5994 | } |
| 5995 | } |
| 5996 | |
| 5997 | void __stdcall glHint(GLenum target, GLenum mode) |
| 5998 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 5999 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6000 | |
| 6001 | try |
| 6002 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6003 | switch (mode) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6004 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6005 | case GL_FASTEST: |
| 6006 | case GL_NICEST: |
| 6007 | case GL_DONT_CARE: |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6008 | break; |
| 6009 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6010 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6011 | } |
| 6012 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6013 | gl::Context *context = gl::getNonLostContext(); |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6014 | switch (target) |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6015 | { |
alokp@chromium.org | d303ef9 | 2010-09-09 17:30:15 +0000 | [diff] [blame] | 6016 | case GL_GENERATE_MIPMAP_HINT: |
| 6017 | if (context) context->setGenerateMipmapHint(mode); |
| 6018 | break; |
| 6019 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 6020 | if (context) context->setFragmentShaderDerivativeHint(mode); |
| 6021 | break; |
| 6022 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6023 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5949aa1 | 2010-03-21 04:31:15 +0000 | [diff] [blame] | 6024 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6025 | } |
| 6026 | catch(std::bad_alloc&) |
| 6027 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6028 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6029 | } |
| 6030 | } |
| 6031 | |
| 6032 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 6033 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6034 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6035 | |
| 6036 | try |
| 6037 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6038 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6039 | |
| 6040 | if (context && buffer) |
| 6041 | { |
| 6042 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 6043 | |
| 6044 | if (bufferObject) |
| 6045 | { |
| 6046 | return GL_TRUE; |
| 6047 | } |
| 6048 | } |
| 6049 | } |
| 6050 | catch(std::bad_alloc&) |
| 6051 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6052 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6053 | } |
| 6054 | |
| 6055 | return GL_FALSE; |
| 6056 | } |
| 6057 | |
| 6058 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 6059 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6060 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6061 | |
| 6062 | try |
| 6063 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6064 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6065 | |
| 6066 | if (context) |
| 6067 | { |
| 6068 | switch (cap) |
| 6069 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6070 | case GL_CULL_FACE: return context->isCullFaceEnabled(); |
| 6071 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled(); |
| 6072 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled(); |
| 6073 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled(); |
| 6074 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled(); |
| 6075 | case GL_STENCIL_TEST: return context->isStencilTestEnabled(); |
| 6076 | case GL_DEPTH_TEST: return context->isDepthTestEnabled(); |
| 6077 | case GL_BLEND: return context->isBlendEnabled(); |
| 6078 | case GL_DITHER: return context->isDitherEnabled(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6079 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6080 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6081 | } |
| 6082 | } |
| 6083 | } |
| 6084 | catch(std::bad_alloc&) |
| 6085 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6086 | return gl::error(GL_OUT_OF_MEMORY, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6087 | } |
| 6088 | |
| 6089 | return false; |
| 6090 | } |
| 6091 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6092 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 6093 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6094 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6095 | |
| 6096 | try |
| 6097 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6098 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6099 | |
| 6100 | if (context) |
| 6101 | { |
| 6102 | gl::Fence *fenceObject = context->getFence(fence); |
| 6103 | |
| 6104 | if (fenceObject == NULL) |
| 6105 | { |
| 6106 | return GL_FALSE; |
| 6107 | } |
| 6108 | |
| 6109 | return fenceObject->isFence(); |
| 6110 | } |
| 6111 | } |
| 6112 | catch(std::bad_alloc&) |
| 6113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6114 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6115 | } |
| 6116 | |
| 6117 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6118 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6119 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6120 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 6121 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6122 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6123 | |
| 6124 | try |
| 6125 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6126 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6127 | |
| 6128 | if (context && framebuffer) |
| 6129 | { |
| 6130 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 6131 | |
| 6132 | if (framebufferObject) |
| 6133 | { |
| 6134 | return GL_TRUE; |
| 6135 | } |
| 6136 | } |
| 6137 | } |
| 6138 | catch(std::bad_alloc&) |
| 6139 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6140 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6141 | } |
| 6142 | |
| 6143 | return GL_FALSE; |
| 6144 | } |
| 6145 | |
| 6146 | GLboolean __stdcall glIsProgram(GLuint program) |
| 6147 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6148 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6149 | |
| 6150 | try |
| 6151 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6152 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6153 | |
| 6154 | if (context && program) |
| 6155 | { |
| 6156 | gl::Program *programObject = context->getProgram(program); |
| 6157 | |
| 6158 | if (programObject) |
| 6159 | { |
| 6160 | return GL_TRUE; |
| 6161 | } |
| 6162 | } |
| 6163 | } |
| 6164 | catch(std::bad_alloc&) |
| 6165 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6166 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6167 | } |
| 6168 | |
| 6169 | return GL_FALSE; |
| 6170 | } |
| 6171 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6172 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 6173 | { |
| 6174 | EVENT("(GLuint id = %d)", id); |
| 6175 | |
| 6176 | try |
| 6177 | { |
| 6178 | if (id == 0) |
| 6179 | { |
| 6180 | return GL_FALSE; |
| 6181 | } |
| 6182 | |
| 6183 | gl::Context *context = gl::getNonLostContext(); |
| 6184 | |
| 6185 | if (context) |
| 6186 | { |
| 6187 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 6188 | |
| 6189 | if (queryObject) |
| 6190 | { |
| 6191 | return GL_TRUE; |
| 6192 | } |
| 6193 | } |
| 6194 | } |
| 6195 | catch(std::bad_alloc&) |
| 6196 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6197 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 6198 | } |
| 6199 | |
| 6200 | return GL_FALSE; |
| 6201 | } |
| 6202 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6203 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 6204 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6205 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6206 | |
| 6207 | try |
| 6208 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6209 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6210 | |
| 6211 | if (context && renderbuffer) |
| 6212 | { |
| 6213 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 6214 | |
| 6215 | if (renderbufferObject) |
| 6216 | { |
| 6217 | return GL_TRUE; |
| 6218 | } |
| 6219 | } |
| 6220 | } |
| 6221 | catch(std::bad_alloc&) |
| 6222 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6223 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6224 | } |
| 6225 | |
| 6226 | return GL_FALSE; |
| 6227 | } |
| 6228 | |
| 6229 | GLboolean __stdcall glIsShader(GLuint shader) |
| 6230 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6231 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6232 | |
| 6233 | try |
| 6234 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6235 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6236 | |
| 6237 | if (context && shader) |
| 6238 | { |
| 6239 | gl::Shader *shaderObject = context->getShader(shader); |
| 6240 | |
| 6241 | if (shaderObject) |
| 6242 | { |
| 6243 | return GL_TRUE; |
| 6244 | } |
| 6245 | } |
| 6246 | } |
| 6247 | catch(std::bad_alloc&) |
| 6248 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6249 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6250 | } |
| 6251 | |
| 6252 | return GL_FALSE; |
| 6253 | } |
| 6254 | |
| 6255 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 6256 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6257 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6258 | |
| 6259 | try |
| 6260 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6261 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6262 | |
| 6263 | if (context && texture) |
| 6264 | { |
| 6265 | gl::Texture *textureObject = context->getTexture(texture); |
| 6266 | |
| 6267 | if (textureObject) |
| 6268 | { |
| 6269 | return GL_TRUE; |
| 6270 | } |
| 6271 | } |
| 6272 | } |
| 6273 | catch(std::bad_alloc&) |
| 6274 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6275 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6276 | } |
| 6277 | |
| 6278 | return GL_FALSE; |
| 6279 | } |
| 6280 | |
| 6281 | void __stdcall glLineWidth(GLfloat width) |
| 6282 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6283 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6284 | |
| 6285 | try |
| 6286 | { |
| 6287 | if (width <= 0.0f) |
| 6288 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6289 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6290 | } |
| 6291 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6292 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 6293 | |
| 6294 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6295 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6296 | context->setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6297 | } |
| 6298 | } |
| 6299 | catch(std::bad_alloc&) |
| 6300 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6301 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6302 | } |
| 6303 | } |
| 6304 | |
| 6305 | void __stdcall glLinkProgram(GLuint program) |
| 6306 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6307 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6308 | |
| 6309 | try |
| 6310 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6311 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6312 | |
| 6313 | if (context) |
| 6314 | { |
| 6315 | gl::Program *programObject = context->getProgram(program); |
| 6316 | |
| 6317 | if (!programObject) |
| 6318 | { |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6319 | if (context->getShader(program)) |
| 6320 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6321 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6322 | } |
| 6323 | else |
| 6324 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6325 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 277b714 | 2010-04-13 03:26:44 +0000 | [diff] [blame] | 6326 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6327 | } |
| 6328 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 6329 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6330 | } |
| 6331 | } |
| 6332 | catch(std::bad_alloc&) |
| 6333 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6334 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6335 | } |
| 6336 | } |
| 6337 | |
| 6338 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 6339 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6340 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6341 | |
| 6342 | try |
| 6343 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6344 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6345 | |
| 6346 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6347 | { |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6348 | switch (pname) |
| 6349 | { |
| 6350 | case GL_UNPACK_ALIGNMENT: |
| 6351 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6352 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6353 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6354 | } |
| 6355 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6356 | context->setUnpackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6357 | break; |
| 6358 | |
| 6359 | case GL_PACK_ALIGNMENT: |
| 6360 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 6361 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6362 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6363 | } |
| 6364 | |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6365 | context->setPackAlignment(param); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6366 | break; |
| 6367 | |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 6368 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 6369 | context->setPackReverseRowOrder(param != 0); |
| 6370 | break; |
| 6371 | |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 6372 | case GL_UNPACK_IMAGE_HEIGHT: |
| 6373 | case GL_UNPACK_SKIP_IMAGES: |
| 6374 | case GL_UNPACK_ROW_LENGTH: |
| 6375 | case GL_UNPACK_SKIP_ROWS: |
| 6376 | case GL_UNPACK_SKIP_PIXELS: |
| 6377 | case GL_PACK_ROW_LENGTH: |
| 6378 | case GL_PACK_SKIP_ROWS: |
| 6379 | case GL_PACK_SKIP_PIXELS: |
| 6380 | if (context->getClientVersion() < 3) |
| 6381 | { |
| 6382 | return gl::error(GL_INVALID_ENUM); |
| 6383 | } |
| 6384 | UNIMPLEMENTED(); |
| 6385 | break; |
| 6386 | |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6387 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6388 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 6389 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6390 | } |
| 6391 | } |
| 6392 | catch(std::bad_alloc&) |
| 6393 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6394 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6395 | } |
| 6396 | } |
| 6397 | |
| 6398 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 6399 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6400 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6401 | |
| 6402 | try |
| 6403 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6404 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 6405 | |
| 6406 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6407 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6408 | context->setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6409 | } |
| 6410 | } |
| 6411 | catch(std::bad_alloc&) |
| 6412 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6413 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6414 | } |
| 6415 | } |
| 6416 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6417 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6418 | GLenum format, GLenum type, GLsizei bufSize, |
| 6419 | GLvoid *data) |
| 6420 | { |
| 6421 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 6422 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 6423 | x, y, width, height, format, type, bufSize, data); |
| 6424 | |
| 6425 | try |
| 6426 | { |
| 6427 | if (width < 0 || height < 0 || bufSize < 0) |
| 6428 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6429 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6430 | } |
| 6431 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6432 | gl::Context *context = gl::getNonLostContext(); |
| 6433 | |
| 6434 | if (context) |
| 6435 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6436 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6437 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6438 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6439 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6440 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6441 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6442 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6443 | return; |
| 6444 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6445 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6446 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6447 | |
| 6448 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6449 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6450 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6451 | } |
| 6452 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6453 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 6454 | } |
| 6455 | } |
| 6456 | catch(std::bad_alloc&) |
| 6457 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6458 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6459 | } |
| 6460 | } |
| 6461 | |
| 6462 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 6463 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6464 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6465 | 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] | 6466 | "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] | 6467 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6468 | |
| 6469 | try |
| 6470 | { |
| 6471 | if (width < 0 || height < 0) |
| 6472 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6473 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6474 | } |
| 6475 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6476 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6477 | |
| 6478 | if (context) |
| 6479 | { |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6480 | GLint currentInternalFormat; |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6481 | GLenum currentFormat, currentType; |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6482 | |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6483 | // Failure in getCurrentReadFormatType indicates that no color attachment is currently bound, |
| 6484 | // and attempting to read back if that's the case is an error. The error will be registered |
| 6485 | // by getCurrentReadFormat. |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6486 | if (!context->getCurrentReadFormatType(¤tInternalFormat, ¤tFormat, ¤tType)) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6487 | return; |
| 6488 | |
shannonwoods@chromium.org | 44a4f98 | 2013-05-30 00:13:49 +0000 | [diff] [blame] | 6489 | bool validReadFormat = (context->getClientVersion() < 3) ? validES2ReadFormatType(format, type) : |
| 6490 | validES3ReadFormatType(currentInternalFormat, format, type); |
| 6491 | |
| 6492 | if (!(currentFormat == format && currentType == type) && !validReadFormat) |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6493 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6494 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 42944b0 | 2012-09-27 17:45:57 +0000 | [diff] [blame] | 6495 | } |
| 6496 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 6497 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6498 | } |
| 6499 | } |
| 6500 | catch(std::bad_alloc&) |
| 6501 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6502 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6503 | } |
| 6504 | } |
| 6505 | |
| 6506 | void __stdcall glReleaseShaderCompiler(void) |
| 6507 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6508 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6509 | |
| 6510 | try |
| 6511 | { |
| 6512 | gl::Shader::releaseCompiler(); |
| 6513 | } |
| 6514 | catch(std::bad_alloc&) |
| 6515 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6516 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6517 | } |
| 6518 | } |
| 6519 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6520 | 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] | 6521 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6522 | 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] | 6523 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6524 | |
| 6525 | try |
| 6526 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6527 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6528 | |
| 6529 | if (context) |
| 6530 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6531 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 6532 | width, height, true)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 6533 | { |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 6534 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6535 | } |
shannon.woods%transgaming.com@gtempaccount.com | 8dce651 | 2013-04-13 03:42:19 +0000 | [diff] [blame] | 6536 | |
| 6537 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6538 | } |
| 6539 | } |
| 6540 | catch(std::bad_alloc&) |
| 6541 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6542 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6543 | } |
| 6544 | } |
| 6545 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 6546 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 6547 | { |
| 6548 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 6549 | } |
| 6550 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6551 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 6552 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6553 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6554 | |
| 6555 | try |
| 6556 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6557 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6558 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6559 | if (context) |
| 6560 | { |
daniel@transgaming.com | a36f98e | 2010-05-18 18:51:09 +0000 | [diff] [blame] | 6561 | context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6562 | } |
| 6563 | } |
| 6564 | catch(std::bad_alloc&) |
| 6565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6566 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6567 | } |
| 6568 | } |
| 6569 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6570 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 6571 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6572 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6573 | |
| 6574 | try |
| 6575 | { |
| 6576 | if (condition != GL_ALL_COMPLETED_NV) |
| 6577 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6578 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6579 | } |
| 6580 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6581 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6582 | |
| 6583 | if (context) |
| 6584 | { |
| 6585 | gl::Fence *fenceObject = context->getFence(fence); |
| 6586 | |
| 6587 | if (fenceObject == NULL) |
| 6588 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6589 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6590 | } |
| 6591 | |
| 6592 | fenceObject->setFence(condition); |
| 6593 | } |
| 6594 | } |
| 6595 | catch(std::bad_alloc&) |
| 6596 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6597 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6598 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6599 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6600 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6601 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 6602 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6603 | 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] | 6604 | |
| 6605 | try |
| 6606 | { |
| 6607 | if (width < 0 || height < 0) |
| 6608 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6609 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6610 | } |
| 6611 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6612 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6613 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6614 | if (context) |
| 6615 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6616 | context->setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6617 | } |
| 6618 | } |
| 6619 | catch(std::bad_alloc&) |
| 6620 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6621 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6622 | } |
| 6623 | } |
| 6624 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6625 | 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] | 6626 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6627 | 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] | 6628 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 6629 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6630 | |
| 6631 | try |
| 6632 | { |
daniel@transgaming.com | d1f667f | 2010-04-29 03:38:52 +0000 | [diff] [blame] | 6633 | // No binary shader formats are supported. |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6634 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6635 | } |
| 6636 | catch(std::bad_alloc&) |
| 6637 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6638 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6639 | } |
| 6640 | } |
| 6641 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 6642 | 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] | 6643 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6644 | 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] | 6645 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6646 | |
| 6647 | try |
| 6648 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6649 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6650 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6651 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6652 | } |
| 6653 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6654 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6655 | |
| 6656 | if (context) |
| 6657 | { |
| 6658 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6659 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6660 | if (!shaderObject) |
| 6661 | { |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6662 | if (context->getProgram(shader)) |
| 6663 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6664 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6665 | } |
| 6666 | else |
| 6667 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6668 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 8e6a6be | 2010-04-13 03:26:41 +0000 | [diff] [blame] | 6669 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6670 | } |
| 6671 | |
| 6672 | shaderObject->setSource(count, string, length); |
| 6673 | } |
| 6674 | } |
| 6675 | catch(std::bad_alloc&) |
| 6676 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6677 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6678 | } |
| 6679 | } |
| 6680 | |
| 6681 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 6682 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6683 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6684 | } |
| 6685 | |
| 6686 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 6687 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6688 | 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] | 6689 | |
| 6690 | try |
| 6691 | { |
| 6692 | switch (face) |
| 6693 | { |
| 6694 | case GL_FRONT: |
| 6695 | case GL_BACK: |
| 6696 | case GL_FRONT_AND_BACK: |
| 6697 | break; |
| 6698 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6699 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6700 | } |
| 6701 | |
| 6702 | switch (func) |
| 6703 | { |
| 6704 | case GL_NEVER: |
| 6705 | case GL_ALWAYS: |
| 6706 | case GL_LESS: |
| 6707 | case GL_LEQUAL: |
| 6708 | case GL_EQUAL: |
| 6709 | case GL_GEQUAL: |
| 6710 | case GL_GREATER: |
| 6711 | case GL_NOTEQUAL: |
| 6712 | break; |
| 6713 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6714 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6715 | } |
| 6716 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6717 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6718 | |
| 6719 | if (context) |
| 6720 | { |
| 6721 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6722 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6723 | context->setStencilParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6724 | } |
| 6725 | |
| 6726 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6727 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6728 | context->setStencilBackParams(func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6729 | } |
| 6730 | } |
| 6731 | } |
| 6732 | catch(std::bad_alloc&) |
| 6733 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6734 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6735 | } |
| 6736 | } |
| 6737 | |
| 6738 | void __stdcall glStencilMask(GLuint mask) |
| 6739 | { |
| 6740 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 6741 | } |
| 6742 | |
| 6743 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 6744 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6745 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6746 | |
| 6747 | try |
| 6748 | { |
| 6749 | switch (face) |
| 6750 | { |
| 6751 | case GL_FRONT: |
| 6752 | case GL_BACK: |
| 6753 | case GL_FRONT_AND_BACK: |
| 6754 | break; |
| 6755 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6756 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6757 | } |
| 6758 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6759 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6760 | |
| 6761 | if (context) |
| 6762 | { |
| 6763 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6764 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6765 | context->setStencilWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6766 | } |
| 6767 | |
| 6768 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6769 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6770 | context->setStencilBackWritemask(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6771 | } |
| 6772 | } |
| 6773 | } |
| 6774 | catch(std::bad_alloc&) |
| 6775 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6776 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6777 | } |
| 6778 | } |
| 6779 | |
| 6780 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 6781 | { |
| 6782 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 6783 | } |
| 6784 | |
| 6785 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 6786 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6787 | 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] | 6788 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6789 | |
| 6790 | try |
| 6791 | { |
| 6792 | switch (face) |
| 6793 | { |
| 6794 | case GL_FRONT: |
| 6795 | case GL_BACK: |
| 6796 | case GL_FRONT_AND_BACK: |
| 6797 | break; |
| 6798 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6799 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6800 | } |
| 6801 | |
| 6802 | switch (fail) |
| 6803 | { |
| 6804 | case GL_ZERO: |
| 6805 | case GL_KEEP: |
| 6806 | case GL_REPLACE: |
| 6807 | case GL_INCR: |
| 6808 | case GL_DECR: |
| 6809 | case GL_INVERT: |
| 6810 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6811 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6812 | break; |
| 6813 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6814 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6815 | } |
| 6816 | |
| 6817 | switch (zfail) |
| 6818 | { |
| 6819 | case GL_ZERO: |
| 6820 | case GL_KEEP: |
| 6821 | case GL_REPLACE: |
| 6822 | case GL_INCR: |
| 6823 | case GL_DECR: |
| 6824 | case GL_INVERT: |
| 6825 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6826 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6827 | break; |
| 6828 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6829 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6830 | } |
| 6831 | |
| 6832 | switch (zpass) |
| 6833 | { |
| 6834 | case GL_ZERO: |
| 6835 | case GL_KEEP: |
| 6836 | case GL_REPLACE: |
| 6837 | case GL_INCR: |
| 6838 | case GL_DECR: |
| 6839 | case GL_INVERT: |
| 6840 | case GL_INCR_WRAP: |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 6841 | case GL_DECR_WRAP: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6842 | break; |
| 6843 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6844 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6845 | } |
| 6846 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6847 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6848 | |
| 6849 | if (context) |
| 6850 | { |
| 6851 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 6852 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6853 | context->setStencilOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6854 | } |
| 6855 | |
| 6856 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 6857 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 6858 | context->setStencilBackOperations(fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6859 | } |
| 6860 | } |
| 6861 | } |
| 6862 | catch(std::bad_alloc&) |
| 6863 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6864 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6865 | } |
| 6866 | } |
| 6867 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6868 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 6869 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6870 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6871 | |
| 6872 | try |
| 6873 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6874 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6875 | |
| 6876 | if (context) |
| 6877 | { |
| 6878 | gl::Fence *fenceObject = context->getFence(fence); |
| 6879 | |
| 6880 | if (fenceObject == NULL) |
| 6881 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6882 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6883 | } |
| 6884 | |
| 6885 | return fenceObject->testFence(); |
| 6886 | } |
| 6887 | } |
| 6888 | catch(std::bad_alloc&) |
| 6889 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6890 | gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6891 | } |
| 6892 | |
| 6893 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 6894 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 6895 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 6896 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 6897 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6898 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 6899 | 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] | 6900 | "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] | 6901 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6902 | |
| 6903 | try |
| 6904 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 6905 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6906 | |
| 6907 | if (context) |
| 6908 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6909 | if (context->getClientVersion() < 3 && |
| 6910 | !validateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 6911 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6912 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6913 | return; |
| 6914 | } |
| 6915 | |
| 6916 | if (context->getClientVersion() >= 3 && |
| 6917 | !validateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 6918 | 0, 0, 0, width, height, 1, border, format, type)) |
| 6919 | { |
| 6920 | return; |
daniel@transgaming.com | 32b1144 | 2011-11-19 02:42:48 +0000 | [diff] [blame] | 6921 | } |
| 6922 | |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6923 | switch (target) |
| 6924 | { |
| 6925 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6926 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6927 | gl::Texture2D *texture = context->getTexture2D(); |
| 6928 | texture->setImage(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6929 | } |
| 6930 | break; |
| 6931 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 6932 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6933 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 6934 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6935 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 6936 | break; |
| 6937 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 6938 | { |
| 6939 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6940 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6941 | } |
| 6942 | break; |
| 6943 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 6944 | { |
| 6945 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6946 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6947 | } |
| 6948 | break; |
| 6949 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 6950 | { |
| 6951 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6952 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6953 | } |
| 6954 | break; |
| 6955 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 6956 | { |
| 6957 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6958 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6959 | } |
| 6960 | break; |
| 6961 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 6962 | { |
| 6963 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 6964 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackAlignment(), pixels); |
| 6965 | } |
| 6966 | break; |
| 6967 | default: UNREACHABLE(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6968 | } |
| 6969 | } |
| 6970 | } |
| 6971 | catch(std::bad_alloc&) |
| 6972 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 6973 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 6974 | } |
| 6975 | } |
| 6976 | |
| 6977 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 6978 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 6979 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 6980 | |
| 6981 | try |
| 6982 | { |
| 6983 | gl::Context *context = gl::getNonLostContext(); |
| 6984 | |
| 6985 | if (context) |
| 6986 | { |
| 6987 | gl::Texture *texture; |
| 6988 | |
| 6989 | switch (target) |
| 6990 | { |
| 6991 | case GL_TEXTURE_2D: |
| 6992 | texture = context->getTexture2D(); |
| 6993 | break; |
| 6994 | case GL_TEXTURE_CUBE_MAP: |
| 6995 | texture = context->getTextureCubeMap(); |
| 6996 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 6997 | case GL_TEXTURE_3D: |
| 6998 | if (context->getClientVersion() < 3) |
| 6999 | { |
| 7000 | return gl::error(GL_INVALID_ENUM); |
| 7001 | } |
| 7002 | texture = context->getTexture3D(); |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 7003 | case GL_TEXTURE_2D_ARRAY: |
| 7004 | if (context->getClientVersion() < 3) |
| 7005 | { |
| 7006 | return gl::error(GL_INVALID_ENUM); |
| 7007 | } |
| 7008 | texture = context->getTexture2DArray(); |
| 7009 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7010 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7011 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7012 | } |
| 7013 | |
| 7014 | switch (pname) |
| 7015 | { |
| 7016 | case GL_TEXTURE_WRAP_S: |
| 7017 | if (!texture->setWrapS((GLenum)param)) |
| 7018 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7019 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7020 | } |
| 7021 | break; |
| 7022 | case GL_TEXTURE_WRAP_T: |
| 7023 | if (!texture->setWrapT((GLenum)param)) |
| 7024 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7025 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7026 | } |
| 7027 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 7028 | case GL_TEXTURE_WRAP_R: |
| 7029 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 7030 | { |
| 7031 | return gl::error(GL_INVALID_ENUM); |
| 7032 | } |
| 7033 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7034 | case GL_TEXTURE_MIN_FILTER: |
| 7035 | if (!texture->setMinFilter((GLenum)param)) |
| 7036 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7037 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7038 | } |
| 7039 | break; |
| 7040 | case GL_TEXTURE_MAG_FILTER: |
| 7041 | if (!texture->setMagFilter((GLenum)param)) |
| 7042 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7043 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7044 | } |
| 7045 | break; |
| 7046 | case GL_TEXTURE_USAGE_ANGLE: |
| 7047 | if (!texture->setUsage((GLenum)param)) |
| 7048 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7049 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7050 | } |
| 7051 | break; |
| 7052 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7053 | if (!context->supportsTextureFilterAnisotropy()) |
| 7054 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7055 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7056 | } |
| 7057 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 7058 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7059 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7060 | } |
| 7061 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7062 | |
| 7063 | case GL_TEXTURE_MIN_LOD: |
| 7064 | case GL_TEXTURE_MAX_LOD: |
| 7065 | if (context->getClientVersion() < 3) |
| 7066 | { |
| 7067 | return gl::error(GL_INVALID_ENUM); |
| 7068 | } |
| 7069 | UNIMPLEMENTED(); |
| 7070 | break; |
| 7071 | |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7072 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7073 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7074 | } |
| 7075 | } |
| 7076 | } |
| 7077 | catch(std::bad_alloc&) |
| 7078 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7079 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7080 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7081 | } |
| 7082 | |
| 7083 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 7084 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7085 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7086 | } |
| 7087 | |
| 7088 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 7089 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7090 | 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] | 7091 | |
| 7092 | try |
| 7093 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7094 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7095 | |
| 7096 | if (context) |
| 7097 | { |
| 7098 | gl::Texture *texture; |
| 7099 | |
| 7100 | switch (target) |
| 7101 | { |
| 7102 | case GL_TEXTURE_2D: |
| 7103 | texture = context->getTexture2D(); |
| 7104 | break; |
| 7105 | case GL_TEXTURE_CUBE_MAP: |
| 7106 | texture = context->getTextureCubeMap(); |
| 7107 | break; |
shannon.woods%transgaming.com@gtempaccount.com | c416e1c | 2013-04-13 03:45:05 +0000 | [diff] [blame] | 7108 | case GL_TEXTURE_3D: |
| 7109 | if (context->getClientVersion() < 3) |
| 7110 | { |
| 7111 | return gl::error(GL_INVALID_ENUM); |
| 7112 | } |
| 7113 | texture = context->getTexture3D(); |
| 7114 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 90dbc44 | 2013-04-13 03:46:14 +0000 | [diff] [blame] | 7115 | case GL_TEXTURE_2D_ARRAY: |
| 7116 | if (context->getClientVersion() < 3) |
| 7117 | { |
| 7118 | return gl::error(GL_INVALID_ENUM); |
| 7119 | } |
| 7120 | texture = context->getTexture2DArray(); |
| 7121 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7122 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7123 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7124 | } |
| 7125 | |
| 7126 | switch (pname) |
| 7127 | { |
| 7128 | case GL_TEXTURE_WRAP_S: |
| 7129 | if (!texture->setWrapS((GLenum)param)) |
| 7130 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7131 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7132 | } |
| 7133 | break; |
| 7134 | case GL_TEXTURE_WRAP_T: |
| 7135 | if (!texture->setWrapT((GLenum)param)) |
| 7136 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7137 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7138 | } |
| 7139 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 0b3a8df | 2013-04-13 03:44:51 +0000 | [diff] [blame] | 7140 | case GL_TEXTURE_WRAP_R: |
| 7141 | if (context->getClientVersion() < 3 || !texture->setWrapR((GLenum)param)) |
| 7142 | { |
| 7143 | return gl::error(GL_INVALID_ENUM); |
| 7144 | } |
| 7145 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7146 | case GL_TEXTURE_MIN_FILTER: |
| 7147 | if (!texture->setMinFilter((GLenum)param)) |
| 7148 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7149 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7150 | } |
| 7151 | break; |
| 7152 | case GL_TEXTURE_MAG_FILTER: |
| 7153 | if (!texture->setMagFilter((GLenum)param)) |
| 7154 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7155 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7156 | } |
| 7157 | break; |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 7158 | case GL_TEXTURE_USAGE_ANGLE: |
| 7159 | if (!texture->setUsage((GLenum)param)) |
| 7160 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7161 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 7d18c17 | 2011-11-11 04:18:21 +0000 | [diff] [blame] | 7162 | } |
| 7163 | break; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7164 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 7165 | if (!context->supportsTextureFilterAnisotropy()) |
| 7166 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7167 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7168 | } |
| 7169 | if (!texture->setMaxAnisotropy((float)param, context->getTextureMaxAnisotropy())) |
| 7170 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7171 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 7172 | } |
| 7173 | break; |
shannonwoods@chromium.org | abf14cc | 2013-05-30 00:20:58 +0000 | [diff] [blame] | 7174 | |
| 7175 | case GL_TEXTURE_SWIZZLE_R: |
| 7176 | case GL_TEXTURE_SWIZZLE_G: |
| 7177 | case GL_TEXTURE_SWIZZLE_B: |
| 7178 | case GL_TEXTURE_SWIZZLE_A: |
| 7179 | case GL_TEXTURE_BASE_LEVEL: |
| 7180 | case GL_TEXTURE_MAX_LEVEL: |
| 7181 | case GL_TEXTURE_COMPARE_MODE: |
| 7182 | case GL_TEXTURE_COMPARE_FUNC: |
| 7183 | if (context->getClientVersion() < 3) |
| 7184 | { |
| 7185 | return gl::error(GL_INVALID_ENUM); |
| 7186 | } |
| 7187 | UNIMPLEMENTED(); |
| 7188 | break; |
| 7189 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7190 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7191 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7192 | } |
| 7193 | } |
| 7194 | } |
| 7195 | catch(std::bad_alloc&) |
| 7196 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7197 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7198 | } |
| 7199 | } |
| 7200 | |
| 7201 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 7202 | { |
| 7203 | glTexParameteri(target, pname, *params); |
| 7204 | } |
| 7205 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7206 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7207 | { |
| 7208 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7209 | target, levels, internalformat, width, height); |
| 7210 | |
| 7211 | try |
| 7212 | { |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7213 | gl::Context *context = gl::getNonLostContext(); |
| 7214 | |
| 7215 | if (context) |
| 7216 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7217 | if (context->getClientVersion() < 3 && |
| 7218 | !validateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7219 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7220 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7221 | } |
| 7222 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7223 | if (context->getClientVersion() >= 3 && |
| 7224 | !validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7225 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7226 | return; |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 7227 | } |
| 7228 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7229 | switch (target) |
| 7230 | { |
| 7231 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7232 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7233 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7234 | texture2d->storage(levels, internalformat, width, height); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7235 | } |
| 7236 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7237 | |
| 7238 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7239 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7240 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7241 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7242 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7243 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7244 | { |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7245 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7246 | textureCube->storage(levels, internalformat, width); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7247 | } |
| 7248 | break; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7249 | |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7250 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7251 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 21f05d7 | 2011-11-29 19:42:28 +0000 | [diff] [blame] | 7252 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7253 | } |
| 7254 | } |
| 7255 | catch(std::bad_alloc&) |
| 7256 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7257 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 7258 | } |
| 7259 | } |
| 7260 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7261 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 7262 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7263 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7264 | 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] | 7265 | "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] | 7266 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7267 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 7268 | |
| 7269 | try |
| 7270 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7271 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7272 | |
| 7273 | if (context) |
| 7274 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7275 | if (context->getClientVersion() < 3 && |
| 7276 | !validateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7277 | 0, 0, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 1d2d3c4 | 2012-05-31 01:14:15 +0000 | [diff] [blame] | 7278 | { |
| 7279 | return; |
| 7280 | } |
| 7281 | |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7282 | if (context->getClientVersion() >= 3 && |
| 7283 | !validateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 7284 | 0, 0, 0, width, height, 1, 0, format, type)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7285 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7286 | return; |
| 7287 | } |
| 7288 | |
| 7289 | switch (target) |
| 7290 | { |
| 7291 | case GL_TEXTURE_2D: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7292 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7293 | gl::Texture2D *texture = context->getTexture2D(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7294 | 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] | 7295 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7296 | break; |
| 7297 | |
| 7298 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 7299 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 7300 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 7301 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 7302 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 7303 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7304 | { |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7305 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
daniel@transgaming.com | 343373a | 2011-11-29 19:42:32 +0000 | [diff] [blame] | 7306 | 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] | 7307 | } |
shannonwoods@chromium.org | f3a3eda | 2013-05-30 00:13:42 +0000 | [diff] [blame] | 7308 | break; |
| 7309 | |
| 7310 | default: |
| 7311 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 7312 | } |
| 7313 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7314 | } |
| 7315 | catch(std::bad_alloc&) |
| 7316 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7317 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7318 | } |
| 7319 | } |
| 7320 | |
| 7321 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 7322 | { |
| 7323 | glUniform1fv(location, 1, &x); |
| 7324 | } |
| 7325 | |
| 7326 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 7327 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7328 | 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] | 7329 | |
| 7330 | try |
| 7331 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7332 | if (count < 0) |
| 7333 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7334 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7335 | } |
| 7336 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7337 | if (location == -1) |
| 7338 | { |
| 7339 | return; |
| 7340 | } |
| 7341 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7342 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7343 | |
| 7344 | if (context) |
| 7345 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7346 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7347 | if (!programBinary) |
| 7348 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7349 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7350 | } |
| 7351 | |
| 7352 | if (!programBinary->setUniform1fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7353 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7354 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7355 | } |
| 7356 | } |
| 7357 | } |
| 7358 | catch(std::bad_alloc&) |
| 7359 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7360 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7361 | } |
| 7362 | } |
| 7363 | |
| 7364 | void __stdcall glUniform1i(GLint location, GLint x) |
| 7365 | { |
| 7366 | glUniform1iv(location, 1, &x); |
| 7367 | } |
| 7368 | |
| 7369 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 7370 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7371 | 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] | 7372 | |
| 7373 | try |
| 7374 | { |
| 7375 | if (count < 0) |
| 7376 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7377 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7378 | } |
| 7379 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7380 | if (location == -1) |
| 7381 | { |
| 7382 | return; |
| 7383 | } |
| 7384 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7385 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7386 | |
| 7387 | if (context) |
| 7388 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7389 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7390 | if (!programBinary) |
| 7391 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7392 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7393 | } |
| 7394 | |
| 7395 | if (!programBinary->setUniform1iv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7396 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7397 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7398 | } |
| 7399 | } |
| 7400 | } |
| 7401 | catch(std::bad_alloc&) |
| 7402 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7403 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7404 | } |
| 7405 | } |
| 7406 | |
| 7407 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 7408 | { |
| 7409 | GLfloat xy[2] = {x, y}; |
| 7410 | |
| 7411 | glUniform2fv(location, 1, (GLfloat*)&xy); |
| 7412 | } |
| 7413 | |
| 7414 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 7415 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7416 | 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] | 7417 | |
| 7418 | try |
| 7419 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7420 | if (count < 0) |
| 7421 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7422 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7423 | } |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7424 | |
| 7425 | if (location == -1) |
| 7426 | { |
| 7427 | return; |
| 7428 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7429 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7430 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7431 | |
| 7432 | if (context) |
| 7433 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7434 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7435 | if (!programBinary) |
| 7436 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7437 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7438 | } |
| 7439 | |
| 7440 | if (!programBinary->setUniform2fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7441 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7442 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7443 | } |
| 7444 | } |
| 7445 | } |
| 7446 | catch(std::bad_alloc&) |
| 7447 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7448 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7449 | } |
| 7450 | } |
| 7451 | |
| 7452 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 7453 | { |
| 7454 | GLint xy[4] = {x, y}; |
| 7455 | |
| 7456 | glUniform2iv(location, 1, (GLint*)&xy); |
| 7457 | } |
| 7458 | |
| 7459 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 7460 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7461 | 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] | 7462 | |
| 7463 | try |
| 7464 | { |
| 7465 | if (count < 0) |
| 7466 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7467 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7468 | } |
| 7469 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7470 | if (location == -1) |
| 7471 | { |
| 7472 | return; |
| 7473 | } |
| 7474 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7475 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7476 | |
| 7477 | if (context) |
| 7478 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7479 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7480 | if (!programBinary) |
| 7481 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7482 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7483 | } |
| 7484 | |
| 7485 | if (!programBinary->setUniform2iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7486 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7487 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7488 | } |
| 7489 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7490 | } |
| 7491 | catch(std::bad_alloc&) |
| 7492 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7493 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7494 | } |
| 7495 | } |
| 7496 | |
| 7497 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 7498 | { |
| 7499 | GLfloat xyz[3] = {x, y, z}; |
| 7500 | |
| 7501 | glUniform3fv(location, 1, (GLfloat*)&xyz); |
| 7502 | } |
| 7503 | |
| 7504 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 7505 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7506 | 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] | 7507 | |
| 7508 | try |
| 7509 | { |
| 7510 | if (count < 0) |
| 7511 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7512 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7513 | } |
| 7514 | |
| 7515 | if (location == -1) |
| 7516 | { |
| 7517 | return; |
| 7518 | } |
| 7519 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7520 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7521 | |
| 7522 | if (context) |
| 7523 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7524 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7525 | if (!programBinary) |
| 7526 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7527 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7528 | } |
| 7529 | |
| 7530 | if (!programBinary->setUniform3fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7531 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7532 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7533 | } |
| 7534 | } |
| 7535 | } |
| 7536 | catch(std::bad_alloc&) |
| 7537 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7538 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7539 | } |
| 7540 | } |
| 7541 | |
| 7542 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 7543 | { |
| 7544 | GLint xyz[3] = {x, y, z}; |
| 7545 | |
| 7546 | glUniform3iv(location, 1, (GLint*)&xyz); |
| 7547 | } |
| 7548 | |
| 7549 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 7550 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7551 | 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] | 7552 | |
| 7553 | try |
| 7554 | { |
| 7555 | if (count < 0) |
| 7556 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7557 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7558 | } |
| 7559 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7560 | if (location == -1) |
| 7561 | { |
| 7562 | return; |
| 7563 | } |
| 7564 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7565 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7566 | |
| 7567 | if (context) |
| 7568 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7569 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7570 | if (!programBinary) |
| 7571 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7572 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7573 | } |
| 7574 | |
| 7575 | if (!programBinary->setUniform3iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7576 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7577 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7578 | } |
| 7579 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7580 | } |
| 7581 | catch(std::bad_alloc&) |
| 7582 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7583 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7584 | } |
| 7585 | } |
| 7586 | |
| 7587 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 7588 | { |
| 7589 | GLfloat xyzw[4] = {x, y, z, w}; |
| 7590 | |
| 7591 | glUniform4fv(location, 1, (GLfloat*)&xyzw); |
| 7592 | } |
| 7593 | |
| 7594 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 7595 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7596 | 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] | 7597 | |
| 7598 | try |
| 7599 | { |
| 7600 | if (count < 0) |
| 7601 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7602 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7603 | } |
| 7604 | |
| 7605 | if (location == -1) |
| 7606 | { |
| 7607 | return; |
| 7608 | } |
| 7609 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7610 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7611 | |
| 7612 | if (context) |
| 7613 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7614 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7615 | if (!programBinary) |
| 7616 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7617 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7618 | } |
| 7619 | |
| 7620 | if (!programBinary->setUniform4fv(location, count, v)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7621 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7622 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7623 | } |
| 7624 | } |
| 7625 | } |
| 7626 | catch(std::bad_alloc&) |
| 7627 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7628 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7629 | } |
| 7630 | } |
| 7631 | |
| 7632 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 7633 | { |
| 7634 | GLint xyzw[4] = {x, y, z, w}; |
| 7635 | |
| 7636 | glUniform4iv(location, 1, (GLint*)&xyzw); |
| 7637 | } |
| 7638 | |
| 7639 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 7640 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7641 | 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] | 7642 | |
| 7643 | try |
| 7644 | { |
| 7645 | if (count < 0) |
| 7646 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7647 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7648 | } |
| 7649 | |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7650 | if (location == -1) |
| 7651 | { |
| 7652 | return; |
| 7653 | } |
| 7654 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7655 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7656 | |
| 7657 | if (context) |
| 7658 | { |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7659 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7660 | if (!programBinary) |
| 7661 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7662 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7663 | } |
| 7664 | |
| 7665 | if (!programBinary->setUniform4iv(location, count, v)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7666 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7667 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 7668 | } |
| 7669 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7670 | } |
| 7671 | catch(std::bad_alloc&) |
| 7672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7673 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7674 | } |
| 7675 | } |
| 7676 | |
| 7677 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7678 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7679 | 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] | 7680 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7681 | |
| 7682 | try |
| 7683 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7684 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7686 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7687 | } |
| 7688 | |
| 7689 | if (location == -1) |
| 7690 | { |
| 7691 | return; |
| 7692 | } |
| 7693 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7694 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7695 | |
| 7696 | if (context) |
| 7697 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7698 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7699 | { |
| 7700 | return gl::error(GL_INVALID_VALUE); |
| 7701 | } |
| 7702 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7703 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7704 | if (!programBinary) |
| 7705 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7706 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7707 | } |
| 7708 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7709 | if (!programBinary->setUniformMatrix2fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7710 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7711 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7712 | } |
| 7713 | } |
| 7714 | } |
| 7715 | catch(std::bad_alloc&) |
| 7716 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7717 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7718 | } |
| 7719 | } |
| 7720 | |
| 7721 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7722 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7723 | 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] | 7724 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7725 | |
| 7726 | try |
| 7727 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7728 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7729 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7730 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7731 | } |
| 7732 | |
| 7733 | if (location == -1) |
| 7734 | { |
| 7735 | return; |
| 7736 | } |
| 7737 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7738 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7739 | |
| 7740 | if (context) |
| 7741 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7742 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7743 | { |
| 7744 | return gl::error(GL_INVALID_VALUE); |
| 7745 | } |
| 7746 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7747 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7748 | if (!programBinary) |
| 7749 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7750 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7751 | } |
| 7752 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7753 | if (!programBinary->setUniformMatrix3fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7754 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7755 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7756 | } |
| 7757 | } |
| 7758 | } |
| 7759 | catch(std::bad_alloc&) |
| 7760 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7761 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7762 | } |
| 7763 | } |
| 7764 | |
| 7765 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 7766 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7767 | 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] | 7768 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7769 | |
| 7770 | try |
| 7771 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7772 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7773 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7774 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7775 | } |
| 7776 | |
| 7777 | if (location == -1) |
| 7778 | { |
| 7779 | return; |
| 7780 | } |
| 7781 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7782 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7783 | |
| 7784 | if (context) |
| 7785 | { |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7786 | if (transpose != GL_FALSE && context->getClientVersion() < 3) |
| 7787 | { |
| 7788 | return gl::error(GL_INVALID_VALUE); |
| 7789 | } |
| 7790 | |
daniel@transgaming.com | 62a2846 | 2012-07-24 18:33:59 +0000 | [diff] [blame] | 7791 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7792 | if (!programBinary) |
| 7793 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7794 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | e2a59bb | 2012-06-07 21:09:53 +0000 | [diff] [blame] | 7795 | } |
| 7796 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 7797 | if (!programBinary->setUniformMatrix4fv(location, count, transpose, value)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7798 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7799 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7800 | } |
| 7801 | } |
| 7802 | } |
| 7803 | catch(std::bad_alloc&) |
| 7804 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7805 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7806 | } |
| 7807 | } |
| 7808 | |
| 7809 | void __stdcall glUseProgram(GLuint program) |
| 7810 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7811 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7812 | |
| 7813 | try |
| 7814 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7815 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7816 | |
| 7817 | if (context) |
| 7818 | { |
| 7819 | gl::Program *programObject = context->getProgram(program); |
| 7820 | |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7821 | if (!programObject && program != 0) |
| 7822 | { |
| 7823 | if (context->getShader(program)) |
| 7824 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7825 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7826 | } |
| 7827 | else |
| 7828 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7829 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | c847820 | 2010-04-13 19:53:35 +0000 | [diff] [blame] | 7830 | } |
| 7831 | } |
| 7832 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 7833 | if (program != 0 && !programObject->isLinked()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7834 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7835 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7836 | } |
| 7837 | |
| 7838 | context->useProgram(program); |
| 7839 | } |
| 7840 | } |
| 7841 | catch(std::bad_alloc&) |
| 7842 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7843 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7844 | } |
| 7845 | } |
| 7846 | |
| 7847 | void __stdcall glValidateProgram(GLuint program) |
| 7848 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7849 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7850 | |
| 7851 | try |
| 7852 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7853 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7854 | |
| 7855 | if (context) |
| 7856 | { |
| 7857 | gl::Program *programObject = context->getProgram(program); |
| 7858 | |
| 7859 | if (!programObject) |
| 7860 | { |
| 7861 | if (context->getShader(program)) |
| 7862 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7863 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7864 | } |
| 7865 | else |
| 7866 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7867 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7868 | } |
| 7869 | } |
| 7870 | |
apatrick@chromium.org | 253b8d2 | 2012-06-22 19:27:21 +0000 | [diff] [blame] | 7871 | programObject->validate(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 7872 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7873 | } |
| 7874 | catch(std::bad_alloc&) |
| 7875 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7876 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7877 | } |
| 7878 | } |
| 7879 | |
| 7880 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 7881 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7882 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7883 | |
| 7884 | try |
| 7885 | { |
| 7886 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7887 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7888 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7889 | } |
| 7890 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7891 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7892 | |
| 7893 | if (context) |
| 7894 | { |
| 7895 | GLfloat vals[4] = { x, 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7896 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7897 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7898 | } |
| 7899 | catch(std::bad_alloc&) |
| 7900 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7901 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7902 | } |
| 7903 | } |
| 7904 | |
| 7905 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 7906 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7907 | 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] | 7908 | |
| 7909 | try |
| 7910 | { |
| 7911 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7912 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7913 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7914 | } |
| 7915 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7916 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7917 | |
| 7918 | if (context) |
| 7919 | { |
| 7920 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7921 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7922 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7923 | } |
| 7924 | catch(std::bad_alloc&) |
| 7925 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7926 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7927 | } |
| 7928 | } |
| 7929 | |
| 7930 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 7931 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7932 | 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] | 7933 | |
| 7934 | try |
| 7935 | { |
| 7936 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7937 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7938 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7939 | } |
| 7940 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7941 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7942 | |
| 7943 | if (context) |
| 7944 | { |
| 7945 | GLfloat vals[4] = { x, y, 0, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7946 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7947 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7948 | } |
| 7949 | catch(std::bad_alloc&) |
| 7950 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7951 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7952 | } |
| 7953 | } |
| 7954 | |
| 7955 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 7956 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7957 | 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] | 7958 | |
| 7959 | try |
| 7960 | { |
| 7961 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7962 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7963 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7964 | } |
| 7965 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7966 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7967 | |
| 7968 | if (context) |
| 7969 | { |
| 7970 | 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] | 7971 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7972 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7973 | } |
| 7974 | catch(std::bad_alloc&) |
| 7975 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7976 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7977 | } |
| 7978 | } |
| 7979 | |
| 7980 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 7981 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7982 | 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] | 7983 | |
| 7984 | try |
| 7985 | { |
| 7986 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7987 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 7988 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7989 | } |
| 7990 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 7991 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7992 | |
| 7993 | if (context) |
| 7994 | { |
| 7995 | GLfloat vals[4] = { x, y, z, 1 }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 7996 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 7997 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7998 | } |
| 7999 | catch(std::bad_alloc&) |
| 8000 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8001 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8002 | } |
| 8003 | } |
| 8004 | |
| 8005 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 8006 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8007 | 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] | 8008 | |
| 8009 | try |
| 8010 | { |
| 8011 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8012 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8013 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8014 | } |
| 8015 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8016 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8017 | |
| 8018 | if (context) |
| 8019 | { |
| 8020 | 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] | 8021 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8022 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8023 | } |
| 8024 | catch(std::bad_alloc&) |
| 8025 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8026 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8027 | } |
| 8028 | } |
| 8029 | |
| 8030 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 8031 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8032 | 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] | 8033 | |
| 8034 | try |
| 8035 | { |
| 8036 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8037 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8038 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8039 | } |
| 8040 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8041 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8042 | |
| 8043 | if (context) |
| 8044 | { |
| 8045 | GLfloat vals[4] = { x, y, z, w }; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8046 | context->setVertexAttribf(index, vals); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8047 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8048 | } |
| 8049 | catch(std::bad_alloc&) |
| 8050 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8051 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8052 | } |
| 8053 | } |
| 8054 | |
| 8055 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 8056 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8057 | 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] | 8058 | |
| 8059 | try |
| 8060 | { |
| 8061 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8062 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8063 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8064 | } |
| 8065 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8066 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8067 | |
| 8068 | if (context) |
| 8069 | { |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8070 | context->setVertexAttribf(index, values); |
daniel@transgaming.com | e4b08c8 | 2010-04-20 18:53:06 +0000 | [diff] [blame] | 8071 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8072 | } |
| 8073 | catch(std::bad_alloc&) |
| 8074 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8075 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8076 | } |
| 8077 | } |
| 8078 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8079 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 8080 | { |
| 8081 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 8082 | |
| 8083 | try |
| 8084 | { |
| 8085 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8086 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8087 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8088 | } |
| 8089 | |
| 8090 | gl::Context *context = gl::getNonLostContext(); |
| 8091 | |
| 8092 | if (context) |
| 8093 | { |
| 8094 | context->setVertexAttribDivisor(index, divisor); |
| 8095 | } |
| 8096 | } |
| 8097 | catch(std::bad_alloc&) |
| 8098 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8099 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 8100 | } |
| 8101 | } |
| 8102 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8103 | 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] | 8104 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8105 | 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] | 8106 | "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] | 8107 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8108 | |
| 8109 | try |
| 8110 | { |
| 8111 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 8112 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8113 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8114 | } |
| 8115 | |
| 8116 | if (size < 1 || size > 4) |
| 8117 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8118 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8119 | } |
| 8120 | |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8121 | gl::Context *context = gl::getNonLostContext(); |
| 8122 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8123 | switch (type) |
| 8124 | { |
| 8125 | case GL_BYTE: |
| 8126 | case GL_UNSIGNED_BYTE: |
| 8127 | case GL_SHORT: |
| 8128 | case GL_UNSIGNED_SHORT: |
| 8129 | case GL_FIXED: |
| 8130 | case GL_FLOAT: |
| 8131 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 8132 | case GL_HALF_FLOAT: |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 8133 | case GL_INT: |
| 8134 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8135 | case GL_INT_2_10_10_10_REV: |
| 8136 | 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] | 8137 | if (context && context->getClientVersion() < 3) |
| 8138 | { |
| 8139 | return gl::error(GL_INVALID_ENUM); |
| 8140 | } |
| 8141 | else |
| 8142 | { |
| 8143 | break; |
| 8144 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8145 | default: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8146 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8147 | } |
| 8148 | |
| 8149 | if (stride < 0) |
| 8150 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8151 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8152 | } |
| 8153 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 8154 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 8155 | { |
| 8156 | return gl::error(GL_INVALID_OPERATION); |
| 8157 | } |
| 8158 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8159 | if (context) |
| 8160 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8de4e6a | 2013-04-13 03:37:44 +0000 | [diff] [blame] | 8161 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, |
| 8162 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8163 | } |
| 8164 | } |
| 8165 | catch(std::bad_alloc&) |
| 8166 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8167 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8168 | } |
| 8169 | } |
| 8170 | |
| 8171 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 8172 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8173 | 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] | 8174 | |
| 8175 | try |
| 8176 | { |
| 8177 | if (width < 0 || height < 0) |
| 8178 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8179 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8180 | } |
| 8181 | |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 8182 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8183 | |
| 8184 | if (context) |
| 8185 | { |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 8186 | context->setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8187 | } |
| 8188 | } |
| 8189 | catch(std::bad_alloc&) |
| 8190 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 8191 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8192 | } |
| 8193 | } |
| 8194 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8195 | // OpenGL ES 3.0 functions |
| 8196 | |
| 8197 | void __stdcall glReadBuffer(GLenum mode) |
| 8198 | { |
| 8199 | EVENT("(GLenum mode = 0x%X)", mode); |
| 8200 | |
| 8201 | try |
| 8202 | { |
| 8203 | gl::Context *context = gl::getNonLostContext(); |
| 8204 | |
| 8205 | if (context) |
| 8206 | { |
| 8207 | if (context->getClientVersion() < 3) |
| 8208 | { |
| 8209 | return gl::error(GL_INVALID_OPERATION); |
| 8210 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8211 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8212 | // glReadBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8213 | UNIMPLEMENTED(); |
| 8214 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8215 | } |
| 8216 | catch(std::bad_alloc&) |
| 8217 | { |
| 8218 | return gl::error(GL_OUT_OF_MEMORY); |
| 8219 | } |
| 8220 | } |
| 8221 | |
| 8222 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 8223 | { |
| 8224 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 8225 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 8226 | |
| 8227 | try |
| 8228 | { |
| 8229 | gl::Context *context = gl::getNonLostContext(); |
| 8230 | |
| 8231 | if (context) |
| 8232 | { |
| 8233 | if (context->getClientVersion() < 3) |
| 8234 | { |
| 8235 | return gl::error(GL_INVALID_OPERATION); |
| 8236 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8237 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8238 | // glDrawRangeElements |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8239 | UNIMPLEMENTED(); |
| 8240 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8241 | } |
| 8242 | catch(std::bad_alloc&) |
| 8243 | { |
| 8244 | return gl::error(GL_OUT_OF_MEMORY); |
| 8245 | } |
| 8246 | } |
| 8247 | |
| 8248 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 8249 | { |
| 8250 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8251 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 8252 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8253 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8254 | |
| 8255 | try |
| 8256 | { |
| 8257 | gl::Context *context = gl::getNonLostContext(); |
| 8258 | |
| 8259 | if (context) |
| 8260 | { |
| 8261 | if (context->getClientVersion() < 3) |
| 8262 | { |
| 8263 | return gl::error(GL_INVALID_OPERATION); |
| 8264 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8265 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8266 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8267 | if (!validateES3TexImageParameters(context, target, level, internalformat, false, false, |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8268 | 0, 0, 0, width, height, depth, border, format, type)) |
| 8269 | { |
| 8270 | return; |
| 8271 | } |
| 8272 | |
| 8273 | switch(target) |
| 8274 | { |
| 8275 | case GL_TEXTURE_3D: |
| 8276 | { |
| 8277 | gl::Texture3D *texture = context->getTexture3D(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8278 | 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] | 8279 | } |
| 8280 | break; |
| 8281 | |
| 8282 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8283 | { |
| 8284 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
shannonwoods@chromium.org | 4ad58e0 | 2013-05-30 00:08:11 +0000 | [diff] [blame] | 8285 | 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] | 8286 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8287 | break; |
| 8288 | |
| 8289 | default: |
| 8290 | return gl::error(GL_INVALID_ENUM); |
| 8291 | } |
| 8292 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8293 | } |
| 8294 | catch(std::bad_alloc&) |
| 8295 | { |
| 8296 | return gl::error(GL_OUT_OF_MEMORY); |
| 8297 | } |
| 8298 | } |
| 8299 | |
| 8300 | 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) |
| 8301 | { |
| 8302 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8303 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8304 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 8305 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 8306 | |
| 8307 | try |
| 8308 | { |
| 8309 | gl::Context *context = gl::getNonLostContext(); |
| 8310 | |
| 8311 | if (context) |
| 8312 | { |
| 8313 | if (context->getClientVersion() < 3) |
| 8314 | { |
| 8315 | return gl::error(GL_INVALID_OPERATION); |
| 8316 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8317 | |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8318 | if (!pixels) |
| 8319 | { |
| 8320 | return gl::error(GL_INVALID_VALUE); |
| 8321 | } |
| 8322 | |
| 8323 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8324 | 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] | 8325 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 8326 | format, type)) |
| 8327 | { |
| 8328 | return; |
| 8329 | } |
| 8330 | |
| 8331 | switch(target) |
| 8332 | { |
| 8333 | case GL_TEXTURE_3D: |
| 8334 | { |
| 8335 | gl::Texture3D *texture = context->getTexture3D(); |
| 8336 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8337 | } |
| 8338 | break; |
| 8339 | |
| 8340 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8341 | { |
| 8342 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8343 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels); |
| 8344 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8345 | break; |
| 8346 | |
| 8347 | default: |
| 8348 | return gl::error(GL_INVALID_ENUM); |
| 8349 | } |
| 8350 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8351 | } |
| 8352 | catch(std::bad_alloc&) |
| 8353 | { |
| 8354 | return gl::error(GL_OUT_OF_MEMORY); |
| 8355 | } |
| 8356 | } |
| 8357 | |
| 8358 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8359 | { |
| 8360 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8361 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8362 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 8363 | |
| 8364 | try |
| 8365 | { |
| 8366 | gl::Context *context = gl::getNonLostContext(); |
| 8367 | |
| 8368 | if (context) |
| 8369 | { |
| 8370 | if (context->getClientVersion() < 3) |
| 8371 | { |
| 8372 | return gl::error(GL_INVALID_OPERATION); |
| 8373 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8374 | |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8375 | if (!validateES3CopyTexImageParameters(context, target, level, GL_NONE, false, xoffset, yoffset, zoffset, |
| 8376 | x, y, width, height, 0)) |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8377 | { |
| 8378 | return; |
| 8379 | } |
| 8380 | |
| 8381 | gl::Framebuffer *framebuffer = context->getReadFramebuffer(); |
| 8382 | gl::Texture *texture = NULL; |
| 8383 | switch (target) |
| 8384 | { |
| 8385 | case GL_TEXTURE_3D: |
| 8386 | texture = context->getTexture3D(); |
| 8387 | break; |
| 8388 | |
| 8389 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8390 | texture = context->getTexture2DArray(); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8391 | break; |
| 8392 | |
| 8393 | default: |
| 8394 | return gl::error(GL_INVALID_ENUM); |
| 8395 | } |
| 8396 | |
| 8397 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
| 8398 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8399 | } |
| 8400 | catch(std::bad_alloc&) |
| 8401 | { |
| 8402 | return gl::error(GL_OUT_OF_MEMORY); |
| 8403 | } |
| 8404 | } |
| 8405 | |
| 8406 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 8407 | { |
| 8408 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 8409 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 8410 | "const GLvoid* data = 0x%0.8p)", |
| 8411 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 8412 | |
| 8413 | try |
| 8414 | { |
| 8415 | gl::Context *context = gl::getNonLostContext(); |
| 8416 | |
| 8417 | if (context) |
| 8418 | { |
| 8419 | if (context->getClientVersion() < 3) |
| 8420 | { |
| 8421 | return gl::error(GL_INVALID_OPERATION); |
| 8422 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8423 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8424 | 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] | 8425 | { |
| 8426 | return gl::error(GL_INVALID_VALUE); |
| 8427 | } |
| 8428 | |
| 8429 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8430 | if (!validateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 8431 | 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] | 8432 | { |
| 8433 | return; |
| 8434 | } |
| 8435 | |
| 8436 | switch(target) |
| 8437 | { |
| 8438 | case GL_TEXTURE_3D: |
| 8439 | { |
| 8440 | gl::Texture3D *texture = context->getTexture3D(); |
| 8441 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8442 | } |
| 8443 | break; |
| 8444 | |
| 8445 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8446 | { |
| 8447 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8448 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 8449 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8450 | break; |
| 8451 | |
| 8452 | default: |
| 8453 | return gl::error(GL_INVALID_ENUM); |
| 8454 | } |
| 8455 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8456 | } |
| 8457 | catch(std::bad_alloc&) |
| 8458 | { |
| 8459 | return gl::error(GL_OUT_OF_MEMORY); |
| 8460 | } |
| 8461 | } |
| 8462 | |
| 8463 | 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) |
| 8464 | { |
| 8465 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 8466 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 8467 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 8468 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 8469 | |
| 8470 | try |
| 8471 | { |
| 8472 | gl::Context *context = gl::getNonLostContext(); |
| 8473 | |
| 8474 | if (context) |
| 8475 | { |
| 8476 | if (context->getClientVersion() < 3) |
| 8477 | { |
| 8478 | return gl::error(GL_INVALID_OPERATION); |
| 8479 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8480 | |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 8481 | 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] | 8482 | { |
| 8483 | return gl::error(GL_INVALID_VALUE); |
| 8484 | } |
| 8485 | |
| 8486 | if (!data) |
| 8487 | { |
| 8488 | return gl::error(GL_INVALID_VALUE); |
| 8489 | } |
| 8490 | |
| 8491 | // validateES3TexImageFormat sets the error code if there is an error |
shannonwoods@chromium.org | 6cf2b0e | 2013-05-30 00:13:36 +0000 | [diff] [blame] | 8492 | if (!validateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 8493 | 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] | 8494 | { |
| 8495 | return; |
| 8496 | } |
| 8497 | |
| 8498 | switch(target) |
| 8499 | { |
| 8500 | case GL_TEXTURE_3D: |
| 8501 | { |
| 8502 | gl::Texture3D *texture = context->getTexture3D(); |
| 8503 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8504 | format, imageSize, data); |
| 8505 | } |
| 8506 | break; |
| 8507 | |
| 8508 | case GL_TEXTURE_2D_ARRAY: |
shannon.woods%transgaming.com@gtempaccount.com | 14e8f59 | 2013-04-13 03:46:21 +0000 | [diff] [blame] | 8509 | { |
| 8510 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 8511 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 8512 | format, imageSize, data); |
| 8513 | } |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 8514 | break; |
| 8515 | |
| 8516 | default: |
| 8517 | return gl::error(GL_INVALID_ENUM); |
| 8518 | } |
| 8519 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8520 | } |
| 8521 | catch(std::bad_alloc&) |
| 8522 | { |
| 8523 | return gl::error(GL_OUT_OF_MEMORY); |
| 8524 | } |
| 8525 | } |
| 8526 | |
| 8527 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 8528 | { |
| 8529 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8530 | |
| 8531 | try |
| 8532 | { |
| 8533 | gl::Context *context = gl::getNonLostContext(); |
| 8534 | |
| 8535 | if (context) |
| 8536 | { |
| 8537 | if (context->getClientVersion() < 3) |
| 8538 | { |
| 8539 | return gl::error(GL_INVALID_OPERATION); |
| 8540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8541 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8542 | // glGenQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8543 | UNIMPLEMENTED(); |
| 8544 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8545 | } |
| 8546 | catch(std::bad_alloc&) |
| 8547 | { |
| 8548 | return gl::error(GL_OUT_OF_MEMORY); |
| 8549 | } |
| 8550 | } |
| 8551 | |
| 8552 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 8553 | { |
| 8554 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8555 | |
| 8556 | try |
| 8557 | { |
| 8558 | gl::Context *context = gl::getNonLostContext(); |
| 8559 | |
| 8560 | if (context) |
| 8561 | { |
| 8562 | if (context->getClientVersion() < 3) |
| 8563 | { |
| 8564 | return gl::error(GL_INVALID_OPERATION); |
| 8565 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8566 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8567 | // glDeleteQueries |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8568 | UNIMPLEMENTED(); |
| 8569 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8570 | } |
| 8571 | catch(std::bad_alloc&) |
| 8572 | { |
| 8573 | return gl::error(GL_OUT_OF_MEMORY); |
| 8574 | } |
| 8575 | } |
| 8576 | |
| 8577 | GLboolean __stdcall glIsQuery(GLuint id) |
| 8578 | { |
| 8579 | EVENT("(GLuint id = %u)", id); |
| 8580 | |
| 8581 | try |
| 8582 | { |
| 8583 | gl::Context *context = gl::getNonLostContext(); |
| 8584 | |
| 8585 | if (context) |
| 8586 | { |
| 8587 | if (context->getClientVersion() < 3) |
| 8588 | { |
| 8589 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8590 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8591 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8592 | // glIsQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8593 | UNIMPLEMENTED(); |
| 8594 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8595 | } |
| 8596 | catch(std::bad_alloc&) |
| 8597 | { |
| 8598 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8599 | } |
| 8600 | |
| 8601 | return GL_FALSE; |
| 8602 | } |
| 8603 | |
| 8604 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 8605 | { |
| 8606 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 8607 | |
| 8608 | try |
| 8609 | { |
| 8610 | gl::Context *context = gl::getNonLostContext(); |
| 8611 | |
| 8612 | if (context) |
| 8613 | { |
| 8614 | if (context->getClientVersion() < 3) |
| 8615 | { |
| 8616 | return gl::error(GL_INVALID_OPERATION); |
| 8617 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8618 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8619 | // glBeginQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8620 | UNIMPLEMENTED(); |
| 8621 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8622 | } |
| 8623 | catch(std::bad_alloc&) |
| 8624 | { |
| 8625 | return gl::error(GL_OUT_OF_MEMORY); |
| 8626 | } |
| 8627 | } |
| 8628 | |
| 8629 | void __stdcall glEndQuery(GLenum target) |
| 8630 | { |
| 8631 | EVENT("(GLenum target = 0x%X)", target); |
| 8632 | |
| 8633 | try |
| 8634 | { |
| 8635 | gl::Context *context = gl::getNonLostContext(); |
| 8636 | |
| 8637 | if (context) |
| 8638 | { |
| 8639 | if (context->getClientVersion() < 3) |
| 8640 | { |
| 8641 | return gl::error(GL_INVALID_OPERATION); |
| 8642 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8643 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8644 | // glEndQuery |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8645 | UNIMPLEMENTED(); |
| 8646 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8647 | } |
| 8648 | catch(std::bad_alloc&) |
| 8649 | { |
| 8650 | return gl::error(GL_OUT_OF_MEMORY); |
| 8651 | } |
| 8652 | } |
| 8653 | |
| 8654 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 8655 | { |
| 8656 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 8657 | |
| 8658 | try |
| 8659 | { |
| 8660 | gl::Context *context = gl::getNonLostContext(); |
| 8661 | |
| 8662 | if (context) |
| 8663 | { |
| 8664 | if (context->getClientVersion() < 3) |
| 8665 | { |
| 8666 | return gl::error(GL_INVALID_OPERATION); |
| 8667 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8668 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8669 | // glGetQueryiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8670 | UNIMPLEMENTED(); |
| 8671 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8672 | } |
| 8673 | catch(std::bad_alloc&) |
| 8674 | { |
| 8675 | return gl::error(GL_OUT_OF_MEMORY); |
| 8676 | } |
| 8677 | } |
| 8678 | |
| 8679 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 8680 | { |
| 8681 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 8682 | |
| 8683 | try |
| 8684 | { |
| 8685 | gl::Context *context = gl::getNonLostContext(); |
| 8686 | |
| 8687 | if (context) |
| 8688 | { |
| 8689 | if (context->getClientVersion() < 3) |
| 8690 | { |
| 8691 | return gl::error(GL_INVALID_OPERATION); |
| 8692 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8693 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8694 | // glGetQueryObjectuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8695 | UNIMPLEMENTED(); |
| 8696 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8697 | } |
| 8698 | catch(std::bad_alloc&) |
| 8699 | { |
| 8700 | return gl::error(GL_OUT_OF_MEMORY); |
| 8701 | } |
| 8702 | } |
| 8703 | |
| 8704 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 8705 | { |
| 8706 | EVENT("(GLenum target = 0x%X)", target); |
| 8707 | |
| 8708 | try |
| 8709 | { |
| 8710 | gl::Context *context = gl::getNonLostContext(); |
| 8711 | |
| 8712 | if (context) |
| 8713 | { |
| 8714 | if (context->getClientVersion() < 3) |
| 8715 | { |
| 8716 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8717 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8718 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8719 | // glUnmapBuffer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8720 | UNIMPLEMENTED(); |
| 8721 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8722 | } |
| 8723 | catch(std::bad_alloc&) |
| 8724 | { |
| 8725 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 8726 | } |
| 8727 | |
| 8728 | return GL_FALSE; |
| 8729 | } |
| 8730 | |
| 8731 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 8732 | { |
| 8733 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8734 | |
| 8735 | try |
| 8736 | { |
| 8737 | gl::Context *context = gl::getNonLostContext(); |
| 8738 | |
| 8739 | if (context) |
| 8740 | { |
| 8741 | if (context->getClientVersion() < 3) |
| 8742 | { |
| 8743 | return gl::error(GL_INVALID_OPERATION); |
| 8744 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8745 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 8746 | // glGetBufferPointerv |
shannonwoods@chromium.org | 2d2190a | 2013-05-30 00:17:35 +0000 | [diff] [blame] | 8747 | UNIMPLEMENTED(); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8748 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8749 | } |
| 8750 | catch(std::bad_alloc&) |
| 8751 | { |
| 8752 | return gl::error(GL_OUT_OF_MEMORY); |
| 8753 | } |
| 8754 | } |
| 8755 | |
| 8756 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 8757 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8758 | try |
| 8759 | { |
| 8760 | gl::Context *context = gl::getNonLostContext(); |
| 8761 | |
| 8762 | if (context) |
| 8763 | { |
| 8764 | if (context->getClientVersion() < 3) |
| 8765 | { |
| 8766 | return gl::error(GL_INVALID_OPERATION); |
| 8767 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8768 | |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 8769 | glDrawBuffersEXT(n, bufs); |
| 8770 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8771 | } |
| 8772 | catch(std::bad_alloc&) |
| 8773 | { |
| 8774 | return gl::error(GL_OUT_OF_MEMORY); |
| 8775 | } |
| 8776 | } |
| 8777 | |
| 8778 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8779 | { |
| 8780 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8781 | location, count, transpose, value); |
| 8782 | |
| 8783 | try |
| 8784 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8785 | if (count < 0) |
| 8786 | { |
| 8787 | return gl::error(GL_INVALID_VALUE); |
| 8788 | } |
| 8789 | |
| 8790 | if (location == -1) |
| 8791 | { |
| 8792 | return; |
| 8793 | } |
| 8794 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8795 | gl::Context *context = gl::getNonLostContext(); |
| 8796 | |
| 8797 | if (context) |
| 8798 | { |
| 8799 | if (context->getClientVersion() < 3) |
| 8800 | { |
| 8801 | return gl::error(GL_INVALID_OPERATION); |
| 8802 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8803 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8804 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8805 | if (!programBinary) |
| 8806 | { |
| 8807 | return gl::error(GL_INVALID_OPERATION); |
| 8808 | } |
| 8809 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8810 | if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8811 | { |
| 8812 | return gl::error(GL_INVALID_OPERATION); |
| 8813 | } |
| 8814 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8815 | } |
| 8816 | catch(std::bad_alloc&) |
| 8817 | { |
| 8818 | return gl::error(GL_OUT_OF_MEMORY); |
| 8819 | } |
| 8820 | } |
| 8821 | |
| 8822 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8823 | { |
| 8824 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8825 | location, count, transpose, value); |
| 8826 | |
| 8827 | try |
| 8828 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8829 | if (count < 0) |
| 8830 | { |
| 8831 | return gl::error(GL_INVALID_VALUE); |
| 8832 | } |
| 8833 | |
| 8834 | if (location == -1) |
| 8835 | { |
| 8836 | return; |
| 8837 | } |
| 8838 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8839 | gl::Context *context = gl::getNonLostContext(); |
| 8840 | |
| 8841 | if (context) |
| 8842 | { |
| 8843 | if (context->getClientVersion() < 3) |
| 8844 | { |
| 8845 | return gl::error(GL_INVALID_OPERATION); |
| 8846 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8847 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8848 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8849 | if (!programBinary) |
| 8850 | { |
| 8851 | return gl::error(GL_INVALID_OPERATION); |
| 8852 | } |
| 8853 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8854 | if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8855 | { |
| 8856 | return gl::error(GL_INVALID_OPERATION); |
| 8857 | } |
| 8858 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8859 | } |
| 8860 | catch(std::bad_alloc&) |
| 8861 | { |
| 8862 | return gl::error(GL_OUT_OF_MEMORY); |
| 8863 | } |
| 8864 | } |
| 8865 | |
| 8866 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8867 | { |
| 8868 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8869 | location, count, transpose, value); |
| 8870 | |
| 8871 | try |
| 8872 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8873 | if (count < 0) |
| 8874 | { |
| 8875 | return gl::error(GL_INVALID_VALUE); |
| 8876 | } |
| 8877 | |
| 8878 | if (location == -1) |
| 8879 | { |
| 8880 | return; |
| 8881 | } |
| 8882 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8883 | gl::Context *context = gl::getNonLostContext(); |
| 8884 | |
| 8885 | if (context) |
| 8886 | { |
| 8887 | if (context->getClientVersion() < 3) |
| 8888 | { |
| 8889 | return gl::error(GL_INVALID_OPERATION); |
| 8890 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8891 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8892 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8893 | if (!programBinary) |
| 8894 | { |
| 8895 | return gl::error(GL_INVALID_OPERATION); |
| 8896 | } |
| 8897 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8898 | if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8899 | { |
| 8900 | return gl::error(GL_INVALID_OPERATION); |
| 8901 | } |
| 8902 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8903 | } |
| 8904 | catch(std::bad_alloc&) |
| 8905 | { |
| 8906 | return gl::error(GL_OUT_OF_MEMORY); |
| 8907 | } |
| 8908 | } |
| 8909 | |
| 8910 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8911 | { |
| 8912 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8913 | location, count, transpose, value); |
| 8914 | |
| 8915 | try |
| 8916 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8917 | if (count < 0) |
| 8918 | { |
| 8919 | return gl::error(GL_INVALID_VALUE); |
| 8920 | } |
| 8921 | |
| 8922 | if (location == -1) |
| 8923 | { |
| 8924 | return; |
| 8925 | } |
| 8926 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8927 | gl::Context *context = gl::getNonLostContext(); |
| 8928 | |
| 8929 | if (context) |
| 8930 | { |
| 8931 | if (context->getClientVersion() < 3) |
| 8932 | { |
| 8933 | return gl::error(GL_INVALID_OPERATION); |
| 8934 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8935 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8936 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8937 | if (!programBinary) |
| 8938 | { |
| 8939 | return gl::error(GL_INVALID_OPERATION); |
| 8940 | } |
| 8941 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8942 | if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8943 | { |
| 8944 | return gl::error(GL_INVALID_OPERATION); |
| 8945 | } |
| 8946 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8947 | } |
| 8948 | catch(std::bad_alloc&) |
| 8949 | { |
| 8950 | return gl::error(GL_OUT_OF_MEMORY); |
| 8951 | } |
| 8952 | } |
| 8953 | |
| 8954 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8955 | { |
| 8956 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 8957 | location, count, transpose, value); |
| 8958 | |
| 8959 | try |
| 8960 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8961 | if (count < 0) |
| 8962 | { |
| 8963 | return gl::error(GL_INVALID_VALUE); |
| 8964 | } |
| 8965 | |
| 8966 | if (location == -1) |
| 8967 | { |
| 8968 | return; |
| 8969 | } |
| 8970 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8971 | gl::Context *context = gl::getNonLostContext(); |
| 8972 | |
| 8973 | if (context) |
| 8974 | { |
| 8975 | if (context->getClientVersion() < 3) |
| 8976 | { |
| 8977 | return gl::error(GL_INVALID_OPERATION); |
| 8978 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8979 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8980 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 8981 | if (!programBinary) |
| 8982 | { |
| 8983 | return gl::error(GL_INVALID_OPERATION); |
| 8984 | } |
| 8985 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 8986 | if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 8987 | { |
| 8988 | return gl::error(GL_INVALID_OPERATION); |
| 8989 | } |
| 8990 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8991 | } |
| 8992 | catch(std::bad_alloc&) |
| 8993 | { |
| 8994 | return gl::error(GL_OUT_OF_MEMORY); |
| 8995 | } |
| 8996 | } |
| 8997 | |
| 8998 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 8999 | { |
| 9000 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 9001 | location, count, transpose, value); |
| 9002 | |
| 9003 | try |
| 9004 | { |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9005 | if (count < 0) |
| 9006 | { |
| 9007 | return gl::error(GL_INVALID_VALUE); |
| 9008 | } |
| 9009 | |
| 9010 | if (location == -1) |
| 9011 | { |
| 9012 | return; |
| 9013 | } |
| 9014 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9015 | gl::Context *context = gl::getNonLostContext(); |
| 9016 | |
| 9017 | if (context) |
| 9018 | { |
| 9019 | if (context->getClientVersion() < 3) |
| 9020 | { |
| 9021 | return gl::error(GL_INVALID_OPERATION); |
| 9022 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9023 | |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9024 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9025 | if (!programBinary) |
| 9026 | { |
| 9027 | return gl::error(GL_INVALID_OPERATION); |
| 9028 | } |
| 9029 | |
shannon.woods%transgaming.com@gtempaccount.com | a741b64 | 2013-04-13 03:40:10 +0000 | [diff] [blame] | 9030 | if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value)) |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 9031 | { |
| 9032 | return gl::error(GL_INVALID_OPERATION); |
| 9033 | } |
| 9034 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9035 | } |
| 9036 | catch(std::bad_alloc&) |
| 9037 | { |
| 9038 | return gl::error(GL_OUT_OF_MEMORY); |
| 9039 | } |
| 9040 | } |
| 9041 | |
| 9042 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 9043 | { |
| 9044 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 9045 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 9046 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 9047 | |
| 9048 | try |
| 9049 | { |
| 9050 | gl::Context *context = gl::getNonLostContext(); |
| 9051 | |
| 9052 | if (context) |
| 9053 | { |
| 9054 | if (context->getClientVersion() < 3) |
| 9055 | { |
| 9056 | return gl::error(GL_INVALID_OPERATION); |
| 9057 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9058 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 9059 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 9060 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 9061 | false)) |
| 9062 | { |
| 9063 | return; |
| 9064 | } |
| 9065 | |
| 9066 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 9067 | mask, filter); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9068 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9069 | } |
| 9070 | catch(std::bad_alloc&) |
| 9071 | { |
| 9072 | return gl::error(GL_OUT_OF_MEMORY); |
| 9073 | } |
| 9074 | } |
| 9075 | |
| 9076 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 9077 | { |
| 9078 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 9079 | target, samples, internalformat, width, height); |
| 9080 | |
| 9081 | try |
| 9082 | { |
| 9083 | gl::Context *context = gl::getNonLostContext(); |
| 9084 | |
| 9085 | if (context) |
| 9086 | { |
| 9087 | if (context->getClientVersion() < 3) |
| 9088 | { |
| 9089 | return gl::error(GL_INVALID_OPERATION); |
| 9090 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9091 | |
Geoff Lang | 2e1dcd5 | 2013-05-29 10:34:08 -0400 | [diff] [blame] | 9092 | if (!validateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 9093 | width, height, false)) |
| 9094 | { |
| 9095 | return; |
| 9096 | } |
| 9097 | |
| 9098 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9099 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9100 | } |
| 9101 | catch(std::bad_alloc&) |
| 9102 | { |
| 9103 | return gl::error(GL_OUT_OF_MEMORY); |
| 9104 | } |
| 9105 | } |
| 9106 | |
| 9107 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 9108 | { |
| 9109 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 9110 | target, attachment, texture, level, layer); |
| 9111 | |
| 9112 | try |
| 9113 | { |
| 9114 | gl::Context *context = gl::getNonLostContext(); |
| 9115 | |
| 9116 | if (context) |
| 9117 | { |
| 9118 | if (context->getClientVersion() < 3) |
| 9119 | { |
| 9120 | return gl::error(GL_INVALID_OPERATION); |
| 9121 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9122 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9123 | // glFramebufferTextureLayer |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9124 | UNIMPLEMENTED(); |
| 9125 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9126 | } |
| 9127 | catch(std::bad_alloc&) |
| 9128 | { |
| 9129 | return gl::error(GL_OUT_OF_MEMORY); |
| 9130 | } |
| 9131 | } |
| 9132 | |
| 9133 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 9134 | { |
| 9135 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 9136 | target, offset, length, access); |
| 9137 | |
| 9138 | try |
| 9139 | { |
| 9140 | gl::Context *context = gl::getNonLostContext(); |
| 9141 | |
| 9142 | if (context) |
| 9143 | { |
| 9144 | if (context->getClientVersion() < 3) |
| 9145 | { |
| 9146 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 9147 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9148 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9149 | // glMapBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9150 | UNIMPLEMENTED(); |
| 9151 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9152 | } |
| 9153 | catch(std::bad_alloc&) |
| 9154 | { |
| 9155 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL)); |
| 9156 | } |
| 9157 | |
| 9158 | return NULL; |
| 9159 | } |
| 9160 | |
| 9161 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 9162 | { |
| 9163 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 9164 | |
| 9165 | try |
| 9166 | { |
| 9167 | gl::Context *context = gl::getNonLostContext(); |
| 9168 | |
| 9169 | if (context) |
| 9170 | { |
| 9171 | if (context->getClientVersion() < 3) |
| 9172 | { |
| 9173 | return gl::error(GL_INVALID_OPERATION); |
| 9174 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9175 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9176 | // glFlushMappedBufferRange |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9177 | UNIMPLEMENTED(); |
| 9178 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9179 | } |
| 9180 | catch(std::bad_alloc&) |
| 9181 | { |
| 9182 | return gl::error(GL_OUT_OF_MEMORY); |
| 9183 | } |
| 9184 | } |
| 9185 | |
| 9186 | void __stdcall glBindVertexArray(GLuint array) |
| 9187 | { |
| 9188 | EVENT("(GLuint array = %u)", array); |
| 9189 | |
| 9190 | try |
| 9191 | { |
| 9192 | gl::Context *context = gl::getNonLostContext(); |
| 9193 | |
| 9194 | if (context) |
| 9195 | { |
| 9196 | if (context->getClientVersion() < 3) |
| 9197 | { |
| 9198 | return gl::error(GL_INVALID_OPERATION); |
| 9199 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9200 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9201 | // glBindVertexArray |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9202 | UNIMPLEMENTED(); |
| 9203 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9204 | } |
| 9205 | catch(std::bad_alloc&) |
| 9206 | { |
| 9207 | return gl::error(GL_OUT_OF_MEMORY); |
| 9208 | } |
| 9209 | } |
| 9210 | |
| 9211 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 9212 | { |
| 9213 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9214 | |
| 9215 | try |
| 9216 | { |
| 9217 | gl::Context *context = gl::getNonLostContext(); |
| 9218 | |
| 9219 | if (context) |
| 9220 | { |
| 9221 | if (context->getClientVersion() < 3) |
| 9222 | { |
| 9223 | return gl::error(GL_INVALID_OPERATION); |
| 9224 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9225 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9226 | // glDeleteVertexArrays |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9227 | UNIMPLEMENTED(); |
| 9228 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9229 | } |
| 9230 | catch(std::bad_alloc&) |
| 9231 | { |
| 9232 | return gl::error(GL_OUT_OF_MEMORY); |
| 9233 | } |
| 9234 | } |
| 9235 | |
| 9236 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 9237 | { |
| 9238 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 9239 | |
| 9240 | try |
| 9241 | { |
| 9242 | gl::Context *context = gl::getNonLostContext(); |
| 9243 | |
| 9244 | if (context) |
| 9245 | { |
| 9246 | if (context->getClientVersion() < 3) |
| 9247 | { |
| 9248 | return gl::error(GL_INVALID_OPERATION); |
| 9249 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9250 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9251 | // glGenVertexArrays |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9252 | UNIMPLEMENTED(); |
| 9253 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9254 | } |
| 9255 | catch(std::bad_alloc&) |
| 9256 | { |
| 9257 | return gl::error(GL_OUT_OF_MEMORY); |
| 9258 | } |
| 9259 | } |
| 9260 | |
| 9261 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 9262 | { |
| 9263 | EVENT("(GLuint array = %u)", array); |
| 9264 | |
| 9265 | try |
| 9266 | { |
| 9267 | gl::Context *context = gl::getNonLostContext(); |
| 9268 | |
| 9269 | if (context) |
| 9270 | { |
| 9271 | if (context->getClientVersion() < 3) |
| 9272 | { |
| 9273 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 9274 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9275 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9276 | // glIsVertexArray |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9277 | UNIMPLEMENTED(); |
| 9278 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9279 | } |
| 9280 | catch(std::bad_alloc&) |
| 9281 | { |
| 9282 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 9283 | } |
| 9284 | |
| 9285 | return GL_FALSE; |
| 9286 | } |
| 9287 | |
| 9288 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 9289 | { |
| 9290 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 9291 | target, index, data); |
| 9292 | |
| 9293 | try |
| 9294 | { |
| 9295 | gl::Context *context = gl::getNonLostContext(); |
| 9296 | |
| 9297 | if (context) |
| 9298 | { |
| 9299 | if (context->getClientVersion() < 3) |
| 9300 | { |
| 9301 | return gl::error(GL_INVALID_OPERATION); |
| 9302 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9303 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9304 | // glGetIntegeri_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9305 | UNIMPLEMENTED(); |
| 9306 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9307 | } |
| 9308 | catch(std::bad_alloc&) |
| 9309 | { |
| 9310 | return gl::error(GL_OUT_OF_MEMORY); |
| 9311 | } |
| 9312 | } |
| 9313 | |
| 9314 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 9315 | { |
| 9316 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 9317 | |
| 9318 | try |
| 9319 | { |
| 9320 | gl::Context *context = gl::getNonLostContext(); |
| 9321 | |
| 9322 | if (context) |
| 9323 | { |
| 9324 | if (context->getClientVersion() < 3) |
| 9325 | { |
| 9326 | return gl::error(GL_INVALID_OPERATION); |
| 9327 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9328 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9329 | // glBeginTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9330 | UNIMPLEMENTED(); |
| 9331 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9332 | } |
| 9333 | catch(std::bad_alloc&) |
| 9334 | { |
| 9335 | return gl::error(GL_OUT_OF_MEMORY); |
| 9336 | } |
| 9337 | } |
| 9338 | |
| 9339 | void __stdcall glEndTransformFeedback(void) |
| 9340 | { |
| 9341 | EVENT("(void)"); |
| 9342 | |
| 9343 | try |
| 9344 | { |
| 9345 | gl::Context *context = gl::getNonLostContext(); |
| 9346 | |
| 9347 | if (context) |
| 9348 | { |
| 9349 | if (context->getClientVersion() < 3) |
| 9350 | { |
| 9351 | return gl::error(GL_INVALID_OPERATION); |
| 9352 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9353 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9354 | // glEndTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9355 | UNIMPLEMENTED(); |
| 9356 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9357 | } |
| 9358 | catch(std::bad_alloc&) |
| 9359 | { |
| 9360 | return gl::error(GL_OUT_OF_MEMORY); |
| 9361 | } |
| 9362 | } |
| 9363 | |
| 9364 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 9365 | { |
| 9366 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 9367 | target, index, buffer, offset, size); |
| 9368 | |
| 9369 | try |
| 9370 | { |
| 9371 | gl::Context *context = gl::getNonLostContext(); |
| 9372 | |
| 9373 | if (context) |
| 9374 | { |
| 9375 | if (context->getClientVersion() < 3) |
| 9376 | { |
| 9377 | return gl::error(GL_INVALID_OPERATION); |
| 9378 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9379 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9380 | switch (target) |
| 9381 | { |
| 9382 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9383 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9384 | { |
| 9385 | return gl::error(GL_INVALID_VALUE); |
| 9386 | } |
| 9387 | break; |
| 9388 | |
| 9389 | case GL_UNIFORM_BUFFER: |
| 9390 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 9391 | { |
| 9392 | return gl::error(GL_INVALID_VALUE); |
| 9393 | } |
| 9394 | break; |
| 9395 | |
| 9396 | default: |
| 9397 | return gl::error(GL_INVALID_ENUM); |
| 9398 | } |
| 9399 | |
shannonwoods@chromium.org | e6e0079 | 2013-05-30 00:06:07 +0000 | [diff] [blame] | 9400 | if (buffer != 0 && size <= 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9401 | { |
| 9402 | return gl::error(GL_INVALID_VALUE); |
| 9403 | } |
| 9404 | |
| 9405 | switch (target) |
| 9406 | { |
| 9407 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | a26aeaf | 2013-05-30 00:06:13 +0000 | [diff] [blame] | 9408 | |
| 9409 | // size and offset must be a multiple of 4 |
| 9410 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
| 9411 | { |
| 9412 | return gl::error(GL_INVALID_VALUE); |
| 9413 | } |
| 9414 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9415 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 9416 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9417 | break; |
| 9418 | |
| 9419 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 97c3d50 | 2013-05-30 00:04:34 +0000 | [diff] [blame] | 9420 | |
| 9421 | // it is an error to bind an offset not a multiple of the alignment |
| 9422 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
| 9423 | { |
| 9424 | return gl::error(GL_INVALID_VALUE); |
| 9425 | } |
| 9426 | |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9427 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 9428 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9429 | break; |
| 9430 | |
| 9431 | default: |
| 9432 | UNREACHABLE(); |
| 9433 | } |
| 9434 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9435 | } |
| 9436 | catch(std::bad_alloc&) |
| 9437 | { |
| 9438 | return gl::error(GL_OUT_OF_MEMORY); |
| 9439 | } |
| 9440 | } |
| 9441 | |
| 9442 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 9443 | { |
| 9444 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 9445 | target, index, buffer); |
| 9446 | |
| 9447 | try |
| 9448 | { |
| 9449 | gl::Context *context = gl::getNonLostContext(); |
| 9450 | |
| 9451 | if (context) |
| 9452 | { |
| 9453 | if (context->getClientVersion() < 3) |
| 9454 | { |
| 9455 | return gl::error(GL_INVALID_OPERATION); |
| 9456 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9457 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9458 | switch (target) |
| 9459 | { |
| 9460 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9461 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9462 | { |
| 9463 | return gl::error(GL_INVALID_VALUE); |
| 9464 | } |
| 9465 | break; |
| 9466 | |
| 9467 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | d11158f | 2013-05-30 00:06:19 +0000 | [diff] [blame] | 9468 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9469 | { |
| 9470 | return gl::error(GL_INVALID_VALUE); |
| 9471 | } |
| 9472 | break; |
| 9473 | |
| 9474 | default: |
| 9475 | return gl::error(GL_INVALID_ENUM); |
| 9476 | } |
| 9477 | |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9478 | switch (target) |
| 9479 | { |
| 9480 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9481 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9482 | context->bindGenericTransformFeedbackBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9483 | break; |
| 9484 | |
| 9485 | case GL_UNIFORM_BUFFER: |
shannonwoods@chromium.org | 3eeca1e | 2013-05-30 00:04:28 +0000 | [diff] [blame] | 9486 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
shannon.woods%transgaming.com@gtempaccount.com | 667a29c | 2013-04-13 03:39:04 +0000 | [diff] [blame] | 9487 | context->bindGenericUniformBuffer(buffer); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 9488 | break; |
| 9489 | |
| 9490 | default: |
| 9491 | UNREACHABLE(); |
| 9492 | } |
| 9493 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9494 | } |
| 9495 | catch(std::bad_alloc&) |
| 9496 | { |
| 9497 | return gl::error(GL_OUT_OF_MEMORY); |
| 9498 | } |
| 9499 | } |
| 9500 | |
| 9501 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 9502 | { |
| 9503 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 9504 | program, count, varyings, bufferMode); |
| 9505 | |
| 9506 | try |
| 9507 | { |
| 9508 | gl::Context *context = gl::getNonLostContext(); |
| 9509 | |
| 9510 | if (context) |
| 9511 | { |
| 9512 | if (context->getClientVersion() < 3) |
| 9513 | { |
| 9514 | return gl::error(GL_INVALID_OPERATION); |
| 9515 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9516 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9517 | // glTransformFeedbackVaryings |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9518 | UNIMPLEMENTED(); |
| 9519 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9520 | } |
| 9521 | catch(std::bad_alloc&) |
| 9522 | { |
| 9523 | return gl::error(GL_OUT_OF_MEMORY); |
| 9524 | } |
| 9525 | } |
| 9526 | |
| 9527 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 9528 | { |
| 9529 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 9530 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 9531 | program, index, bufSize, length, size, type, name); |
| 9532 | |
| 9533 | try |
| 9534 | { |
| 9535 | gl::Context *context = gl::getNonLostContext(); |
| 9536 | |
| 9537 | if (context) |
| 9538 | { |
| 9539 | if (context->getClientVersion() < 3) |
| 9540 | { |
| 9541 | return gl::error(GL_INVALID_OPERATION); |
| 9542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9543 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9544 | // glGetTransformFeedbackVarying |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9545 | UNIMPLEMENTED(); |
| 9546 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9547 | } |
| 9548 | catch(std::bad_alloc&) |
| 9549 | { |
| 9550 | return gl::error(GL_OUT_OF_MEMORY); |
| 9551 | } |
| 9552 | } |
| 9553 | |
| 9554 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 9555 | { |
| 9556 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 9557 | index, size, type, stride, pointer); |
| 9558 | |
| 9559 | try |
| 9560 | { |
| 9561 | gl::Context *context = gl::getNonLostContext(); |
| 9562 | |
| 9563 | if (context) |
| 9564 | { |
| 9565 | if (context->getClientVersion() < 3) |
| 9566 | { |
| 9567 | return gl::error(GL_INVALID_OPERATION); |
| 9568 | } |
| 9569 | } |
| 9570 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9571 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9572 | { |
| 9573 | return gl::error(GL_INVALID_VALUE); |
| 9574 | } |
| 9575 | |
| 9576 | if (size < 1 || size > 4) |
| 9577 | { |
| 9578 | return gl::error(GL_INVALID_VALUE); |
| 9579 | } |
| 9580 | |
| 9581 | switch (type) |
| 9582 | { |
| 9583 | case GL_BYTE: |
| 9584 | case GL_UNSIGNED_BYTE: |
| 9585 | case GL_SHORT: |
| 9586 | case GL_UNSIGNED_SHORT: |
| 9587 | case GL_INT: |
| 9588 | case GL_UNSIGNED_INT: |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9589 | case GL_INT_2_10_10_10_REV: |
| 9590 | 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] | 9591 | break; |
| 9592 | default: |
| 9593 | return gl::error(GL_INVALID_ENUM); |
| 9594 | } |
| 9595 | |
| 9596 | if (stride < 0) |
| 9597 | { |
| 9598 | return gl::error(GL_INVALID_VALUE); |
| 9599 | } |
| 9600 | |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 9601 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 9602 | { |
| 9603 | return gl::error(GL_INVALID_OPERATION); |
| 9604 | } |
| 9605 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9606 | if (context) |
| 9607 | { |
| 9608 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true, |
| 9609 | stride, pointer); |
| 9610 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9611 | } |
| 9612 | catch(std::bad_alloc&) |
| 9613 | { |
| 9614 | return gl::error(GL_OUT_OF_MEMORY); |
| 9615 | } |
| 9616 | } |
| 9617 | |
| 9618 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 9619 | { |
| 9620 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 9621 | index, pname, params); |
| 9622 | |
| 9623 | try |
| 9624 | { |
| 9625 | gl::Context *context = gl::getNonLostContext(); |
| 9626 | |
| 9627 | if (context) |
| 9628 | { |
| 9629 | if (context->getClientVersion() < 3) |
| 9630 | { |
| 9631 | return gl::error(GL_INVALID_OPERATION); |
| 9632 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9633 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9634 | // glGetVertexAttribIiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9635 | UNIMPLEMENTED(); |
| 9636 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9637 | } |
| 9638 | catch(std::bad_alloc&) |
| 9639 | { |
| 9640 | return gl::error(GL_OUT_OF_MEMORY); |
| 9641 | } |
| 9642 | } |
| 9643 | |
| 9644 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 9645 | { |
| 9646 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 9647 | index, pname, params); |
| 9648 | |
| 9649 | try |
| 9650 | { |
| 9651 | gl::Context *context = gl::getNonLostContext(); |
| 9652 | |
| 9653 | if (context) |
| 9654 | { |
| 9655 | if (context->getClientVersion() < 3) |
| 9656 | { |
| 9657 | return gl::error(GL_INVALID_OPERATION); |
| 9658 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9659 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 9660 | // glGetVertexAttribIuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9661 | UNIMPLEMENTED(); |
| 9662 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9663 | } |
| 9664 | catch(std::bad_alloc&) |
| 9665 | { |
| 9666 | return gl::error(GL_OUT_OF_MEMORY); |
| 9667 | } |
| 9668 | } |
| 9669 | |
| 9670 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 9671 | { |
| 9672 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 9673 | index, x, y, z, w); |
| 9674 | |
| 9675 | try |
| 9676 | { |
| 9677 | gl::Context *context = gl::getNonLostContext(); |
| 9678 | |
| 9679 | if (context) |
| 9680 | { |
| 9681 | if (context->getClientVersion() < 3) |
| 9682 | { |
| 9683 | return gl::error(GL_INVALID_OPERATION); |
| 9684 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9685 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9686 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9687 | { |
| 9688 | return gl::error(GL_INVALID_VALUE); |
| 9689 | } |
| 9690 | |
| 9691 | GLint vals[4] = { x, y, z, w }; |
| 9692 | context->setVertexAttribi(index, vals); |
| 9693 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9694 | } |
| 9695 | catch(std::bad_alloc&) |
| 9696 | { |
| 9697 | return gl::error(GL_OUT_OF_MEMORY); |
| 9698 | } |
| 9699 | } |
| 9700 | |
| 9701 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 9702 | { |
| 9703 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 9704 | index, x, y, z, w); |
| 9705 | |
| 9706 | try |
| 9707 | { |
| 9708 | gl::Context *context = gl::getNonLostContext(); |
| 9709 | |
| 9710 | if (context) |
| 9711 | { |
| 9712 | if (context->getClientVersion() < 3) |
| 9713 | { |
| 9714 | return gl::error(GL_INVALID_OPERATION); |
| 9715 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9716 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9717 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9718 | { |
| 9719 | return gl::error(GL_INVALID_VALUE); |
| 9720 | } |
| 9721 | |
| 9722 | GLuint vals[4] = { x, y, z, w }; |
| 9723 | context->setVertexAttribu(index, vals); |
| 9724 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9725 | } |
| 9726 | catch(std::bad_alloc&) |
| 9727 | { |
| 9728 | return gl::error(GL_OUT_OF_MEMORY); |
| 9729 | } |
| 9730 | } |
| 9731 | |
| 9732 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 9733 | { |
| 9734 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 9735 | |
| 9736 | try |
| 9737 | { |
| 9738 | gl::Context *context = gl::getNonLostContext(); |
| 9739 | |
| 9740 | if (context) |
| 9741 | { |
| 9742 | if (context->getClientVersion() < 3) |
| 9743 | { |
| 9744 | return gl::error(GL_INVALID_OPERATION); |
| 9745 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9746 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9747 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9748 | { |
| 9749 | return gl::error(GL_INVALID_VALUE); |
| 9750 | } |
| 9751 | |
| 9752 | context->setVertexAttribi(index, v); |
| 9753 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9754 | } |
| 9755 | catch(std::bad_alloc&) |
| 9756 | { |
| 9757 | return gl::error(GL_OUT_OF_MEMORY); |
| 9758 | } |
| 9759 | } |
| 9760 | |
| 9761 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 9762 | { |
| 9763 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 9764 | |
| 9765 | try |
| 9766 | { |
| 9767 | gl::Context *context = gl::getNonLostContext(); |
| 9768 | |
| 9769 | if (context) |
| 9770 | { |
| 9771 | if (context->getClientVersion() < 3) |
| 9772 | { |
| 9773 | return gl::error(GL_INVALID_OPERATION); |
| 9774 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9775 | |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 9776 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 9777 | { |
| 9778 | return gl::error(GL_INVALID_VALUE); |
| 9779 | } |
| 9780 | |
| 9781 | context->setVertexAttribu(index, v); |
| 9782 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9783 | } |
| 9784 | catch(std::bad_alloc&) |
| 9785 | { |
| 9786 | return gl::error(GL_OUT_OF_MEMORY); |
| 9787 | } |
| 9788 | } |
| 9789 | |
| 9790 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 9791 | { |
| 9792 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 9793 | program, location, params); |
| 9794 | |
| 9795 | try |
| 9796 | { |
| 9797 | gl::Context *context = gl::getNonLostContext(); |
| 9798 | |
| 9799 | if (context) |
| 9800 | { |
| 9801 | if (context->getClientVersion() < 3) |
| 9802 | { |
| 9803 | return gl::error(GL_INVALID_OPERATION); |
| 9804 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9805 | |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 9806 | if (program == 0) |
| 9807 | { |
| 9808 | return gl::error(GL_INVALID_VALUE); |
| 9809 | } |
| 9810 | |
| 9811 | gl::Program *programObject = context->getProgram(program); |
| 9812 | |
| 9813 | if (!programObject || !programObject->isLinked()) |
| 9814 | { |
| 9815 | return gl::error(GL_INVALID_OPERATION); |
| 9816 | } |
| 9817 | |
| 9818 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9819 | if (!programBinary) |
| 9820 | { |
| 9821 | return gl::error(GL_INVALID_OPERATION); |
| 9822 | } |
| 9823 | |
| 9824 | if (!programBinary->getUniformuiv(location, NULL, params)) |
| 9825 | { |
| 9826 | return gl::error(GL_INVALID_OPERATION); |
| 9827 | } |
| 9828 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9829 | } |
| 9830 | catch(std::bad_alloc&) |
| 9831 | { |
| 9832 | return gl::error(GL_OUT_OF_MEMORY); |
| 9833 | } |
| 9834 | } |
| 9835 | |
| 9836 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 9837 | { |
| 9838 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 9839 | program, name); |
| 9840 | |
| 9841 | try |
| 9842 | { |
| 9843 | gl::Context *context = gl::getNonLostContext(); |
| 9844 | |
| 9845 | if (context) |
| 9846 | { |
| 9847 | if (context->getClientVersion() < 3) |
| 9848 | { |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 9849 | return gl::error(GL_INVALID_OPERATION, -1); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9850 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9851 | |
Jamie Madill | d1e78c9 | 2013-06-20 11:55:50 -0400 | [diff] [blame] | 9852 | if (program == 0) |
| 9853 | { |
| 9854 | return gl::error(GL_INVALID_VALUE, -1); |
| 9855 | } |
| 9856 | |
| 9857 | gl::Program *programObject = context->getProgram(program); |
| 9858 | |
| 9859 | if (!programObject || !programObject->isLinked()) |
| 9860 | { |
| 9861 | return gl::error(GL_INVALID_OPERATION, -1); |
| 9862 | } |
| 9863 | |
| 9864 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 9865 | if (!programBinary) |
| 9866 | { |
| 9867 | return gl::error(GL_INVALID_OPERATION, -1); |
| 9868 | } |
| 9869 | |
| 9870 | return programBinary->getFragDataLocation(name); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 9871 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9872 | } |
| 9873 | catch(std::bad_alloc&) |
| 9874 | { |
| 9875 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 9876 | } |
| 9877 | |
| 9878 | return 0; |
| 9879 | } |
| 9880 | |
| 9881 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 9882 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9883 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9884 | } |
| 9885 | |
| 9886 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 9887 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9888 | const GLuint xy[] = { v0, v1 }; |
| 9889 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9890 | } |
| 9891 | |
| 9892 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 9893 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9894 | const GLuint xyz[] = { v0, v1, v2 }; |
| 9895 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9896 | } |
| 9897 | |
| 9898 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 9899 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 9900 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 9901 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9902 | } |
| 9903 | |
| 9904 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 9905 | { |
| 9906 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9907 | location, count, value); |
| 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 | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9920 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9921 | if (!programBinary) |
| 9922 | { |
| 9923 | return gl::error(GL_INVALID_OPERATION); |
| 9924 | } |
| 9925 | |
| 9926 | if (!programBinary->setUniform1uiv(location, count, value)) |
| 9927 | { |
| 9928 | return gl::error(GL_INVALID_OPERATION); |
| 9929 | } |
| 9930 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9931 | } |
| 9932 | catch(std::bad_alloc&) |
| 9933 | { |
| 9934 | return gl::error(GL_OUT_OF_MEMORY); |
| 9935 | } |
| 9936 | } |
| 9937 | |
| 9938 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 9939 | { |
| 9940 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 9941 | location, count, value); |
| 9942 | |
| 9943 | try |
| 9944 | { |
| 9945 | gl::Context *context = gl::getNonLostContext(); |
| 9946 | |
| 9947 | if (context) |
| 9948 | { |
| 9949 | if (context->getClientVersion() < 3) |
| 9950 | { |
| 9951 | return gl::error(GL_INVALID_OPERATION); |
| 9952 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9953 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9954 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9955 | if (!programBinary) |
| 9956 | { |
| 9957 | return gl::error(GL_INVALID_OPERATION); |
| 9958 | } |
| 9959 | |
| 9960 | if (!programBinary->setUniform2uiv(location, count, value)) |
| 9961 | { |
| 9962 | return gl::error(GL_INVALID_OPERATION); |
| 9963 | } |
| 9964 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9965 | } |
| 9966 | catch(std::bad_alloc&) |
| 9967 | { |
| 9968 | return gl::error(GL_OUT_OF_MEMORY); |
| 9969 | } |
| 9970 | } |
| 9971 | |
| 9972 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 9973 | { |
| 9974 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 9975 | location, count, value); |
| 9976 | |
| 9977 | try |
| 9978 | { |
| 9979 | gl::Context *context = gl::getNonLostContext(); |
| 9980 | |
| 9981 | if (context) |
| 9982 | { |
| 9983 | if (context->getClientVersion() < 3) |
| 9984 | { |
| 9985 | return gl::error(GL_INVALID_OPERATION); |
| 9986 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9987 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 9988 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 9989 | if (!programBinary) |
| 9990 | { |
| 9991 | return gl::error(GL_INVALID_OPERATION); |
| 9992 | } |
| 9993 | |
| 9994 | if (!programBinary->setUniform3uiv(location, count, value)) |
| 9995 | { |
| 9996 | return gl::error(GL_INVALID_OPERATION); |
| 9997 | } |
| 9998 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 9999 | } |
| 10000 | catch(std::bad_alloc&) |
| 10001 | { |
| 10002 | return gl::error(GL_OUT_OF_MEMORY); |
| 10003 | } |
| 10004 | } |
| 10005 | |
| 10006 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 10007 | { |
| 10008 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 10009 | location, count, value); |
| 10010 | |
| 10011 | try |
| 10012 | { |
| 10013 | gl::Context *context = gl::getNonLostContext(); |
| 10014 | |
| 10015 | if (context) |
| 10016 | { |
| 10017 | if (context->getClientVersion() < 3) |
| 10018 | { |
| 10019 | return gl::error(GL_INVALID_OPERATION); |
| 10020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10021 | |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 10022 | gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); |
| 10023 | if (!programBinary) |
| 10024 | { |
| 10025 | return gl::error(GL_INVALID_OPERATION); |
| 10026 | } |
| 10027 | |
| 10028 | if (!programBinary->setUniform4uiv(location, count, value)) |
| 10029 | { |
| 10030 | return gl::error(GL_INVALID_OPERATION); |
| 10031 | } |
| 10032 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10033 | } |
| 10034 | catch(std::bad_alloc&) |
| 10035 | { |
| 10036 | return gl::error(GL_OUT_OF_MEMORY); |
| 10037 | } |
| 10038 | } |
| 10039 | |
| 10040 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 10041 | { |
| 10042 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 10043 | buffer, drawbuffer, value); |
| 10044 | |
| 10045 | try |
| 10046 | { |
| 10047 | gl::Context *context = gl::getNonLostContext(); |
| 10048 | |
| 10049 | if (context) |
| 10050 | { |
| 10051 | if (context->getClientVersion() < 3) |
| 10052 | { |
| 10053 | return gl::error(GL_INVALID_OPERATION); |
| 10054 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10055 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10056 | // glClearBufferiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10057 | UNIMPLEMENTED(); |
| 10058 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10059 | } |
| 10060 | catch(std::bad_alloc&) |
| 10061 | { |
| 10062 | return gl::error(GL_OUT_OF_MEMORY); |
| 10063 | } |
| 10064 | } |
| 10065 | |
| 10066 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 10067 | { |
| 10068 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 10069 | buffer, drawbuffer, value); |
| 10070 | |
| 10071 | try |
| 10072 | { |
| 10073 | gl::Context *context = gl::getNonLostContext(); |
| 10074 | |
| 10075 | if (context) |
| 10076 | { |
| 10077 | if (context->getClientVersion() < 3) |
| 10078 | { |
| 10079 | return gl::error(GL_INVALID_OPERATION); |
| 10080 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10081 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10082 | // glClearBufferuiv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10083 | UNIMPLEMENTED(); |
| 10084 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10085 | } |
| 10086 | catch(std::bad_alloc&) |
| 10087 | { |
| 10088 | return gl::error(GL_OUT_OF_MEMORY); |
| 10089 | } |
| 10090 | } |
| 10091 | |
| 10092 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 10093 | { |
| 10094 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 10095 | buffer, drawbuffer, value); |
| 10096 | |
| 10097 | try |
| 10098 | { |
| 10099 | gl::Context *context = gl::getNonLostContext(); |
| 10100 | |
| 10101 | if (context) |
| 10102 | { |
| 10103 | if (context->getClientVersion() < 3) |
| 10104 | { |
| 10105 | return gl::error(GL_INVALID_OPERATION); |
| 10106 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10107 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10108 | // glClearBufferfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10109 | UNIMPLEMENTED(); |
| 10110 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10111 | } |
| 10112 | catch(std::bad_alloc&) |
| 10113 | { |
| 10114 | return gl::error(GL_OUT_OF_MEMORY); |
| 10115 | } |
| 10116 | } |
| 10117 | |
| 10118 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 10119 | { |
| 10120 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 10121 | buffer, drawbuffer, depth, stencil); |
| 10122 | |
| 10123 | try |
| 10124 | { |
| 10125 | gl::Context *context = gl::getNonLostContext(); |
| 10126 | |
| 10127 | if (context) |
| 10128 | { |
| 10129 | if (context->getClientVersion() < 3) |
| 10130 | { |
| 10131 | return gl::error(GL_INVALID_OPERATION); |
| 10132 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10133 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10134 | // glClearBufferfi |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10135 | UNIMPLEMENTED(); |
| 10136 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10137 | } |
| 10138 | catch(std::bad_alloc&) |
| 10139 | { |
| 10140 | return gl::error(GL_OUT_OF_MEMORY); |
| 10141 | } |
| 10142 | } |
| 10143 | |
| 10144 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 10145 | { |
| 10146 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 10147 | |
| 10148 | try |
| 10149 | { |
| 10150 | gl::Context *context = gl::getNonLostContext(); |
| 10151 | |
| 10152 | if (context) |
| 10153 | { |
| 10154 | if (context->getClientVersion() < 3) |
| 10155 | { |
| 10156 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
| 10157 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10158 | |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 10159 | if (name != GL_EXTENSIONS) |
| 10160 | { |
| 10161 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 10162 | } |
| 10163 | |
| 10164 | if (index >= context->getNumExtensions()) |
| 10165 | { |
| 10166 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 10167 | } |
| 10168 | |
| 10169 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index)); |
| 10170 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10171 | } |
| 10172 | catch(std::bad_alloc&) |
| 10173 | { |
| 10174 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL)); |
| 10175 | } |
| 10176 | |
| 10177 | return NULL; |
| 10178 | } |
| 10179 | |
| 10180 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 10181 | { |
| 10182 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 10183 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 10184 | |
| 10185 | try |
| 10186 | { |
| 10187 | gl::Context *context = gl::getNonLostContext(); |
| 10188 | |
| 10189 | if (context) |
| 10190 | { |
| 10191 | if (context->getClientVersion() < 3) |
| 10192 | { |
| 10193 | return gl::error(GL_INVALID_OPERATION); |
| 10194 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10195 | |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10196 | gl::Buffer *readBuffer = NULL; |
| 10197 | switch (readTarget) |
| 10198 | { |
| 10199 | case GL_ARRAY_BUFFER: |
| 10200 | readBuffer = context->getArrayBuffer(); |
| 10201 | break; |
| 10202 | case GL_COPY_READ_BUFFER: |
| 10203 | readBuffer = context->getCopyReadBuffer(); |
| 10204 | break; |
| 10205 | case GL_COPY_WRITE_BUFFER: |
| 10206 | readBuffer = context->getCopyWriteBuffer(); |
| 10207 | break; |
| 10208 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10209 | readBuffer = context->getElementArrayBuffer(); |
| 10210 | break; |
| 10211 | case GL_PIXEL_PACK_BUFFER: |
| 10212 | readBuffer = context->getPixelPackBuffer(); |
| 10213 | break; |
| 10214 | case GL_PIXEL_UNPACK_BUFFER: |
| 10215 | readBuffer = context->getPixelUnpackBuffer(); |
| 10216 | break; |
| 10217 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10218 | readBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10219 | break; |
| 10220 | case GL_UNIFORM_BUFFER: |
| 10221 | readBuffer = context->getGenericUniformBuffer(); |
| 10222 | break; |
| 10223 | default: |
| 10224 | return gl::error(GL_INVALID_ENUM); |
| 10225 | } |
| 10226 | |
| 10227 | gl::Buffer *writeBuffer = NULL; |
| 10228 | switch (writeTarget) |
| 10229 | { |
| 10230 | case GL_ARRAY_BUFFER: |
| 10231 | writeBuffer = context->getArrayBuffer(); |
| 10232 | break; |
| 10233 | case GL_COPY_READ_BUFFER: |
| 10234 | writeBuffer = context->getCopyReadBuffer(); |
| 10235 | break; |
| 10236 | case GL_COPY_WRITE_BUFFER: |
| 10237 | writeBuffer = context->getCopyWriteBuffer(); |
| 10238 | break; |
| 10239 | case GL_ELEMENT_ARRAY_BUFFER: |
| 10240 | writeBuffer = context->getElementArrayBuffer(); |
| 10241 | break; |
| 10242 | case GL_PIXEL_PACK_BUFFER: |
| 10243 | writeBuffer = context->getPixelPackBuffer(); |
| 10244 | break; |
| 10245 | case GL_PIXEL_UNPACK_BUFFER: |
| 10246 | writeBuffer = context->getPixelUnpackBuffer(); |
| 10247 | break; |
| 10248 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 10249 | writeBuffer = context->getGenericTransformFeedbackBuffer(); |
| 10250 | break; |
| 10251 | case GL_UNIFORM_BUFFER: |
| 10252 | writeBuffer = context->getGenericUniformBuffer(); |
| 10253 | break; |
| 10254 | default: |
| 10255 | return gl::error(GL_INVALID_ENUM); |
| 10256 | } |
| 10257 | |
| 10258 | if (!readBuffer || !writeBuffer) |
| 10259 | { |
| 10260 | return gl::error(GL_INVALID_OPERATION); |
| 10261 | } |
| 10262 | |
| 10263 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 10264 | static_cast<unsigned int>(readOffset + size) > readBuffer->size() || |
| 10265 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->size()) |
| 10266 | { |
| 10267 | return gl::error(GL_INVALID_VALUE); |
| 10268 | } |
| 10269 | |
| 10270 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 10271 | { |
| 10272 | return gl::error(GL_INVALID_VALUE); |
| 10273 | } |
| 10274 | |
| 10275 | // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION) |
| 10276 | |
shannon.woods%transgaming.com@gtempaccount.com | c53376a | 2013-04-13 03:41:23 +0000 | [diff] [blame] | 10277 | // if size is zero, the copy is a successful no-op |
| 10278 | if (size > 0) |
| 10279 | { |
| 10280 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 10281 | } |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 10282 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10283 | } |
| 10284 | catch(std::bad_alloc&) |
| 10285 | { |
| 10286 | return gl::error(GL_OUT_OF_MEMORY); |
| 10287 | } |
| 10288 | } |
| 10289 | |
| 10290 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 10291 | { |
| 10292 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 10293 | program, uniformCount, uniformNames, uniformIndices); |
| 10294 | |
| 10295 | try |
| 10296 | { |
| 10297 | gl::Context *context = gl::getNonLostContext(); |
| 10298 | |
| 10299 | if (context) |
| 10300 | { |
| 10301 | if (context->getClientVersion() < 3) |
| 10302 | { |
| 10303 | return gl::error(GL_INVALID_OPERATION); |
| 10304 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10305 | |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 10306 | if (uniformCount < 0) |
| 10307 | { |
| 10308 | return gl::error(GL_INVALID_VALUE); |
| 10309 | } |
| 10310 | |
| 10311 | gl::Program *programObject = context->getProgram(program); |
| 10312 | |
| 10313 | if (!programObject) |
| 10314 | { |
| 10315 | if (context->getShader(program)) |
| 10316 | { |
| 10317 | return gl::error(GL_INVALID_OPERATION); |
| 10318 | } |
| 10319 | else |
| 10320 | { |
| 10321 | return gl::error(GL_INVALID_VALUE); |
| 10322 | } |
| 10323 | } |
| 10324 | |
| 10325 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10326 | if (!programObject->isLinked() || !programBinary) |
| 10327 | { |
| 10328 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10329 | { |
| 10330 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
| 10331 | } |
| 10332 | } |
| 10333 | else |
| 10334 | { |
| 10335 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10336 | { |
| 10337 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 10338 | } |
| 10339 | } |
| 10340 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10341 | } |
| 10342 | catch(std::bad_alloc&) |
| 10343 | { |
| 10344 | return gl::error(GL_OUT_OF_MEMORY); |
| 10345 | } |
| 10346 | } |
| 10347 | |
| 10348 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 10349 | { |
| 10350 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10351 | program, uniformCount, uniformIndices, pname, params); |
| 10352 | |
| 10353 | try |
| 10354 | { |
| 10355 | gl::Context *context = gl::getNonLostContext(); |
| 10356 | |
| 10357 | if (context) |
| 10358 | { |
| 10359 | if (context->getClientVersion() < 3) |
| 10360 | { |
| 10361 | return gl::error(GL_INVALID_OPERATION); |
| 10362 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10363 | |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 10364 | if (uniformCount < 0) |
| 10365 | { |
| 10366 | return gl::error(GL_INVALID_VALUE); |
| 10367 | } |
| 10368 | |
| 10369 | gl::Program *programObject = context->getProgram(program); |
| 10370 | |
| 10371 | if (!programObject) |
| 10372 | { |
| 10373 | if (context->getShader(program)) |
| 10374 | { |
| 10375 | return gl::error(GL_INVALID_OPERATION); |
| 10376 | } |
| 10377 | else |
| 10378 | { |
| 10379 | return gl::error(GL_INVALID_VALUE); |
| 10380 | } |
| 10381 | } |
| 10382 | |
| 10383 | switch (pname) |
| 10384 | { |
| 10385 | case GL_UNIFORM_TYPE: |
| 10386 | case GL_UNIFORM_SIZE: |
| 10387 | case GL_UNIFORM_NAME_LENGTH: |
| 10388 | case GL_UNIFORM_BLOCK_INDEX: |
| 10389 | case GL_UNIFORM_OFFSET: |
| 10390 | case GL_UNIFORM_ARRAY_STRIDE: |
| 10391 | case GL_UNIFORM_MATRIX_STRIDE: |
| 10392 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 10393 | break; |
| 10394 | default: |
| 10395 | return gl::error(GL_INVALID_ENUM); |
| 10396 | } |
| 10397 | |
| 10398 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10399 | |
| 10400 | if (!programBinary && uniformCount > 0) |
| 10401 | { |
| 10402 | return gl::error(GL_INVALID_VALUE); |
| 10403 | } |
| 10404 | |
| 10405 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10406 | { |
| 10407 | const GLuint index = uniformIndices[uniformId]; |
| 10408 | |
| 10409 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 10410 | { |
| 10411 | return gl::error(GL_INVALID_VALUE); |
| 10412 | } |
| 10413 | } |
| 10414 | |
| 10415 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 10416 | { |
| 10417 | const GLuint index = uniformIndices[uniformId]; |
| 10418 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 10419 | } |
| 10420 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10421 | } |
| 10422 | catch(std::bad_alloc&) |
| 10423 | { |
| 10424 | return gl::error(GL_OUT_OF_MEMORY); |
| 10425 | } |
| 10426 | } |
| 10427 | |
| 10428 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 10429 | { |
| 10430 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 10431 | |
| 10432 | try |
| 10433 | { |
| 10434 | gl::Context *context = gl::getNonLostContext(); |
| 10435 | |
| 10436 | if (context) |
| 10437 | { |
| 10438 | if (context->getClientVersion() < 3) |
| 10439 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10440 | 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] | 10441 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10442 | |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 10443 | gl::Program *programObject = context->getProgram(program); |
| 10444 | |
| 10445 | if (!programObject) |
| 10446 | { |
| 10447 | if (context->getShader(program)) |
| 10448 | { |
| 10449 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 10450 | } |
| 10451 | else |
| 10452 | { |
| 10453 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
| 10454 | } |
| 10455 | } |
| 10456 | |
| 10457 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10458 | if (!programBinary) |
| 10459 | { |
| 10460 | return GL_INVALID_INDEX; |
| 10461 | } |
| 10462 | |
| 10463 | return programBinary->getUniformBlockIndex(uniformBlockName); |
| 10464 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10465 | } |
| 10466 | catch(std::bad_alloc&) |
| 10467 | { |
| 10468 | return gl::error(GL_OUT_OF_MEMORY, 0); |
| 10469 | } |
| 10470 | |
| 10471 | return 0; |
| 10472 | } |
| 10473 | |
| 10474 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 10475 | { |
| 10476 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 10477 | program, uniformBlockIndex, pname, params); |
| 10478 | |
| 10479 | try |
| 10480 | { |
| 10481 | gl::Context *context = gl::getNonLostContext(); |
| 10482 | |
| 10483 | if (context) |
| 10484 | { |
| 10485 | if (context->getClientVersion() < 3) |
| 10486 | { |
| 10487 | return gl::error(GL_INVALID_OPERATION); |
| 10488 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10489 | gl::Program *programObject = context->getProgram(program); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10490 | |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 10491 | if (!programObject) |
| 10492 | { |
| 10493 | if (context->getShader(program)) |
| 10494 | { |
| 10495 | return gl::error(GL_INVALID_OPERATION); |
| 10496 | } |
| 10497 | else |
| 10498 | { |
| 10499 | return gl::error(GL_INVALID_VALUE); |
| 10500 | } |
| 10501 | } |
| 10502 | |
| 10503 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10504 | |
| 10505 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10506 | { |
| 10507 | return gl::error(GL_INVALID_VALUE); |
| 10508 | } |
| 10509 | |
| 10510 | switch (pname) |
| 10511 | { |
| 10512 | case GL_UNIFORM_BLOCK_BINDING: |
| 10513 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 10514 | break; |
| 10515 | |
| 10516 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 10517 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 10518 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 10519 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 10520 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 10521 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 10522 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 10523 | break; |
| 10524 | |
| 10525 | default: |
| 10526 | return gl::error(GL_INVALID_ENUM); |
| 10527 | } |
| 10528 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10529 | } |
| 10530 | catch(std::bad_alloc&) |
| 10531 | { |
| 10532 | return gl::error(GL_OUT_OF_MEMORY); |
| 10533 | } |
| 10534 | } |
| 10535 | |
| 10536 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 10537 | { |
| 10538 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 10539 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 10540 | |
| 10541 | try |
| 10542 | { |
| 10543 | gl::Context *context = gl::getNonLostContext(); |
| 10544 | |
| 10545 | if (context) |
| 10546 | { |
| 10547 | if (context->getClientVersion() < 3) |
| 10548 | { |
| 10549 | return gl::error(GL_INVALID_OPERATION); |
| 10550 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10551 | |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 10552 | gl::Program *programObject = context->getProgram(program); |
| 10553 | |
| 10554 | if (!programObject) |
| 10555 | { |
| 10556 | if (context->getShader(program)) |
| 10557 | { |
| 10558 | return gl::error(GL_INVALID_OPERATION); |
| 10559 | } |
| 10560 | else |
| 10561 | { |
| 10562 | return gl::error(GL_INVALID_VALUE); |
| 10563 | } |
| 10564 | } |
| 10565 | |
| 10566 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10567 | |
| 10568 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10569 | { |
| 10570 | return gl::error(GL_INVALID_VALUE); |
| 10571 | } |
| 10572 | |
| 10573 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
| 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 glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 10583 | { |
| 10584 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 10585 | program, uniformBlockIndex, uniformBlockBinding); |
| 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 | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 10598 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 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 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 10618 | |
| 10619 | // if never linked, there won't be any uniform blocks |
| 10620 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 10621 | { |
| 10622 | return gl::error(GL_INVALID_VALUE); |
| 10623 | } |
| 10624 | |
| 10625 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
| 10626 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10627 | } |
| 10628 | catch(std::bad_alloc&) |
| 10629 | { |
| 10630 | return gl::error(GL_OUT_OF_MEMORY); |
| 10631 | } |
| 10632 | } |
| 10633 | |
| 10634 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 10635 | { |
| 10636 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 10637 | mode, first, count, instanceCount); |
| 10638 | |
| 10639 | try |
| 10640 | { |
| 10641 | gl::Context *context = gl::getNonLostContext(); |
| 10642 | |
| 10643 | if (context) |
| 10644 | { |
| 10645 | if (context->getClientVersion() < 3) |
| 10646 | { |
| 10647 | return gl::error(GL_INVALID_OPERATION); |
| 10648 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10649 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10650 | // glDrawArraysInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10651 | UNIMPLEMENTED(); |
| 10652 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10653 | } |
| 10654 | catch(std::bad_alloc&) |
| 10655 | { |
| 10656 | return gl::error(GL_OUT_OF_MEMORY); |
| 10657 | } |
| 10658 | } |
| 10659 | |
| 10660 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 10661 | { |
| 10662 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 10663 | mode, count, type, indices, instanceCount); |
| 10664 | |
| 10665 | try |
| 10666 | { |
| 10667 | gl::Context *context = gl::getNonLostContext(); |
| 10668 | |
| 10669 | if (context) |
| 10670 | { |
| 10671 | if (context->getClientVersion() < 3) |
| 10672 | { |
| 10673 | return gl::error(GL_INVALID_OPERATION); |
| 10674 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10675 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10676 | // glDrawElementsInstanced |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10677 | UNIMPLEMENTED(); |
| 10678 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10679 | } |
| 10680 | catch(std::bad_alloc&) |
| 10681 | { |
| 10682 | return gl::error(GL_OUT_OF_MEMORY); |
| 10683 | } |
| 10684 | } |
| 10685 | |
| 10686 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 10687 | { |
| 10688 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 10689 | |
| 10690 | try |
| 10691 | { |
| 10692 | gl::Context *context = gl::getNonLostContext(); |
| 10693 | |
| 10694 | if (context) |
| 10695 | { |
| 10696 | if (context->getClientVersion() < 3) |
| 10697 | { |
| 10698 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(NULL)); |
| 10699 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10700 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10701 | // glFenceSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10702 | UNIMPLEMENTED(); |
| 10703 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10704 | } |
| 10705 | catch(std::bad_alloc&) |
| 10706 | { |
| 10707 | return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL)); |
| 10708 | } |
| 10709 | |
| 10710 | return NULL; |
| 10711 | } |
| 10712 | |
| 10713 | GLboolean __stdcall glIsSync(GLsync sync) |
| 10714 | { |
| 10715 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10716 | |
| 10717 | try |
| 10718 | { |
| 10719 | gl::Context *context = gl::getNonLostContext(); |
| 10720 | |
| 10721 | if (context) |
| 10722 | { |
| 10723 | if (context->getClientVersion() < 3) |
| 10724 | { |
| 10725 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10726 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10727 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10728 | // glIsSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10729 | UNIMPLEMENTED(); |
| 10730 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10731 | } |
| 10732 | catch(std::bad_alloc&) |
| 10733 | { |
| 10734 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10735 | } |
| 10736 | |
| 10737 | return GL_FALSE; |
| 10738 | } |
| 10739 | |
| 10740 | void __stdcall glDeleteSync(GLsync sync) |
| 10741 | { |
| 10742 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 10743 | |
| 10744 | try |
| 10745 | { |
| 10746 | gl::Context *context = gl::getNonLostContext(); |
| 10747 | |
| 10748 | if (context) |
| 10749 | { |
| 10750 | if (context->getClientVersion() < 3) |
| 10751 | { |
| 10752 | return gl::error(GL_INVALID_OPERATION); |
| 10753 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10754 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10755 | // glDeleteSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10756 | UNIMPLEMENTED(); |
| 10757 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10758 | } |
| 10759 | catch(std::bad_alloc&) |
| 10760 | { |
| 10761 | return gl::error(GL_OUT_OF_MEMORY); |
| 10762 | } |
| 10763 | } |
| 10764 | |
| 10765 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10766 | { |
| 10767 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10768 | sync, flags, timeout); |
| 10769 | |
| 10770 | try |
| 10771 | { |
| 10772 | gl::Context *context = gl::getNonLostContext(); |
| 10773 | |
| 10774 | if (context) |
| 10775 | { |
| 10776 | if (context->getClientVersion() < 3) |
| 10777 | { |
| 10778 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10779 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10780 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10781 | // glClientWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10782 | UNIMPLEMENTED(); |
| 10783 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10784 | } |
| 10785 | catch(std::bad_alloc&) |
| 10786 | { |
| 10787 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10788 | } |
| 10789 | |
| 10790 | return GL_FALSE; |
| 10791 | } |
| 10792 | |
| 10793 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 10794 | { |
| 10795 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 10796 | sync, flags, timeout); |
| 10797 | |
| 10798 | try |
| 10799 | { |
| 10800 | gl::Context *context = gl::getNonLostContext(); |
| 10801 | |
| 10802 | if (context) |
| 10803 | { |
| 10804 | if (context->getClientVersion() < 3) |
| 10805 | { |
| 10806 | return gl::error(GL_INVALID_OPERATION); |
| 10807 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10808 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10809 | // glWaitSync |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10810 | UNIMPLEMENTED(); |
| 10811 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10812 | } |
| 10813 | catch(std::bad_alloc&) |
| 10814 | { |
| 10815 | return gl::error(GL_OUT_OF_MEMORY); |
| 10816 | } |
| 10817 | } |
| 10818 | |
| 10819 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 10820 | { |
| 10821 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10822 | pname, params); |
| 10823 | |
| 10824 | try |
| 10825 | { |
| 10826 | gl::Context *context = gl::getNonLostContext(); |
| 10827 | |
| 10828 | if (context) |
| 10829 | { |
| 10830 | if (context->getClientVersion() < 3) |
| 10831 | { |
| 10832 | return gl::error(GL_INVALID_OPERATION); |
| 10833 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10834 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10835 | // glGetInteger64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10836 | UNIMPLEMENTED(); |
| 10837 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10838 | } |
| 10839 | catch(std::bad_alloc&) |
| 10840 | { |
| 10841 | return gl::error(GL_OUT_OF_MEMORY); |
| 10842 | } |
| 10843 | } |
| 10844 | |
| 10845 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 10846 | { |
| 10847 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 10848 | sync, pname, bufSize, length, values); |
| 10849 | |
| 10850 | try |
| 10851 | { |
| 10852 | gl::Context *context = gl::getNonLostContext(); |
| 10853 | |
| 10854 | if (context) |
| 10855 | { |
| 10856 | if (context->getClientVersion() < 3) |
| 10857 | { |
| 10858 | return gl::error(GL_INVALID_OPERATION); |
| 10859 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10860 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10861 | // glGetSynciv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10862 | UNIMPLEMENTED(); |
| 10863 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10864 | } |
| 10865 | catch(std::bad_alloc&) |
| 10866 | { |
| 10867 | return gl::error(GL_OUT_OF_MEMORY); |
| 10868 | } |
| 10869 | } |
| 10870 | |
| 10871 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 10872 | { |
| 10873 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 10874 | target, index, data); |
| 10875 | |
| 10876 | try |
| 10877 | { |
| 10878 | gl::Context *context = gl::getNonLostContext(); |
| 10879 | |
| 10880 | if (context) |
| 10881 | { |
| 10882 | if (context->getClientVersion() < 3) |
| 10883 | { |
| 10884 | return gl::error(GL_INVALID_OPERATION); |
| 10885 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10886 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10887 | // glGetInteger64i_v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10888 | UNIMPLEMENTED(); |
| 10889 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10890 | } |
| 10891 | catch(std::bad_alloc&) |
| 10892 | { |
| 10893 | return gl::error(GL_OUT_OF_MEMORY); |
| 10894 | } |
| 10895 | } |
| 10896 | |
| 10897 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 10898 | { |
| 10899 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 10900 | target, pname, params); |
| 10901 | |
| 10902 | try |
| 10903 | { |
| 10904 | gl::Context *context = gl::getNonLostContext(); |
| 10905 | |
| 10906 | if (context) |
| 10907 | { |
| 10908 | if (context->getClientVersion() < 3) |
| 10909 | { |
| 10910 | return gl::error(GL_INVALID_OPERATION); |
| 10911 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10912 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10913 | // glGetBufferParameteri64v |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10914 | UNIMPLEMENTED(); |
| 10915 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10916 | } |
| 10917 | catch(std::bad_alloc&) |
| 10918 | { |
| 10919 | return gl::error(GL_OUT_OF_MEMORY); |
| 10920 | } |
| 10921 | } |
| 10922 | |
| 10923 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 10924 | { |
| 10925 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10926 | |
| 10927 | try |
| 10928 | { |
| 10929 | gl::Context *context = gl::getNonLostContext(); |
| 10930 | |
| 10931 | if (context) |
| 10932 | { |
| 10933 | if (context->getClientVersion() < 3) |
| 10934 | { |
| 10935 | return gl::error(GL_INVALID_OPERATION); |
| 10936 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10937 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10938 | // glGenSamplers |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10939 | UNIMPLEMENTED(); |
| 10940 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10941 | } |
| 10942 | catch(std::bad_alloc&) |
| 10943 | { |
| 10944 | return gl::error(GL_OUT_OF_MEMORY); |
| 10945 | } |
| 10946 | } |
| 10947 | |
| 10948 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 10949 | { |
| 10950 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 10951 | |
| 10952 | try |
| 10953 | { |
| 10954 | gl::Context *context = gl::getNonLostContext(); |
| 10955 | |
| 10956 | if (context) |
| 10957 | { |
| 10958 | if (context->getClientVersion() < 3) |
| 10959 | { |
| 10960 | return gl::error(GL_INVALID_OPERATION); |
| 10961 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10962 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10963 | // glDeleteSamplers |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10964 | UNIMPLEMENTED(); |
| 10965 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10966 | } |
| 10967 | catch(std::bad_alloc&) |
| 10968 | { |
| 10969 | return gl::error(GL_OUT_OF_MEMORY); |
| 10970 | } |
| 10971 | } |
| 10972 | |
| 10973 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 10974 | { |
| 10975 | EVENT("(GLuint sampler = %u)", sampler); |
| 10976 | |
| 10977 | try |
| 10978 | { |
| 10979 | gl::Context *context = gl::getNonLostContext(); |
| 10980 | |
| 10981 | if (context) |
| 10982 | { |
| 10983 | if (context->getClientVersion() < 3) |
| 10984 | { |
| 10985 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 10986 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10987 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 10988 | // glIsSampler |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 10989 | UNIMPLEMENTED(); |
| 10990 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 10991 | } |
| 10992 | catch(std::bad_alloc&) |
| 10993 | { |
| 10994 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 10995 | } |
| 10996 | |
| 10997 | return GL_FALSE; |
| 10998 | } |
| 10999 | |
| 11000 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 11001 | { |
| 11002 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 11003 | |
| 11004 | try |
| 11005 | { |
| 11006 | gl::Context *context = gl::getNonLostContext(); |
| 11007 | |
| 11008 | if (context) |
| 11009 | { |
| 11010 | if (context->getClientVersion() < 3) |
| 11011 | { |
| 11012 | return gl::error(GL_INVALID_OPERATION); |
| 11013 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11014 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11015 | // glBindSampler |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11016 | UNIMPLEMENTED(); |
| 11017 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11018 | } |
| 11019 | catch(std::bad_alloc&) |
| 11020 | { |
| 11021 | return gl::error(GL_OUT_OF_MEMORY); |
| 11022 | } |
| 11023 | } |
| 11024 | |
| 11025 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 11026 | { |
| 11027 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 11028 | |
| 11029 | try |
| 11030 | { |
| 11031 | gl::Context *context = gl::getNonLostContext(); |
| 11032 | |
| 11033 | if (context) |
| 11034 | { |
| 11035 | if (context->getClientVersion() < 3) |
| 11036 | { |
| 11037 | return gl::error(GL_INVALID_OPERATION); |
| 11038 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11039 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11040 | // glSamplerParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11041 | UNIMPLEMENTED(); |
| 11042 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11043 | } |
| 11044 | catch(std::bad_alloc&) |
| 11045 | { |
| 11046 | return gl::error(GL_OUT_OF_MEMORY); |
| 11047 | } |
| 11048 | } |
| 11049 | |
| 11050 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 11051 | { |
| 11052 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLint* param = 0x%0.8p)", |
| 11053 | sampler, pname, param); |
| 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 | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11066 | // glSamplerParameteriv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11067 | UNIMPLEMENTED(); |
| 11068 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11069 | } |
| 11070 | catch(std::bad_alloc&) |
| 11071 | { |
| 11072 | return gl::error(GL_OUT_OF_MEMORY); |
| 11073 | } |
| 11074 | } |
| 11075 | |
| 11076 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 11077 | { |
| 11078 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 11079 | |
| 11080 | try |
| 11081 | { |
| 11082 | gl::Context *context = gl::getNonLostContext(); |
| 11083 | |
| 11084 | if (context) |
| 11085 | { |
| 11086 | if (context->getClientVersion() < 3) |
| 11087 | { |
| 11088 | return gl::error(GL_INVALID_OPERATION); |
| 11089 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11090 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11091 | // glSamplerParameterf |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11092 | UNIMPLEMENTED(); |
| 11093 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11094 | } |
| 11095 | catch(std::bad_alloc&) |
| 11096 | { |
| 11097 | return gl::error(GL_OUT_OF_MEMORY); |
| 11098 | } |
| 11099 | } |
| 11100 | |
| 11101 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 11102 | { |
| 11103 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, const GLfloat* param = 0x%0.8p)", sampler, pname, param); |
| 11104 | |
| 11105 | try |
| 11106 | { |
| 11107 | gl::Context *context = gl::getNonLostContext(); |
| 11108 | |
| 11109 | if (context) |
| 11110 | { |
| 11111 | if (context->getClientVersion() < 3) |
| 11112 | { |
| 11113 | return gl::error(GL_INVALID_OPERATION); |
| 11114 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11115 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11116 | // glSamplerParameterfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11117 | UNIMPLEMENTED(); |
| 11118 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11119 | } |
| 11120 | catch(std::bad_alloc&) |
| 11121 | { |
| 11122 | return gl::error(GL_OUT_OF_MEMORY); |
| 11123 | } |
| 11124 | } |
| 11125 | |
| 11126 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 11127 | { |
| 11128 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 11129 | |
| 11130 | try |
| 11131 | { |
| 11132 | gl::Context *context = gl::getNonLostContext(); |
| 11133 | |
| 11134 | if (context) |
| 11135 | { |
| 11136 | if (context->getClientVersion() < 3) |
| 11137 | { |
| 11138 | return gl::error(GL_INVALID_OPERATION); |
| 11139 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11140 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11141 | // glGetSamplerParameteriv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11142 | UNIMPLEMENTED(); |
| 11143 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11144 | } |
| 11145 | catch(std::bad_alloc&) |
| 11146 | { |
| 11147 | return gl::error(GL_OUT_OF_MEMORY); |
| 11148 | } |
| 11149 | } |
| 11150 | |
| 11151 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 11152 | { |
| 11153 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 11154 | |
| 11155 | try |
| 11156 | { |
| 11157 | gl::Context *context = gl::getNonLostContext(); |
| 11158 | |
| 11159 | if (context) |
| 11160 | { |
| 11161 | if (context->getClientVersion() < 3) |
| 11162 | { |
| 11163 | return gl::error(GL_INVALID_OPERATION); |
| 11164 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11165 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11166 | // glGetSamplerParameterfv |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11167 | UNIMPLEMENTED(); |
| 11168 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11169 | } |
| 11170 | catch(std::bad_alloc&) |
| 11171 | { |
| 11172 | return gl::error(GL_OUT_OF_MEMORY); |
| 11173 | } |
| 11174 | } |
| 11175 | |
| 11176 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 11177 | { |
| 11178 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 11179 | |
| 11180 | try |
| 11181 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11182 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 11183 | { |
| 11184 | return gl::error(GL_INVALID_VALUE); |
| 11185 | } |
| 11186 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 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 | |
shannon.woods%transgaming.com@gtempaccount.com | 8736bd6 | 2013-04-13 03:35:41 +0000 | [diff] [blame] | 11196 | context->setVertexAttribDivisor(index, divisor); |
| 11197 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11198 | } |
| 11199 | catch(std::bad_alloc&) |
| 11200 | { |
| 11201 | return gl::error(GL_OUT_OF_MEMORY); |
| 11202 | } |
| 11203 | } |
| 11204 | |
| 11205 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 11206 | { |
| 11207 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 11208 | |
| 11209 | try |
| 11210 | { |
| 11211 | gl::Context *context = gl::getNonLostContext(); |
| 11212 | |
| 11213 | if (context) |
| 11214 | { |
| 11215 | if (context->getClientVersion() < 3) |
| 11216 | { |
| 11217 | return gl::error(GL_INVALID_OPERATION); |
| 11218 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11219 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11220 | // glBindTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11221 | UNIMPLEMENTED(); |
| 11222 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11223 | } |
| 11224 | catch(std::bad_alloc&) |
| 11225 | { |
| 11226 | return gl::error(GL_OUT_OF_MEMORY); |
| 11227 | } |
| 11228 | } |
| 11229 | |
| 11230 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 11231 | { |
| 11232 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 11233 | |
| 11234 | try |
| 11235 | { |
| 11236 | gl::Context *context = gl::getNonLostContext(); |
| 11237 | |
| 11238 | if (context) |
| 11239 | { |
| 11240 | if (context->getClientVersion() < 3) |
| 11241 | { |
| 11242 | return gl::error(GL_INVALID_OPERATION); |
| 11243 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11244 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11245 | // glDeleteTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11246 | UNIMPLEMENTED(); |
| 11247 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11248 | } |
| 11249 | catch(std::bad_alloc&) |
| 11250 | { |
| 11251 | return gl::error(GL_OUT_OF_MEMORY); |
| 11252 | } |
| 11253 | } |
| 11254 | |
| 11255 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 11256 | { |
| 11257 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 11258 | |
| 11259 | try |
| 11260 | { |
| 11261 | gl::Context *context = gl::getNonLostContext(); |
| 11262 | |
| 11263 | if (context) |
| 11264 | { |
| 11265 | if (context->getClientVersion() < 3) |
| 11266 | { |
| 11267 | return gl::error(GL_INVALID_OPERATION); |
| 11268 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11269 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11270 | // glGenTransformFeedbacks |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11271 | UNIMPLEMENTED(); |
| 11272 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11273 | } |
| 11274 | catch(std::bad_alloc&) |
| 11275 | { |
| 11276 | return gl::error(GL_OUT_OF_MEMORY); |
| 11277 | } |
| 11278 | } |
| 11279 | |
| 11280 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 11281 | { |
| 11282 | EVENT("(GLuint id = %u)", id); |
| 11283 | |
| 11284 | try |
| 11285 | { |
| 11286 | gl::Context *context = gl::getNonLostContext(); |
| 11287 | |
| 11288 | if (context) |
| 11289 | { |
| 11290 | if (context->getClientVersion() < 3) |
| 11291 | { |
| 11292 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 11293 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11294 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11295 | // glIsTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11296 | UNIMPLEMENTED(); |
| 11297 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11298 | } |
| 11299 | catch(std::bad_alloc&) |
| 11300 | { |
| 11301 | return gl::error(GL_OUT_OF_MEMORY, GL_FALSE); |
| 11302 | } |
| 11303 | |
| 11304 | return GL_FALSE; |
| 11305 | } |
| 11306 | |
| 11307 | void __stdcall glPauseTransformFeedback(void) |
| 11308 | { |
| 11309 | EVENT("(void)"); |
| 11310 | |
| 11311 | try |
| 11312 | { |
| 11313 | gl::Context *context = gl::getNonLostContext(); |
| 11314 | |
| 11315 | if (context) |
| 11316 | { |
| 11317 | if (context->getClientVersion() < 3) |
| 11318 | { |
| 11319 | return gl::error(GL_INVALID_OPERATION); |
| 11320 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11321 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11322 | // glPauseTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11323 | UNIMPLEMENTED(); |
| 11324 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11325 | } |
| 11326 | catch(std::bad_alloc&) |
| 11327 | { |
| 11328 | return gl::error(GL_OUT_OF_MEMORY); |
| 11329 | } |
| 11330 | } |
| 11331 | |
| 11332 | void __stdcall glResumeTransformFeedback(void) |
| 11333 | { |
| 11334 | EVENT("(void)"); |
| 11335 | |
| 11336 | try |
| 11337 | { |
| 11338 | gl::Context *context = gl::getNonLostContext(); |
| 11339 | |
| 11340 | if (context) |
| 11341 | { |
| 11342 | if (context->getClientVersion() < 3) |
| 11343 | { |
| 11344 | return gl::error(GL_INVALID_OPERATION); |
| 11345 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11346 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11347 | // glResumeTransformFeedback |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11348 | UNIMPLEMENTED(); |
| 11349 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11350 | } |
| 11351 | catch(std::bad_alloc&) |
| 11352 | { |
| 11353 | return gl::error(GL_OUT_OF_MEMORY); |
| 11354 | } |
| 11355 | } |
| 11356 | |
| 11357 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 11358 | { |
| 11359 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 11360 | program, bufSize, length, binaryFormat, binary); |
| 11361 | |
| 11362 | try |
| 11363 | { |
| 11364 | gl::Context *context = gl::getNonLostContext(); |
| 11365 | |
| 11366 | if (context) |
| 11367 | { |
| 11368 | if (context->getClientVersion() < 3) |
| 11369 | { |
| 11370 | return gl::error(GL_INVALID_OPERATION); |
| 11371 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11372 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11373 | // glGetProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11374 | UNIMPLEMENTED(); |
| 11375 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11376 | } |
| 11377 | catch(std::bad_alloc&) |
| 11378 | { |
| 11379 | return gl::error(GL_OUT_OF_MEMORY); |
| 11380 | } |
| 11381 | } |
| 11382 | |
| 11383 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 11384 | { |
| 11385 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 11386 | program, binaryFormat, binary, length); |
| 11387 | |
| 11388 | try |
| 11389 | { |
| 11390 | gl::Context *context = gl::getNonLostContext(); |
| 11391 | |
| 11392 | if (context) |
| 11393 | { |
| 11394 | if (context->getClientVersion() < 3) |
| 11395 | { |
| 11396 | return gl::error(GL_INVALID_OPERATION); |
| 11397 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11398 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11399 | // glProgramBinary |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11400 | UNIMPLEMENTED(); |
| 11401 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11402 | } |
| 11403 | catch(std::bad_alloc&) |
| 11404 | { |
| 11405 | return gl::error(GL_OUT_OF_MEMORY); |
| 11406 | } |
| 11407 | } |
| 11408 | |
| 11409 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 11410 | { |
| 11411 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 11412 | program, pname, value); |
| 11413 | |
| 11414 | try |
| 11415 | { |
| 11416 | gl::Context *context = gl::getNonLostContext(); |
| 11417 | |
| 11418 | if (context) |
| 11419 | { |
| 11420 | if (context->getClientVersion() < 3) |
| 11421 | { |
| 11422 | return gl::error(GL_INVALID_OPERATION); |
| 11423 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11424 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11425 | // glProgramParameteri |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11426 | UNIMPLEMENTED(); |
| 11427 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11428 | } |
| 11429 | catch(std::bad_alloc&) |
| 11430 | { |
| 11431 | return gl::error(GL_OUT_OF_MEMORY); |
| 11432 | } |
| 11433 | } |
| 11434 | |
| 11435 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 11436 | { |
| 11437 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 11438 | target, numAttachments, attachments); |
| 11439 | |
| 11440 | try |
| 11441 | { |
| 11442 | gl::Context *context = gl::getNonLostContext(); |
| 11443 | |
| 11444 | if (context) |
| 11445 | { |
| 11446 | if (context->getClientVersion() < 3) |
| 11447 | { |
| 11448 | return gl::error(GL_INVALID_OPERATION); |
| 11449 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11450 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11451 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11452 | { |
| 11453 | return; |
| 11454 | } |
| 11455 | |
| 11456 | int maxDimension = context->getMaximumRenderbufferDimension(); |
| 11457 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
| 11458 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11459 | } |
| 11460 | catch(std::bad_alloc&) |
| 11461 | { |
| 11462 | return gl::error(GL_OUT_OF_MEMORY); |
| 11463 | } |
| 11464 | } |
| 11465 | |
| 11466 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 11467 | { |
| 11468 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 11469 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 11470 | target, numAttachments, attachments, x, y, width, height); |
| 11471 | |
| 11472 | try |
| 11473 | { |
| 11474 | gl::Context *context = gl::getNonLostContext(); |
| 11475 | |
| 11476 | if (context) |
| 11477 | { |
| 11478 | if (context->getClientVersion() < 3) |
| 11479 | { |
| 11480 | return gl::error(GL_INVALID_OPERATION); |
| 11481 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11482 | |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 11483 | if (!validateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 11484 | { |
| 11485 | return; |
| 11486 | } |
| 11487 | |
| 11488 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
| 11489 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11490 | } |
| 11491 | catch(std::bad_alloc&) |
| 11492 | { |
| 11493 | return gl::error(GL_OUT_OF_MEMORY); |
| 11494 | } |
| 11495 | } |
| 11496 | |
| 11497 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 11498 | { |
| 11499 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 11500 | target, levels, internalformat, width, height); |
| 11501 | |
| 11502 | try |
| 11503 | { |
| 11504 | gl::Context *context = gl::getNonLostContext(); |
| 11505 | |
| 11506 | if (context) |
| 11507 | { |
| 11508 | if (context->getClientVersion() < 3) |
| 11509 | { |
| 11510 | return gl::error(GL_INVALID_OPERATION); |
| 11511 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11512 | |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11513 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 11514 | { |
| 11515 | return; |
| 11516 | } |
| 11517 | |
| 11518 | switch (target) |
| 11519 | { |
| 11520 | case GL_TEXTURE_2D: |
| 11521 | { |
| 11522 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 11523 | texture2d->storage(levels, internalformat, width, height); |
| 11524 | } |
| 11525 | break; |
| 11526 | |
| 11527 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 11528 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 11529 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 11530 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 11531 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 11532 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 11533 | { |
| 11534 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 11535 | textureCube->storage(levels, internalformat, width); |
| 11536 | } |
| 11537 | break; |
| 11538 | |
| 11539 | default: |
| 11540 | return gl::error(GL_INVALID_ENUM); |
| 11541 | } |
| 11542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11543 | } |
| 11544 | catch(std::bad_alloc&) |
| 11545 | { |
| 11546 | return gl::error(GL_OUT_OF_MEMORY); |
| 11547 | } |
| 11548 | } |
| 11549 | |
| 11550 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 11551 | { |
| 11552 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 11553 | "GLsizei height = %d, GLsizei depth = %d)", |
| 11554 | target, levels, internalformat, width, height, depth); |
| 11555 | |
| 11556 | try |
| 11557 | { |
| 11558 | gl::Context *context = gl::getNonLostContext(); |
| 11559 | |
| 11560 | if (context) |
| 11561 | { |
| 11562 | if (context->getClientVersion() < 3) |
| 11563 | { |
| 11564 | return gl::error(GL_INVALID_OPERATION); |
| 11565 | } |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 11566 | |
| 11567 | if (!validateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 11568 | { |
| 11569 | return; |
| 11570 | } |
| 11571 | |
| 11572 | switch (target) |
| 11573 | { |
| 11574 | case GL_TEXTURE_3D: |
| 11575 | { |
| 11576 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 11577 | texture3d->storage(levels, internalformat, width, height, depth); |
| 11578 | } |
| 11579 | break; |
| 11580 | |
| 11581 | case GL_TEXTURE_2D_ARRAY: |
| 11582 | { |
| 11583 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 11584 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 11585 | } |
| 11586 | break; |
| 11587 | |
| 11588 | default: |
| 11589 | return gl::error(GL_INVALID_ENUM); |
| 11590 | } |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 11591 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11592 | } |
| 11593 | catch(std::bad_alloc&) |
| 11594 | { |
| 11595 | return gl::error(GL_OUT_OF_MEMORY); |
| 11596 | } |
| 11597 | } |
| 11598 | |
| 11599 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 11600 | { |
| 11601 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 11602 | "GLint* params = 0x%0.8p)", |
| 11603 | target, internalformat, pname, bufSize, params); |
| 11604 | |
| 11605 | try |
| 11606 | { |
| 11607 | gl::Context *context = gl::getNonLostContext(); |
| 11608 | |
| 11609 | if (context) |
| 11610 | { |
| 11611 | if (context->getClientVersion() < 3) |
| 11612 | { |
| 11613 | return gl::error(GL_INVALID_OPERATION); |
| 11614 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11615 | |
Jamie Madill | 5413351 | 2013-06-21 09:33:07 -0400 | [diff] [blame] | 11616 | // glGetInternalformativ |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 11617 | UNIMPLEMENTED(); |
| 11618 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 11619 | } |
| 11620 | catch(std::bad_alloc&) |
| 11621 | { |
| 11622 | return gl::error(GL_OUT_OF_MEMORY); |
| 11623 | } |
| 11624 | } |
| 11625 | |
| 11626 | // Extension functions |
| 11627 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11628 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 11629 | GLbitfield mask, GLenum filter) |
| 11630 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11631 | 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] | 11632 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 11633 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 11634 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 11635 | |
| 11636 | try |
| 11637 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11638 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11639 | |
| 11640 | if (context) |
| 11641 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11642 | if (!validateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 11643 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 11644 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11645 | { |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11646 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11647 | } |
| 11648 | |
Geoff Lang | 758d5b2 | 2013-06-11 11:42:50 -0400 | [diff] [blame] | 11649 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 11650 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11651 | } |
| 11652 | } |
| 11653 | catch(std::bad_alloc&) |
| 11654 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11655 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 11656 | } |
| 11657 | } |
| 11658 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 11659 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 11660 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11661 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 11662 | 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] | 11663 | "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] | 11664 | "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] | 11665 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 11666 | |
| 11667 | try |
| 11668 | { |
| 11669 | UNIMPLEMENTED(); // FIXME |
| 11670 | } |
| 11671 | catch(std::bad_alloc&) |
| 11672 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11673 | return gl::error(GL_OUT_OF_MEMORY); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11674 | } |
| 11675 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11676 | |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11677 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
| 11678 | GLenum *binaryFormat, void *binary) |
| 11679 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11680 | 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] | 11681 | program, bufSize, length, binaryFormat, binary); |
| 11682 | |
| 11683 | try |
| 11684 | { |
| 11685 | gl::Context *context = gl::getNonLostContext(); |
| 11686 | |
| 11687 | if (context) |
| 11688 | { |
| 11689 | gl::Program *programObject = context->getProgram(program); |
| 11690 | |
daniel@transgaming.com | 716056c | 2012-07-24 18:38:59 +0000 | [diff] [blame] | 11691 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11692 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11693 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11694 | } |
| 11695 | |
| 11696 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 11697 | |
| 11698 | if (!programBinary) |
| 11699 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11700 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11701 | } |
| 11702 | |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11703 | if (!programBinary->save(binary, bufSize, length)) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11704 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11705 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11706 | } |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 11707 | |
| 11708 | *binaryFormat = GL_PROGRAM_BINARY_ANGLE; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11709 | } |
| 11710 | } |
| 11711 | catch(std::bad_alloc&) |
| 11712 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11713 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11714 | } |
| 11715 | } |
| 11716 | |
| 11717 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 11718 | const void *binary, GLint length) |
| 11719 | { |
| 11720 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 11721 | program, binaryFormat, binary, length); |
| 11722 | |
| 11723 | try |
| 11724 | { |
| 11725 | gl::Context *context = gl::getNonLostContext(); |
| 11726 | |
| 11727 | if (context) |
| 11728 | { |
| 11729 | if (binaryFormat != GL_PROGRAM_BINARY_ANGLE) |
| 11730 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11731 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11732 | } |
| 11733 | |
| 11734 | gl::Program *programObject = context->getProgram(program); |
| 11735 | |
| 11736 | if (!programObject) |
| 11737 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11738 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11739 | } |
| 11740 | |
daniel@transgaming.com | 95d2942 | 2012-07-24 18:36:10 +0000 | [diff] [blame] | 11741 | context->setProgramBinary(program, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11742 | } |
| 11743 | } |
| 11744 | catch(std::bad_alloc&) |
| 11745 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11746 | return gl::error(GL_OUT_OF_MEMORY); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11747 | } |
| 11748 | } |
| 11749 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11750 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 11751 | { |
| 11752 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 11753 | |
| 11754 | try |
| 11755 | { |
| 11756 | gl::Context *context = gl::getNonLostContext(); |
| 11757 | |
| 11758 | if (context) |
| 11759 | { |
| 11760 | if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets()) |
| 11761 | { |
| 11762 | return gl::error(GL_INVALID_VALUE); |
| 11763 | } |
| 11764 | |
| 11765 | if (context->getDrawFramebufferHandle() == 0) |
| 11766 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11767 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11768 | { |
| 11769 | return gl::error(GL_INVALID_OPERATION); |
| 11770 | } |
| 11771 | |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11772 | 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] | 11773 | { |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11774 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11775 | } |
| 11776 | } |
| 11777 | else |
| 11778 | { |
| 11779 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11780 | { |
| 11781 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 11782 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 11783 | { |
| 11784 | return gl::error(GL_INVALID_OPERATION); |
| 11785 | } |
| 11786 | } |
| 11787 | } |
| 11788 | |
| 11789 | gl::Framebuffer *framebuffer = context->getDrawFramebuffer(); |
| 11790 | |
| 11791 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 11792 | { |
| 11793 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 11794 | } |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 11795 | |
| 11796 | for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++) |
| 11797 | { |
| 11798 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 11799 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 11800 | } |
| 11801 | } |
| 11802 | catch (std::bad_alloc&) |
| 11803 | { |
| 11804 | return gl::error(GL_OUT_OF_MEMORY); |
| 11805 | } |
| 11806 | } |
| 11807 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11808 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 11809 | { |
| 11810 | struct Extension |
| 11811 | { |
| 11812 | const char *name; |
| 11813 | __eglMustCastToProperFunctionPointerType address; |
| 11814 | }; |
| 11815 | |
| 11816 | static const Extension glExtensions[] = |
| 11817 | { |
| 11818 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 11819 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 11820 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 11821 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 11822 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 11823 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 11824 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 11825 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 11826 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 11827 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 11828 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 11829 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 11830 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 11831 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 11832 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 11833 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 11834 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 11835 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 11836 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 11837 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 11838 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 11839 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 11840 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 11841 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 11842 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 11843 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 11844 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 11845 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
| 11846 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11847 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 11848 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 11849 | { |
| 11850 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 11851 | { |
| 11852 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 11853 | } |
| 11854 | } |
| 11855 | |
| 11856 | return NULL; |
| 11857 | } |
| 11858 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 11859 | // Non-public functions used by EGL |
| 11860 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11861 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11862 | { |
| 11863 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 11864 | surface); |
| 11865 | |
| 11866 | try |
| 11867 | { |
daniel@transgaming.com | 9d78850 | 2011-11-09 17:46:55 +0000 | [diff] [blame] | 11868 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11869 | |
| 11870 | if (context) |
| 11871 | { |
| 11872 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 11873 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11874 | if (textureObject->isImmutable()) |
| 11875 | { |
| 11876 | return false; |
| 11877 | } |
| 11878 | |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11879 | if (textureObject) |
| 11880 | { |
| 11881 | textureObject->bindTexImage(surface); |
| 11882 | } |
| 11883 | } |
| 11884 | } |
| 11885 | catch(std::bad_alloc&) |
| 11886 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 11887 | return gl::error(GL_OUT_OF_MEMORY, false); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11888 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 11889 | |
| 11890 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 11891 | } |
| 11892 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11893 | } |