John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1 | // SwiftShader Software Renderer
|
| 2 | //
|
| 3 | // Copyright(c) 2005-2013 TransGaming Inc.
|
| 4 | //
|
| 5 | // All rights reserved. No part of this software may be copied, distributed, transmitted,
|
| 6 | // transcribed, stored in a retrieval system, translated into any human or computer
|
| 7 | // language by any means, or disclosed to third parties without the explicit written
|
| 8 | // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
|
| 9 | // or implied, including but not limited to any patent rights, are granted to you.
|
| 10 | //
|
| 11 | // libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
|
| 12 |
|
| 13 | #include "main.h"
|
| 14 | #include "mathutil.h"
|
| 15 | #include "utilities.h"
|
| 16 | #include "Buffer.h"
|
| 17 | #include "Context.h"
|
| 18 | #include "Fence.h"
|
| 19 | #include "Framebuffer.h"
|
| 20 | #include "Program.h"
|
| 21 | #include "Renderbuffer.h"
|
| 22 | #include "Shader.h"
|
| 23 | #include "Texture.h"
|
| 24 | #include "Query.h"
|
| 25 | #include "common/debug.h"
|
| 26 | #include "Common/Version.h"
|
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 27 | #include "Main/Register.hpp"
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 28 |
|
| 29 | #define GL_APICALL
|
| 30 | #include <GLES2/gl2.h>
|
| 31 | #include <GLES2/gl2ext.h>
|
Alexis Hetu | fceb183 | 2015-03-10 16:42:04 -0400 | [diff] [blame] | 32 | #include <GLES3/gl3.h>
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 33 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 34 | #include <limits>
|
| 35 |
|
Greg Hartman | 6074f12 | 2015-04-08 09:57:16 -0700 | [diff] [blame] | 36 | #ifdef ANDROID
|
| 37 | #include <cutils/log.h>
|
| 38 | #endif
|
| 39 |
|
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 40 | using namespace es2;
|
| 41 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 42 | typedef std::pair<GLenum, GLenum> InternalFormatTypePair;
|
| 43 | typedef std::map<InternalFormatTypePair, GLenum> FormatMap;
|
| 44 |
|
| 45 | // A helper function to insert data into the format map with fewer characters.
|
| 46 | static void InsertFormatMapping(FormatMap& map, GLenum internalformat, GLenum format, GLenum type)
|
| 47 | {
|
| 48 | map[InternalFormatTypePair(internalformat, type)] = format;
|
| 49 | }
|
| 50 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 51 | static bool validImageSize(GLint level, GLsizei width, GLsizei height)
|
| 52 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 53 | if(level < 0 || level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0)
|
| 54 | {
|
| 55 | return false;
|
| 56 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 57 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 58 | return true;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 59 | }
|
| 60 |
|
Nicolas Capens | 14ee762 | 2014-10-28 23:48:41 -0400 | [diff] [blame] | 61 | static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, es2::Texture *texture)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 62 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 63 | if(!texture)
|
| 64 | {
|
| 65 | return error(GL_INVALID_OPERATION, false);
|
| 66 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 67 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 68 | if(compressed != texture->isCompressed(target, level))
|
| 69 | {
|
| 70 | return error(GL_INVALID_OPERATION, false);
|
| 71 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 72 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 73 | if(format != GL_NONE && format != texture->getFormat(target, level))
|
| 74 | {
|
| 75 | return error(GL_INVALID_OPERATION, false);
|
| 76 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 77 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 78 | if(compressed)
|
| 79 | {
|
| 80 | if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 81 | (height % 4 != 0 && height != texture->getHeight(target, 0)))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 82 | {
|
| 83 | return error(GL_INVALID_OPERATION, false);
|
| 84 | }
|
| 85 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 86 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 87 | if(xoffset + width > texture->getWidth(target, level) ||
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 88 | yoffset + height > texture->getHeight(target, level))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 89 | {
|
| 90 | return error(GL_INVALID_VALUE, false);
|
| 91 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 92 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 93 | return true;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 94 | }
|
| 95 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 96 | static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLsizei depth, GLint xoffset, GLint yoffset, GLint zoffset, GLenum target, GLint level, GLenum format, es2::Texture *texture)
|
| 97 | {
|
| 98 | if(!texture)
|
| 99 | {
|
| 100 | return error(GL_INVALID_OPERATION, false);
|
| 101 | }
|
| 102 |
|
| 103 | if(compressed != texture->isCompressed(target, level))
|
| 104 | {
|
| 105 | return error(GL_INVALID_OPERATION, false);
|
| 106 | }
|
| 107 |
|
| 108 | if(format != GL_NONE && format != texture->getFormat(target, level))
|
| 109 | {
|
| 110 | return error(GL_INVALID_OPERATION, false);
|
| 111 | }
|
| 112 |
|
| 113 | if(compressed)
|
| 114 | {
|
| 115 | if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
|
| 116 | (height % 4 != 0 && height != texture->getHeight(target, 0)) ||
|
| 117 | (depth % 4 != 0 && depth != texture->getDepth(target, 0)))
|
| 118 | {
|
| 119 | return error(GL_INVALID_OPERATION, false);
|
| 120 | }
|
| 121 | }
|
| 122 |
|
| 123 | if(xoffset + width > texture->getWidth(target, level) ||
|
| 124 | yoffset + height > texture->getHeight(target, level) ||
|
| 125 | zoffset + depth > texture->getDepth(target, level))
|
| 126 | {
|
| 127 | return error(GL_INVALID_VALUE, false);
|
| 128 | }
|
| 129 |
|
| 130 | return true;
|
| 131 | }
|
| 132 |
|
| 133 | static bool validateColorBufferFormat(GLenum textureFormat, GLenum colorbufferFormat)
|
| 134 | {
|
| 135 | // [OpenGL ES 2.0.24] table 3.9
|
| 136 | switch(textureFormat)
|
| 137 | {
|
| 138 | case GL_ALPHA:
|
| 139 | if(colorbufferFormat != GL_ALPHA &&
|
| 140 | colorbufferFormat != GL_RGBA &&
|
| 141 | colorbufferFormat != GL_RGBA4 &&
|
| 142 | colorbufferFormat != GL_RGB5_A1 &&
|
| 143 | colorbufferFormat != GL_RGBA8_OES)
|
| 144 | {
|
| 145 | return error(GL_INVALID_OPERATION, false);
|
| 146 | }
|
| 147 | break;
|
| 148 | case GL_LUMINANCE:
|
| 149 | case GL_RGB:
|
| 150 | if(colorbufferFormat != GL_RGB &&
|
| 151 | colorbufferFormat != GL_RGB565 &&
|
| 152 | colorbufferFormat != GL_RGB8_OES &&
|
| 153 | colorbufferFormat != GL_RGBA &&
|
| 154 | colorbufferFormat != GL_RGBA4 &&
|
| 155 | colorbufferFormat != GL_RGB5_A1 &&
|
| 156 | colorbufferFormat != GL_RGBA8_OES)
|
| 157 | {
|
| 158 | return error(GL_INVALID_OPERATION, false);
|
| 159 | }
|
| 160 | break;
|
| 161 | case GL_LUMINANCE_ALPHA:
|
| 162 | case GL_RGBA:
|
| 163 | if(colorbufferFormat != GL_RGBA &&
|
| 164 | colorbufferFormat != GL_RGBA4 &&
|
| 165 | colorbufferFormat != GL_RGB5_A1 &&
|
| 166 | colorbufferFormat != GL_RGBA8_OES)
|
| 167 | {
|
| 168 | return error(GL_INVALID_OPERATION, false);
|
| 169 | }
|
| 170 | break;
|
| 171 | case GL_ETC1_RGB8_OES:
|
| 172 | return error(GL_INVALID_OPERATION, false);
|
| 173 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| 174 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| 175 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
|
| 176 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
|
| 177 | if(S3TC_SUPPORT)
|
| 178 | {
|
| 179 | return error(GL_INVALID_OPERATION, false);
|
| 180 | }
|
| 181 | else
|
| 182 | {
|
| 183 | return error(GL_INVALID_ENUM, false);
|
| 184 | }
|
| 185 | case GL_DEPTH_COMPONENT:
|
| 186 | case GL_DEPTH_STENCIL_OES:
|
| 187 | return error(GL_INVALID_OPERATION, false);
|
| 188 | default:
|
| 189 | return error(GL_INVALID_ENUM, false);
|
| 190 | }
|
| 191 | return true;
|
| 192 | }
|
| 193 |
|
| 194 | static FormatMap BuildFormatMap3D()
|
| 195 | {
|
| 196 | FormatMap map;
|
| 197 |
|
| 198 | // Internal format | Format | Type
|
| 199 | InsertFormatMapping(map, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE);
|
| 200 | InsertFormatMapping(map, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
|
| 201 | InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 202 | InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
|
| 203 | InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
|
| 204 | InsertFormatMapping(map, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
|
| 205 | InsertFormatMapping(map, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE);
|
| 206 | InsertFormatMapping(map, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE);
|
| 207 | InsertFormatMapping(map, GL_R8_EXT, GL_RED_EXT, GL_UNSIGNED_BYTE);
|
| 208 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_HALF_FLOAT_OES);
|
| 209 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_FLOAT);
|
| 210 | InsertFormatMapping(map, GL_R32F_EXT, GL_RED_EXT, GL_FLOAT);
|
| 211 | InsertFormatMapping(map, GL_RG8_EXT, GL_RG_EXT, GL_UNSIGNED_BYTE);
|
| 212 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_HALF_FLOAT_OES);
|
| 213 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_FLOAT);
|
| 214 | InsertFormatMapping(map, GL_RG32F_EXT, GL_RG_EXT, GL_FLOAT);
|
| 215 | InsertFormatMapping(map, GL_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE);
|
| 216 | InsertFormatMapping(map, GL_SRGB8_NV, GL_RGB, GL_UNSIGNED_BYTE);
|
| 217 | InsertFormatMapping(map, GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE);
|
| 218 | InsertFormatMapping(map, GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
|
Alexis Hetu | 0300e3c | 2015-03-12 17:33:07 -0400 | [diff] [blame] | 219 | InsertFormatMapping(map, GL_RGB16F_EXT, GL_RGB, GL_HALF_FLOAT_OES);
|
| 220 | InsertFormatMapping(map, GL_RGB16F_EXT, GL_RGB, GL_FLOAT);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 221 | InsertFormatMapping(map, GL_RGB32F_EXT, GL_RGB, GL_FLOAT);
|
| 222 | InsertFormatMapping(map, GL_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 223 | InsertFormatMapping(map, GL_SRGB8_ALPHA8_EXT, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 224 | InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 225 | InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
|
| 226 | InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV_EXT);
|
| 227 | InsertFormatMapping(map, GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 228 | InsertFormatMapping(map, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
|
| 229 | InsertFormatMapping(map, GL_RGB10_A2_EXT, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV_EXT);
|
| 230 | InsertFormatMapping(map, GL_RGBA16F_EXT, GL_RGBA, GL_HALF_FLOAT_OES);
|
| 231 | InsertFormatMapping(map, GL_RGBA16F_EXT, GL_RGBA, GL_FLOAT);
|
| 232 | InsertFormatMapping(map, GL_RGBA32F_EXT, GL_RGBA, GL_FLOAT);
|
| 233 |
|
| 234 | return map;
|
| 235 | }
|
| 236 |
|
| 237 | static bool ValidateType3D(GLenum type)
|
| 238 | {
|
| 239 | switch(type)
|
| 240 | {
|
| 241 | case GL_UNSIGNED_BYTE:
|
| 242 | case GL_BYTE:
|
| 243 | case GL_UNSIGNED_SHORT:
|
| 244 | case GL_SHORT:
|
| 245 | case GL_UNSIGNED_INT:
|
| 246 | case GL_INT:
|
| 247 | case GL_HALF_FLOAT_OES:
|
| 248 | case GL_FLOAT:
|
| 249 | case GL_UNSIGNED_SHORT_5_6_5:
|
| 250 | case GL_UNSIGNED_SHORT_4_4_4_4:
|
| 251 | case GL_UNSIGNED_SHORT_5_5_5_1:
|
| 252 | case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
|
| 253 | return true;
|
| 254 | default:
|
| 255 | break;
|
| 256 | }
|
| 257 | return false;
|
| 258 | }
|
| 259 |
|
| 260 | static bool ValidateFormat3D(GLenum format)
|
| 261 | {
|
| 262 | switch(format)
|
| 263 | {
|
| 264 | case GL_RED_EXT:
|
| 265 | case GL_RG_EXT:
|
| 266 | case GL_RGB:
|
| 267 | case GL_RGBA:
|
| 268 | case GL_DEPTH_COMPONENT:
|
| 269 | case GL_DEPTH_STENCIL_OES:
|
| 270 | case GL_LUMINANCE_ALPHA:
|
| 271 | case GL_LUMINANCE:
|
| 272 | case GL_ALPHA:
|
| 273 | return true;
|
| 274 | default:
|
| 275 | break;
|
| 276 | }
|
| 277 | return false;
|
| 278 | }
|
| 279 |
|
| 280 | static bool ValidateInternalFormat3D(GLenum internalformat, GLenum format, GLenum type)
|
| 281 | {
|
| 282 | static const FormatMap formatMap = BuildFormatMap3D();
|
| 283 | FormatMap::const_iterator iter = formatMap.find(InternalFormatTypePair(internalformat, type));
|
| 284 | if(iter != formatMap.end())
|
| 285 | {
|
| 286 | return iter->second == format;
|
| 287 | }
|
| 288 | return false;
|
| 289 | }
|
| 290 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 291 | extern "C"
|
| 292 | {
|
| 293 |
|
| 294 | void GL_APIENTRY glActiveTexture(GLenum texture)
|
| 295 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 296 | TRACE("(GLenum texture = 0x%X)", texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 297 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 298 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 299 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 300 | if(context)
|
| 301 | {
|
| 302 | if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + es2::MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)
|
| 303 | {
|
| 304 | return error(GL_INVALID_ENUM);
|
| 305 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 306 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 307 | context->setActiveSampler(texture - GL_TEXTURE0);
|
| 308 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 309 | }
|
| 310 |
|
| 311 | void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
|
| 312 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 313 | TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 314 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 315 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 316 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 317 | if(context)
|
| 318 | {
|
| 319 | es2::Program *programObject = context->getProgram(program);
|
| 320 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 321 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 322 | if(!programObject)
|
| 323 | {
|
| 324 | if(context->getShader(program))
|
| 325 | {
|
| 326 | return error(GL_INVALID_OPERATION);
|
| 327 | }
|
| 328 | else
|
| 329 | {
|
| 330 | return error(GL_INVALID_VALUE);
|
| 331 | }
|
| 332 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 333 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 334 | if(!shaderObject)
|
| 335 | {
|
| 336 | if(context->getProgram(shader))
|
| 337 | {
|
| 338 | return error(GL_INVALID_OPERATION);
|
| 339 | }
|
| 340 | else
|
| 341 | {
|
| 342 | return error(GL_INVALID_VALUE);
|
| 343 | }
|
| 344 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 345 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 346 | if(!programObject->attachShader(shaderObject))
|
| 347 | {
|
| 348 | return error(GL_INVALID_OPERATION);
|
| 349 | }
|
| 350 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 351 | }
|
| 352 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 353 | void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 354 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 355 | TRACE("(GLenum target = 0x%X, GLuint name = %d)", target, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 356 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 357 | switch(target)
|
| 358 | {
|
| 359 | case GL_ANY_SAMPLES_PASSED_EXT:
|
| 360 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
|
| 361 | break;
|
| 362 | default:
|
| 363 | return error(GL_INVALID_ENUM);
|
| 364 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 365 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 366 | if(name == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 367 | {
|
| 368 | return error(GL_INVALID_OPERATION);
|
| 369 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 370 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 371 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 372 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 373 | if(context)
|
| 374 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 375 | context->beginQuery(target, name);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 376 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 377 | }
|
| 378 |
|
| 379 | void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
|
| 380 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 381 | TRACE("(GLuint program = %d, GLuint index = %d, const GLchar* name = %s)", program, index, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 382 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 383 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 384 | {
|
| 385 | return error(GL_INVALID_VALUE);
|
| 386 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 387 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 388 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 389 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 390 | if(context)
|
| 391 | {
|
| 392 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 393 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 394 | if(!programObject)
|
| 395 | {
|
| 396 | if(context->getShader(program))
|
| 397 | {
|
| 398 | return error(GL_INVALID_OPERATION);
|
| 399 | }
|
| 400 | else
|
| 401 | {
|
| 402 | return error(GL_INVALID_VALUE);
|
| 403 | }
|
| 404 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 405 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 406 | if(strncmp(name, "gl_", 3) == 0)
|
| 407 | {
|
| 408 | return error(GL_INVALID_OPERATION);
|
| 409 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 410 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 411 | programObject->bindAttributeLocation(index, name);
|
| 412 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 413 | }
|
| 414 |
|
| 415 | void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
|
| 416 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 417 | TRACE("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 418 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 419 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 420 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 421 | if(context)
|
| 422 | {
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 423 | egl::GLint clientVersion = egl::getClientVersion();
|
| 424 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 425 | switch(target)
|
| 426 | {
|
| 427 | case GL_ARRAY_BUFFER:
|
| 428 | context->bindArrayBuffer(buffer);
|
| 429 | return;
|
| 430 | case GL_ELEMENT_ARRAY_BUFFER:
|
| 431 | context->bindElementArrayBuffer(buffer);
|
| 432 | return;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 433 | case GL_COPY_READ_BUFFER:
|
| 434 | if(clientVersion >= 3)
|
| 435 | {
|
| 436 | context->bindCopyReadBuffer(buffer);
|
| 437 | return;
|
| 438 | }
|
| 439 | else return error(GL_INVALID_ENUM);
|
| 440 | case GL_COPY_WRITE_BUFFER:
|
| 441 | if(clientVersion >= 3)
|
| 442 | {
|
| 443 | context->bindCopyWriteBuffer(buffer);
|
| 444 | return;
|
| 445 | }
|
| 446 | else return error(GL_INVALID_ENUM);
|
| 447 | case GL_PIXEL_PACK_BUFFER:
|
| 448 | if(clientVersion >= 3)
|
| 449 | {
|
| 450 | context->bindPixelPackBuffer(buffer);
|
| 451 | return;
|
| 452 | }
|
| 453 | else return error(GL_INVALID_ENUM);
|
| 454 | case GL_PIXEL_UNPACK_BUFFER:
|
| 455 | if(clientVersion >= 3)
|
| 456 | {
|
| 457 | context->bindPixelUnpackBuffer(buffer);
|
| 458 | return;
|
| 459 | }
|
| 460 | else return error(GL_INVALID_ENUM);
|
| 461 | case GL_TRANSFORM_FEEDBACK_BUFFER:
|
| 462 | if(clientVersion >= 3)
|
| 463 | {
|
| 464 | UNIMPLEMENTED();
|
| 465 | return;
|
| 466 | }
|
| 467 | else return error(GL_INVALID_ENUM);
|
| 468 | case GL_UNIFORM_BUFFER:
|
| 469 | if(clientVersion >= 3)
|
| 470 | {
|
| 471 | context->bindUniformBuffer(buffer);
|
| 472 | return;
|
| 473 | }
|
| 474 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 475 | default:
|
| 476 | return error(GL_INVALID_ENUM);
|
| 477 | }
|
| 478 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 479 | }
|
| 480 |
|
| 481 | void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
|
| 482 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 483 | TRACE("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 484 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 485 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 486 | {
|
| 487 | return error(GL_INVALID_ENUM);
|
| 488 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 489 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 490 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 491 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 492 | if(context)
|
| 493 | {
|
| 494 | if(target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
|
| 495 | {
|
| 496 | context->bindReadFramebuffer(framebuffer);
|
| 497 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 498 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 499 | if(target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
|
| 500 | {
|
| 501 | context->bindDrawFramebuffer(framebuffer);
|
| 502 | }
|
| 503 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 504 | }
|
| 505 |
|
| 506 | void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
|
| 507 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 508 | TRACE("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 509 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 510 | if(target != GL_RENDERBUFFER)
|
| 511 | {
|
| 512 | return error(GL_INVALID_ENUM);
|
| 513 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 514 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 515 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 516 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 517 | if(context)
|
| 518 | {
|
| 519 | if(renderbuffer != 0 && !context->getRenderbuffer(renderbuffer))
|
| 520 | {
|
| 521 | // [OpenGL ES 2.0.25] Section 4.4.3 page 112
|
| 522 | // [OpenGL ES 3.0.2] Section 4.4.2 page 201
|
| 523 | // 'renderbuffer' must be either zero or the name of an existing renderbuffer object of
|
| 524 | // type 'renderbuffertarget', otherwise an INVALID_OPERATION error is generated.
|
| 525 | return error(GL_INVALID_OPERATION);
|
| 526 | }
|
Alexis Hetu | 42a584d | 2014-11-07 14:23:33 -0500 | [diff] [blame] | 527 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 528 | context->bindRenderbuffer(renderbuffer);
|
| 529 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 530 | }
|
| 531 |
|
| 532 | void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
|
| 533 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 534 | TRACE("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 535 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 536 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 537 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 538 | if(context)
|
| 539 | {
|
| 540 | es2::Texture *textureObject = context->getTexture(texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 541 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 542 | if(textureObject && textureObject->getTarget() != target && texture != 0)
|
| 543 | {
|
| 544 | return error(GL_INVALID_OPERATION);
|
| 545 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 546 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 547 | egl::GLint clientVersion = context->getClientVersion();
|
| 548 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 549 | switch(target)
|
| 550 | {
|
| 551 | case GL_TEXTURE_2D:
|
| 552 | context->bindTexture2D(texture);
|
| 553 | return;
|
| 554 | case GL_TEXTURE_CUBE_MAP:
|
| 555 | context->bindTextureCubeMap(texture);
|
| 556 | return;
|
| 557 | case GL_TEXTURE_EXTERNAL_OES:
|
| 558 | context->bindTextureExternal(texture);
|
| 559 | return;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 560 | case GL_TEXTURE_2D_ARRAY:
|
| 561 | if(clientVersion < 3)
|
| 562 | {
|
| 563 | return error(GL_INVALID_ENUM);
|
| 564 | }
|
| 565 | else
|
| 566 | {
|
| 567 | UNIMPLEMENTED();
|
| 568 | context->bindTexture3D(texture);
|
| 569 | break;
|
| 570 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 571 | case GL_TEXTURE_3D_OES:
|
| 572 | context->bindTexture3D(texture);
|
| 573 | return;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 574 | default:
|
| 575 | return error(GL_INVALID_ENUM);
|
| 576 | }
|
| 577 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 578 | }
|
| 579 |
|
| 580 | void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
| 581 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 582 | TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
|
| 583 | red, green, blue, alpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 584 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 585 | es2::Context* context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 586 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 587 | if(context)
|
| 588 | {
|
| 589 | context->setBlendColor(es2::clamp01(red), es2::clamp01(green), es2::clamp01(blue), es2::clamp01(alpha));
|
| 590 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 591 | }
|
| 592 |
|
| 593 | void GL_APIENTRY glBlendEquation(GLenum mode)
|
| 594 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 595 | glBlendEquationSeparate(mode, mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 596 | }
|
| 597 |
|
| 598 | void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
|
| 599 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 600 | TRACE("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 601 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 602 | switch(modeRGB)
|
| 603 | {
|
| 604 | case GL_FUNC_ADD:
|
| 605 | case GL_FUNC_SUBTRACT:
|
| 606 | case GL_FUNC_REVERSE_SUBTRACT:
|
| 607 | case GL_MIN_EXT:
|
| 608 | case GL_MAX_EXT:
|
| 609 | break;
|
| 610 | default:
|
| 611 | return error(GL_INVALID_ENUM);
|
| 612 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 613 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 614 | switch(modeAlpha)
|
| 615 | {
|
| 616 | case GL_FUNC_ADD:
|
| 617 | case GL_FUNC_SUBTRACT:
|
| 618 | case GL_FUNC_REVERSE_SUBTRACT:
|
| 619 | case GL_MIN_EXT:
|
| 620 | case GL_MAX_EXT:
|
| 621 | break;
|
| 622 | default:
|
| 623 | return error(GL_INVALID_ENUM);
|
| 624 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 625 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 626 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 627 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 628 | if(context)
|
| 629 | {
|
| 630 | context->setBlendEquation(modeRGB, modeAlpha);
|
| 631 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 632 | }
|
| 633 |
|
| 634 | void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
|
| 635 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 636 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 637 | }
|
| 638 |
|
| 639 | void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
| 640 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 641 | TRACE("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
|
| 642 | srcRGB, dstRGB, srcAlpha, dstAlpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 643 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 644 | switch(srcRGB)
|
| 645 | {
|
| 646 | case GL_ZERO:
|
| 647 | case GL_ONE:
|
| 648 | case GL_SRC_COLOR:
|
| 649 | case GL_ONE_MINUS_SRC_COLOR:
|
| 650 | case GL_DST_COLOR:
|
| 651 | case GL_ONE_MINUS_DST_COLOR:
|
| 652 | case GL_SRC_ALPHA:
|
| 653 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 654 | case GL_DST_ALPHA:
|
| 655 | case GL_ONE_MINUS_DST_ALPHA:
|
| 656 | case GL_CONSTANT_COLOR:
|
| 657 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 658 | case GL_CONSTANT_ALPHA:
|
| 659 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 660 | case GL_SRC_ALPHA_SATURATE:
|
| 661 | break;
|
| 662 | default:
|
| 663 | return error(GL_INVALID_ENUM);
|
| 664 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 665 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 666 | switch(dstRGB)
|
| 667 | {
|
| 668 | case GL_ZERO:
|
| 669 | case GL_ONE:
|
| 670 | case GL_SRC_COLOR:
|
| 671 | case GL_ONE_MINUS_SRC_COLOR:
|
| 672 | case GL_DST_COLOR:
|
| 673 | case GL_ONE_MINUS_DST_COLOR:
|
| 674 | case GL_SRC_ALPHA:
|
| 675 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 676 | case GL_DST_ALPHA:
|
| 677 | case GL_ONE_MINUS_DST_ALPHA:
|
| 678 | case GL_CONSTANT_COLOR:
|
| 679 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 680 | case GL_CONSTANT_ALPHA:
|
| 681 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 682 | break;
|
| 683 | default:
|
| 684 | return error(GL_INVALID_ENUM);
|
| 685 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 686 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 687 | switch(srcAlpha)
|
| 688 | {
|
| 689 | case GL_ZERO:
|
| 690 | case GL_ONE:
|
| 691 | case GL_SRC_COLOR:
|
| 692 | case GL_ONE_MINUS_SRC_COLOR:
|
| 693 | case GL_DST_COLOR:
|
| 694 | case GL_ONE_MINUS_DST_COLOR:
|
| 695 | case GL_SRC_ALPHA:
|
| 696 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 697 | case GL_DST_ALPHA:
|
| 698 | case GL_ONE_MINUS_DST_ALPHA:
|
| 699 | case GL_CONSTANT_COLOR:
|
| 700 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 701 | case GL_CONSTANT_ALPHA:
|
| 702 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 703 | case GL_SRC_ALPHA_SATURATE:
|
| 704 | break;
|
| 705 | default:
|
| 706 | return error(GL_INVALID_ENUM);
|
| 707 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 708 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 709 | switch(dstAlpha)
|
| 710 | {
|
| 711 | case GL_ZERO:
|
| 712 | case GL_ONE:
|
| 713 | case GL_SRC_COLOR:
|
| 714 | case GL_ONE_MINUS_SRC_COLOR:
|
| 715 | case GL_DST_COLOR:
|
| 716 | case GL_ONE_MINUS_DST_COLOR:
|
| 717 | case GL_SRC_ALPHA:
|
| 718 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 719 | case GL_DST_ALPHA:
|
| 720 | case GL_ONE_MINUS_DST_ALPHA:
|
| 721 | case GL_CONSTANT_COLOR:
|
| 722 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 723 | case GL_CONSTANT_ALPHA:
|
| 724 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 725 | break;
|
| 726 | default:
|
| 727 | return error(GL_INVALID_ENUM);
|
| 728 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 729 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 730 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 731 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 732 | if(context)
|
| 733 | {
|
| 734 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
| 735 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 736 | }
|
| 737 |
|
| 738 | void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
|
Nicolas Capens | 54b721d | 2014-12-12 12:50:04 -0500 | [diff] [blame] | 739 | {
|
| 740 | size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
|
Nicolas Capens | 4cadfe3 | 2014-12-10 22:26:26 -0500 | [diff] [blame] | 741 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 742 | TRACE("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
|
| 743 | target, size, data, usage);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 744 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 745 | if(size < 0)
|
| 746 | {
|
| 747 | return error(GL_INVALID_VALUE);
|
| 748 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 749 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 750 | egl::GLint clientVersion = egl::getClientVersion();
|
| 751 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 752 | switch(usage)
|
| 753 | {
|
| 754 | case GL_STREAM_DRAW:
|
| 755 | case GL_STATIC_DRAW:
|
| 756 | case GL_DYNAMIC_DRAW:
|
| 757 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 758 | case GL_STREAM_READ:
|
| 759 | case GL_STREAM_COPY:
|
| 760 | case GL_STATIC_READ:
|
| 761 | case GL_STATIC_COPY:
|
| 762 | case GL_DYNAMIC_READ:
|
| 763 | case GL_DYNAMIC_COPY:
|
| 764 | if(clientVersion < 3)
|
| 765 | {
|
| 766 | return error(GL_INVALID_ENUM);
|
| 767 | }
|
| 768 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 769 | default:
|
| 770 | return error(GL_INVALID_ENUM);
|
| 771 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 772 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 773 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 774 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 775 | if(context)
|
| 776 | {
|
| 777 | es2::Buffer *buffer;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 778 | if(!context->getBuffer(target, &buffer))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 779 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 780 | return error(GL_INVALID_ENUM);
|
| 781 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 782 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 783 | if(!buffer)
|
| 784 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 785 | // A null buffer means that "0" is bound to the requested buffer target
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 786 | return error(GL_INVALID_OPERATION);
|
| 787 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 788 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 789 | buffer->bufferData(data, size, usage);
|
| 790 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 791 | }
|
| 792 |
|
| 793 | void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
|
Nicolas Capens | 54b721d | 2014-12-12 12:50:04 -0500 | [diff] [blame] | 794 | {
|
| 795 | size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
|
| 796 | offset = static_cast<GLint>(offset);
|
Nicolas Capens | 4cadfe3 | 2014-12-10 22:26:26 -0500 | [diff] [blame] | 797 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 798 | TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
|
| 799 | target, offset, size, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 800 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 801 | if(size < 0 || offset < 0)
|
| 802 | {
|
| 803 | return error(GL_INVALID_VALUE);
|
| 804 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 805 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 806 | if(data == NULL)
|
| 807 | {
|
| 808 | return;
|
| 809 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 810 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 811 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 812 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 813 | if(context)
|
| 814 | {
|
| 815 | es2::Buffer *buffer;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 816 | if(!context->getBuffer(target, &buffer))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 817 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 818 | return error(GL_INVALID_ENUM);
|
| 819 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 820 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 821 | if(!buffer)
|
| 822 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 823 | // A null buffer means that "0" is bound to the requested buffer target
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 824 | return error(GL_INVALID_OPERATION);
|
| 825 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 826 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 827 | if((size_t)size + offset > buffer->size())
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 828 | {
|
| 829 | return error(GL_INVALID_VALUE);
|
| 830 | }
|
| 831 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 832 | buffer->bufferSubData(data, size, offset);
|
| 833 | }
|
| 834 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 835 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 836 | GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
|
| 837 | {
|
| 838 | TRACE("(GLenum target = 0x%X)", target);
|
| 839 |
|
| 840 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 841 | {
|
| 842 | return error(GL_INVALID_ENUM, 0);
|
| 843 | }
|
| 844 |
|
| 845 | es2::Context *context = es2::getContext();
|
| 846 |
|
| 847 | if(context)
|
| 848 | {
|
| 849 | es2::Framebuffer *framebuffer = NULL;
|
| 850 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 851 | {
|
| 852 | framebuffer = context->getReadFramebuffer();
|
| 853 | }
|
| 854 | else
|
| 855 | {
|
| 856 | framebuffer = context->getDrawFramebuffer();
|
| 857 | }
|
| 858 |
|
| 859 | return framebuffer->completeness();
|
| 860 | }
|
| 861 |
|
| 862 | return 0;
|
| 863 | }
|
| 864 |
|
| 865 | void GL_APIENTRY glClear(GLbitfield mask)
|
| 866 | {
|
| 867 | TRACE("(GLbitfield mask = %X)", mask);
|
| 868 |
|
| 869 | if((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
|
| 870 | {
|
| 871 | return error(GL_INVALID_VALUE);
|
| 872 | }
|
| 873 |
|
| 874 | es2::Context *context = es2::getContext();
|
| 875 |
|
| 876 | if(context)
|
| 877 | {
|
| 878 | context->clear(mask);
|
| 879 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 880 | }
|
| 881 |
|
| 882 | void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
| 883 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 884 | TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
|
| 885 | red, green, blue, alpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 886 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 887 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 888 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 889 | if(context)
|
| 890 | {
|
| 891 | context->setClearColor(red, green, blue, alpha);
|
| 892 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 893 | }
|
| 894 |
|
| 895 | void GL_APIENTRY glClearDepthf(GLclampf depth)
|
| 896 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 897 | TRACE("(GLclampf depth = %f)", depth);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 898 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 899 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 900 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 901 | if(context)
|
| 902 | {
|
| 903 | context->setClearDepth(depth);
|
| 904 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 905 | }
|
| 906 |
|
| 907 | void GL_APIENTRY glClearStencil(GLint s)
|
| 908 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 909 | TRACE("(GLint s = %d)", s);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 910 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 911 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 912 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 913 | if(context)
|
| 914 | {
|
| 915 | context->setClearStencil(s);
|
| 916 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 917 | }
|
| 918 |
|
| 919 | void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
|
| 920 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 921 | TRACE("(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)",
|
| 922 | red, green, blue, alpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 923 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 924 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 925 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 926 | if(context)
|
| 927 | {
|
| 928 | context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
|
| 929 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 930 | }
|
| 931 |
|
| 932 | void GL_APIENTRY glCompileShader(GLuint shader)
|
| 933 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 934 | TRACE("(GLuint shader = %d)", shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 935 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 936 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 937 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 938 | if(context)
|
| 939 | {
|
| 940 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 941 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 942 | if(!shaderObject)
|
| 943 | {
|
| 944 | if(context->getProgram(shader))
|
| 945 | {
|
| 946 | return error(GL_INVALID_OPERATION);
|
| 947 | }
|
| 948 | else
|
| 949 | {
|
| 950 | return error(GL_INVALID_VALUE);
|
| 951 | }
|
| 952 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 953 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 954 | shaderObject->compile();
|
| 955 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 956 | }
|
| 957 |
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 958 | void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 959 | GLint border, GLsizei imageSize, const GLvoid* data)
|
| 960 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 961 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
|
| 962 | "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
|
| 963 | target, level, internalformat, width, height, border, imageSize, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 964 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 965 | if(!validImageSize(level, width, height) || border != 0 || imageSize < 0)
|
| 966 | {
|
| 967 | return error(GL_INVALID_VALUE);
|
| 968 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 969 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 970 | egl::GLint clientVersion = egl::getClientVersion();
|
| 971 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 972 | switch(internalformat)
|
| 973 | {
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 974 | case GL_ETC1_RGB8_OES:
|
| 975 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 976 | case GL_COMPRESSED_R11_EAC:
|
| 977 | case GL_COMPRESSED_SIGNED_R11_EAC:
|
| 978 | case GL_COMPRESSED_RG11_EAC:
|
| 979 | case GL_COMPRESSED_SIGNED_RG11_EAC:
|
| 980 | case GL_COMPRESSED_RGB8_ETC2:
|
| 981 | case GL_COMPRESSED_SRGB8_ETC2:
|
| 982 | case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
| 983 | case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
| 984 | case GL_COMPRESSED_RGBA8_ETC2_EAC:
|
| 985 | case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
| 986 | if(clientVersion >= 3)
|
| 987 | {
|
| 988 | break;
|
| 989 | }
|
| 990 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 991 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| 992 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| 993 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
|
| 994 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
|
| 995 | if(!S3TC_SUPPORT)
|
| 996 | {
|
| 997 | return error(GL_INVALID_ENUM);
|
| 998 | }
|
| 999 | break;
|
| 1000 | case GL_DEPTH_COMPONENT:
|
| 1001 | case GL_DEPTH_COMPONENT16:
|
| 1002 | case GL_DEPTH_COMPONENT32_OES:
|
| 1003 | case GL_DEPTH_STENCIL_OES:
|
| 1004 | case GL_DEPTH24_STENCIL8_OES:
|
| 1005 | return error(GL_INVALID_OPERATION);
|
| 1006 | default:
|
| 1007 | return error(GL_INVALID_ENUM);
|
| 1008 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1009 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1010 | if(border != 0)
|
| 1011 | {
|
| 1012 | return error(GL_INVALID_VALUE);
|
| 1013 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1014 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1015 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1016 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1017 | if(context)
|
| 1018 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1019 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1020 | {
|
| 1021 | return error(GL_INVALID_VALUE);
|
| 1022 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1023 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1024 | switch(target)
|
| 1025 | {
|
| 1026 | case GL_TEXTURE_2D:
|
| 1027 | if(width > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
|
| 1028 | height > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
|
| 1029 | {
|
| 1030 | return error(GL_INVALID_VALUE);
|
| 1031 | }
|
| 1032 | break;
|
| 1033 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 1034 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 1035 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 1036 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 1037 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 1038 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 1039 | if(width != height)
|
| 1040 | {
|
| 1041 | return error(GL_INVALID_VALUE);
|
| 1042 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1043 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1044 | if(width > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
|
| 1045 | height > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
|
| 1046 | {
|
| 1047 | return error(GL_INVALID_VALUE);
|
| 1048 | }
|
| 1049 | break;
|
| 1050 | default:
|
| 1051 | return error(GL_INVALID_ENUM);
|
| 1052 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1053 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1054 | if(imageSize != es2::ComputeCompressedSize(width, height, internalformat))
|
| 1055 | {
|
| 1056 | return error(GL_INVALID_VALUE);
|
| 1057 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1058 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1059 | if(target == GL_TEXTURE_2D)
|
| 1060 | {
|
| 1061 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1062 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1063 | if(!texture)
|
| 1064 | {
|
| 1065 | return error(GL_INVALID_OPERATION);
|
| 1066 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1067 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1068 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
|
| 1069 | }
|
| 1070 | else
|
| 1071 | {
|
| 1072 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1073 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1074 | if(!texture)
|
| 1075 | {
|
| 1076 | return error(GL_INVALID_OPERATION);
|
| 1077 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1078 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1079 | switch(target)
|
| 1080 | {
|
| 1081 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 1082 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 1083 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 1084 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 1085 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 1086 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 1087 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
|
| 1088 | break;
|
| 1089 | default: UNREACHABLE();
|
| 1090 | }
|
| 1091 | }
|
| 1092 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1093 | }
|
| 1094 |
|
| 1095 | void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1096 | GLenum format, GLsizei imageSize, const GLvoid* data)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1097 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1098 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 1099 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
|
| 1100 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
|
| 1101 | target, level, xoffset, yoffset, width, height, format, imageSize, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1102 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1103 | if(!es2::IsTextureTarget(target))
|
| 1104 | {
|
| 1105 | return error(GL_INVALID_ENUM);
|
| 1106 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1107 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1108 | if(xoffset < 0 || yoffset < 0 || !validImageSize(level, width, height) || imageSize < 0)
|
| 1109 | {
|
| 1110 | return error(GL_INVALID_VALUE);
|
| 1111 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1112 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 1113 | egl::GLint clientVersion = egl::getClientVersion();
|
| 1114 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1115 | switch(format)
|
| 1116 | {
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 1117 | case GL_ETC1_RGB8_OES:
|
| 1118 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 1119 | case GL_COMPRESSED_R11_EAC:
|
| 1120 | case GL_COMPRESSED_SIGNED_R11_EAC:
|
| 1121 | case GL_COMPRESSED_RG11_EAC:
|
| 1122 | case GL_COMPRESSED_SIGNED_RG11_EAC:
|
| 1123 | case GL_COMPRESSED_RGB8_ETC2:
|
| 1124 | case GL_COMPRESSED_SRGB8_ETC2:
|
| 1125 | case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
| 1126 | case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
| 1127 | case GL_COMPRESSED_RGBA8_ETC2_EAC:
|
| 1128 | case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
| 1129 | if(clientVersion >= 3)
|
| 1130 | {
|
| 1131 | break;
|
| 1132 | }
|
| 1133 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1134 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| 1135 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| 1136 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
|
| 1137 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
|
| 1138 | if(!S3TC_SUPPORT)
|
| 1139 | {
|
| 1140 | return error(GL_INVALID_ENUM);
|
| 1141 | }
|
| 1142 | break;
|
| 1143 | default:
|
| 1144 | return error(GL_INVALID_ENUM);
|
| 1145 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1146 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1147 | if(width == 0 || height == 0 || data == NULL)
|
| 1148 | {
|
| 1149 | return;
|
| 1150 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1151 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1152 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1153 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1154 | if(context)
|
| 1155 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1156 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1157 | {
|
| 1158 | return error(GL_INVALID_VALUE);
|
| 1159 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1160 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1161 | if(imageSize != es2::ComputeCompressedSize(width, height, format))
|
| 1162 | {
|
| 1163 | return error(GL_INVALID_VALUE);
|
| 1164 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1165 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1166 | if(xoffset % 4 != 0 || yoffset % 4 != 0)
|
| 1167 | {
|
| 1168 | // We wait to check the offsets until this point, because the multiple-of-four restriction does not exist unless DXT1 textures are supported
|
| 1169 | return error(GL_INVALID_OPERATION);
|
| 1170 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1171 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1172 | if(target == GL_TEXTURE_2D)
|
| 1173 | {
|
| 1174 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1175 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1176 | if(validateSubImageParams(true, width, height, xoffset, yoffset, target, level, format, texture))
|
| 1177 | {
|
| 1178 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
|
| 1179 | }
|
| 1180 | }
|
| 1181 | else if(es2::IsCubemapTextureTarget(target))
|
| 1182 | {
|
| 1183 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1184 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1185 | if(validateSubImageParams(true, width, height, xoffset, yoffset, target, level, format, texture))
|
| 1186 | {
|
| 1187 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
|
| 1188 | }
|
| 1189 | }
|
| 1190 | else
|
| 1191 | {
|
| 1192 | UNREACHABLE();
|
| 1193 | }
|
| 1194 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1195 | }
|
| 1196 |
|
| 1197 | void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
|
| 1198 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1199 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
|
| 1200 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
|
| 1201 | target, level, internalformat, x, y, width, height, border);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1202 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1203 | if(!validImageSize(level, width, height))
|
| 1204 | {
|
| 1205 | return error(GL_INVALID_VALUE);
|
| 1206 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1207 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1208 | if(border != 0)
|
| 1209 | {
|
| 1210 | return error(GL_INVALID_VALUE);
|
| 1211 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1212 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1213 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1214 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1215 | if(context)
|
| 1216 | {
|
| 1217 | switch(target)
|
| 1218 | {
|
| 1219 | case GL_TEXTURE_2D:
|
| 1220 | if(width > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
|
| 1221 | height > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
|
| 1222 | {
|
| 1223 | return error(GL_INVALID_VALUE);
|
| 1224 | }
|
| 1225 | break;
|
| 1226 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 1227 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 1228 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 1229 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 1230 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 1231 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 1232 | if(width != height)
|
| 1233 | {
|
| 1234 | return error(GL_INVALID_VALUE);
|
| 1235 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1236 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1237 | if(width > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
|
| 1238 | height > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
|
| 1239 | {
|
| 1240 | return error(GL_INVALID_VALUE);
|
| 1241 | }
|
| 1242 | break;
|
| 1243 | default:
|
| 1244 | return error(GL_INVALID_ENUM);
|
| 1245 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1246 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1247 | es2::Framebuffer *framebuffer = context->getReadFramebuffer();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1248 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1249 | if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
|
| 1250 | {
|
| 1251 | return error(GL_INVALID_FRAMEBUFFER_OPERATION);
|
| 1252 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1253 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 1254 | if(context->getReadFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1255 | {
|
| 1256 | return error(GL_INVALID_OPERATION);
|
| 1257 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1258 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1259 | es2::Renderbuffer *source = framebuffer->getColorbuffer();
|
| 1260 | GLenum colorbufferFormat = source->getFormat();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1261 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1262 | if(!validateColorBufferFormat(internalformat, colorbufferFormat))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1263 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1264 | return;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1265 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1266 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1267 | if(target == GL_TEXTURE_2D)
|
| 1268 | {
|
| 1269 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1270 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1271 | if(!texture)
|
| 1272 | {
|
| 1273 | return error(GL_INVALID_OPERATION);
|
| 1274 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1275 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1276 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
|
| 1277 | }
|
| 1278 | else if(es2::IsCubemapTextureTarget(target))
|
| 1279 | {
|
| 1280 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1281 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1282 | if(!texture)
|
| 1283 | {
|
| 1284 | return error(GL_INVALID_OPERATION);
|
| 1285 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1286 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1287 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
|
| 1288 | }
|
| 1289 | else UNREACHABLE();
|
| 1290 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1291 | }
|
| 1292 |
|
| 1293 | void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
|
| 1294 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1295 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 1296 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
|
| 1297 | target, level, xoffset, yoffset, x, y, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1298 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1299 | if(!es2::IsTextureTarget(target))
|
| 1300 | {
|
| 1301 | return error(GL_INVALID_ENUM);
|
| 1302 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1303 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1304 | if(level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
|
| 1305 | {
|
| 1306 | return error(GL_INVALID_VALUE);
|
| 1307 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1308 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1309 | if(std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
|
| 1310 | {
|
| 1311 | return error(GL_INVALID_VALUE);
|
| 1312 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1313 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1314 | if(width == 0 || height == 0)
|
| 1315 | {
|
| 1316 | return;
|
| 1317 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1318 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1319 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1320 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1321 | if(context)
|
| 1322 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1323 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1324 | {
|
| 1325 | return error(GL_INVALID_VALUE);
|
| 1326 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1327 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1328 | es2::Framebuffer *framebuffer = context->getReadFramebuffer();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1329 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1330 | if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
|
| 1331 | {
|
| 1332 | return error(GL_INVALID_FRAMEBUFFER_OPERATION);
|
| 1333 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1334 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 1335 | if(context->getReadFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1336 | {
|
| 1337 | return error(GL_INVALID_OPERATION);
|
| 1338 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1339 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1340 | es2::Renderbuffer *source = framebuffer->getColorbuffer();
|
| 1341 | GLenum colorbufferFormat = source->getFormat();
|
| 1342 | es2::Texture *texture = NULL;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1343 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1344 | if(target == GL_TEXTURE_2D)
|
| 1345 | {
|
| 1346 | texture = context->getTexture2D();
|
| 1347 | }
|
| 1348 | else if(es2::IsCubemapTextureTarget(target))
|
| 1349 | {
|
| 1350 | texture = context->getTextureCubeMap();
|
| 1351 | }
|
| 1352 | else UNREACHABLE();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1353 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1354 | if(!validateSubImageParams(false, width, height, xoffset, yoffset, target, level, GL_NONE, texture))
|
| 1355 | {
|
| 1356 | return;
|
| 1357 | }
|
| 1358 |
|
| 1359 | GLenum textureFormat = texture->getFormat(target, level);
|
| 1360 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1361 | if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1362 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1363 | return;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1364 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1365 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1366 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1367 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1368 | }
|
| 1369 |
|
| 1370 | GLuint GL_APIENTRY glCreateProgram(void)
|
| 1371 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1372 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1373 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1374 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1375 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1376 | if(context)
|
| 1377 | {
|
| 1378 | return context->createProgram();
|
| 1379 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1380 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1381 | return 0;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1382 | }
|
| 1383 |
|
| 1384 | GLuint GL_APIENTRY glCreateShader(GLenum type)
|
| 1385 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1386 | TRACE("(GLenum type = 0x%X)", type);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1387 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1388 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1389 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1390 | if(context)
|
| 1391 | {
|
| 1392 | switch(type)
|
| 1393 | {
|
| 1394 | case GL_FRAGMENT_SHADER:
|
| 1395 | case GL_VERTEX_SHADER:
|
| 1396 | return context->createShader(type);
|
| 1397 | default:
|
| 1398 | return error(GL_INVALID_ENUM, 0);
|
| 1399 | }
|
| 1400 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1401 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1402 | return 0;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1403 | }
|
| 1404 |
|
| 1405 | void GL_APIENTRY glCullFace(GLenum mode)
|
| 1406 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1407 | TRACE("(GLenum mode = 0x%X)", mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1408 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1409 | switch(mode)
|
| 1410 | {
|
| 1411 | case GL_FRONT:
|
| 1412 | case GL_BACK:
|
| 1413 | case GL_FRONT_AND_BACK:
|
| 1414 | {
|
| 1415 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1416 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1417 | if(context)
|
| 1418 | {
|
| 1419 | context->setCullMode(mode);
|
| 1420 | }
|
| 1421 | }
|
| 1422 | break;
|
| 1423 | default:
|
| 1424 | return error(GL_INVALID_ENUM);
|
| 1425 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1426 | }
|
| 1427 |
|
| 1428 | void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
|
| 1429 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1430 | TRACE("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1431 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1432 | if(n < 0)
|
| 1433 | {
|
| 1434 | return error(GL_INVALID_VALUE);
|
| 1435 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1436 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1437 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1438 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1439 | if(context)
|
| 1440 | {
|
| 1441 | for(int i = 0; i < n; i++)
|
| 1442 | {
|
| 1443 | context->deleteBuffer(buffers[i]);
|
| 1444 | }
|
| 1445 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1446 | }
|
| 1447 |
|
| 1448 | void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
|
| 1449 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1450 | TRACE("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1451 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1452 | if(n < 0)
|
| 1453 | {
|
| 1454 | return error(GL_INVALID_VALUE);
|
| 1455 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1456 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1457 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1458 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1459 | if(context)
|
| 1460 | {
|
| 1461 | for(int i = 0; i < n; i++)
|
| 1462 | {
|
| 1463 | context->deleteFence(fences[i]);
|
| 1464 | }
|
| 1465 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1466 | }
|
| 1467 |
|
| 1468 | void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
|
| 1469 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1470 | TRACE("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1471 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1472 | if(n < 0)
|
| 1473 | {
|
| 1474 | return error(GL_INVALID_VALUE);
|
| 1475 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1476 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1477 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1478 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1479 | if(context)
|
| 1480 | {
|
| 1481 | for(int i = 0; i < n; i++)
|
| 1482 | {
|
| 1483 | if(framebuffers[i] != 0)
|
| 1484 | {
|
| 1485 | context->deleteFramebuffer(framebuffers[i]);
|
| 1486 | }
|
| 1487 | }
|
| 1488 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1489 | }
|
| 1490 |
|
| 1491 | void GL_APIENTRY glDeleteProgram(GLuint program)
|
| 1492 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1493 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1494 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1495 | if(program == 0)
|
| 1496 | {
|
| 1497 | return;
|
| 1498 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1499 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1500 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1501 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1502 | if(context)
|
| 1503 | {
|
| 1504 | if(!context->getProgram(program))
|
| 1505 | {
|
| 1506 | if(context->getShader(program))
|
| 1507 | {
|
| 1508 | return error(GL_INVALID_OPERATION);
|
| 1509 | }
|
| 1510 | else
|
| 1511 | {
|
| 1512 | return error(GL_INVALID_VALUE);
|
| 1513 | }
|
| 1514 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1515 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1516 | context->deleteProgram(program);
|
| 1517 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1518 | }
|
| 1519 |
|
| 1520 | void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
|
| 1521 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1522 | TRACE("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1523 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1524 | if(n < 0)
|
| 1525 | {
|
| 1526 | return error(GL_INVALID_VALUE);
|
| 1527 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1528 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1529 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1530 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1531 | if(context)
|
| 1532 | {
|
| 1533 | for(int i = 0; i < n; i++)
|
| 1534 | {
|
| 1535 | context->deleteQuery(ids[i]);
|
| 1536 | }
|
| 1537 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1538 | }
|
| 1539 |
|
| 1540 | void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
|
| 1541 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1542 | TRACE("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1543 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1544 | if(n < 0)
|
| 1545 | {
|
| 1546 | return error(GL_INVALID_VALUE);
|
| 1547 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1548 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1549 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1550 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1551 | if(context)
|
| 1552 | {
|
| 1553 | for(int i = 0; i < n; i++)
|
| 1554 | {
|
| 1555 | context->deleteRenderbuffer(renderbuffers[i]);
|
| 1556 | }
|
| 1557 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1558 | }
|
| 1559 |
|
| 1560 | void GL_APIENTRY glDeleteShader(GLuint shader)
|
| 1561 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1562 | TRACE("(GLuint shader = %d)", shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1563 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1564 | if(shader == 0)
|
| 1565 | {
|
| 1566 | return;
|
| 1567 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1568 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1569 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1570 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1571 | if(context)
|
| 1572 | {
|
| 1573 | if(!context->getShader(shader))
|
| 1574 | {
|
| 1575 | if(context->getProgram(shader))
|
| 1576 | {
|
| 1577 | return error(GL_INVALID_OPERATION);
|
| 1578 | }
|
| 1579 | else
|
| 1580 | {
|
| 1581 | return error(GL_INVALID_VALUE);
|
| 1582 | }
|
| 1583 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1584 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1585 | context->deleteShader(shader);
|
| 1586 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1587 | }
|
| 1588 |
|
| 1589 | void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
|
| 1590 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1591 | TRACE("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1592 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1593 | if(n < 0)
|
| 1594 | {
|
| 1595 | return error(GL_INVALID_VALUE);
|
| 1596 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1597 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1598 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1599 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1600 | if(context)
|
| 1601 | {
|
| 1602 | for(int i = 0; i < n; i++)
|
| 1603 | {
|
| 1604 | if(textures[i] != 0)
|
| 1605 | {
|
| 1606 | context->deleteTexture(textures[i]);
|
| 1607 | }
|
| 1608 | }
|
| 1609 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1610 | }
|
| 1611 |
|
| 1612 | void GL_APIENTRY glDepthFunc(GLenum func)
|
| 1613 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1614 | TRACE("(GLenum func = 0x%X)", func);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1615 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1616 | switch(func)
|
| 1617 | {
|
| 1618 | case GL_NEVER:
|
| 1619 | case GL_ALWAYS:
|
| 1620 | case GL_LESS:
|
| 1621 | case GL_LEQUAL:
|
| 1622 | case GL_EQUAL:
|
| 1623 | case GL_GREATER:
|
| 1624 | case GL_GEQUAL:
|
| 1625 | case GL_NOTEQUAL:
|
| 1626 | break;
|
| 1627 | default:
|
| 1628 | return error(GL_INVALID_ENUM);
|
| 1629 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1630 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1631 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1632 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1633 | if(context)
|
| 1634 | {
|
| 1635 | context->setDepthFunc(func);
|
| 1636 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1637 | }
|
| 1638 |
|
| 1639 | void GL_APIENTRY glDepthMask(GLboolean flag)
|
| 1640 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1641 | TRACE("(GLboolean flag = %d)", flag);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1642 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1643 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1644 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1645 | if(context)
|
| 1646 | {
|
| 1647 | context->setDepthMask(flag != GL_FALSE);
|
| 1648 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1649 | }
|
| 1650 |
|
| 1651 | void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
|
| 1652 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1653 | TRACE("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1654 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1655 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1656 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1657 | if(context)
|
| 1658 | {
|
| 1659 | context->setDepthRange(zNear, zFar);
|
| 1660 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1661 | }
|
| 1662 |
|
| 1663 | void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
|
| 1664 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1665 | TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1666 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1667 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1668 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1669 | if(context)
|
| 1670 | {
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1671 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1672 | es2::Program *programObject = context->getProgram(program);
|
| 1673 | es2::Shader *shaderObject = context->getShader(shader);
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 1674 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1675 | if(!programObject)
|
| 1676 | {
|
| 1677 | es2::Shader *shaderByProgramHandle;
|
| 1678 | shaderByProgramHandle = context->getShader(program);
|
| 1679 | if(!shaderByProgramHandle)
|
| 1680 | {
|
| 1681 | return error(GL_INVALID_VALUE);
|
| 1682 | }
|
| 1683 | else
|
| 1684 | {
|
| 1685 | return error(GL_INVALID_OPERATION);
|
| 1686 | }
|
| 1687 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1688 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1689 | if(!shaderObject)
|
| 1690 | {
|
| 1691 | es2::Program *programByShaderHandle = context->getProgram(shader);
|
| 1692 | if(!programByShaderHandle)
|
| 1693 | {
|
| 1694 | return error(GL_INVALID_VALUE);
|
| 1695 | }
|
| 1696 | else
|
| 1697 | {
|
| 1698 | return error(GL_INVALID_OPERATION);
|
| 1699 | }
|
| 1700 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1701 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1702 | if(!programObject->detachShader(shaderObject))
|
| 1703 | {
|
| 1704 | return error(GL_INVALID_OPERATION);
|
| 1705 | }
|
| 1706 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1707 | }
|
| 1708 |
|
| 1709 | void GL_APIENTRY glDisable(GLenum cap)
|
| 1710 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1711 | TRACE("(GLenum cap = 0x%X)", cap);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1712 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1713 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1714 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1715 | if(context)
|
| 1716 | {
|
| 1717 | switch(cap)
|
| 1718 | {
|
| 1719 | case GL_CULL_FACE: context->setCullFace(false); break;
|
| 1720 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(false); break;
|
| 1721 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(false); break;
|
| 1722 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(false); break;
|
| 1723 | case GL_SCISSOR_TEST: context->setScissorTest(false); break;
|
| 1724 | case GL_STENCIL_TEST: context->setStencilTest(false); break;
|
| 1725 | case GL_DEPTH_TEST: context->setDepthTest(false); break;
|
| 1726 | case GL_BLEND: context->setBlend(false); break;
|
| 1727 | case GL_DITHER: context->setDither(false); break;
|
Alexis Hetu | fceb183 | 2015-03-10 16:42:04 -0400 | [diff] [blame] | 1728 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: context->setPrimitiveRestartFixedIndex(false); break;
|
| 1729 | case GL_RASTERIZER_DISCARD: context->setRasterizerDiscard(false); break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1730 | default:
|
| 1731 | return error(GL_INVALID_ENUM);
|
| 1732 | }
|
| 1733 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1734 | }
|
| 1735 |
|
| 1736 | void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
|
| 1737 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1738 | TRACE("(GLuint index = %d)", index);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1739 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1740 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 1741 | {
|
| 1742 | return error(GL_INVALID_VALUE);
|
| 1743 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1744 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1745 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1746 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1747 | if(context)
|
| 1748 | {
|
| 1749 | context->setEnableVertexAttribArray(index, false);
|
| 1750 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1751 | }
|
| 1752 |
|
| 1753 | void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
|
| 1754 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1755 | TRACE("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1756 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 1757 | switch(mode)
|
| 1758 | {
|
| 1759 | case GL_POINTS:
|
| 1760 | case GL_LINES:
|
| 1761 | case GL_LINE_LOOP:
|
| 1762 | case GL_LINE_STRIP:
|
| 1763 | case GL_TRIANGLES:
|
| 1764 | case GL_TRIANGLE_FAN:
|
| 1765 | case GL_TRIANGLE_STRIP:
|
| 1766 | break;
|
| 1767 | default:
|
| 1768 | return error(GL_INVALID_ENUM);
|
| 1769 | }
|
| 1770 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1771 | if(count < 0 || first < 0)
|
| 1772 | {
|
| 1773 | return error(GL_INVALID_VALUE);
|
| 1774 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1775 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1776 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1777 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1778 | if(context)
|
| 1779 | {
|
| 1780 | context->drawArrays(mode, first, count);
|
| 1781 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1782 | }
|
| 1783 |
|
| 1784 | void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
|
| 1785 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1786 | TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
|
| 1787 | mode, count, type, indices);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1788 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 1789 | switch(mode)
|
| 1790 | {
|
| 1791 | case GL_POINTS:
|
| 1792 | case GL_LINES:
|
| 1793 | case GL_LINE_LOOP:
|
| 1794 | case GL_LINE_STRIP:
|
| 1795 | case GL_TRIANGLES:
|
| 1796 | case GL_TRIANGLE_FAN:
|
| 1797 | case GL_TRIANGLE_STRIP:
|
| 1798 | break;
|
| 1799 | default:
|
| 1800 | return error(GL_INVALID_ENUM);
|
| 1801 | }
|
| 1802 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1803 | if(count < 0)
|
| 1804 | {
|
| 1805 | return error(GL_INVALID_VALUE);
|
| 1806 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1807 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1808 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1809 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1810 | if(context)
|
| 1811 | {
|
| 1812 | switch(type)
|
| 1813 | {
|
| 1814 | case GL_UNSIGNED_BYTE:
|
| 1815 | case GL_UNSIGNED_SHORT:
|
| 1816 | case GL_UNSIGNED_INT:
|
| 1817 | break;
|
| 1818 | default:
|
| 1819 | return error(GL_INVALID_ENUM);
|
| 1820 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 1821 |
|
Alexis Hetu | 0733469 | 2015-04-10 14:51:27 -0400 | [diff] [blame^] | 1822 | context->drawElements(mode, 0, UINT_MAX, count, type, indices);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1823 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1824 | }
|
| 1825 |
|
| 1826 | void GL_APIENTRY glEnable(GLenum cap)
|
| 1827 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1828 | TRACE("(GLenum cap = 0x%X)", cap);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1829 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1830 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1831 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1832 | if(context)
|
| 1833 | {
|
| 1834 | switch(cap)
|
| 1835 | {
|
| 1836 | case GL_CULL_FACE: context->setCullFace(true); break;
|
| 1837 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFill(true); break;
|
| 1838 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverage(true); break;
|
| 1839 | case GL_SAMPLE_COVERAGE: context->setSampleCoverage(true); break;
|
| 1840 | case GL_SCISSOR_TEST: context->setScissorTest(true); break;
|
| 1841 | case GL_STENCIL_TEST: context->setStencilTest(true); break;
|
| 1842 | case GL_DEPTH_TEST: context->setDepthTest(true); break;
|
| 1843 | case GL_BLEND: context->setBlend(true); break;
|
| 1844 | case GL_DITHER: context->setDither(true); break;
|
Alexis Hetu | fceb183 | 2015-03-10 16:42:04 -0400 | [diff] [blame] | 1845 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: context->setPrimitiveRestartFixedIndex(true); break;
|
| 1846 | case GL_RASTERIZER_DISCARD: context->setRasterizerDiscard(true); break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1847 | default:
|
| 1848 | return error(GL_INVALID_ENUM);
|
| 1849 | }
|
| 1850 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1851 | }
|
| 1852 |
|
| 1853 | void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
|
| 1854 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1855 | TRACE("(GLuint index = %d)", index);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1856 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1857 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 1858 | {
|
| 1859 | return error(GL_INVALID_VALUE);
|
| 1860 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1861 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1862 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1863 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1864 | if(context)
|
| 1865 | {
|
| 1866 | context->setEnableVertexAttribArray(index, true);
|
| 1867 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1868 | }
|
| 1869 |
|
| 1870 | void GL_APIENTRY glEndQueryEXT(GLenum target)
|
| 1871 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1872 | TRACE("GLenum target = 0x%X)", target);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1873 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1874 | switch(target)
|
| 1875 | {
|
| 1876 | case GL_ANY_SAMPLES_PASSED_EXT:
|
| 1877 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
|
| 1878 | break;
|
| 1879 | default:
|
| 1880 | return error(GL_INVALID_ENUM);
|
| 1881 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1882 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1883 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1884 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1885 | if(context)
|
| 1886 | {
|
| 1887 | context->endQuery(target);
|
| 1888 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1889 | }
|
| 1890 |
|
| 1891 | void GL_APIENTRY glFinishFenceNV(GLuint fence)
|
| 1892 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1893 | TRACE("(GLuint fence = %d)", fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1894 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1895 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1896 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1897 | if(context)
|
| 1898 | {
|
| 1899 | es2::Fence* fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1900 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1901 | if(fenceObject == NULL)
|
| 1902 | {
|
| 1903 | return error(GL_INVALID_OPERATION);
|
| 1904 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1905 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1906 | fenceObject->finishFence();
|
| 1907 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1908 | }
|
| 1909 |
|
| 1910 | void GL_APIENTRY glFinish(void)
|
| 1911 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1912 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1913 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1914 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1915 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1916 | if(context)
|
| 1917 | {
|
| 1918 | context->finish();
|
| 1919 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1920 | }
|
| 1921 |
|
| 1922 | void GL_APIENTRY glFlush(void)
|
| 1923 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1924 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1925 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1926 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1927 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1928 | if(context)
|
| 1929 | {
|
| 1930 | context->flush();
|
| 1931 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1932 | }
|
| 1933 |
|
| 1934 | void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
| 1935 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1936 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
|
| 1937 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1938 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1939 | if((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) ||
|
| 1940 | (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
|
| 1941 | {
|
| 1942 | return error(GL_INVALID_ENUM);
|
| 1943 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1944 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1945 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1946 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1947 | if(context)
|
| 1948 | {
|
| 1949 | es2::Framebuffer *framebuffer = NULL;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 1950 | GLuint framebufferName = 0;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1951 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 1952 | {
|
| 1953 | framebuffer = context->getReadFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 1954 | framebufferName = context->getReadFramebufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1955 | }
|
| 1956 | else
|
| 1957 | {
|
| 1958 | framebuffer = context->getDrawFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 1959 | framebufferName = context->getDrawFramebufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1960 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1961 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 1962 | if(!framebuffer || (framebufferName == 0 && renderbuffer != 0))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1963 | {
|
| 1964 | return error(GL_INVALID_OPERATION);
|
| 1965 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1966 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1967 | switch(attachment)
|
| 1968 | {
|
| 1969 | case GL_COLOR_ATTACHMENT0:
|
| 1970 | framebuffer->setColorbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 1971 | break;
|
| 1972 | case GL_DEPTH_ATTACHMENT:
|
| 1973 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 1974 | break;
|
| 1975 | case GL_STENCIL_ATTACHMENT:
|
| 1976 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 1977 | break;
|
| 1978 | default:
|
| 1979 | return error(GL_INVALID_ENUM);
|
| 1980 | }
|
| 1981 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1982 | }
|
| 1983 |
|
| 1984 | void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
| 1985 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1986 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
|
| 1987 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1988 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1989 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 1990 | {
|
| 1991 | return error(GL_INVALID_ENUM);
|
| 1992 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1993 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1994 | switch(attachment)
|
| 1995 | {
|
| 1996 | case GL_COLOR_ATTACHMENT0:
|
| 1997 | case GL_DEPTH_ATTACHMENT:
|
| 1998 | case GL_STENCIL_ATTACHMENT:
|
| 1999 | break;
|
| 2000 | default:
|
| 2001 | return error(GL_INVALID_ENUM);
|
| 2002 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2003 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2004 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2005 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2006 | if(context)
|
| 2007 | {
|
| 2008 | if(texture == 0)
|
| 2009 | {
|
| 2010 | textarget = GL_NONE;
|
| 2011 | }
|
| 2012 | else
|
| 2013 | {
|
| 2014 | es2::Texture *tex = context->getTexture(texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2015 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2016 | if(tex == NULL)
|
| 2017 | {
|
| 2018 | return error(GL_INVALID_OPERATION);
|
| 2019 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2020 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2021 | if(tex->isCompressed(textarget, level))
|
| 2022 | {
|
| 2023 | return error(GL_INVALID_OPERATION);
|
| 2024 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2025 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2026 | switch(textarget)
|
| 2027 | {
|
| 2028 | case GL_TEXTURE_2D:
|
| 2029 | if(tex->getTarget() != GL_TEXTURE_2D)
|
| 2030 | {
|
| 2031 | return error(GL_INVALID_OPERATION);
|
| 2032 | }
|
| 2033 | break;
|
| 2034 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 2035 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 2036 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 2037 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 2038 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 2039 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 2040 | if(tex->getTarget() != GL_TEXTURE_CUBE_MAP)
|
| 2041 | {
|
| 2042 | return error(GL_INVALID_OPERATION);
|
| 2043 | }
|
| 2044 | break;
|
| 2045 | default:
|
| 2046 | return error(GL_INVALID_ENUM);
|
| 2047 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2048 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2049 | if(level != 0)
|
| 2050 | {
|
| 2051 | return error(GL_INVALID_VALUE);
|
| 2052 | }
|
| 2053 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2054 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2055 | es2::Framebuffer *framebuffer = NULL;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2056 | GLuint framebufferName = 0;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2057 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 2058 | {
|
| 2059 | framebuffer = context->getReadFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2060 | framebufferName = context->getReadFramebufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2061 | }
|
| 2062 | else
|
| 2063 | {
|
| 2064 | framebuffer = context->getDrawFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2065 | framebufferName = context->getDrawFramebufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2066 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2067 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2068 | if(framebufferName == 0 || !framebuffer)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2069 | {
|
| 2070 | return error(GL_INVALID_OPERATION);
|
| 2071 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2072 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2073 | switch(attachment)
|
| 2074 | {
|
| 2075 | case GL_COLOR_ATTACHMENT0: framebuffer->setColorbuffer(textarget, texture); break;
|
| 2076 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
|
| 2077 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
|
| 2078 | }
|
| 2079 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2080 | }
|
| 2081 |
|
| 2082 | void GL_APIENTRY glFrontFace(GLenum mode)
|
| 2083 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2084 | TRACE("(GLenum mode = 0x%X)", mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2085 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2086 | switch(mode)
|
| 2087 | {
|
| 2088 | case GL_CW:
|
| 2089 | case GL_CCW:
|
| 2090 | {
|
| 2091 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2092 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2093 | if(context)
|
| 2094 | {
|
| 2095 | context->setFrontFace(mode);
|
| 2096 | }
|
| 2097 | }
|
| 2098 | break;
|
| 2099 | default:
|
| 2100 | return error(GL_INVALID_ENUM);
|
| 2101 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2102 | }
|
| 2103 |
|
| 2104 | void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
|
| 2105 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2106 | TRACE("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2107 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2108 | if(n < 0)
|
| 2109 | {
|
| 2110 | return error(GL_INVALID_VALUE);
|
| 2111 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2112 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2113 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2114 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2115 | if(context)
|
| 2116 | {
|
| 2117 | for(int i = 0; i < n; i++)
|
| 2118 | {
|
| 2119 | buffers[i] = context->createBuffer();
|
| 2120 | }
|
| 2121 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2122 | }
|
| 2123 |
|
| 2124 | void GL_APIENTRY glGenerateMipmap(GLenum target)
|
| 2125 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2126 | TRACE("(GLenum target = 0x%X)", target);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2127 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2128 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2129 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2130 | if(context)
|
| 2131 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2132 | es2::Texture *texture = nullptr;
|
| 2133 |
|
| 2134 | egl::GLint clientVersion = context->getClientVersion();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2135 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2136 | switch(target)
|
| 2137 | {
|
| 2138 | case GL_TEXTURE_2D:
|
| 2139 | texture = context->getTexture2D();
|
| 2140 | break;
|
| 2141 | case GL_TEXTURE_CUBE_MAP:
|
| 2142 | texture = context->getTextureCubeMap();
|
| 2143 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2144 | case GL_TEXTURE_2D_ARRAY:
|
| 2145 | if(clientVersion < 3)
|
| 2146 | {
|
| 2147 | return error(GL_INVALID_ENUM);
|
| 2148 | }
|
| 2149 | else
|
| 2150 | {
|
| 2151 | UNIMPLEMENTED();
|
| 2152 | texture = context->getTexture3D();
|
| 2153 | break;
|
| 2154 | }
|
| 2155 | case GL_TEXTURE_3D_OES:
|
| 2156 | texture = context->getTexture3D();
|
| 2157 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2158 | default:
|
| 2159 | return error(GL_INVALID_ENUM);
|
| 2160 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2161 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2162 | if(texture->isCompressed(target, 0) || texture->isDepth(target, 0))
|
| 2163 | {
|
| 2164 | return error(GL_INVALID_OPERATION);
|
| 2165 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2166 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2167 | texture->generateMipmaps();
|
| 2168 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2169 | }
|
| 2170 |
|
| 2171 | void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
|
| 2172 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2173 | TRACE("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2174 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2175 | if(n < 0)
|
| 2176 | {
|
| 2177 | return error(GL_INVALID_VALUE);
|
| 2178 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2179 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2180 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2181 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2182 | if(context)
|
| 2183 | {
|
| 2184 | for(int i = 0; i < n; i++)
|
| 2185 | {
|
| 2186 | fences[i] = context->createFence();
|
| 2187 | }
|
| 2188 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2189 | }
|
| 2190 |
|
| 2191 | void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
|
| 2192 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2193 | TRACE("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2194 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2195 | if(n < 0)
|
| 2196 | {
|
| 2197 | return error(GL_INVALID_VALUE);
|
| 2198 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2199 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2200 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2201 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2202 | if(context)
|
| 2203 | {
|
| 2204 | for(int i = 0; i < n; i++)
|
| 2205 | {
|
| 2206 | framebuffers[i] = context->createFramebuffer();
|
| 2207 | }
|
| 2208 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2209 | }
|
| 2210 |
|
| 2211 | void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
|
| 2212 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2213 | TRACE("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2214 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2215 | if(n < 0)
|
| 2216 | {
|
| 2217 | return error(GL_INVALID_VALUE);
|
| 2218 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2219 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2220 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2221 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2222 | if(context)
|
| 2223 | {
|
| 2224 | for(int i = 0; i < n; i++)
|
| 2225 | {
|
| 2226 | ids[i] = context->createQuery();
|
| 2227 | }
|
| 2228 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2229 | }
|
| 2230 |
|
| 2231 | void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
|
| 2232 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2233 | TRACE("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2234 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2235 | if(n < 0)
|
| 2236 | {
|
| 2237 | return error(GL_INVALID_VALUE);
|
| 2238 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2239 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2240 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2241 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2242 | if(context)
|
| 2243 | {
|
| 2244 | for(int i = 0; i < n; i++)
|
| 2245 | {
|
| 2246 | renderbuffers[i] = context->createRenderbuffer();
|
| 2247 | }
|
| 2248 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2249 | }
|
| 2250 |
|
| 2251 | void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
|
| 2252 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2253 | TRACE("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2254 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2255 | if(n < 0)
|
| 2256 | {
|
| 2257 | return error(GL_INVALID_VALUE);
|
| 2258 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2259 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2260 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2261 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2262 | if(context)
|
| 2263 | {
|
| 2264 | for(int i = 0; i < n; i++)
|
| 2265 | {
|
| 2266 | textures[i] = context->createTexture();
|
| 2267 | }
|
| 2268 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2269 | }
|
| 2270 |
|
| 2271 | void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
|
| 2272 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2273 | TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
|
| 2274 | "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
|
| 2275 | program, index, bufsize, length, size, type, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2276 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2277 | if(bufsize < 0)
|
| 2278 | {
|
| 2279 | return error(GL_INVALID_VALUE);
|
| 2280 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2281 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2282 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2283 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2284 | if(context)
|
| 2285 | {
|
| 2286 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2287 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2288 | if(!programObject)
|
| 2289 | {
|
| 2290 | if(context->getShader(program))
|
| 2291 | {
|
| 2292 | return error(GL_INVALID_OPERATION);
|
| 2293 | }
|
| 2294 | else
|
| 2295 | {
|
| 2296 | return error(GL_INVALID_VALUE);
|
| 2297 | }
|
| 2298 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2299 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2300 | if(index >= (GLuint)programObject->getActiveAttributeCount())
|
| 2301 | {
|
| 2302 | return error(GL_INVALID_VALUE);
|
| 2303 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2304 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2305 | programObject->getActiveAttribute(index, bufsize, length, size, type, name);
|
| 2306 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2307 | }
|
| 2308 |
|
| 2309 | void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
|
| 2310 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2311 | TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
|
| 2312 | "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = %s)",
|
| 2313 | program, index, bufsize, length, size, type, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2314 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2315 | if(bufsize < 0)
|
| 2316 | {
|
| 2317 | return error(GL_INVALID_VALUE);
|
| 2318 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2319 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2320 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2321 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2322 | if(context)
|
| 2323 | {
|
| 2324 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2325 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2326 | if(!programObject)
|
| 2327 | {
|
| 2328 | if(context->getShader(program))
|
| 2329 | {
|
| 2330 | return error(GL_INVALID_OPERATION);
|
| 2331 | }
|
| 2332 | else
|
| 2333 | {
|
| 2334 | return error(GL_INVALID_VALUE);
|
| 2335 | }
|
| 2336 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2337 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2338 | if(index >= (GLuint)programObject->getActiveUniformCount())
|
| 2339 | {
|
| 2340 | return error(GL_INVALID_VALUE);
|
| 2341 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2342 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2343 | programObject->getActiveUniform(index, bufsize, length, size, type, name);
|
| 2344 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2345 | }
|
| 2346 |
|
| 2347 | void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
|
| 2348 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2349 | TRACE("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
|
| 2350 | program, maxcount, count, shaders);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2351 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2352 | if(maxcount < 0)
|
| 2353 | {
|
| 2354 | return error(GL_INVALID_VALUE);
|
| 2355 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2356 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2357 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2358 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2359 | if(context)
|
| 2360 | {
|
| 2361 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2362 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2363 | if(!programObject)
|
| 2364 | {
|
| 2365 | if(context->getShader(program))
|
| 2366 | {
|
| 2367 | return error(GL_INVALID_OPERATION);
|
| 2368 | }
|
| 2369 | else
|
| 2370 | {
|
| 2371 | return error(GL_INVALID_VALUE);
|
| 2372 | }
|
| 2373 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2374 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2375 | return programObject->getAttachedShaders(maxcount, count, shaders);
|
| 2376 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2377 | }
|
| 2378 |
|
| 2379 | int GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
|
| 2380 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2381 | TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2382 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2383 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2384 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2385 | if(context)
|
| 2386 | {
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2387 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2388 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2389 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2390 | if(!programObject)
|
| 2391 | {
|
| 2392 | if(context->getShader(program))
|
| 2393 | {
|
| 2394 | return error(GL_INVALID_OPERATION, -1);
|
| 2395 | }
|
| 2396 | else
|
| 2397 | {
|
| 2398 | return error(GL_INVALID_VALUE, -1);
|
| 2399 | }
|
| 2400 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2401 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2402 | if(!programObject->isLinked())
|
| 2403 | {
|
| 2404 | return error(GL_INVALID_OPERATION, -1);
|
| 2405 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2406 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2407 | return programObject->getAttributeLocation(name);
|
| 2408 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2409 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2410 | return -1;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2411 | }
|
| 2412 |
|
| 2413 | void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
|
| 2414 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2415 | TRACE("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2416 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2417 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2418 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2419 | if(context)
|
| 2420 | {
|
| 2421 | if(!(context->getBooleanv(pname, params)))
|
| 2422 | {
|
| 2423 | GLenum nativeType;
|
| 2424 | unsigned int numParams = 0;
|
| 2425 | if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
|
| 2426 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2427 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2428 | if(numParams == 0)
|
| 2429 | return; // it is known that the pname is valid, but there are no parameters to return
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2430 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2431 | if(nativeType == GL_FLOAT)
|
| 2432 | {
|
| 2433 | GLfloat *floatParams = NULL;
|
| 2434 | floatParams = new GLfloat[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2435 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2436 | context->getFloatv(pname, floatParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2437 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2438 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2439 | {
|
| 2440 | if(floatParams[i] == 0.0f)
|
| 2441 | params[i] = GL_FALSE;
|
| 2442 | else
|
| 2443 | params[i] = GL_TRUE;
|
| 2444 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2445 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2446 | delete [] floatParams;
|
| 2447 | }
|
| 2448 | else if(nativeType == GL_INT)
|
| 2449 | {
|
| 2450 | GLint *intParams = NULL;
|
| 2451 | intParams = new GLint[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2452 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2453 | context->getIntegerv(pname, intParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2454 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2455 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2456 | {
|
| 2457 | if(intParams[i] == 0)
|
| 2458 | params[i] = GL_FALSE;
|
| 2459 | else
|
| 2460 | params[i] = GL_TRUE;
|
| 2461 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2462 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2463 | delete [] intParams;
|
| 2464 | }
|
| 2465 | }
|
| 2466 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2467 | }
|
| 2468 |
|
| 2469 | void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
|
| 2470 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2471 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2472 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2473 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2474 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2475 | if(context)
|
| 2476 | {
|
| 2477 | es2::Buffer *buffer;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 2478 | if(!context->getBuffer(target, &buffer))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2479 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2480 | return error(GL_INVALID_ENUM);
|
| 2481 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2482 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2483 | if(!buffer)
|
| 2484 | {
|
| 2485 | // A null buffer means that "0" is bound to the requested buffer target
|
| 2486 | return error(GL_INVALID_OPERATION);
|
| 2487 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2488 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2489 | egl::GLint clientVersion = context->getClientVersion();
|
| 2490 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2491 | switch(pname)
|
| 2492 | {
|
| 2493 | case GL_BUFFER_USAGE:
|
| 2494 | *params = buffer->usage();
|
| 2495 | break;
|
| 2496 | case GL_BUFFER_SIZE:
|
| 2497 | *params = buffer->size();
|
| 2498 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2499 | case GL_BUFFER_ACCESS_FLAGS:
|
| 2500 | if(clientVersion >= 3)
|
| 2501 | {
|
| 2502 | *params = buffer->access();
|
| 2503 | break;
|
| 2504 | }
|
| 2505 | else return error(GL_INVALID_ENUM);
|
| 2506 | case GL_BUFFER_MAPPED:
|
| 2507 | if(clientVersion >= 3)
|
| 2508 | {
|
| 2509 | *params = buffer->isMapped();
|
| 2510 | break;
|
| 2511 | }
|
| 2512 | else return error(GL_INVALID_ENUM);
|
| 2513 | case GL_BUFFER_MAP_LENGTH:
|
| 2514 | if(clientVersion >= 3)
|
| 2515 | {
|
| 2516 | *params = buffer->length();
|
| 2517 | break;
|
| 2518 | }
|
| 2519 | else return error(GL_INVALID_ENUM);
|
| 2520 | case GL_BUFFER_MAP_OFFSET:
|
| 2521 | if(clientVersion >= 3)
|
| 2522 | {
|
| 2523 | *params = buffer->offset();
|
| 2524 | break;
|
| 2525 | }
|
| 2526 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2527 | default:
|
| 2528 | return error(GL_INVALID_ENUM);
|
| 2529 | }
|
| 2530 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2531 | }
|
| 2532 |
|
| 2533 | GLenum GL_APIENTRY glGetError(void)
|
| 2534 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2535 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2536 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2537 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2538 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2539 | if(context)
|
| 2540 | {
|
| 2541 | return context->getError();
|
| 2542 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2543 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2544 | return GL_NO_ERROR;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2545 | }
|
| 2546 |
|
| 2547 | void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
|
| 2548 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2549 | TRACE("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2550 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2551 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2552 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2553 | if(context)
|
| 2554 | {
|
| 2555 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2556 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2557 | if(fenceObject == NULL)
|
| 2558 | {
|
| 2559 | return error(GL_INVALID_OPERATION);
|
| 2560 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2561 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2562 | fenceObject->getFenceiv(pname, params);
|
| 2563 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2564 | }
|
| 2565 |
|
| 2566 | void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
|
| 2567 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2568 | TRACE("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2569 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2570 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2571 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2572 | if(context)
|
| 2573 | {
|
| 2574 | if(!(context->getFloatv(pname, params)))
|
| 2575 | {
|
| 2576 | GLenum nativeType;
|
| 2577 | unsigned int numParams = 0;
|
| 2578 | if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
|
| 2579 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2580 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2581 | if(numParams == 0)
|
| 2582 | return; // it is known that the pname is valid, but that there are no parameters to return.
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2583 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2584 | if(nativeType == GL_BOOL)
|
| 2585 | {
|
| 2586 | GLboolean *boolParams = NULL;
|
| 2587 | boolParams = new GLboolean[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2588 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2589 | context->getBooleanv(pname, boolParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2590 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2591 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2592 | {
|
| 2593 | if(boolParams[i] == GL_FALSE)
|
| 2594 | params[i] = 0.0f;
|
| 2595 | else
|
| 2596 | params[i] = 1.0f;
|
| 2597 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2598 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2599 | delete [] boolParams;
|
| 2600 | }
|
| 2601 | else if(nativeType == GL_INT)
|
| 2602 | {
|
| 2603 | GLint *intParams = NULL;
|
| 2604 | intParams = new GLint[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2605 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2606 | context->getIntegerv(pname, intParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2607 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2608 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2609 | {
|
| 2610 | params[i] = (GLfloat)intParams[i];
|
| 2611 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2612 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2613 | delete [] intParams;
|
| 2614 | }
|
| 2615 | }
|
| 2616 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2617 | }
|
| 2618 |
|
| 2619 | void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
|
| 2620 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2621 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
|
| 2622 | target, attachment, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2623 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2624 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2625 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2626 | if(context)
|
| 2627 | {
|
| 2628 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 2629 | {
|
| 2630 | return error(GL_INVALID_ENUM);
|
| 2631 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2632 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2633 | es2::Framebuffer *framebuffer = NULL;
|
| 2634 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 2635 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2636 | if(context->getReadFramebufferName() == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2637 | {
|
| 2638 | return error(GL_INVALID_OPERATION);
|
| 2639 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2640 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2641 | framebuffer = context->getReadFramebuffer();
|
| 2642 | }
|
| 2643 | else
|
| 2644 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2645 | if(context->getDrawFramebufferName() == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2646 | {
|
| 2647 | return error(GL_INVALID_OPERATION);
|
| 2648 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2649 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2650 | framebuffer = context->getDrawFramebuffer();
|
| 2651 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2652 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2653 | GLenum attachmentType;
|
| 2654 | GLuint attachmentHandle;
|
| 2655 | switch(attachment)
|
| 2656 | {
|
| 2657 | case GL_COLOR_ATTACHMENT0:
|
| 2658 | attachmentType = framebuffer->getColorbufferType();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2659 | attachmentHandle = framebuffer->getColorbufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2660 | break;
|
| 2661 | case GL_DEPTH_ATTACHMENT:
|
| 2662 | attachmentType = framebuffer->getDepthbufferType();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2663 | attachmentHandle = framebuffer->getDepthbufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2664 | break;
|
| 2665 | case GL_STENCIL_ATTACHMENT:
|
| 2666 | attachmentType = framebuffer->getStencilbufferType();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2667 | attachmentHandle = framebuffer->getStencilbufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2668 | break;
|
| 2669 | default:
|
| 2670 | return error(GL_INVALID_ENUM);
|
| 2671 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2672 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2673 | GLenum attachmentObjectType; // Type category
|
| 2674 | if(attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
|
| 2675 | {
|
| 2676 | attachmentObjectType = attachmentType;
|
| 2677 | }
|
| 2678 | else if(es2::IsTextureTarget(attachmentType))
|
| 2679 | {
|
| 2680 | attachmentObjectType = GL_TEXTURE;
|
| 2681 | }
|
| 2682 | else UNREACHABLE();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2683 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2684 | switch(pname)
|
| 2685 | {
|
| 2686 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
|
| 2687 | *params = attachmentObjectType;
|
| 2688 | break;
|
| 2689 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
|
| 2690 | if(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
|
| 2691 | {
|
| 2692 | *params = attachmentHandle;
|
| 2693 | }
|
| 2694 | else
|
| 2695 | {
|
| 2696 | return error(GL_INVALID_ENUM);
|
| 2697 | }
|
| 2698 | break;
|
| 2699 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
|
| 2700 | if(attachmentObjectType == GL_TEXTURE)
|
| 2701 | {
|
| 2702 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
|
| 2703 | }
|
| 2704 | else
|
| 2705 | {
|
| 2706 | return error(GL_INVALID_ENUM);
|
| 2707 | }
|
| 2708 | break;
|
| 2709 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
|
| 2710 | if(attachmentObjectType == GL_TEXTURE)
|
| 2711 | {
|
| 2712 | if(es2::IsCubemapTextureTarget(attachmentType))
|
| 2713 | {
|
| 2714 | *params = attachmentType;
|
| 2715 | }
|
| 2716 | else
|
| 2717 | {
|
| 2718 | *params = 0;
|
| 2719 | }
|
| 2720 | }
|
| 2721 | else
|
| 2722 | {
|
| 2723 | return error(GL_INVALID_ENUM);
|
| 2724 | }
|
| 2725 | break;
|
| 2726 | default:
|
| 2727 | return error(GL_INVALID_ENUM);
|
| 2728 | }
|
| 2729 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2730 | }
|
| 2731 |
|
| 2732 | GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
|
| 2733 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2734 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2735 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2736 | return GL_NO_ERROR;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2737 | }
|
| 2738 |
|
| 2739 | void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
|
| 2740 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2741 | TRACE("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2742 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2743 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2744 |
|
Nicolas Capens | 7ae353d | 2015-03-13 17:59:58 -0400 | [diff] [blame] | 2745 | if(!context)
|
| 2746 | {
|
Greg Hartman | 6074f12 | 2015-04-08 09:57:16 -0700 | [diff] [blame] | 2747 | // Not strictly an error, but probably unintended or attempting to rely on non-compliant behavior
|
| 2748 | #ifdef __ANDROID__
|
| 2749 | ALOGI("expected_badness glGetIntegerv() called without current context.");
|
| 2750 | #else
|
| 2751 | ERR("glGetIntegerv() called without current context.");
|
| 2752 | #endif
|
Nicolas Capens | 7ae353d | 2015-03-13 17:59:58 -0400 | [diff] [blame] | 2753 |
|
| 2754 | // This is not spec compliant! When there is no current GL context, functions should
|
| 2755 | // have no side effects. Google Maps queries these values before creating a context,
|
| 2756 | // so we need this as a bug-compatible workaround.
|
| 2757 | switch(pname)
|
| 2758 | {
|
| 2759 | case GL_MAX_TEXTURE_SIZE: *params = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE; return;
|
| 2760 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = es2::MAX_VERTEX_TEXTURE_IMAGE_UNITS; return;
|
| 2761 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = es2::MAX_COMBINED_TEXTURE_IMAGE_UNITS; return;
|
| 2762 | case GL_STENCIL_BITS: *params = 8; return;
|
| 2763 | case GL_ALIASED_LINE_WIDTH_RANGE:
|
| 2764 | params[0] = (GLint)es2::ALIASED_LINE_WIDTH_RANGE_MIN;
|
| 2765 | params[1] = (GLint)es2::ALIASED_LINE_WIDTH_RANGE_MAX;
|
| 2766 | return;
|
| 2767 | }
|
| 2768 | }
|
| 2769 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2770 | if(context)
|
| 2771 | {
|
| 2772 | if(!(context->getIntegerv(pname, params)))
|
| 2773 | {
|
| 2774 | GLenum nativeType;
|
| 2775 | unsigned int numParams = 0;
|
| 2776 | if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
|
| 2777 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2778 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2779 | if(numParams == 0)
|
| 2780 | return; // it is known that pname is valid, but there are no parameters to return
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2781 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2782 | if(nativeType == GL_BOOL)
|
| 2783 | {
|
| 2784 | GLboolean *boolParams = NULL;
|
| 2785 | boolParams = new GLboolean[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2786 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2787 | context->getBooleanv(pname, boolParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2788 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2789 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2790 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2791 | params[i] = (boolParams[i] == GL_FALSE) ? 0 : 1;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2792 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2793 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2794 | delete [] boolParams;
|
| 2795 | }
|
| 2796 | else if(nativeType == GL_FLOAT)
|
| 2797 | {
|
| 2798 | GLfloat *floatParams = NULL;
|
| 2799 | floatParams = new GLfloat[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2800 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2801 | context->getFloatv(pname, floatParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2802 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2803 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2804 | {
|
| 2805 | if(pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
|
| 2806 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2807 | params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) * 0.5f);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2808 | }
|
| 2809 | else
|
| 2810 | {
|
| 2811 | params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
|
| 2812 | }
|
| 2813 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2814 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2815 | delete [] floatParams;
|
| 2816 | }
|
| 2817 | }
|
| 2818 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2819 | }
|
| 2820 |
|
| 2821 | void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
|
| 2822 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2823 | TRACE("(GLuint program = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", program, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2824 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2825 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2826 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2827 | if(context)
|
| 2828 | {
|
| 2829 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2830 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2831 | if(!programObject)
|
| 2832 | {
|
| 2833 | return error(GL_INVALID_VALUE);
|
| 2834 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2835 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2836 | switch(pname)
|
| 2837 | {
|
| 2838 | case GL_DELETE_STATUS:
|
| 2839 | *params = programObject->isFlaggedForDeletion();
|
| 2840 | return;
|
| 2841 | case GL_LINK_STATUS:
|
| 2842 | *params = programObject->isLinked();
|
| 2843 | return;
|
| 2844 | case GL_VALIDATE_STATUS:
|
| 2845 | *params = programObject->isValidated();
|
| 2846 | return;
|
| 2847 | case GL_INFO_LOG_LENGTH:
|
| 2848 | *params = programObject->getInfoLogLength();
|
| 2849 | return;
|
| 2850 | case GL_ATTACHED_SHADERS:
|
| 2851 | *params = programObject->getAttachedShadersCount();
|
| 2852 | return;
|
| 2853 | case GL_ACTIVE_ATTRIBUTES:
|
| 2854 | *params = programObject->getActiveAttributeCount();
|
| 2855 | return;
|
| 2856 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
|
| 2857 | *params = programObject->getActiveAttributeMaxLength();
|
| 2858 | return;
|
| 2859 | case GL_ACTIVE_UNIFORMS:
|
| 2860 | *params = programObject->getActiveUniformCount();
|
| 2861 | return;
|
| 2862 | case GL_ACTIVE_UNIFORM_MAX_LENGTH:
|
| 2863 | *params = programObject->getActiveUniformMaxLength();
|
| 2864 | return;
|
| 2865 | default:
|
| 2866 | return error(GL_INVALID_ENUM);
|
| 2867 | }
|
| 2868 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2869 | }
|
| 2870 |
|
| 2871 | void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
|
| 2872 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2873 | TRACE("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
|
| 2874 | program, bufsize, length, infolog);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2875 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2876 | if(bufsize < 0)
|
| 2877 | {
|
| 2878 | return error(GL_INVALID_VALUE);
|
| 2879 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2880 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2881 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2882 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2883 | if(context)
|
| 2884 | {
|
| 2885 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2886 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2887 | if(!programObject)
|
| 2888 | {
|
| 2889 | return error(GL_INVALID_VALUE);
|
| 2890 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2891 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2892 | programObject->getInfoLog(bufsize, length, infolog);
|
| 2893 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2894 | }
|
| 2895 |
|
| 2896 | void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
|
| 2897 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2898 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2899 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2900 | switch(pname)
|
| 2901 | {
|
| 2902 | case GL_CURRENT_QUERY_EXT:
|
| 2903 | break;
|
| 2904 | default:
|
| 2905 | return error(GL_INVALID_ENUM);
|
| 2906 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2907 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2908 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2909 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2910 | if(context)
|
| 2911 | {
|
| 2912 | params[0] = context->getActiveQuery(target);
|
| 2913 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2914 | }
|
| 2915 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2916 | void GL_APIENTRY glGetQueryObjectuivEXT(GLuint name, GLenum pname, GLuint *params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2917 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2918 | TRACE("(GLuint name = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", name, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2919 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2920 | switch(pname)
|
| 2921 | {
|
| 2922 | case GL_QUERY_RESULT_EXT:
|
| 2923 | case GL_QUERY_RESULT_AVAILABLE_EXT:
|
| 2924 | break;
|
| 2925 | default:
|
| 2926 | return error(GL_INVALID_ENUM);
|
| 2927 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2928 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2929 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2930 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2931 | if(context)
|
| 2932 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2933 | es2::Query *queryObject = context->getQuery(name, false, GL_NONE);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2934 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2935 | if(!queryObject)
|
| 2936 | {
|
| 2937 | return error(GL_INVALID_OPERATION);
|
| 2938 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2939 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2940 | if(context->getActiveQuery(queryObject->getType()) == name)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2941 | {
|
| 2942 | return error(GL_INVALID_OPERATION);
|
| 2943 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2944 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2945 | switch(pname)
|
| 2946 | {
|
| 2947 | case GL_QUERY_RESULT_EXT:
|
| 2948 | params[0] = queryObject->getResult();
|
| 2949 | break;
|
| 2950 | case GL_QUERY_RESULT_AVAILABLE_EXT:
|
| 2951 | params[0] = queryObject->isResultAvailable();
|
| 2952 | break;
|
| 2953 | default:
|
| 2954 | ASSERT(false);
|
| 2955 | }
|
| 2956 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2957 | }
|
| 2958 |
|
| 2959 | void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
|
| 2960 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2961 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2962 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2963 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2964 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2965 | if(context)
|
| 2966 | {
|
| 2967 | if(target != GL_RENDERBUFFER)
|
| 2968 | {
|
| 2969 | return error(GL_INVALID_ENUM);
|
| 2970 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2971 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2972 | if(context->getRenderbufferName() == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2973 | {
|
| 2974 | return error(GL_INVALID_OPERATION);
|
| 2975 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2976 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2977 | es2::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferName());
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2978 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2979 | switch(pname)
|
| 2980 | {
|
| 2981 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
|
| 2982 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
|
| 2983 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getFormat(); break;
|
| 2984 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
|
| 2985 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
|
| 2986 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
|
| 2987 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
|
| 2988 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
|
| 2989 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
|
| 2990 | case GL_RENDERBUFFER_SAMPLES_ANGLE: *params = renderbuffer->getSamples(); break;
|
| 2991 | default:
|
| 2992 | return error(GL_INVALID_ENUM);
|
| 2993 | }
|
| 2994 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2995 | }
|
| 2996 |
|
| 2997 | void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
|
| 2998 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2999 | TRACE("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3000 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3001 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3002 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3003 | if(context)
|
| 3004 | {
|
| 3005 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3006 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3007 | if(!shaderObject)
|
| 3008 | {
|
| 3009 | return error(GL_INVALID_VALUE);
|
| 3010 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3011 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3012 | switch(pname)
|
| 3013 | {
|
| 3014 | case GL_SHADER_TYPE:
|
| 3015 | *params = shaderObject->getType();
|
| 3016 | return;
|
| 3017 | case GL_DELETE_STATUS:
|
| 3018 | *params = shaderObject->isFlaggedForDeletion();
|
| 3019 | return;
|
| 3020 | case GL_COMPILE_STATUS:
|
| 3021 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
|
| 3022 | return;
|
| 3023 | case GL_INFO_LOG_LENGTH:
|
| 3024 | *params = shaderObject->getInfoLogLength();
|
| 3025 | return;
|
| 3026 | case GL_SHADER_SOURCE_LENGTH:
|
| 3027 | *params = shaderObject->getSourceLength();
|
| 3028 | return;
|
| 3029 | default:
|
| 3030 | return error(GL_INVALID_ENUM);
|
| 3031 | }
|
| 3032 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3033 | }
|
| 3034 |
|
| 3035 | void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
|
| 3036 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3037 | TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
|
| 3038 | shader, bufsize, length, infolog);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3039 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3040 | if(bufsize < 0)
|
| 3041 | {
|
| 3042 | return error(GL_INVALID_VALUE);
|
| 3043 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3044 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3045 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3046 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3047 | if(context)
|
| 3048 | {
|
| 3049 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3050 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3051 | if(!shaderObject)
|
| 3052 | {
|
| 3053 | return error(GL_INVALID_VALUE);
|
| 3054 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3055 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3056 | shaderObject->getInfoLog(bufsize, length, infolog);
|
| 3057 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3058 | }
|
| 3059 |
|
| 3060 | void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
|
| 3061 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3062 | TRACE("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
|
| 3063 | shadertype, precisiontype, range, precision);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3064 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3065 | switch(shadertype)
|
| 3066 | {
|
| 3067 | case GL_VERTEX_SHADER:
|
| 3068 | case GL_FRAGMENT_SHADER:
|
| 3069 | break;
|
| 3070 | default:
|
| 3071 | return error(GL_INVALID_ENUM);
|
| 3072 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3073 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3074 | switch(precisiontype)
|
| 3075 | {
|
| 3076 | case GL_LOW_FLOAT:
|
| 3077 | case GL_MEDIUM_FLOAT:
|
| 3078 | case GL_HIGH_FLOAT:
|
| 3079 | // IEEE 754 single-precision
|
| 3080 | range[0] = 127;
|
| 3081 | range[1] = 127;
|
| 3082 | *precision = 23;
|
| 3083 | break;
|
| 3084 | case GL_LOW_INT:
|
| 3085 | case GL_MEDIUM_INT:
|
| 3086 | case GL_HIGH_INT:
|
| 3087 | // Single-precision floating-point numbers can accurately represent integers up to +/-16777216
|
| 3088 | range[0] = 24;
|
| 3089 | range[1] = 24;
|
| 3090 | *precision = 0;
|
| 3091 | break;
|
| 3092 | default:
|
| 3093 | return error(GL_INVALID_ENUM);
|
| 3094 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3095 | }
|
| 3096 |
|
| 3097 | void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
|
| 3098 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3099 | TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
|
| 3100 | shader, bufsize, length, source);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3101 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3102 | if(bufsize < 0)
|
| 3103 | {
|
| 3104 | return error(GL_INVALID_VALUE);
|
| 3105 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3106 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3107 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3108 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3109 | if(context)
|
| 3110 | {
|
| 3111 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3112 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3113 | if(!shaderObject)
|
| 3114 | {
|
| 3115 | return error(GL_INVALID_OPERATION);
|
| 3116 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3117 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3118 | shaderObject->getSource(bufsize, length, source);
|
| 3119 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3120 | }
|
| 3121 |
|
| 3122 | const GLubyte* GL_APIENTRY glGetString(GLenum name)
|
| 3123 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3124 | TRACE("(GLenum name = 0x%X)", name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3125 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3126 | switch(name)
|
| 3127 | {
|
| 3128 | case GL_VENDOR:
|
Alexis Hetu | 8141d7c | 2015-04-02 16:45:59 -0400 | [diff] [blame] | 3129 | return (GLubyte*)"Google Inc.";
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3130 | case GL_RENDERER:
|
| 3131 | return (GLubyte*)"SwiftShader";
|
| 3132 | case GL_VERSION:
|
| 3133 | return (GLubyte*)"OpenGL ES 2.0 SwiftShader " VERSION_STRING;
|
| 3134 | case GL_SHADING_LANGUAGE_VERSION:
|
| 3135 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader " VERSION_STRING;
|
| 3136 | case GL_EXTENSIONS:
|
Alexis Hetu | 8141d7c | 2015-04-02 16:45:59 -0400 | [diff] [blame] | 3137 | {
|
| 3138 | es2::Context *context = es2::getContext();
|
| 3139 | return context ? context->getExtensions(GL_INVALID_INDEX) : (GLubyte*)NULL;
|
| 3140 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3141 | default:
|
| 3142 | return error(GL_INVALID_ENUM, (GLubyte*)NULL);
|
| 3143 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3144 | }
|
| 3145 |
|
| 3146 | void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
|
| 3147 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3148 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3149 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3150 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3151 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3152 | if(context)
|
| 3153 | {
|
| 3154 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3155 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3156 | egl::GLint clientVersion = context->getClientVersion();
|
| 3157 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3158 | switch(target)
|
| 3159 | {
|
| 3160 | case GL_TEXTURE_2D:
|
| 3161 | texture = context->getTexture2D();
|
| 3162 | break;
|
| 3163 | case GL_TEXTURE_CUBE_MAP:
|
| 3164 | texture = context->getTextureCubeMap();
|
| 3165 | break;
|
| 3166 | case GL_TEXTURE_EXTERNAL_OES:
|
| 3167 | texture = context->getTextureExternal();
|
| 3168 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3169 | case GL_TEXTURE_2D_ARRAY:
|
| 3170 | if(clientVersion < 3)
|
| 3171 | {
|
| 3172 | return error(GL_INVALID_ENUM);
|
| 3173 | }
|
| 3174 | else
|
| 3175 | {
|
| 3176 | UNIMPLEMENTED();
|
| 3177 | texture = context->getTexture3D();
|
| 3178 | break;
|
| 3179 | }
|
| 3180 | case GL_TEXTURE_3D_OES:
|
| 3181 | texture = context->getTexture3D();
|
| 3182 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3183 | default:
|
| 3184 | return error(GL_INVALID_ENUM);
|
| 3185 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3186 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3187 | switch(pname)
|
| 3188 | {
|
| 3189 | case GL_TEXTURE_MAG_FILTER:
|
| 3190 | *params = (GLfloat)texture->getMagFilter();
|
| 3191 | break;
|
| 3192 | case GL_TEXTURE_MIN_FILTER:
|
| 3193 | *params = (GLfloat)texture->getMinFilter();
|
| 3194 | break;
|
| 3195 | case GL_TEXTURE_WRAP_S:
|
| 3196 | *params = (GLfloat)texture->getWrapS();
|
| 3197 | break;
|
| 3198 | case GL_TEXTURE_WRAP_T:
|
| 3199 | *params = (GLfloat)texture->getWrapT();
|
| 3200 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 3201 | case GL_TEXTURE_WRAP_R_OES:
|
| 3202 | *params = (GLfloat)texture->getWrapR();
|
| 3203 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3204 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 3205 | *params = texture->getMaxAnisotropy();
|
| 3206 | break;
|
| 3207 | case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
|
| 3208 | *params = (GLfloat)1;
|
| 3209 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3210 | case GL_TEXTURE_BASE_LEVEL:
|
| 3211 | if(clientVersion >= 3)
|
| 3212 | {
|
| 3213 | *params = (GLfloat)texture->getBaseLevel();
|
| 3214 | break;
|
| 3215 | }
|
| 3216 | else return error(GL_INVALID_ENUM);
|
| 3217 | case GL_TEXTURE_COMPARE_FUNC:
|
| 3218 | if(clientVersion >= 3)
|
| 3219 | {
|
| 3220 | *params = (GLfloat)texture->getCompareFunc();
|
| 3221 | break;
|
| 3222 | }
|
| 3223 | else return error(GL_INVALID_ENUM);
|
| 3224 | case GL_TEXTURE_COMPARE_MODE:
|
| 3225 | if(clientVersion >= 3)
|
| 3226 | {
|
| 3227 | *params = (GLfloat)texture->getCompareMode();
|
| 3228 | break;
|
| 3229 | }
|
| 3230 | else return error(GL_INVALID_ENUM);
|
| 3231 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
| 3232 | if(clientVersion >= 3)
|
| 3233 | {
|
| 3234 | *params = (GLfloat)texture->getImmutableFormat();
|
| 3235 | break;
|
| 3236 | }
|
| 3237 | else return error(GL_INVALID_ENUM);
|
| 3238 | case GL_TEXTURE_MAX_LEVEL:
|
| 3239 | if(clientVersion >= 3)
|
| 3240 | {
|
| 3241 | *params = (GLfloat)texture->getMaxLevel();
|
| 3242 | break;
|
| 3243 | }
|
| 3244 | else return error(GL_INVALID_ENUM);
|
| 3245 | case GL_TEXTURE_MAX_LOD:
|
| 3246 | if(clientVersion >= 3)
|
| 3247 | {
|
| 3248 | *params = texture->getMaxLOD();
|
| 3249 | break;
|
| 3250 | }
|
| 3251 | else return error(GL_INVALID_ENUM);
|
| 3252 | case GL_TEXTURE_MIN_LOD:
|
| 3253 | if(clientVersion >= 3)
|
| 3254 | {
|
| 3255 | *params = texture->getMinLOD();
|
| 3256 | break;
|
| 3257 | }
|
| 3258 | else return error(GL_INVALID_ENUM);
|
| 3259 | case GL_TEXTURE_SWIZZLE_R:
|
| 3260 | if(clientVersion >= 3)
|
| 3261 | {
|
| 3262 | *params = (GLfloat)texture->getSwizzleR();
|
| 3263 | break;
|
| 3264 | }
|
| 3265 | else return error(GL_INVALID_ENUM);
|
| 3266 | case GL_TEXTURE_SWIZZLE_G:
|
| 3267 | if(clientVersion >= 3)
|
| 3268 | {
|
| 3269 | *params = (GLfloat)texture->getSwizzleG();
|
| 3270 | break;
|
| 3271 | }
|
| 3272 | else return error(GL_INVALID_ENUM);
|
| 3273 | case GL_TEXTURE_SWIZZLE_B:
|
| 3274 | if(clientVersion >= 3)
|
| 3275 | {
|
| 3276 | *params = (GLfloat)texture->getSwizzleB();
|
| 3277 | break;
|
| 3278 | }
|
| 3279 | else return error(GL_INVALID_ENUM);
|
| 3280 | case GL_TEXTURE_SWIZZLE_A:
|
| 3281 | if(clientVersion >= 3)
|
| 3282 | {
|
| 3283 | *params = (GLfloat)texture->getSwizzleA();
|
| 3284 | break;
|
| 3285 | }
|
| 3286 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3287 | default:
|
| 3288 | return error(GL_INVALID_ENUM);
|
| 3289 | }
|
| 3290 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3291 | }
|
| 3292 |
|
| 3293 | void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
|
| 3294 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3295 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3296 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3297 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3298 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3299 | if(context)
|
| 3300 | {
|
| 3301 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3302 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3303 | egl::GLint clientVersion = context->getClientVersion();
|
| 3304 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3305 | switch(target)
|
| 3306 | {
|
| 3307 | case GL_TEXTURE_2D:
|
| 3308 | texture = context->getTexture2D();
|
| 3309 | break;
|
| 3310 | case GL_TEXTURE_CUBE_MAP:
|
| 3311 | texture = context->getTextureCubeMap();
|
| 3312 | break;
|
| 3313 | case GL_TEXTURE_EXTERNAL_OES:
|
| 3314 | texture = context->getTextureExternal();
|
| 3315 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3316 | case GL_TEXTURE_2D_ARRAY:
|
| 3317 | if(clientVersion < 3)
|
| 3318 | {
|
| 3319 | return error(GL_INVALID_ENUM);
|
| 3320 | }
|
| 3321 | else
|
| 3322 | {
|
| 3323 | UNIMPLEMENTED();
|
| 3324 | texture = context->getTexture3D();
|
| 3325 | break;
|
| 3326 | }
|
| 3327 | case GL_TEXTURE_3D_OES:
|
| 3328 | texture = context->getTexture3D();
|
| 3329 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3330 | default:
|
| 3331 | return error(GL_INVALID_ENUM);
|
| 3332 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3333 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3334 | switch(pname)
|
| 3335 | {
|
| 3336 | case GL_TEXTURE_MAG_FILTER:
|
| 3337 | *params = texture->getMagFilter();
|
| 3338 | break;
|
| 3339 | case GL_TEXTURE_MIN_FILTER:
|
| 3340 | *params = texture->getMinFilter();
|
| 3341 | break;
|
| 3342 | case GL_TEXTURE_WRAP_S:
|
| 3343 | *params = texture->getWrapS();
|
| 3344 | break;
|
| 3345 | case GL_TEXTURE_WRAP_T:
|
| 3346 | *params = texture->getWrapT();
|
| 3347 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 3348 | case GL_TEXTURE_WRAP_R_OES:
|
| 3349 | *params = texture->getWrapR();
|
| 3350 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3351 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 3352 | *params = (GLint)texture->getMaxAnisotropy();
|
| 3353 | break;
|
| 3354 | case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
|
| 3355 | *params = 1;
|
| 3356 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3357 | case GL_TEXTURE_BASE_LEVEL:
|
| 3358 | if(clientVersion >= 3)
|
| 3359 | {
|
| 3360 | *params = texture->getBaseLevel();
|
| 3361 | break;
|
| 3362 | }
|
| 3363 | else return error(GL_INVALID_ENUM);
|
| 3364 | case GL_TEXTURE_COMPARE_FUNC:
|
| 3365 | if(clientVersion >= 3)
|
| 3366 | {
|
| 3367 | *params = (GLint)texture->getCompareFunc();
|
| 3368 | break;
|
| 3369 | }
|
| 3370 | else return error(GL_INVALID_ENUM);
|
| 3371 | case GL_TEXTURE_COMPARE_MODE:
|
| 3372 | if(clientVersion >= 3)
|
| 3373 | {
|
| 3374 | *params = (GLint)texture->getCompareMode();
|
| 3375 | break;
|
| 3376 | }
|
| 3377 | else return error(GL_INVALID_ENUM);
|
| 3378 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
| 3379 | if(clientVersion >= 3)
|
| 3380 | {
|
| 3381 | *params = (GLint)texture->getImmutableFormat();
|
| 3382 | break;
|
| 3383 | }
|
| 3384 | else return error(GL_INVALID_ENUM);
|
| 3385 | case GL_TEXTURE_MAX_LEVEL:
|
| 3386 | if(clientVersion >= 3)
|
| 3387 | {
|
| 3388 | *params = texture->getMaxLevel();
|
| 3389 | break;
|
| 3390 | }
|
| 3391 | else return error(GL_INVALID_ENUM);
|
| 3392 | case GL_TEXTURE_MAX_LOD:
|
| 3393 | if(clientVersion >= 3)
|
| 3394 | {
|
| 3395 | *params = (GLint)texture->getMaxLOD();
|
| 3396 | break;
|
| 3397 | }
|
| 3398 | else return error(GL_INVALID_ENUM);
|
| 3399 | case GL_TEXTURE_MIN_LOD:
|
| 3400 | if(clientVersion >= 3)
|
| 3401 | {
|
| 3402 | *params = (GLint)texture->getMinLOD();
|
| 3403 | break;
|
| 3404 | }
|
| 3405 | else return error(GL_INVALID_ENUM);
|
| 3406 | case GL_TEXTURE_SWIZZLE_R:
|
| 3407 | if(clientVersion >= 3)
|
| 3408 | {
|
| 3409 | *params = (GLint)texture->getSwizzleR();
|
| 3410 | break;
|
| 3411 | }
|
| 3412 | else return error(GL_INVALID_ENUM);
|
| 3413 | case GL_TEXTURE_SWIZZLE_G:
|
| 3414 | if(clientVersion >= 3)
|
| 3415 | {
|
| 3416 | *params = (GLint)texture->getSwizzleG();
|
| 3417 | break;
|
| 3418 | }
|
| 3419 | else return error(GL_INVALID_ENUM);
|
| 3420 | case GL_TEXTURE_SWIZZLE_B:
|
| 3421 | if(clientVersion >= 3)
|
| 3422 | {
|
| 3423 | *params = (GLint)texture->getSwizzleB();
|
| 3424 | break;
|
| 3425 | }
|
| 3426 | else return error(GL_INVALID_ENUM);
|
| 3427 | case GL_TEXTURE_SWIZZLE_A:
|
| 3428 | if(clientVersion >= 3)
|
| 3429 | {
|
| 3430 | *params = (GLint)texture->getSwizzleA();
|
| 3431 | break;
|
| 3432 | }
|
| 3433 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3434 | default:
|
| 3435 | return error(GL_INVALID_ENUM);
|
| 3436 | }
|
| 3437 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3438 | }
|
| 3439 |
|
| 3440 | void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
|
| 3441 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3442 | TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
|
| 3443 | program, location, bufSize, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3444 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3445 | if(bufSize < 0)
|
| 3446 | {
|
| 3447 | return error(GL_INVALID_VALUE);
|
| 3448 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3449 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3450 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3451 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3452 | if(context)
|
| 3453 | {
|
| 3454 | if(program == 0)
|
| 3455 | {
|
| 3456 | return error(GL_INVALID_VALUE);
|
| 3457 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3458 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3459 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3460 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3461 | if(!programObject || !programObject->isLinked())
|
| 3462 | {
|
| 3463 | return error(GL_INVALID_OPERATION);
|
| 3464 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3465 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3466 | if(!programObject->getUniformfv(location, &bufSize, params))
|
| 3467 | {
|
| 3468 | return error(GL_INVALID_OPERATION);
|
| 3469 | }
|
| 3470 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3471 | }
|
| 3472 |
|
| 3473 | void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
|
| 3474 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3475 | TRACE("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3476 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3477 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3478 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3479 | if(context)
|
| 3480 | {
|
| 3481 | if(program == 0)
|
| 3482 | {
|
| 3483 | return error(GL_INVALID_VALUE);
|
| 3484 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3485 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3486 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3487 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3488 | if(!programObject || !programObject->isLinked())
|
| 3489 | {
|
| 3490 | return error(GL_INVALID_OPERATION);
|
| 3491 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3492 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3493 | if(!programObject->getUniformfv(location, NULL, params))
|
| 3494 | {
|
| 3495 | return error(GL_INVALID_OPERATION);
|
| 3496 | }
|
| 3497 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3498 | }
|
| 3499 |
|
| 3500 | void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
|
| 3501 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3502 | TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
|
| 3503 | program, location, bufSize, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3504 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3505 | if(bufSize < 0)
|
| 3506 | {
|
| 3507 | return error(GL_INVALID_VALUE);
|
| 3508 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3509 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3510 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3511 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3512 | if(context)
|
| 3513 | {
|
| 3514 | if(program == 0)
|
| 3515 | {
|
| 3516 | return error(GL_INVALID_VALUE);
|
| 3517 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3518 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3519 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3520 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3521 | if(!programObject || !programObject->isLinked())
|
| 3522 | {
|
| 3523 | return error(GL_INVALID_OPERATION);
|
| 3524 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3525 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3526 | if(!programObject)
|
| 3527 | {
|
| 3528 | return error(GL_INVALID_OPERATION);
|
| 3529 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3530 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3531 | if(!programObject->getUniformiv(location, &bufSize, params))
|
| 3532 | {
|
| 3533 | return error(GL_INVALID_OPERATION);
|
| 3534 | }
|
| 3535 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3536 | }
|
| 3537 |
|
| 3538 | void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
|
| 3539 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3540 | TRACE("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3541 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3542 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3543 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3544 | if(context)
|
| 3545 | {
|
| 3546 | if(program == 0)
|
| 3547 | {
|
| 3548 | return error(GL_INVALID_VALUE);
|
| 3549 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3550 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3551 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3552 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3553 | if(!programObject || !programObject->isLinked())
|
| 3554 | {
|
| 3555 | return error(GL_INVALID_OPERATION);
|
| 3556 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3557 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3558 | if(!programObject)
|
| 3559 | {
|
| 3560 | return error(GL_INVALID_OPERATION);
|
| 3561 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3562 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3563 | if(!programObject->getUniformiv(location, NULL, params))
|
| 3564 | {
|
| 3565 | return error(GL_INVALID_OPERATION);
|
| 3566 | }
|
| 3567 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3568 | }
|
| 3569 |
|
| 3570 | int GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
|
| 3571 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3572 | TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3573 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3574 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3575 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3576 | if(strstr(name, "gl_") == name)
|
| 3577 | {
|
| 3578 | return -1;
|
| 3579 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3580 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3581 | if(context)
|
| 3582 | {
|
| 3583 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3584 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3585 | if(!programObject)
|
| 3586 | {
|
| 3587 | if(context->getShader(program))
|
| 3588 | {
|
| 3589 | return error(GL_INVALID_OPERATION, -1);
|
| 3590 | }
|
| 3591 | else
|
| 3592 | {
|
| 3593 | return error(GL_INVALID_VALUE, -1);
|
| 3594 | }
|
| 3595 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3596 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3597 | if(!programObject->isLinked())
|
| 3598 | {
|
| 3599 | return error(GL_INVALID_OPERATION, -1);
|
| 3600 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3601 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3602 | return programObject->getUniformLocation(name);
|
| 3603 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3604 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3605 | return -1;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3606 | }
|
| 3607 |
|
| 3608 | void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
|
| 3609 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3610 | TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3611 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3612 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3613 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3614 | if(context)
|
| 3615 | {
|
| 3616 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 3617 | {
|
| 3618 | return error(GL_INVALID_VALUE);
|
| 3619 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3620 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3621 | const es2::VertexAttribute &attribState = context->getVertexAttribState(index);
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3622 |
|
| 3623 | egl::GLint clientVersion = context->getClientVersion();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3624 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3625 | switch(pname)
|
| 3626 | {
|
| 3627 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
|
| 3628 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
|
| 3629 | break;
|
| 3630 | case GL_VERTEX_ATTRIB_ARRAY_SIZE:
|
| 3631 | *params = (GLfloat)attribState.mSize;
|
| 3632 | break;
|
| 3633 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
|
| 3634 | *params = (GLfloat)attribState.mStride;
|
| 3635 | break;
|
| 3636 | case GL_VERTEX_ATTRIB_ARRAY_TYPE:
|
| 3637 | *params = (GLfloat)attribState.mType;
|
| 3638 | break;
|
| 3639 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
| 3640 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
|
| 3641 | break;
|
| 3642 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3643 | *params = (GLfloat)attribState.mBoundBuffer.name();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3644 | break;
|
| 3645 | case GL_CURRENT_VERTEX_ATTRIB:
|
| 3646 | for(int i = 0; i < 4; ++i)
|
| 3647 | {
|
Alexis Hetu | 93ae103 | 2015-04-10 14:31:01 -0400 | [diff] [blame] | 3648 | params[i] = attribState.getCurrentValue(i);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3649 | }
|
| 3650 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3651 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
|
| 3652 | if(clientVersion >= 3)
|
| 3653 | {
|
| 3654 | switch(attribState.mType)
|
| 3655 | {
|
| 3656 | case GL_BYTE:
|
| 3657 | case GL_UNSIGNED_BYTE:
|
| 3658 | case GL_SHORT:
|
| 3659 | case GL_UNSIGNED_SHORT:
|
| 3660 | case GL_INT:
|
| 3661 | case GL_INT_2_10_10_10_REV:
|
| 3662 | case GL_UNSIGNED_INT:
|
| 3663 | case GL_FIXED:
|
| 3664 | *params = (GLfloat)GL_TRUE;
|
| 3665 | break;
|
| 3666 | default:
|
| 3667 | *params = (GLfloat)GL_FALSE;
|
| 3668 | break;
|
| 3669 | }
|
| 3670 | break;
|
| 3671 | }
|
| 3672 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3673 | default: return error(GL_INVALID_ENUM);
|
| 3674 | }
|
| 3675 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3676 | }
|
| 3677 |
|
| 3678 | void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
|
| 3679 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3680 | TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3681 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3682 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3683 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3684 | if(context)
|
| 3685 | {
|
| 3686 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 3687 | {
|
| 3688 | return error(GL_INVALID_VALUE);
|
| 3689 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3690 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3691 | const es2::VertexAttribute &attribState = context->getVertexAttribState(index);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3692 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3693 | egl::GLint clientVersion = context->getClientVersion();
|
| 3694 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3695 | switch(pname)
|
| 3696 | {
|
| 3697 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
|
| 3698 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
|
| 3699 | break;
|
| 3700 | case GL_VERTEX_ATTRIB_ARRAY_SIZE:
|
| 3701 | *params = attribState.mSize;
|
| 3702 | break;
|
| 3703 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
|
| 3704 | *params = attribState.mStride;
|
| 3705 | break;
|
| 3706 | case GL_VERTEX_ATTRIB_ARRAY_TYPE:
|
| 3707 | *params = attribState.mType;
|
| 3708 | break;
|
| 3709 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
| 3710 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
|
| 3711 | break;
|
| 3712 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3713 | *params = attribState.mBoundBuffer.name();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3714 | break;
|
| 3715 | case GL_CURRENT_VERTEX_ATTRIB:
|
| 3716 | for(int i = 0; i < 4; ++i)
|
| 3717 | {
|
Alexis Hetu | 93ae103 | 2015-04-10 14:31:01 -0400 | [diff] [blame] | 3718 | float currentValue = attribState.getCurrentValue(i);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3719 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
|
| 3720 | }
|
| 3721 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3722 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
|
| 3723 | if(clientVersion >= 3)
|
| 3724 | {
|
| 3725 | switch(attribState.mType)
|
| 3726 | {
|
| 3727 | case GL_BYTE:
|
| 3728 | case GL_UNSIGNED_BYTE:
|
| 3729 | case GL_SHORT:
|
| 3730 | case GL_UNSIGNED_SHORT:
|
| 3731 | case GL_INT:
|
| 3732 | case GL_INT_2_10_10_10_REV:
|
| 3733 | case GL_UNSIGNED_INT:
|
| 3734 | case GL_FIXED:
|
| 3735 | *params = GL_TRUE;
|
| 3736 | break;
|
| 3737 | default:
|
| 3738 | *params = GL_FALSE;
|
| 3739 | break;
|
| 3740 | }
|
| 3741 | break;
|
| 3742 | }
|
| 3743 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3744 | default: return error(GL_INVALID_ENUM);
|
| 3745 | }
|
| 3746 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3747 | }
|
| 3748 |
|
| 3749 | void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
|
| 3750 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3751 | TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3752 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3753 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3754 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3755 | if(context)
|
| 3756 | {
|
| 3757 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 3758 | {
|
| 3759 | return error(GL_INVALID_VALUE);
|
| 3760 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3761 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3762 | if(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
|
| 3763 | {
|
| 3764 | return error(GL_INVALID_ENUM);
|
| 3765 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3766 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3767 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
|
| 3768 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3769 | }
|
| 3770 |
|
| 3771 | void GL_APIENTRY glHint(GLenum target, GLenum mode)
|
| 3772 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3773 | TRACE("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3774 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3775 | switch(mode)
|
| 3776 | {
|
| 3777 | case GL_FASTEST:
|
| 3778 | case GL_NICEST:
|
| 3779 | case GL_DONT_CARE:
|
| 3780 | break;
|
| 3781 | default:
|
| 3782 | return error(GL_INVALID_ENUM);
|
| 3783 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3784 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3785 | es2::Context *context = es2::getContext();
|
| 3786 | switch(target)
|
| 3787 | {
|
| 3788 | case GL_GENERATE_MIPMAP_HINT:
|
| 3789 | if(context) context->setGenerateMipmapHint(mode);
|
| 3790 | break;
|
| 3791 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
|
| 3792 | if(context) context->setFragmentShaderDerivativeHint(mode);
|
| 3793 | break;
|
| 3794 | default:
|
| 3795 | return error(GL_INVALID_ENUM);
|
| 3796 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3797 | }
|
| 3798 |
|
| 3799 | GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
|
| 3800 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3801 | TRACE("(GLuint buffer = %d)", buffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3802 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3803 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3804 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3805 | if(context && buffer)
|
| 3806 | {
|
| 3807 | es2::Buffer *bufferObject = context->getBuffer(buffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3808 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3809 | if(bufferObject)
|
| 3810 | {
|
| 3811 | return GL_TRUE;
|
| 3812 | }
|
| 3813 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3814 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3815 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3816 | }
|
| 3817 |
|
| 3818 | GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
|
| 3819 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3820 | TRACE("(GLenum cap = 0x%X)", cap);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3821 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3822 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3823 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3824 | if(context)
|
| 3825 | {
|
| 3826 | switch(cap)
|
| 3827 | {
|
| 3828 | case GL_CULL_FACE: return context->isCullFaceEnabled();
|
| 3829 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
|
| 3830 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
|
| 3831 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
|
| 3832 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
|
| 3833 | case GL_STENCIL_TEST: return context->isStencilTestEnabled();
|
| 3834 | case GL_DEPTH_TEST: return context->isDepthTestEnabled();
|
| 3835 | case GL_BLEND: return context->isBlendEnabled();
|
| 3836 | case GL_DITHER: return context->isDitherEnabled();
|
| 3837 | default:
|
| 3838 | return error(GL_INVALID_ENUM, false);
|
| 3839 | }
|
| 3840 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3841 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3842 | return false;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3843 | }
|
| 3844 |
|
| 3845 | GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
|
| 3846 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3847 | TRACE("(GLuint fence = %d)", fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3848 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3849 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3850 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3851 | if(context)
|
| 3852 | {
|
| 3853 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3854 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3855 | if(fenceObject == NULL)
|
| 3856 | {
|
| 3857 | return GL_FALSE;
|
| 3858 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3859 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3860 | return fenceObject->isFence();
|
| 3861 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3862 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3863 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3864 | }
|
| 3865 |
|
| 3866 | GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
|
| 3867 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3868 | TRACE("(GLuint framebuffer = %d)", framebuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3869 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3870 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3871 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3872 | if(context && framebuffer)
|
| 3873 | {
|
| 3874 | es2::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3875 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3876 | if(framebufferObject)
|
| 3877 | {
|
| 3878 | return GL_TRUE;
|
| 3879 | }
|
| 3880 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3881 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3882 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3883 | }
|
| 3884 |
|
| 3885 | GLboolean GL_APIENTRY glIsProgram(GLuint program)
|
| 3886 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3887 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3888 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3889 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3890 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3891 | if(context && program)
|
| 3892 | {
|
| 3893 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3894 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3895 | if(programObject)
|
| 3896 | {
|
| 3897 | return GL_TRUE;
|
| 3898 | }
|
| 3899 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3900 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3901 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3902 | }
|
| 3903 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3904 | GLboolean GL_APIENTRY glIsQueryEXT(GLuint name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3905 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3906 | TRACE("(GLuint name = %d)", name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3907 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3908 | if(name == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3909 | {
|
| 3910 | return GL_FALSE;
|
| 3911 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3912 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3913 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3914 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3915 | if(context)
|
| 3916 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3917 | es2::Query *queryObject = context->getQuery(name, false, GL_NONE);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3918 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3919 | if(queryObject)
|
| 3920 | {
|
| 3921 | return GL_TRUE;
|
| 3922 | }
|
| 3923 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3924 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3925 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3926 | }
|
| 3927 |
|
| 3928 | GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
|
| 3929 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3930 | TRACE("(GLuint renderbuffer = %d)", renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3931 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3932 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3933 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3934 | if(context && renderbuffer)
|
| 3935 | {
|
| 3936 | es2::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3937 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3938 | if(renderbufferObject)
|
| 3939 | {
|
| 3940 | return GL_TRUE;
|
| 3941 | }
|
| 3942 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3943 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3944 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3945 | }
|
| 3946 |
|
| 3947 | GLboolean GL_APIENTRY glIsShader(GLuint shader)
|
| 3948 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3949 | TRACE("(GLuint shader = %d)", shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3950 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3951 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3952 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3953 | if(context && shader)
|
| 3954 | {
|
| 3955 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3956 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3957 | if(shaderObject)
|
| 3958 | {
|
| 3959 | return GL_TRUE;
|
| 3960 | }
|
| 3961 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3962 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3963 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3964 | }
|
| 3965 |
|
| 3966 | GLboolean GL_APIENTRY glIsTexture(GLuint texture)
|
| 3967 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3968 | TRACE("(GLuint texture = %d)", texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3969 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3970 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3971 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3972 | if(context && texture)
|
| 3973 | {
|
| 3974 | es2::Texture *textureObject = context->getTexture(texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3975 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3976 | if(textureObject)
|
| 3977 | {
|
| 3978 | return GL_TRUE;
|
| 3979 | }
|
| 3980 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3981 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3982 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3983 | }
|
| 3984 |
|
| 3985 | void GL_APIENTRY glLineWidth(GLfloat width)
|
| 3986 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3987 | TRACE("(GLfloat width = %f)", width);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3988 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3989 | if(width <= 0.0f)
|
| 3990 | {
|
| 3991 | return error(GL_INVALID_VALUE);
|
| 3992 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3993 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3994 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3995 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3996 | if(context)
|
| 3997 | {
|
| 3998 | context->setLineWidth(width);
|
| 3999 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4000 | }
|
| 4001 |
|
| 4002 | void GL_APIENTRY glLinkProgram(GLuint program)
|
| 4003 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4004 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4005 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4006 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4007 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4008 | if(context)
|
| 4009 | {
|
| 4010 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4011 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4012 | if(!programObject)
|
| 4013 | {
|
| 4014 | if(context->getShader(program))
|
| 4015 | {
|
| 4016 | return error(GL_INVALID_OPERATION);
|
| 4017 | }
|
| 4018 | else
|
| 4019 | {
|
| 4020 | return error(GL_INVALID_VALUE);
|
| 4021 | }
|
| 4022 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4023 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4024 | programObject->link();
|
| 4025 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4026 | }
|
| 4027 |
|
| 4028 | void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
|
| 4029 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4030 | TRACE("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4031 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4032 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4033 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4034 | if(context)
|
| 4035 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4036 | egl::GLint clientVersion = context->getClientVersion();
|
| 4037 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4038 | switch(pname)
|
| 4039 | {
|
| 4040 | case GL_UNPACK_ALIGNMENT:
|
| 4041 | if(param != 1 && param != 2 && param != 4 && param != 8)
|
| 4042 | {
|
| 4043 | return error(GL_INVALID_VALUE);
|
| 4044 | }
|
| 4045 | context->setUnpackAlignment(param);
|
| 4046 | break;
|
| 4047 | case GL_PACK_ALIGNMENT:
|
| 4048 | if(param != 1 && param != 2 && param != 4 && param != 8)
|
| 4049 | {
|
| 4050 | return error(GL_INVALID_VALUE);
|
| 4051 | }
|
| 4052 | context->setPackAlignment(param);
|
| 4053 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4054 | case GL_PACK_ROW_LENGTH:
|
| 4055 | case GL_PACK_SKIP_PIXELS:
|
| 4056 | case GL_PACK_SKIP_ROWS:
|
| 4057 | case GL_UNPACK_ROW_LENGTH:
|
| 4058 | case GL_UNPACK_IMAGE_HEIGHT:
|
| 4059 | case GL_UNPACK_SKIP_PIXELS:
|
| 4060 | case GL_UNPACK_SKIP_ROWS:
|
| 4061 | case GL_UNPACK_SKIP_IMAGES:
|
| 4062 | if(clientVersion >= 3)
|
| 4063 | {
|
| 4064 | UNIMPLEMENTED();
|
| 4065 | break;
|
| 4066 | }
|
| 4067 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4068 | default:
|
| 4069 | return error(GL_INVALID_ENUM);
|
| 4070 | }
|
| 4071 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4072 | }
|
| 4073 |
|
| 4074 | void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
|
| 4075 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4076 | TRACE("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4077 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4078 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4079 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4080 | if(context)
|
| 4081 | {
|
| 4082 | context->setPolygonOffsetParams(factor, units);
|
| 4083 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4084 | }
|
| 4085 |
|
| 4086 | void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4087 | GLenum format, GLenum type, GLsizei bufSize, GLvoid *data)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4088 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4089 | TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
|
| 4090 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
|
| 4091 | x, y, width, height, format, type, bufSize, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4092 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4093 | if(width < 0 || height < 0 || bufSize < 0)
|
| 4094 | {
|
| 4095 | return error(GL_INVALID_VALUE);
|
| 4096 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4097 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4098 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4099 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4100 | if(context)
|
| 4101 | {
|
| 4102 | context->readPixels(x, y, width, height, format, type, &bufSize, data);
|
| 4103 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4104 | }
|
| 4105 |
|
| 4106 | void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
|
| 4107 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4108 | TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
|
| 4109 | "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
|
| 4110 | x, y, width, height, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4111 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4112 | if(width < 0 || height < 0)
|
| 4113 | {
|
| 4114 | return error(GL_INVALID_VALUE);
|
| 4115 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4116 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4117 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4118 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4119 | if(context)
|
| 4120 | {
|
| 4121 | context->readPixels(x, y, width, height, format, type, NULL, pixels);
|
| 4122 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4123 | }
|
| 4124 |
|
| 4125 | void GL_APIENTRY glReleaseShaderCompiler(void)
|
| 4126 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4127 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4128 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4129 | es2::Shader::releaseCompiler();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4130 | }
|
| 4131 |
|
| 4132 | void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
|
| 4133 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4134 | TRACE("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
|
| 4135 | target, samples, internalformat, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4136 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4137 | switch(target)
|
| 4138 | {
|
| 4139 | case GL_RENDERBUFFER:
|
| 4140 | break;
|
| 4141 | default:
|
| 4142 | return error(GL_INVALID_ENUM);
|
| 4143 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4144 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4145 | if(!es2::IsColorRenderable(internalformat) && !es2::IsDepthRenderable(internalformat) && !es2::IsStencilRenderable(internalformat))
|
| 4146 | {
|
| 4147 | return error(GL_INVALID_ENUM);
|
| 4148 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4149 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4150 | if(width < 0 || height < 0 || samples < 0)
|
| 4151 | {
|
| 4152 | return error(GL_INVALID_VALUE);
|
| 4153 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4154 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4155 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4156 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4157 | if(context)
|
| 4158 | {
|
| 4159 | if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
|
| 4160 | height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
|
| 4161 | samples > es2::IMPLEMENTATION_MAX_SAMPLES)
|
| 4162 | {
|
| 4163 | return error(GL_INVALID_VALUE);
|
| 4164 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4165 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 4166 | GLuint handle = context->getRenderbufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4167 | if(handle == 0)
|
| 4168 | {
|
| 4169 | return error(GL_INVALID_OPERATION);
|
| 4170 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4171 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4172 | switch(internalformat)
|
| 4173 | {
|
| 4174 | case GL_DEPTH_COMPONENT16:
|
| 4175 | context->setRenderbufferStorage(new es2::Depthbuffer(width, height, samples));
|
| 4176 | break;
|
| 4177 | case GL_RGBA4:
|
| 4178 | case GL_RGB5_A1:
|
| 4179 | case GL_RGB565:
|
| 4180 | case GL_RGB8_OES:
|
| 4181 | case GL_RGBA8_OES:
|
| 4182 | context->setRenderbufferStorage(new es2::Colorbuffer(width, height, internalformat, samples));
|
| 4183 | break;
|
| 4184 | case GL_STENCIL_INDEX8:
|
| 4185 | context->setRenderbufferStorage(new es2::Stencilbuffer(width, height, samples));
|
| 4186 | break;
|
| 4187 | case GL_DEPTH24_STENCIL8_OES:
|
| 4188 | context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, samples));
|
| 4189 | break;
|
| 4190 | default:
|
| 4191 | return error(GL_INVALID_ENUM);
|
| 4192 | }
|
| 4193 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4194 | }
|
| 4195 |
|
| 4196 | void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
|
| 4197 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4198 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4199 | }
|
| 4200 |
|
| 4201 | void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
|
| 4202 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4203 | TRACE("(GLclampf value = %f, GLboolean invert = %d)", value, invert);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4204 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4205 | es2::Context* context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4206 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4207 | if(context)
|
| 4208 | {
|
| 4209 | context->setSampleCoverageParams(es2::clamp01(value), invert == GL_TRUE);
|
| 4210 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4211 | }
|
| 4212 |
|
| 4213 | void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
|
| 4214 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4215 | TRACE("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4216 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4217 | if(condition != GL_ALL_COMPLETED_NV)
|
| 4218 | {
|
| 4219 | return error(GL_INVALID_ENUM);
|
| 4220 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4221 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4222 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4223 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4224 | if(context)
|
| 4225 | {
|
| 4226 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4227 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4228 | if(fenceObject == NULL)
|
| 4229 | {
|
| 4230 | return error(GL_INVALID_OPERATION);
|
| 4231 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4232 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4233 | fenceObject->setFence(condition);
|
| 4234 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4235 | }
|
| 4236 |
|
| 4237 | void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
|
| 4238 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4239 | TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4240 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4241 | if(width < 0 || height < 0)
|
| 4242 | {
|
| 4243 | return error(GL_INVALID_VALUE);
|
| 4244 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4245 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4246 | es2::Context* context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4247 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4248 | if(context)
|
| 4249 | {
|
| 4250 | context->setScissorParams(x, y, width, height);
|
| 4251 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4252 | }
|
| 4253 |
|
| 4254 | void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
|
| 4255 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4256 | TRACE("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
|
| 4257 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
|
| 4258 | n, shaders, binaryformat, binary, length);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4259 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4260 | // No binary shader formats are supported.
|
| 4261 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4262 | }
|
| 4263 |
|
Nicolas Capens | b0e9355 | 2014-10-28 11:54:43 -0400 | [diff] [blame] | 4264 | void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4265 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4266 | TRACE("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
|
| 4267 | shader, count, string, length);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4268 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4269 | if(count < 0)
|
| 4270 | {
|
| 4271 | return error(GL_INVALID_VALUE);
|
| 4272 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4273 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4274 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4275 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4276 | if(context)
|
| 4277 | {
|
| 4278 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4279 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4280 | if(!shaderObject)
|
| 4281 | {
|
| 4282 | if(context->getProgram(shader))
|
| 4283 | {
|
| 4284 | return error(GL_INVALID_OPERATION);
|
| 4285 | }
|
| 4286 | else
|
| 4287 | {
|
| 4288 | return error(GL_INVALID_VALUE);
|
| 4289 | }
|
| 4290 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4291 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4292 | shaderObject->setSource(count, string, length);
|
| 4293 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4294 | }
|
| 4295 |
|
| 4296 | void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
|
| 4297 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4298 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4299 | }
|
| 4300 |
|
| 4301 | void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
|
| 4302 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4303 | TRACE("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4304 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4305 | switch(face)
|
| 4306 | {
|
| 4307 | case GL_FRONT:
|
| 4308 | case GL_BACK:
|
| 4309 | case GL_FRONT_AND_BACK:
|
| 4310 | break;
|
| 4311 | default:
|
| 4312 | return error(GL_INVALID_ENUM);
|
| 4313 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4314 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4315 | switch(func)
|
| 4316 | {
|
| 4317 | case GL_NEVER:
|
| 4318 | case GL_ALWAYS:
|
| 4319 | case GL_LESS:
|
| 4320 | case GL_LEQUAL:
|
| 4321 | case GL_EQUAL:
|
| 4322 | case GL_GEQUAL:
|
| 4323 | case GL_GREATER:
|
| 4324 | case GL_NOTEQUAL:
|
| 4325 | break;
|
| 4326 | default:
|
| 4327 | return error(GL_INVALID_ENUM);
|
| 4328 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4329 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4330 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4331 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4332 | if(context)
|
| 4333 | {
|
| 4334 | if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
|
| 4335 | {
|
| 4336 | context->setStencilParams(func, ref, mask);
|
| 4337 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4338 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4339 | if(face == GL_BACK || face == GL_FRONT_AND_BACK)
|
| 4340 | {
|
| 4341 | context->setStencilBackParams(func, ref, mask);
|
| 4342 | }
|
| 4343 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4344 | }
|
| 4345 |
|
| 4346 | void GL_APIENTRY glStencilMask(GLuint mask)
|
| 4347 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4348 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4349 | }
|
| 4350 |
|
| 4351 | void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
|
| 4352 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4353 | TRACE("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4354 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4355 | switch(face)
|
| 4356 | {
|
| 4357 | case GL_FRONT:
|
| 4358 | case GL_BACK:
|
| 4359 | case GL_FRONT_AND_BACK:
|
| 4360 | break;
|
| 4361 | default:
|
| 4362 | return error(GL_INVALID_ENUM);
|
| 4363 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4364 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4365 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4366 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4367 | if(context)
|
| 4368 | {
|
| 4369 | if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
|
| 4370 | {
|
| 4371 | context->setStencilWritemask(mask);
|
| 4372 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4373 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4374 | if(face == GL_BACK || face == GL_FRONT_AND_BACK)
|
| 4375 | {
|
| 4376 | context->setStencilBackWritemask(mask);
|
| 4377 | }
|
| 4378 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4379 | }
|
| 4380 |
|
| 4381 | void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
|
| 4382 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4383 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4384 | }
|
| 4385 |
|
| 4386 | void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
|
| 4387 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4388 | TRACE("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
|
| 4389 | face, fail, zfail, zpass);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4390 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4391 | switch(face)
|
| 4392 | {
|
| 4393 | case GL_FRONT:
|
| 4394 | case GL_BACK:
|
| 4395 | case GL_FRONT_AND_BACK:
|
| 4396 | break;
|
| 4397 | default:
|
| 4398 | return error(GL_INVALID_ENUM);
|
| 4399 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4400 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4401 | switch(fail)
|
| 4402 | {
|
| 4403 | case GL_ZERO:
|
| 4404 | case GL_KEEP:
|
| 4405 | case GL_REPLACE:
|
| 4406 | case GL_INCR:
|
| 4407 | case GL_DECR:
|
| 4408 | case GL_INVERT:
|
| 4409 | case GL_INCR_WRAP:
|
| 4410 | case GL_DECR_WRAP:
|
| 4411 | break;
|
| 4412 | default:
|
| 4413 | return error(GL_INVALID_ENUM);
|
| 4414 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4415 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4416 | switch(zfail)
|
| 4417 | {
|
| 4418 | case GL_ZERO:
|
| 4419 | case GL_KEEP:
|
| 4420 | case GL_REPLACE:
|
| 4421 | case GL_INCR:
|
| 4422 | case GL_DECR:
|
| 4423 | case GL_INVERT:
|
| 4424 | case GL_INCR_WRAP:
|
| 4425 | case GL_DECR_WRAP:
|
| 4426 | break;
|
| 4427 | default:
|
| 4428 | return error(GL_INVALID_ENUM);
|
| 4429 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4430 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4431 | switch(zpass)
|
| 4432 | {
|
| 4433 | case GL_ZERO:
|
| 4434 | case GL_KEEP:
|
| 4435 | case GL_REPLACE:
|
| 4436 | case GL_INCR:
|
| 4437 | case GL_DECR:
|
| 4438 | case GL_INVERT:
|
| 4439 | case GL_INCR_WRAP:
|
| 4440 | case GL_DECR_WRAP:
|
| 4441 | break;
|
| 4442 | default:
|
| 4443 | return error(GL_INVALID_ENUM);
|
| 4444 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4445 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4446 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4447 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4448 | if(context)
|
| 4449 | {
|
| 4450 | if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
|
| 4451 | {
|
| 4452 | context->setStencilOperations(fail, zfail, zpass);
|
| 4453 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4454 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4455 | if(face == GL_BACK || face == GL_FRONT_AND_BACK)
|
| 4456 | {
|
| 4457 | context->setStencilBackOperations(fail, zfail, zpass);
|
| 4458 | }
|
| 4459 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4460 | }
|
| 4461 |
|
| 4462 | GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
|
| 4463 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4464 | TRACE("(GLuint fence = %d)", fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4465 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4466 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4467 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4468 | if(context)
|
| 4469 | {
|
| 4470 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4471 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4472 | if(fenceObject == NULL)
|
| 4473 | {
|
| 4474 | return error(GL_INVALID_OPERATION, GL_TRUE);
|
| 4475 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4476 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4477 | return fenceObject->testFence();
|
| 4478 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 4479 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4480 | return GL_TRUE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4481 | }
|
| 4482 |
|
| 4483 | void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
|
| 4484 | GLint border, GLenum format, GLenum type, const GLvoid* pixels)
|
| 4485 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4486 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
|
| 4487 | "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
|
| 4488 | target, level, internalformat, width, height, border, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4489 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4490 | if(!validImageSize(level, width, height))
|
| 4491 | {
|
| 4492 | return error(GL_INVALID_VALUE);
|
| 4493 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4494 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4495 | es2::Context *context = es2::getContext();
|
| 4496 |
|
| 4497 | if(context)
|
| 4498 | {
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 4499 | if(context->getClientVersion() < 3)
|
| 4500 | {
|
| 4501 | if(internalformat != format)
|
| 4502 | {
|
| 4503 | return error(GL_INVALID_OPERATION);
|
| 4504 | }
|
| 4505 | }
|
| 4506 |
|
| 4507 | switch(format)
|
| 4508 | {
|
| 4509 | case GL_ALPHA:
|
| 4510 | case GL_LUMINANCE:
|
| 4511 | case GL_LUMINANCE_ALPHA:
|
| 4512 | switch(type)
|
| 4513 | {
|
| 4514 | case GL_UNSIGNED_BYTE:
|
| 4515 | case GL_FLOAT:
|
| 4516 | case GL_HALF_FLOAT_OES:
|
| 4517 | break;
|
| 4518 | default:
|
| 4519 | return error(GL_INVALID_ENUM);
|
| 4520 | }
|
| 4521 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4522 | case GL_RED:
|
| 4523 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 4524 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4525 | case GL_R8:
|
| 4526 | switch(type)
|
| 4527 | {
|
| 4528 | case GL_UNSIGNED_BYTE:
|
| 4529 | break;
|
| 4530 | default:
|
| 4531 | return error(GL_INVALID_ENUM);
|
| 4532 | }
|
| 4533 | break;
|
| 4534 | case GL_R8_SNORM:
|
| 4535 | switch(type)
|
| 4536 | {
|
| 4537 | case GL_BYTE:
|
| 4538 | break;
|
| 4539 | default:
|
| 4540 | return error(GL_INVALID_ENUM);
|
| 4541 | }
|
| 4542 | break;
|
| 4543 | case GL_R16F:
|
| 4544 | switch(type)
|
| 4545 | {
|
| 4546 | case GL_FLOAT:
|
| 4547 | case GL_HALF_FLOAT:
|
| 4548 | break;
|
| 4549 | default:
|
| 4550 | return error(GL_INVALID_ENUM);
|
| 4551 | }
|
| 4552 | break;
|
| 4553 | case GL_R32F:
|
| 4554 | switch(type)
|
| 4555 | {
|
| 4556 | case GL_FLOAT:
|
| 4557 | break;
|
| 4558 | default:
|
| 4559 | return error(GL_INVALID_ENUM);
|
| 4560 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 4561 | break;
|
| 4562 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4563 | return error(GL_INVALID_VALUE);
|
| 4564 | }
|
| 4565 | break;
|
| 4566 | case GL_RED_INTEGER:
|
| 4567 | switch(internalformat)
|
| 4568 | {
|
| 4569 | case GL_R8UI:
|
| 4570 | switch(type)
|
| 4571 | {
|
| 4572 | case GL_UNSIGNED_BYTE:
|
| 4573 | break;
|
| 4574 | default:
|
| 4575 | return error(GL_INVALID_ENUM);
|
| 4576 | }
|
| 4577 | break;
|
| 4578 | case GL_R8I:
|
| 4579 | switch(type)
|
| 4580 | {
|
| 4581 | case GL_BYTE:
|
| 4582 | break;
|
| 4583 | default:
|
| 4584 | return error(GL_INVALID_ENUM);
|
| 4585 | }
|
| 4586 | break;
|
| 4587 | case GL_R16UI:
|
| 4588 | switch(type)
|
| 4589 | {
|
| 4590 | case GL_UNSIGNED_SHORT:
|
| 4591 | break;
|
| 4592 | default:
|
| 4593 | return error(GL_INVALID_ENUM);
|
| 4594 | }
|
| 4595 | break;
|
| 4596 | case GL_R16I:
|
| 4597 | switch(type)
|
| 4598 | {
|
| 4599 | case GL_SHORT:
|
| 4600 | break;
|
| 4601 | default:
|
| 4602 | return error(GL_INVALID_ENUM);
|
| 4603 | }
|
| 4604 | break;
|
| 4605 | case GL_R32UI:
|
| 4606 | switch(type)
|
| 4607 | {
|
| 4608 | case GL_UNSIGNED_INT:
|
| 4609 | break;
|
| 4610 | default:
|
| 4611 | return error(GL_INVALID_ENUM);
|
| 4612 | }
|
| 4613 | break;
|
| 4614 | case GL_R32I:
|
| 4615 | switch(type)
|
| 4616 | {
|
| 4617 | case GL_INT:
|
| 4618 | break;
|
| 4619 | default:
|
| 4620 | return error(GL_INVALID_ENUM);
|
| 4621 | }
|
| 4622 | break;
|
| 4623 | default:
|
| 4624 | return error(GL_INVALID_VALUE);
|
| 4625 | }
|
| 4626 | break;
|
| 4627 | case GL_RG_INTEGER:
|
| 4628 | switch(internalformat)
|
| 4629 | {
|
| 4630 | case GL_RG8UI:
|
| 4631 | switch(type)
|
| 4632 | {
|
| 4633 | case GL_UNSIGNED_BYTE:
|
| 4634 | break;
|
| 4635 | default:
|
| 4636 | return error(GL_INVALID_ENUM);
|
| 4637 | }
|
| 4638 | break;
|
| 4639 | case GL_RG8I:
|
| 4640 | switch(type)
|
| 4641 | {
|
| 4642 | case GL_BYTE:
|
| 4643 | break;
|
| 4644 | default:
|
| 4645 | return error(GL_INVALID_ENUM);
|
| 4646 | }
|
| 4647 | break;
|
| 4648 | case GL_RG16UI:
|
| 4649 | switch(type)
|
| 4650 | {
|
| 4651 | case GL_UNSIGNED_SHORT:
|
| 4652 | break;
|
| 4653 | default:
|
| 4654 | return error(GL_INVALID_ENUM);
|
| 4655 | }
|
| 4656 | break;
|
| 4657 | case GL_RG16I:
|
| 4658 | switch(type)
|
| 4659 | {
|
| 4660 | case GL_SHORT:
|
| 4661 | break;
|
| 4662 | default:
|
| 4663 | return error(GL_INVALID_ENUM);
|
| 4664 | }
|
| 4665 | break;
|
| 4666 | case GL_RG32UI:
|
| 4667 | switch(type)
|
| 4668 | {
|
| 4669 | case GL_UNSIGNED_INT:
|
| 4670 | break;
|
| 4671 | default:
|
| 4672 | return error(GL_INVALID_ENUM);
|
| 4673 | }
|
| 4674 | break;
|
| 4675 | case GL_RG32I:
|
| 4676 | switch(type)
|
| 4677 | {
|
| 4678 | case GL_INT:
|
| 4679 | break;
|
| 4680 | default:
|
| 4681 | return error(GL_INVALID_ENUM);
|
| 4682 | }
|
| 4683 | break;
|
| 4684 | default:
|
| 4685 | return error(GL_INVALID_VALUE);
|
| 4686 | }
|
| 4687 | break;
|
| 4688 | case GL_RGB_INTEGER:
|
| 4689 | switch(internalformat)
|
| 4690 | {
|
| 4691 | case GL_RGB8UI:
|
| 4692 | switch(type)
|
| 4693 | {
|
| 4694 | case GL_UNSIGNED_BYTE:
|
| 4695 | break;
|
| 4696 | default:
|
| 4697 | return error(GL_INVALID_ENUM);
|
| 4698 | }
|
| 4699 | break;
|
| 4700 | case GL_RGB8I:
|
| 4701 | switch(type)
|
| 4702 | {
|
| 4703 | case GL_BYTE:
|
| 4704 | break;
|
| 4705 | default:
|
| 4706 | return error(GL_INVALID_ENUM);
|
| 4707 | }
|
| 4708 | break;
|
| 4709 | case GL_RGB16UI:
|
| 4710 | switch(type)
|
| 4711 | {
|
| 4712 | case GL_UNSIGNED_SHORT:
|
| 4713 | break;
|
| 4714 | default:
|
| 4715 | return error(GL_INVALID_ENUM);
|
| 4716 | }
|
| 4717 | break;
|
| 4718 | case GL_RGB16I:
|
| 4719 | switch(type)
|
| 4720 | {
|
| 4721 | case GL_SHORT:
|
| 4722 | break;
|
| 4723 | default:
|
| 4724 | return error(GL_INVALID_ENUM);
|
| 4725 | }
|
| 4726 | break;
|
| 4727 | case GL_RGB32UI:
|
| 4728 | switch(type)
|
| 4729 | {
|
| 4730 | case GL_UNSIGNED_INT:
|
| 4731 | break;
|
| 4732 | default:
|
| 4733 | return error(GL_INVALID_ENUM);
|
| 4734 | }
|
| 4735 | break;
|
| 4736 | case GL_RGB32I:
|
| 4737 | switch(type)
|
| 4738 | {
|
| 4739 | case GL_INT:
|
| 4740 | break;
|
| 4741 | default:
|
| 4742 | return error(GL_INVALID_ENUM);
|
| 4743 | }
|
| 4744 | break;
|
| 4745 | default:
|
| 4746 | return error(GL_INVALID_VALUE);
|
| 4747 | }
|
| 4748 | break;
|
| 4749 | case GL_RGBA_INTEGER:
|
| 4750 | switch(internalformat)
|
| 4751 | {
|
| 4752 | case GL_RGBA8UI:
|
| 4753 | switch(type)
|
| 4754 | {
|
| 4755 | case GL_UNSIGNED_BYTE:
|
| 4756 | break;
|
| 4757 | default:
|
| 4758 | return error(GL_INVALID_ENUM);
|
| 4759 | }
|
| 4760 | break;
|
| 4761 | case GL_RGBA8I:
|
| 4762 | switch(type)
|
| 4763 | {
|
| 4764 | case GL_BYTE:
|
| 4765 | break;
|
| 4766 | default:
|
| 4767 | return error(GL_INVALID_ENUM);
|
| 4768 | }
|
| 4769 | break;
|
| 4770 | case GL_RGB10_A2UI:
|
| 4771 | switch(type)
|
| 4772 | {
|
| 4773 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 4774 | break;
|
| 4775 | default:
|
| 4776 | return error(GL_INVALID_ENUM);
|
| 4777 | }
|
| 4778 | break;
|
| 4779 | case GL_RGBA16UI:
|
| 4780 | switch(type)
|
| 4781 | {
|
| 4782 | case GL_UNSIGNED_SHORT:
|
| 4783 | break;
|
| 4784 | default:
|
| 4785 | return error(GL_INVALID_ENUM);
|
| 4786 | }
|
| 4787 | break;
|
| 4788 | case GL_RGBA16I:
|
| 4789 | switch(type)
|
| 4790 | {
|
| 4791 | case GL_SHORT:
|
| 4792 | break;
|
| 4793 | default:
|
| 4794 | return error(GL_INVALID_ENUM);
|
| 4795 | }
|
| 4796 | break;
|
| 4797 | case GL_RGBA32UI:
|
| 4798 | switch(type)
|
| 4799 | {
|
| 4800 | case GL_INT:
|
| 4801 | break;
|
| 4802 | default:
|
| 4803 | return error(GL_INVALID_ENUM);
|
| 4804 | }
|
| 4805 | break;
|
| 4806 | case GL_RGBA32I:
|
| 4807 | switch(type)
|
| 4808 | {
|
| 4809 | case GL_UNSIGNED_INT:
|
| 4810 | break;
|
| 4811 | default:
|
| 4812 | return error(GL_INVALID_ENUM);
|
| 4813 | }
|
| 4814 | break;
|
| 4815 | default:
|
| 4816 | return error(GL_INVALID_VALUE);
|
| 4817 | }
|
| 4818 | break;
|
| 4819 | case GL_RG:
|
| 4820 | switch(internalformat)
|
| 4821 | {
|
| 4822 | case GL_RG8:
|
| 4823 | switch(type)
|
| 4824 | {
|
| 4825 | case GL_UNSIGNED_BYTE:
|
| 4826 | break;
|
| 4827 | default:
|
| 4828 | return error(GL_INVALID_ENUM);
|
| 4829 | }
|
| 4830 | break;
|
| 4831 | case GL_RG8_SNORM:
|
| 4832 | switch(type)
|
| 4833 | {
|
| 4834 | case GL_BYTE:
|
| 4835 | break;
|
| 4836 | default:
|
| 4837 | return error(GL_INVALID_ENUM);
|
| 4838 | }
|
| 4839 | break;
|
| 4840 | case GL_RG16F:
|
| 4841 | switch(type)
|
| 4842 | {
|
| 4843 | case GL_FLOAT:
|
| 4844 | case GL_HALF_FLOAT:
|
| 4845 | break;
|
| 4846 | default:
|
| 4847 | return error(GL_INVALID_ENUM);
|
| 4848 | }
|
| 4849 | break;
|
| 4850 | case GL_RG32F:
|
| 4851 | switch(type)
|
| 4852 | {
|
| 4853 | case GL_FLOAT:
|
| 4854 | break;
|
| 4855 | default:
|
| 4856 | return error(GL_INVALID_ENUM);
|
| 4857 | }
|
| 4858 | break;
|
| 4859 | default:
|
| 4860 | return error(GL_INVALID_VALUE);
|
| 4861 | }
|
| 4862 | break;
|
| 4863 | case GL_RGB:
|
| 4864 | switch(internalformat)
|
| 4865 | {
|
| 4866 | case GL_RGB:
|
| 4867 | switch(type)
|
| 4868 | {
|
| 4869 | case GL_UNSIGNED_BYTE:
|
| 4870 | case GL_UNSIGNED_SHORT_5_6_5:
|
| 4871 | case GL_FLOAT:
|
| 4872 | case GL_HALF_FLOAT_OES:
|
| 4873 | break;
|
| 4874 | default:
|
| 4875 | return error(GL_INVALID_ENUM);
|
| 4876 | }
|
| 4877 | break;
|
| 4878 | case GL_RGB8:
|
| 4879 | switch(type)
|
| 4880 | {
|
| 4881 | case GL_UNSIGNED_BYTE:
|
| 4882 | break;
|
| 4883 | default:
|
| 4884 | return error(GL_INVALID_ENUM);
|
| 4885 | }
|
| 4886 | break;
|
| 4887 | case GL_SRGB8:
|
| 4888 | switch(type)
|
| 4889 | {
|
| 4890 | case GL_UNSIGNED_BYTE:
|
| 4891 | break;
|
| 4892 | default:
|
| 4893 | return error(GL_INVALID_ENUM);
|
| 4894 | }
|
| 4895 | break;
|
| 4896 | case GL_RGB565:
|
| 4897 | switch(type)
|
| 4898 | {
|
| 4899 | case GL_UNSIGNED_BYTE:
|
| 4900 | case GL_UNSIGNED_SHORT_5_6_5:
|
| 4901 | break;
|
| 4902 | default:
|
| 4903 | return error(GL_INVALID_ENUM);
|
| 4904 | }
|
| 4905 | break;
|
| 4906 | case GL_RGB8_SNORM:
|
| 4907 | switch(type)
|
| 4908 | {
|
| 4909 | case GL_BYTE:
|
| 4910 | break;
|
| 4911 | default:
|
| 4912 | return error(GL_INVALID_ENUM);
|
| 4913 | }
|
| 4914 | break;
|
| 4915 | case GL_R11F_G11F_B10F:
|
| 4916 | switch(type)
|
| 4917 | {
|
| 4918 | case GL_UNSIGNED_INT_10F_11F_11F_REV:
|
| 4919 | case GL_FLOAT:
|
| 4920 | case GL_HALF_FLOAT:
|
| 4921 | break;
|
| 4922 | default:
|
| 4923 | return error(GL_INVALID_ENUM);
|
| 4924 | }
|
| 4925 | break;
|
| 4926 | case GL_RGB9_E5:
|
| 4927 | switch(type)
|
| 4928 | {
|
| 4929 | case GL_UNSIGNED_INT_5_9_9_9_REV:
|
| 4930 | case GL_FLOAT:
|
| 4931 | case GL_HALF_FLOAT:
|
| 4932 | break;
|
| 4933 | default:
|
| 4934 | return error(GL_INVALID_ENUM);
|
| 4935 | }
|
| 4936 | break;
|
| 4937 | case GL_RGB16F:
|
| 4938 | switch(type)
|
| 4939 | {
|
| 4940 | case GL_FLOAT:
|
| 4941 | case GL_HALF_FLOAT:
|
| 4942 | break;
|
| 4943 | default:
|
| 4944 | return error(GL_INVALID_ENUM);
|
| 4945 | }
|
| 4946 | break;
|
| 4947 | case GL_RGB32F:
|
| 4948 | switch(type)
|
| 4949 | {
|
| 4950 | case GL_FLOAT:
|
| 4951 | break;
|
| 4952 | default:
|
| 4953 | return error(GL_INVALID_ENUM);
|
| 4954 | }
|
| 4955 | break;
|
| 4956 | default:
|
| 4957 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 4958 | }
|
| 4959 | break;
|
| 4960 | case GL_RGBA:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4961 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 4962 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4963 | case GL_RGBA:
|
| 4964 | switch(type)
|
| 4965 | {
|
| 4966 | case GL_UNSIGNED_BYTE:
|
| 4967 | case GL_UNSIGNED_SHORT_4_4_4_4:
|
| 4968 | case GL_UNSIGNED_SHORT_5_5_5_1:
|
| 4969 | case GL_FLOAT:
|
| 4970 | case GL_HALF_FLOAT_OES:
|
| 4971 | break;
|
| 4972 | default:
|
| 4973 | return error(GL_INVALID_ENUM);
|
| 4974 | }
|
| 4975 | break;
|
| 4976 | case GL_RGBA8:
|
| 4977 | switch(type)
|
| 4978 | {
|
| 4979 | case GL_UNSIGNED_BYTE:
|
| 4980 | break;
|
| 4981 | default:
|
| 4982 | return error(GL_INVALID_ENUM);
|
| 4983 | }
|
| 4984 | break;
|
| 4985 | case GL_SRGB8_ALPHA8:
|
| 4986 | switch(type)
|
| 4987 | {
|
| 4988 | case GL_UNSIGNED_BYTE:
|
| 4989 | break;
|
| 4990 | default:
|
| 4991 | return error(GL_INVALID_ENUM);
|
| 4992 | }
|
| 4993 | break;
|
| 4994 | case GL_RGB5_A1:
|
| 4995 | switch(type)
|
| 4996 | {
|
| 4997 | case GL_UNSIGNED_BYTE:
|
| 4998 | case GL_UNSIGNED_SHORT_5_5_5_1:
|
| 4999 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 5000 | break;
|
| 5001 | default:
|
| 5002 | return error(GL_INVALID_ENUM);
|
| 5003 | }
|
| 5004 | break;
|
| 5005 | case GL_RGBA8_SNORM:
|
| 5006 | switch(type)
|
| 5007 | {
|
| 5008 | case GL_BYTE:
|
| 5009 | break;
|
| 5010 | default:
|
| 5011 | return error(GL_INVALID_ENUM);
|
| 5012 | }
|
| 5013 | break;
|
| 5014 | case GL_RGBA4:
|
| 5015 | switch(type)
|
| 5016 | {
|
| 5017 | case GL_UNSIGNED_BYTE:
|
| 5018 | case GL_UNSIGNED_SHORT_4_4_4_4:
|
| 5019 | break;
|
| 5020 | default:
|
| 5021 | return error(GL_INVALID_ENUM);
|
| 5022 | }
|
| 5023 | break;
|
| 5024 | case GL_RGB10_A2:
|
| 5025 | switch(type)
|
| 5026 | {
|
| 5027 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 5028 | break;
|
| 5029 | default:
|
| 5030 | return error(GL_INVALID_ENUM);
|
| 5031 | }
|
| 5032 | break;
|
| 5033 | case GL_RGBA16F:
|
| 5034 | switch(type)
|
| 5035 | {
|
| 5036 | case GL_FLOAT:
|
| 5037 | case GL_HALF_FLOAT:
|
| 5038 | break;
|
| 5039 | default:
|
| 5040 | return error(GL_INVALID_ENUM);
|
| 5041 | }
|
| 5042 | break;
|
| 5043 | case GL_RGBA32F:
|
| 5044 | switch(type)
|
| 5045 | {
|
| 5046 | case GL_FLOAT:
|
| 5047 | break;
|
| 5048 | default:
|
| 5049 | return error(GL_INVALID_ENUM);
|
| 5050 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5051 | break;
|
| 5052 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5053 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5054 | }
|
| 5055 | break;
|
| 5056 | case GL_BGRA_EXT:
|
| 5057 | switch(type)
|
| 5058 | {
|
| 5059 | case GL_UNSIGNED_BYTE:
|
| 5060 | break;
|
| 5061 | default:
|
| 5062 | return error(GL_INVALID_ENUM);
|
| 5063 | }
|
| 5064 | break;
|
| 5065 | case GL_ETC1_RGB8_OES:
|
| 5066 | return error(GL_INVALID_OPERATION);
|
| 5067 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| 5068 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| 5069 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
|
| 5070 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
|
| 5071 | if(S3TC_SUPPORT)
|
| 5072 | {
|
| 5073 | return error(GL_INVALID_OPERATION);
|
| 5074 | }
|
| 5075 | else
|
| 5076 | {
|
| 5077 | return error(GL_INVALID_ENUM);
|
| 5078 | }
|
| 5079 | case GL_DEPTH_COMPONENT:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5080 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5081 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5082 | case GL_DEPTH_COMPONENT:
|
| 5083 | case GL_DEPTH_COMPONENT16:
|
| 5084 | switch(type)
|
| 5085 | {
|
| 5086 | case GL_UNSIGNED_SHORT:
|
| 5087 | case GL_UNSIGNED_INT:
|
| 5088 | break;
|
| 5089 | default:
|
| 5090 | return error(GL_INVALID_ENUM);
|
| 5091 | }
|
| 5092 | break;
|
| 5093 | case GL_DEPTH_COMPONENT24:
|
| 5094 | switch(type)
|
| 5095 | {
|
| 5096 | case GL_UNSIGNED_INT:
|
| 5097 | break;
|
| 5098 | default:
|
| 5099 | return error(GL_INVALID_ENUM);
|
| 5100 | }
|
| 5101 | break;
|
| 5102 | case GL_DEPTH_COMPONENT32F:
|
| 5103 | switch(type)
|
| 5104 | {
|
| 5105 | case GL_UNSIGNED_INT:
|
| 5106 | break;
|
| 5107 | default:
|
| 5108 | return error(GL_INVALID_ENUM);
|
| 5109 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5110 | break;
|
| 5111 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5112 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5113 | }
|
| 5114 | break;
|
| 5115 | case GL_DEPTH_STENCIL_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5116 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5117 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5118 | case GL_DEPTH_STENCIL_OES:
|
| 5119 | case GL_DEPTH24_STENCIL8:
|
| 5120 | switch(type)
|
| 5121 | {
|
| 5122 | case GL_UNSIGNED_INT_24_8_OES:
|
| 5123 | break;
|
| 5124 | default:
|
| 5125 | return error(GL_INVALID_ENUM);
|
| 5126 | }
|
| 5127 | break;
|
| 5128 | case GL_DEPTH32F_STENCIL8:
|
| 5129 | switch(type)
|
| 5130 | {
|
| 5131 | case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
| 5132 | break;
|
| 5133 | default:
|
| 5134 | return error(GL_INVALID_ENUM);
|
| 5135 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5136 | break;
|
| 5137 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5138 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5139 | }
|
| 5140 | break;
|
| 5141 | default:
|
| 5142 | return error(GL_INVALID_VALUE);
|
| 5143 | }
|
| 5144 |
|
| 5145 | if(border != 0)
|
| 5146 | {
|
| 5147 | return error(GL_INVALID_VALUE);
|
| 5148 | }
|
| 5149 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5150 | switch(target)
|
| 5151 | {
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 5152 | case GL_TEXTURE_2D:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5153 | if(width > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
|
| 5154 | height > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5155 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5156 | return error(GL_INVALID_VALUE);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5157 | }
|
| 5158 | break;
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 5159 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 5160 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 5161 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 5162 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 5163 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 5164 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5165 | if(width != height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5166 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5167 | return error(GL_INVALID_VALUE);
|
| 5168 | }
|
| 5169 |
|
| 5170 | if(width > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
|
| 5171 | height > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
|
| 5172 | {
|
| 5173 | return error(GL_INVALID_VALUE);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5174 | }
|
| 5175 | break;
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 5176 | default:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5177 | return error(GL_INVALID_ENUM);
|
| 5178 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5179 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5180 | if(target == GL_TEXTURE_2D)
|
| 5181 | {
|
| 5182 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5183 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5184 | if(!texture)
|
| 5185 | {
|
| 5186 | return error(GL_INVALID_OPERATION);
|
| 5187 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5188 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5189 | texture->setImage(level, width, height, format, type, context->getUnpackAlignment(), pixels);
|
| 5190 | }
|
| 5191 | else
|
| 5192 | {
|
| 5193 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5194 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5195 | if(!texture)
|
| 5196 | {
|
| 5197 | return error(GL_INVALID_OPERATION);
|
| 5198 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 5199 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5200 | texture->setImage(target, level, width, height, format, type, context->getUnpackAlignment(), pixels);
|
| 5201 | }
|
| 5202 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5203 | }
|
| 5204 |
|
| 5205 | void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
|
| 5206 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5207 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat param = %f)", target, pname, param);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5208 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5209 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5210 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5211 | if(context)
|
| 5212 | {
|
| 5213 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5214 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5215 | egl::GLint clientVersion = context->getClientVersion();
|
| 5216 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5217 | switch(target)
|
| 5218 | {
|
| 5219 | case GL_TEXTURE_2D:
|
| 5220 | texture = context->getTexture2D();
|
| 5221 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5222 | case GL_TEXTURE_2D_ARRAY:
|
| 5223 | if(clientVersion < 3)
|
| 5224 | {
|
| 5225 | return error(GL_INVALID_ENUM);
|
| 5226 | }
|
| 5227 | else
|
| 5228 | {
|
| 5229 | UNIMPLEMENTED();
|
| 5230 | texture = context->getTexture3D();
|
| 5231 | break;
|
| 5232 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5233 | case GL_TEXTURE_3D_OES:
|
| 5234 | texture = context->getTexture3D();
|
| 5235 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5236 | case GL_TEXTURE_CUBE_MAP:
|
| 5237 | texture = context->getTextureCubeMap();
|
| 5238 | break;
|
| 5239 | case GL_TEXTURE_EXTERNAL_OES:
|
| 5240 | texture = context->getTextureExternal();
|
| 5241 | break;
|
| 5242 | default:
|
| 5243 | return error(GL_INVALID_ENUM);
|
| 5244 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5245 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5246 | switch(pname)
|
| 5247 | {
|
| 5248 | case GL_TEXTURE_WRAP_S:
|
| 5249 | if(!texture->setWrapS((GLenum)param))
|
| 5250 | {
|
| 5251 | return error(GL_INVALID_ENUM);
|
| 5252 | }
|
| 5253 | break;
|
| 5254 | case GL_TEXTURE_WRAP_T:
|
| 5255 | if(!texture->setWrapT((GLenum)param))
|
| 5256 | {
|
| 5257 | return error(GL_INVALID_ENUM);
|
| 5258 | }
|
| 5259 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5260 | case GL_TEXTURE_WRAP_R_OES:
|
| 5261 | if(!texture->setWrapR((GLenum)param))
|
| 5262 | {
|
| 5263 | return error(GL_INVALID_ENUM);
|
| 5264 | }
|
| 5265 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5266 | case GL_TEXTURE_MIN_FILTER:
|
| 5267 | if(!texture->setMinFilter((GLenum)param))
|
| 5268 | {
|
| 5269 | return error(GL_INVALID_ENUM);
|
| 5270 | }
|
| 5271 | break;
|
| 5272 | case GL_TEXTURE_MAG_FILTER:
|
| 5273 | if(!texture->setMagFilter((GLenum)param))
|
| 5274 | {
|
| 5275 | return error(GL_INVALID_ENUM);
|
| 5276 | }
|
| 5277 | break;
|
| 5278 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 5279 | if(!texture->setMaxAnisotropy(param))
|
| 5280 | {
|
| 5281 | return error(GL_INVALID_VALUE);
|
| 5282 | }
|
| 5283 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5284 | case GL_TEXTURE_BASE_LEVEL:
|
| 5285 | if(clientVersion < 3 || !texture->setBaseLevel((GLint)param))
|
| 5286 | {
|
| 5287 | return error(GL_INVALID_VALUE);
|
| 5288 | }
|
| 5289 | break;
|
| 5290 | case GL_TEXTURE_COMPARE_FUNC:
|
| 5291 | if(clientVersion < 3 || !texture->setCompareFunc((GLenum)param))
|
| 5292 | {
|
| 5293 | return error(GL_INVALID_VALUE);
|
| 5294 | }
|
| 5295 | break;
|
| 5296 | case GL_TEXTURE_COMPARE_MODE:
|
| 5297 | if(clientVersion < 3 || !texture->setCompareMode((GLenum)param))
|
| 5298 | {
|
| 5299 | return error(GL_INVALID_VALUE);
|
| 5300 | }
|
| 5301 | break;
|
| 5302 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
| 5303 | if(clientVersion < 3 || !texture->setCompareMode((GLboolean)param))
|
| 5304 | {
|
| 5305 | return error(GL_INVALID_VALUE);
|
| 5306 | }
|
| 5307 | break;
|
| 5308 | case GL_TEXTURE_MAX_LEVEL:
|
| 5309 | if(clientVersion < 3 || !texture->setMaxLevel((GLint)param))
|
| 5310 | {
|
| 5311 | return error(GL_INVALID_VALUE);
|
| 5312 | }
|
| 5313 | break;
|
| 5314 | case GL_TEXTURE_MAX_LOD:
|
| 5315 | if(clientVersion < 3 || !texture->setMaxLOD(param))
|
| 5316 | {
|
| 5317 | return error(GL_INVALID_VALUE);
|
| 5318 | }
|
| 5319 | break;
|
| 5320 | case GL_TEXTURE_MIN_LOD:
|
| 5321 | if(clientVersion < 3 || !texture->setMinLOD(param))
|
| 5322 | {
|
| 5323 | return error(GL_INVALID_VALUE);
|
| 5324 | }
|
| 5325 | break;
|
| 5326 | case GL_TEXTURE_SWIZZLE_R:
|
| 5327 | if(clientVersion < 3 || !texture->setSwizzleR((GLenum)param))
|
| 5328 | {
|
| 5329 | return error(GL_INVALID_VALUE);
|
| 5330 | }
|
| 5331 | break;
|
| 5332 | case GL_TEXTURE_SWIZZLE_G:
|
| 5333 | if(clientVersion < 3 || !texture->setSwizzleG((GLenum)param))
|
| 5334 | {
|
| 5335 | return error(GL_INVALID_VALUE);
|
| 5336 | }
|
| 5337 | break;
|
| 5338 | case GL_TEXTURE_SWIZZLE_B:
|
| 5339 | if(clientVersion < 3 || !texture->setSwizzleB((GLenum)param))
|
| 5340 | {
|
| 5341 | return error(GL_INVALID_VALUE);
|
| 5342 | }
|
| 5343 | break;
|
| 5344 | case GL_TEXTURE_SWIZZLE_A:
|
| 5345 | if(clientVersion < 3 || !texture->setSwizzleA((GLenum)param))
|
| 5346 | {
|
| 5347 | return error(GL_INVALID_VALUE);
|
| 5348 | }
|
| 5349 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5350 | default:
|
| 5351 | return error(GL_INVALID_ENUM);
|
| 5352 | }
|
| 5353 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5354 | }
|
| 5355 |
|
| 5356 | void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
|
| 5357 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5358 | glTexParameterf(target, pname, *params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5359 | }
|
| 5360 |
|
| 5361 | void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
|
| 5362 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5363 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5364 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5365 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5366 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5367 | if(context)
|
| 5368 | {
|
| 5369 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5370 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5371 | egl::GLint clientVersion = context->getClientVersion();
|
| 5372 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5373 | switch(target)
|
| 5374 | {
|
| 5375 | case GL_TEXTURE_2D:
|
| 5376 | texture = context->getTexture2D();
|
| 5377 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5378 | case GL_TEXTURE_2D_ARRAY:
|
| 5379 | if(clientVersion < 3)
|
| 5380 | {
|
| 5381 | return error(GL_INVALID_ENUM);
|
| 5382 | }
|
| 5383 | else
|
| 5384 | {
|
| 5385 | UNIMPLEMENTED();
|
| 5386 | texture = context->getTexture3D();
|
| 5387 | break;
|
| 5388 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5389 | case GL_TEXTURE_3D_OES:
|
| 5390 | texture = context->getTexture3D();
|
| 5391 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5392 | case GL_TEXTURE_CUBE_MAP:
|
| 5393 | texture = context->getTextureCubeMap();
|
| 5394 | break;
|
| 5395 | case GL_TEXTURE_EXTERNAL_OES:
|
Alexis Hetu | f7be67f | 2015-02-11 16:11:07 -0500 | [diff] [blame] | 5396 | texture = context->getTextureExternal();
|
| 5397 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5398 | default:
|
| 5399 | return error(GL_INVALID_ENUM);
|
| 5400 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5401 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5402 | switch(pname)
|
| 5403 | {
|
| 5404 | case GL_TEXTURE_WRAP_S:
|
| 5405 | if(!texture->setWrapS((GLenum)param))
|
| 5406 | {
|
| 5407 | return error(GL_INVALID_ENUM);
|
| 5408 | }
|
| 5409 | break;
|
| 5410 | case GL_TEXTURE_WRAP_T:
|
| 5411 | if(!texture->setWrapT((GLenum)param))
|
| 5412 | {
|
| 5413 | return error(GL_INVALID_ENUM);
|
| 5414 | }
|
| 5415 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5416 | case GL_TEXTURE_WRAP_R_OES:
|
| 5417 | if(!texture->setWrapR((GLenum)param))
|
| 5418 | {
|
| 5419 | return error(GL_INVALID_ENUM);
|
| 5420 | }
|
| 5421 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5422 | case GL_TEXTURE_MIN_FILTER:
|
| 5423 | if(!texture->setMinFilter((GLenum)param))
|
| 5424 | {
|
| 5425 | return error(GL_INVALID_ENUM);
|
| 5426 | }
|
| 5427 | break;
|
| 5428 | case GL_TEXTURE_MAG_FILTER:
|
| 5429 | if(!texture->setMagFilter((GLenum)param))
|
| 5430 | {
|
| 5431 | return error(GL_INVALID_ENUM);
|
| 5432 | }
|
| 5433 | break;
|
| 5434 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 5435 | if(!texture->setMaxAnisotropy((GLfloat)param))
|
| 5436 | {
|
| 5437 | return error(GL_INVALID_VALUE);
|
| 5438 | }
|
| 5439 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5440 | case GL_TEXTURE_BASE_LEVEL:
|
| 5441 | if(clientVersion < 3 || !texture->setBaseLevel(param))
|
| 5442 | {
|
| 5443 | return error(GL_INVALID_VALUE);
|
| 5444 | }
|
| 5445 | break;
|
| 5446 | case GL_TEXTURE_COMPARE_FUNC:
|
| 5447 | if(clientVersion < 3 || !texture->setCompareFunc((GLenum)param))
|
| 5448 | {
|
| 5449 | return error(GL_INVALID_VALUE);
|
| 5450 | }
|
| 5451 | break;
|
| 5452 | case GL_TEXTURE_COMPARE_MODE:
|
| 5453 | if(clientVersion < 3 || !texture->setCompareMode((GLenum)param))
|
| 5454 | {
|
| 5455 | return error(GL_INVALID_VALUE);
|
| 5456 | }
|
| 5457 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
| 5458 | if(clientVersion < 3 || !texture->setCompareMode((GLboolean)param))
|
| 5459 | {
|
| 5460 | return error(GL_INVALID_VALUE);
|
| 5461 | }
|
| 5462 | break;
|
| 5463 | case GL_TEXTURE_MAX_LEVEL:
|
| 5464 | if(clientVersion < 3 || !texture->setMaxLevel(param))
|
| 5465 | {
|
| 5466 | return error(GL_INVALID_VALUE);
|
| 5467 | }
|
| 5468 | break;
|
| 5469 | case GL_TEXTURE_MAX_LOD:
|
| 5470 | if(clientVersion < 3 || !texture->setMaxLOD((GLfloat)param))
|
| 5471 | {
|
| 5472 | return error(GL_INVALID_VALUE);
|
| 5473 | }
|
| 5474 | break;
|
| 5475 | case GL_TEXTURE_MIN_LOD:
|
| 5476 | if(clientVersion < 3 || !texture->setMinLOD((GLfloat)param))
|
| 5477 | {
|
| 5478 | return error(GL_INVALID_VALUE);
|
| 5479 | }
|
| 5480 | break;
|
| 5481 | case GL_TEXTURE_SWIZZLE_R:
|
| 5482 | if(clientVersion < 3 || !texture->setSwizzleR((GLenum)param))
|
| 5483 | {
|
| 5484 | return error(GL_INVALID_VALUE);
|
| 5485 | }
|
| 5486 | break;
|
| 5487 | case GL_TEXTURE_SWIZZLE_G:
|
| 5488 | if(clientVersion < 3 || !texture->setSwizzleG((GLenum)param))
|
| 5489 | {
|
| 5490 | return error(GL_INVALID_VALUE);
|
| 5491 | }
|
| 5492 | break;
|
| 5493 | case GL_TEXTURE_SWIZZLE_B:
|
| 5494 | if(clientVersion < 3 || !texture->setSwizzleB((GLenum)param))
|
| 5495 | {
|
| 5496 | return error(GL_INVALID_VALUE);
|
| 5497 | }
|
| 5498 | break;
|
| 5499 | case GL_TEXTURE_SWIZZLE_A:
|
| 5500 | if(clientVersion < 3 || !texture->setSwizzleA((GLenum)param))
|
| 5501 | {
|
| 5502 | return error(GL_INVALID_VALUE);
|
| 5503 | }
|
| 5504 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5505 | default:
|
| 5506 | return error(GL_INVALID_ENUM);
|
| 5507 | }
|
| 5508 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5509 | }
|
| 5510 |
|
| 5511 | void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
|
| 5512 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5513 | glTexParameteri(target, pname, *params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5514 | }
|
| 5515 |
|
| 5516 | void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5517 | GLenum format, GLenum type, const GLvoid* pixels)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5518 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5519 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 5520 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
|
| 5521 | "const GLvoid* pixels = 0x%0.8p)",
|
| 5522 | target, level, xoffset, yoffset, width, height, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5523 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5524 | if(!es2::IsTextureTarget(target))
|
| 5525 | {
|
| 5526 | return error(GL_INVALID_ENUM);
|
| 5527 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5528 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5529 | if(level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
|
| 5530 | {
|
| 5531 | return error(GL_INVALID_VALUE);
|
| 5532 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5533 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5534 | if(std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
|
| 5535 | {
|
| 5536 | return error(GL_INVALID_VALUE);
|
| 5537 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5538 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5539 | if(!es2::CheckTextureFormatType(format, type))
|
| 5540 | {
|
| 5541 | return error(GL_INVALID_ENUM);
|
| 5542 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5543 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5544 | if(width == 0 || height == 0 || pixels == NULL)
|
| 5545 | {
|
| 5546 | return;
|
| 5547 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5548 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5549 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5550 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5551 | if(context)
|
| 5552 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5553 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5554 | {
|
| 5555 | return error(GL_INVALID_VALUE);
|
| 5556 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5557 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5558 | if(target == GL_TEXTURE_2D)
|
| 5559 | {
|
| 5560 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5561 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5562 | if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture))
|
| 5563 | {
|
| 5564 | texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
|
| 5565 | }
|
| 5566 | }
|
| 5567 | else if(es2::IsCubemapTextureTarget(target))
|
| 5568 | {
|
| 5569 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 5570 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5571 | if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture))
|
| 5572 | {
|
| 5573 | texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
|
| 5574 | }
|
| 5575 | }
|
| 5576 | else
|
| 5577 | {
|
| 5578 | UNREACHABLE();
|
| 5579 | }
|
| 5580 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5581 | }
|
| 5582 |
|
| 5583 | void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
|
| 5584 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5585 | glUniform1fv(location, 1, &x);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5586 | }
|
| 5587 |
|
| 5588 | void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
|
| 5589 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5590 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5591 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5592 | if(count < 0)
|
| 5593 | {
|
| 5594 | return error(GL_INVALID_VALUE);
|
| 5595 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5596 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5597 | if(location == -1)
|
| 5598 | {
|
| 5599 | return;
|
| 5600 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5601 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5602 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5603 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5604 | if(context)
|
| 5605 | {
|
| 5606 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5607 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5608 | if(!program)
|
| 5609 | {
|
| 5610 | return error(GL_INVALID_OPERATION);
|
| 5611 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5612 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5613 | if(!program->setUniform1fv(location, count, v))
|
| 5614 | {
|
| 5615 | return error(GL_INVALID_OPERATION);
|
| 5616 | }
|
| 5617 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5618 | }
|
| 5619 |
|
| 5620 | void GL_APIENTRY glUniform1i(GLint location, GLint x)
|
| 5621 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5622 | glUniform1iv(location, 1, &x);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5623 | }
|
| 5624 |
|
| 5625 | void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
|
| 5626 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5627 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5628 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5629 | if(count < 0)
|
| 5630 | {
|
| 5631 | return error(GL_INVALID_VALUE);
|
| 5632 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5633 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5634 | if(location == -1)
|
| 5635 | {
|
| 5636 | return;
|
| 5637 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5638 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5639 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5640 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5641 | if(context)
|
| 5642 | {
|
| 5643 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5644 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5645 | if(!program)
|
| 5646 | {
|
| 5647 | return error(GL_INVALID_OPERATION);
|
| 5648 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5649 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5650 | if(!program->setUniform1iv(location, count, v))
|
| 5651 | {
|
| 5652 | return error(GL_INVALID_OPERATION);
|
| 5653 | }
|
| 5654 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5655 | }
|
| 5656 |
|
| 5657 | void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
|
| 5658 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5659 | GLfloat xy[2] = {x, y};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5660 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5661 | glUniform2fv(location, 1, (GLfloat*)&xy);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5662 | }
|
| 5663 |
|
| 5664 | void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
|
| 5665 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5666 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5667 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5668 | if(count < 0)
|
| 5669 | {
|
| 5670 | return error(GL_INVALID_VALUE);
|
| 5671 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 5672 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5673 | if(location == -1)
|
| 5674 | {
|
| 5675 | return;
|
| 5676 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5677 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5678 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5679 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5680 | if(context)
|
| 5681 | {
|
| 5682 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5683 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5684 | if(!program)
|
| 5685 | {
|
| 5686 | return error(GL_INVALID_OPERATION);
|
| 5687 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5688 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5689 | if(!program->setUniform2fv(location, count, v))
|
| 5690 | {
|
| 5691 | return error(GL_INVALID_OPERATION);
|
| 5692 | }
|
| 5693 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5694 | }
|
| 5695 |
|
| 5696 | void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
|
| 5697 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5698 | GLint xy[4] = {x, y};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5699 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5700 | glUniform2iv(location, 1, (GLint*)&xy);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5701 | }
|
| 5702 |
|
| 5703 | void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
|
| 5704 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5705 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5706 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5707 | if(count < 0)
|
| 5708 | {
|
| 5709 | return error(GL_INVALID_VALUE);
|
| 5710 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5711 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5712 | if(location == -1)
|
| 5713 | {
|
| 5714 | return;
|
| 5715 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5716 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5717 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5718 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5719 | if(context)
|
| 5720 | {
|
| 5721 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5722 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5723 | if(!program)
|
| 5724 | {
|
| 5725 | return error(GL_INVALID_OPERATION);
|
| 5726 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5727 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5728 | if(!program->setUniform2iv(location, count, v))
|
| 5729 | {
|
| 5730 | return error(GL_INVALID_OPERATION);
|
| 5731 | }
|
| 5732 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5733 | }
|
| 5734 |
|
| 5735 | void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
|
| 5736 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5737 | GLfloat xyz[3] = {x, y, z};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5738 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5739 | glUniform3fv(location, 1, (GLfloat*)&xyz);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5740 | }
|
| 5741 |
|
| 5742 | void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
|
| 5743 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5744 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5745 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5746 | if(count < 0)
|
| 5747 | {
|
| 5748 | return error(GL_INVALID_VALUE);
|
| 5749 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5750 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5751 | if(location == -1)
|
| 5752 | {
|
| 5753 | return;
|
| 5754 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5755 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5756 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5757 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5758 | if(context)
|
| 5759 | {
|
| 5760 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5761 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5762 | if(!program)
|
| 5763 | {
|
| 5764 | return error(GL_INVALID_OPERATION);
|
| 5765 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5766 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5767 | if(!program->setUniform3fv(location, count, v))
|
| 5768 | {
|
| 5769 | return error(GL_INVALID_OPERATION);
|
| 5770 | }
|
| 5771 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5772 | }
|
| 5773 |
|
| 5774 | void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
|
| 5775 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5776 | GLint xyz[3] = {x, y, z};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5777 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5778 | glUniform3iv(location, 1, (GLint*)&xyz);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5779 | }
|
| 5780 |
|
| 5781 | void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
|
| 5782 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5783 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5784 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5785 | if(count < 0)
|
| 5786 | {
|
| 5787 | return error(GL_INVALID_VALUE);
|
| 5788 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5789 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5790 | if(location == -1)
|
| 5791 | {
|
| 5792 | return;
|
| 5793 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5794 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5795 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5796 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5797 | if(context)
|
| 5798 | {
|
| 5799 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5800 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5801 | if(!program)
|
| 5802 | {
|
| 5803 | return error(GL_INVALID_OPERATION);
|
| 5804 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5805 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5806 | if(!program->setUniform3iv(location, count, v))
|
| 5807 | {
|
| 5808 | return error(GL_INVALID_OPERATION);
|
| 5809 | }
|
| 5810 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5811 | }
|
| 5812 |
|
| 5813 | void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
| 5814 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5815 | GLfloat xyzw[4] = {x, y, z, w};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5816 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5817 | glUniform4fv(location, 1, (GLfloat*)&xyzw);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5818 | }
|
| 5819 |
|
| 5820 | void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
|
| 5821 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5822 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5823 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5824 | if(count < 0)
|
| 5825 | {
|
| 5826 | return error(GL_INVALID_VALUE);
|
| 5827 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5828 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5829 | if(location == -1)
|
| 5830 | {
|
| 5831 | return;
|
| 5832 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5833 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5834 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5835 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5836 | if(context)
|
| 5837 | {
|
| 5838 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5839 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5840 | if(!program)
|
| 5841 | {
|
| 5842 | return error(GL_INVALID_OPERATION);
|
| 5843 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5844 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5845 | if(!program->setUniform4fv(location, count, v))
|
| 5846 | {
|
| 5847 | return error(GL_INVALID_OPERATION);
|
| 5848 | }
|
| 5849 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5850 | }
|
| 5851 |
|
| 5852 | void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
|
| 5853 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5854 | GLint xyzw[4] = {x, y, z, w};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5855 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5856 | glUniform4iv(location, 1, (GLint*)&xyzw);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5857 | }
|
| 5858 |
|
| 5859 | void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
|
| 5860 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5861 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5862 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5863 | if(count < 0)
|
| 5864 | {
|
| 5865 | return error(GL_INVALID_VALUE);
|
| 5866 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5867 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5868 | if(location == -1)
|
| 5869 | {
|
| 5870 | return;
|
| 5871 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5872 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5873 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5874 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5875 | if(context)
|
| 5876 | {
|
| 5877 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5878 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5879 | if(!program)
|
| 5880 | {
|
| 5881 | return error(GL_INVALID_OPERATION);
|
| 5882 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5883 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5884 | if(!program->setUniform4iv(location, count, v))
|
| 5885 | {
|
| 5886 | return error(GL_INVALID_OPERATION);
|
| 5887 | }
|
| 5888 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5889 | }
|
| 5890 |
|
| 5891 | void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
|
| 5892 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5893 | TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
|
| 5894 | location, count, transpose, value);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5895 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5896 | if(count < 0 || transpose != GL_FALSE)
|
| 5897 | {
|
| 5898 | return error(GL_INVALID_VALUE);
|
| 5899 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5900 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5901 | if(location == -1)
|
| 5902 | {
|
| 5903 | return;
|
| 5904 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5905 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5906 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5907 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5908 | if(context)
|
| 5909 | {
|
| 5910 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5911 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5912 | if(!program)
|
| 5913 | {
|
| 5914 | return error(GL_INVALID_OPERATION);
|
| 5915 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5916 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5917 | if(!program->setUniformMatrix2fv(location, count, value))
|
| 5918 | {
|
| 5919 | return error(GL_INVALID_OPERATION);
|
| 5920 | }
|
| 5921 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5922 | }
|
| 5923 |
|
| 5924 | void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
|
| 5925 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5926 | TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
|
| 5927 | location, count, transpose, value);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5928 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5929 | if(count < 0 || transpose != GL_FALSE)
|
| 5930 | {
|
| 5931 | return error(GL_INVALID_VALUE);
|
| 5932 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5933 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5934 | if(location == -1)
|
| 5935 | {
|
| 5936 | return;
|
| 5937 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5938 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5939 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5940 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5941 | if(context)
|
| 5942 | {
|
| 5943 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5944 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5945 | if(!program)
|
| 5946 | {
|
| 5947 | return error(GL_INVALID_OPERATION);
|
| 5948 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5949 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5950 | if(!program->setUniformMatrix3fv(location, count, value))
|
| 5951 | {
|
| 5952 | return error(GL_INVALID_OPERATION);
|
| 5953 | }
|
| 5954 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5955 | }
|
| 5956 |
|
| 5957 | void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
|
| 5958 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5959 | TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
|
| 5960 | location, count, transpose, value);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5961 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5962 | if(count < 0 || transpose != GL_FALSE)
|
| 5963 | {
|
| 5964 | return error(GL_INVALID_VALUE);
|
| 5965 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5966 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5967 | if(location == -1)
|
| 5968 | {
|
| 5969 | return;
|
| 5970 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5971 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5972 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5973 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5974 | if(context)
|
| 5975 | {
|
| 5976 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5977 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5978 | if(!program)
|
| 5979 | {
|
| 5980 | return error(GL_INVALID_OPERATION);
|
| 5981 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5982 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5983 | if(!program->setUniformMatrix4fv(location, count, value))
|
| 5984 | {
|
| 5985 | return error(GL_INVALID_OPERATION);
|
| 5986 | }
|
| 5987 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5988 | }
|
| 5989 |
|
| 5990 | void GL_APIENTRY glUseProgram(GLuint program)
|
| 5991 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5992 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5993 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5994 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5995 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5996 | if(context)
|
| 5997 | {
|
| 5998 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5999 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6000 | if(!programObject && program != 0)
|
| 6001 | {
|
| 6002 | if(context->getShader(program))
|
| 6003 | {
|
| 6004 | return error(GL_INVALID_OPERATION);
|
| 6005 | }
|
| 6006 | else
|
| 6007 | {
|
| 6008 | return error(GL_INVALID_VALUE);
|
| 6009 | }
|
| 6010 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6011 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6012 | if(program != 0 && !programObject->isLinked())
|
| 6013 | {
|
| 6014 | return error(GL_INVALID_OPERATION);
|
| 6015 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6016 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6017 | context->useProgram(program);
|
| 6018 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6019 | }
|
| 6020 |
|
| 6021 | void GL_APIENTRY glValidateProgram(GLuint program)
|
| 6022 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6023 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6024 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6025 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6026 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6027 | if(context)
|
| 6028 | {
|
| 6029 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6030 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6031 | if(!programObject)
|
| 6032 | {
|
| 6033 | if(context->getShader(program))
|
| 6034 | {
|
| 6035 | return error(GL_INVALID_OPERATION);
|
| 6036 | }
|
| 6037 | else
|
| 6038 | {
|
| 6039 | return error(GL_INVALID_VALUE);
|
| 6040 | }
|
| 6041 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6042 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6043 | programObject->validate();
|
| 6044 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6045 | }
|
| 6046 |
|
| 6047 | void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
|
| 6048 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6049 | TRACE("(GLuint index = %d, GLfloat x = %f)", index, x);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6050 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6051 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6052 | {
|
| 6053 | return error(GL_INVALID_VALUE);
|
| 6054 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6055 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6056 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6057 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6058 | if(context)
|
| 6059 | {
|
| 6060 | GLfloat vals[4] = { x, 0, 0, 1 };
|
| 6061 | context->setVertexAttrib(index, vals);
|
| 6062 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6063 | }
|
| 6064 |
|
| 6065 | void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
|
| 6066 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6067 | TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6068 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6069 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6070 | {
|
| 6071 | return error(GL_INVALID_VALUE);
|
| 6072 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6073 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6074 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6075 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6076 | if(context)
|
| 6077 | {
|
| 6078 | GLfloat vals[4] = { values[0], 0, 0, 1 };
|
| 6079 | context->setVertexAttrib(index, vals);
|
| 6080 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6081 | }
|
| 6082 |
|
| 6083 | void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
|
| 6084 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6085 | TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6086 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6087 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6088 | {
|
| 6089 | return error(GL_INVALID_VALUE);
|
| 6090 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6091 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6092 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6093 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6094 | if(context)
|
| 6095 | {
|
| 6096 | GLfloat vals[4] = { x, y, 0, 1 };
|
| 6097 | context->setVertexAttrib(index, vals);
|
| 6098 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6099 | }
|
| 6100 |
|
| 6101 | void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
|
| 6102 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6103 | TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6104 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6105 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6106 | {
|
| 6107 | return error(GL_INVALID_VALUE);
|
| 6108 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6109 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6110 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6111 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6112 | if(context)
|
| 6113 | {
|
| 6114 | GLfloat vals[4] = { values[0], values[1], 0, 1 };
|
| 6115 | context->setVertexAttrib(index, vals);
|
| 6116 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6117 | }
|
| 6118 |
|
| 6119 | void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
|
| 6120 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6121 | TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6122 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6123 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6124 | {
|
| 6125 | return error(GL_INVALID_VALUE);
|
| 6126 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6127 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6128 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6129 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6130 | if(context)
|
| 6131 | {
|
| 6132 | GLfloat vals[4] = { x, y, z, 1 };
|
| 6133 | context->setVertexAttrib(index, vals);
|
| 6134 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6135 | }
|
| 6136 |
|
| 6137 | void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
|
| 6138 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6139 | TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6140 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6141 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6142 | {
|
| 6143 | return error(GL_INVALID_VALUE);
|
| 6144 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6145 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6146 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6147 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6148 | if(context)
|
| 6149 | {
|
| 6150 | GLfloat vals[4] = { values[0], values[1], values[2], 1 };
|
| 6151 | context->setVertexAttrib(index, vals);
|
| 6152 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6153 | }
|
| 6154 |
|
| 6155 | void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
| 6156 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6157 | TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6158 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6159 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6160 | {
|
| 6161 | return error(GL_INVALID_VALUE);
|
| 6162 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6163 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6164 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6165 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6166 | if(context)
|
| 6167 | {
|
| 6168 | GLfloat vals[4] = { x, y, z, w };
|
| 6169 | context->setVertexAttrib(index, vals);
|
| 6170 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6171 | }
|
| 6172 |
|
| 6173 | void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
|
| 6174 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6175 | TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6176 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6177 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6178 | {
|
| 6179 | return error(GL_INVALID_VALUE);
|
| 6180 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6181 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6182 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6183 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6184 | if(context)
|
| 6185 | {
|
| 6186 | context->setVertexAttrib(index, values);
|
| 6187 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6188 | }
|
| 6189 |
|
| 6190 | void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
|
| 6191 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6192 | TRACE("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
|
| 6193 | "GLboolean normalized = %d, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
|
| 6194 | index, size, type, normalized, stride, ptr);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6195 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6196 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6197 | {
|
| 6198 | return error(GL_INVALID_VALUE);
|
| 6199 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6200 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6201 | if(size < 1 || size > 4)
|
| 6202 | {
|
| 6203 | return error(GL_INVALID_VALUE);
|
| 6204 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6205 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6206 | egl::GLint clientVersion = egl::getClientVersion();
|
| 6207 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6208 | switch(type)
|
| 6209 | {
|
| 6210 | case GL_BYTE:
|
| 6211 | case GL_UNSIGNED_BYTE:
|
| 6212 | case GL_SHORT:
|
| 6213 | case GL_UNSIGNED_SHORT:
|
| 6214 | case GL_FIXED:
|
| 6215 | case GL_FLOAT:
|
| 6216 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6217 | case GL_INT_2_10_10_10_REV:
|
| 6218 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 6219 | if(clientVersion >= 3)
|
| 6220 | {
|
| 6221 | if(size != 4)
|
| 6222 | {
|
| 6223 | return error(GL_INVALID_OPERATION);
|
| 6224 | }
|
| 6225 | break;
|
| 6226 | }
|
| 6227 | else return error(GL_INVALID_ENUM);
|
| 6228 | case GL_INT:
|
| 6229 | case GL_UNSIGNED_INT:
|
| 6230 | case GL_HALF_FLOAT:
|
| 6231 | if(clientVersion >= 3)
|
| 6232 | {
|
| 6233 | break;
|
| 6234 | }
|
| 6235 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6236 | default:
|
| 6237 | return error(GL_INVALID_ENUM);
|
| 6238 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6239 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6240 | if(stride < 0)
|
| 6241 | {
|
| 6242 | return error(GL_INVALID_VALUE);
|
| 6243 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6244 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6245 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6246 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6247 | if(context)
|
| 6248 | {
|
| 6249 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr);
|
| 6250 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6251 | }
|
| 6252 |
|
| 6253 | void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
| 6254 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6255 | TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6256 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6257 | if(width < 0 || height < 0)
|
| 6258 | {
|
| 6259 | return error(GL_INVALID_VALUE);
|
| 6260 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6261 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6262 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6263 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6264 | if(context)
|
| 6265 | {
|
| 6266 | context->setViewportParams(x, y, width, height);
|
| 6267 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6268 | }
|
| 6269 |
|
Alexis Hetu | e9233fb | 2015-02-11 10:31:58 -0500 | [diff] [blame] | 6270 | void GL_APIENTRY glBlitFramebufferNV(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6271 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6272 | TRACE("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
|
| 6273 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
|
| 6274 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
|
| 6275 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6276 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6277 | switch(filter)
|
| 6278 | {
|
| 6279 | case GL_NEAREST:
|
| 6280 | break;
|
| 6281 | default:
|
| 6282 | return error(GL_INVALID_ENUM);
|
| 6283 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6284 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6285 | if((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
|
| 6286 | {
|
| 6287 | return error(GL_INVALID_VALUE);
|
| 6288 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6289 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6290 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6291 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6292 | if(context)
|
| 6293 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6294 | if(context->getReadFramebufferName() == context->getDrawFramebufferName())
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6295 | {
|
| 6296 | ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
|
| 6297 | return error(GL_INVALID_OPERATION);
|
| 6298 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6299 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6300 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
|
| 6301 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6302 | }
|
| 6303 |
|
Alexis Hetu | e9233fb | 2015-02-11 10:31:58 -0500 | [diff] [blame] | 6304 | void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
| 6305 | GLbitfield mask, GLenum filter)
|
| 6306 | {
|
| 6307 | if(srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
|
| 6308 | {
|
| 6309 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
|
| 6310 | return error(GL_INVALID_OPERATION);
|
| 6311 | }
|
| 6312 |
|
| 6313 | glBlitFramebufferNV(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
| 6314 | }
|
| 6315 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6316 | void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6317 | GLint border, GLenum format, GLenum type, const GLvoid* pixels)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6318 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6319 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
|
| 6320 | "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
|
| 6321 | "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
|
| 6322 | target, level, internalformat, width, height, depth, border, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6323 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6324 | switch(target)
|
| 6325 | {
|
| 6326 | case GL_TEXTURE_3D_OES:
|
| 6327 | switch(format)
|
| 6328 | {
|
| 6329 | case GL_DEPTH_COMPONENT:
|
| 6330 | case GL_DEPTH_STENCIL_OES:
|
| 6331 | return error(GL_INVALID_OPERATION);
|
| 6332 | default:
|
| 6333 | break;
|
| 6334 | }
|
| 6335 | break;
|
| 6336 | default:
|
| 6337 | return error(GL_INVALID_ENUM);
|
| 6338 | }
|
| 6339 |
|
| 6340 | if(!ValidateType3D(type) || !ValidateFormat3D(format))
|
| 6341 | {
|
| 6342 | return error(GL_INVALID_ENUM);
|
| 6343 | }
|
| 6344 |
|
| 6345 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 6346 | {
|
| 6347 | return error(GL_INVALID_VALUE);
|
| 6348 | }
|
| 6349 |
|
| 6350 | const GLsizei maxSize3D = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level;
|
| 6351 | if((width < 0) || (height < 0) || (depth < 0) || (width > maxSize3D) || (height > maxSize3D) || (depth > maxSize3D))
|
| 6352 | {
|
| 6353 | return error(GL_INVALID_VALUE);
|
| 6354 | }
|
| 6355 |
|
| 6356 | if(border != 0)
|
| 6357 | {
|
| 6358 | return error(GL_INVALID_VALUE);
|
| 6359 | }
|
| 6360 |
|
| 6361 | if(!ValidateInternalFormat3D(internalformat, format, type))
|
| 6362 | {
|
| 6363 | return error(GL_INVALID_OPERATION);
|
| 6364 | }
|
| 6365 |
|
| 6366 | es2::Context *context = es2::getContext();
|
| 6367 |
|
| 6368 | if(context)
|
| 6369 | {
|
| 6370 | es2::Texture3D *texture = context->getTexture3D();
|
| 6371 |
|
| 6372 | if(!texture)
|
| 6373 | {
|
| 6374 | return error(GL_INVALID_OPERATION);
|
| 6375 | }
|
| 6376 |
|
| 6377 | texture->setImage(level, width, height, depth, internalformat, type, context->getUnpackAlignment(), pixels);
|
| 6378 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6379 | }
|
| 6380 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6381 | void GL_APIENTRY glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels)
|
| 6382 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6383 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 6384 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
|
| 6385 | "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6386 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
|
| 6387 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6388 | switch(target)
|
| 6389 | {
|
| 6390 | case GL_TEXTURE_3D_OES:
|
| 6391 | break;
|
| 6392 | default:
|
| 6393 | return error(GL_INVALID_ENUM);
|
| 6394 | }
|
| 6395 |
|
| 6396 | if(!ValidateType3D(type) || !ValidateFormat3D(format))
|
| 6397 | {
|
| 6398 | return error(GL_INVALID_ENUM);
|
| 6399 | }
|
| 6400 |
|
| 6401 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 6402 | {
|
| 6403 | return error(GL_INVALID_VALUE);
|
| 6404 | }
|
| 6405 |
|
| 6406 | if((width < 0) || (height < 0) || (depth < 0))
|
| 6407 | {
|
| 6408 | return error(GL_INVALID_VALUE);
|
| 6409 | }
|
| 6410 |
|
| 6411 | es2::Context *context = es2::getContext();
|
| 6412 |
|
| 6413 | if(context)
|
| 6414 | {
|
| 6415 | es2::Texture3D *texture = context->getTexture3D();
|
| 6416 |
|
| 6417 | if(validateSubImageParams(false, width, height, depth, xoffset, yoffset, zoffset, target, level, format, texture))
|
| 6418 | {
|
| 6419 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackAlignment(), pixels);
|
| 6420 | }
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6421 | }
|
| 6422 | }
|
| 6423 |
|
| 6424 | void GL_APIENTRY glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
|
| 6425 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6426 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 6427 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6428 | target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
| 6429 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6430 | switch(target)
|
| 6431 | {
|
| 6432 | case GL_TEXTURE_3D_OES:
|
| 6433 | break;
|
| 6434 | default:
|
| 6435 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6436 | }
|
| 6437 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6438 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 6439 | {
|
| 6440 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6441 | }
|
| 6442 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6443 | es2::Context *context = es2::getContext();
|
| 6444 |
|
| 6445 | if(context)
|
| 6446 | {
|
| 6447 | es2::Framebuffer *framebuffer = context->getReadFramebuffer();
|
| 6448 |
|
| 6449 | if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
|
| 6450 | {
|
| 6451 | return error(GL_INVALID_FRAMEBUFFER_OPERATION);
|
| 6452 | }
|
| 6453 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6454 | if(context->getReadFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6455 | {
|
| 6456 | return error(GL_INVALID_OPERATION);
|
| 6457 | }
|
| 6458 |
|
| 6459 | es2::Renderbuffer *source = framebuffer->getColorbuffer();
|
| 6460 | GLenum colorbufferFormat = source->getFormat();
|
| 6461 | es2::Texture3D *texture = context->getTexture3D();
|
| 6462 |
|
| 6463 | if(!validateSubImageParams(false, width, height, 1, xoffset, yoffset, zoffset, target, level, GL_NONE, texture))
|
| 6464 | {
|
| 6465 | return;
|
| 6466 | }
|
| 6467 |
|
| 6468 | GLenum textureFormat = texture->getFormat(target, level);
|
| 6469 |
|
| 6470 | if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
|
| 6471 | {
|
| 6472 | return;
|
| 6473 | }
|
| 6474 |
|
| 6475 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6476 | }
|
| 6477 | }
|
| 6478 |
|
| 6479 | void GL_APIENTRY glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data)
|
| 6480 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6481 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
|
| 6482 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
|
| 6483 | target, level, internalformat, width, height, depth, border, imageSize, data);
|
| 6484 |
|
| 6485 | switch(target)
|
| 6486 | {
|
| 6487 | case GL_TEXTURE_3D_OES:
|
| 6488 | break;
|
| 6489 | default:
|
| 6490 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6491 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6492 |
|
| 6493 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 6494 | {
|
| 6495 | return error(GL_INVALID_VALUE);
|
| 6496 | }
|
| 6497 |
|
| 6498 | const GLsizei maxSize3D = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level;
|
| 6499 | if((width < 0) || (height < 0) || (depth < 0) || (width > maxSize3D) || (height > maxSize3D) || (depth > maxSize3D) ||(border != 0) || (imageSize < 0))
|
| 6500 | {
|
| 6501 | return error(GL_INVALID_VALUE);
|
| 6502 | }
|
| 6503 |
|
| 6504 | switch(internalformat)
|
| 6505 | {
|
| 6506 | case GL_ETC1_RGB8_OES:
|
| 6507 | break;
|
| 6508 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| 6509 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| 6510 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
|
| 6511 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
|
| 6512 | if(!S3TC_SUPPORT)
|
| 6513 | {
|
| 6514 | return error(GL_INVALID_ENUM);
|
| 6515 | }
|
| 6516 | break;
|
| 6517 | case GL_DEPTH_COMPONENT:
|
| 6518 | case GL_DEPTH_COMPONENT16:
|
| 6519 | case GL_DEPTH_COMPONENT32_OES:
|
| 6520 | case GL_DEPTH_STENCIL_OES:
|
| 6521 | case GL_DEPTH24_STENCIL8_OES:
|
| 6522 | return error(GL_INVALID_OPERATION);
|
| 6523 | default:
|
| 6524 | return error(GL_INVALID_ENUM);
|
| 6525 | }
|
| 6526 |
|
| 6527 | if(imageSize != es2::ComputeCompressedSize(width, height, internalformat) * depth)
|
| 6528 | {
|
| 6529 | return error(GL_INVALID_VALUE);
|
| 6530 | }
|
| 6531 |
|
| 6532 | es2::Context *context = es2::getContext();
|
| 6533 |
|
| 6534 | if(context)
|
| 6535 | {
|
| 6536 | es2::Texture3D *texture = context->getTexture3D();
|
| 6537 |
|
| 6538 | if(!texture)
|
| 6539 | {
|
| 6540 | return error(GL_INVALID_OPERATION);
|
| 6541 | }
|
| 6542 |
|
| 6543 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6544 | }
|
| 6545 | }
|
| 6546 |
|
| 6547 | void GL_APIENTRY glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data)
|
| 6548 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6549 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 6550 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
|
| 6551 | "GLenum format = 0x%X, GLsizei imageSize = %d, const void *data = 0x%0.8p)",
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6552 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
|
| 6553 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6554 | switch(target)
|
| 6555 | {
|
| 6556 | case GL_TEXTURE_3D_OES:
|
| 6557 | break;
|
| 6558 | default:
|
| 6559 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6560 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6561 |
|
| 6562 | if(xoffset < 0 || yoffset < 0 || zoffset < 0 || !validImageSize(level, width, height) || depth < 0 || imageSize < 0)
|
| 6563 | {
|
| 6564 | return error(GL_INVALID_VALUE);
|
| 6565 | }
|
| 6566 |
|
| 6567 | switch(format)
|
| 6568 | {
|
| 6569 | case GL_ETC1_RGB8_OES:
|
| 6570 | break;
|
| 6571 | case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| 6572 | case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| 6573 | case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
|
| 6574 | case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
|
| 6575 | if(!S3TC_SUPPORT)
|
| 6576 | {
|
| 6577 | return error(GL_INVALID_ENUM);
|
| 6578 | }
|
| 6579 | break;
|
| 6580 | default:
|
| 6581 | return error(GL_INVALID_ENUM);
|
| 6582 | }
|
| 6583 |
|
| 6584 | if(width == 0 || height == 0 || depth == 0 || data == NULL)
|
| 6585 | {
|
| 6586 | return;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6587 | }
|
| 6588 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6589 | es2::Context *context = es2::getContext();
|
| 6590 |
|
| 6591 | if(context)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6592 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6593 | es2::Texture3D *texture = context->getTexture3D();
|
| 6594 |
|
| 6595 | if(!texture)
|
| 6596 | {
|
| 6597 | return error(GL_INVALID_OPERATION);
|
| 6598 | }
|
| 6599 |
|
| 6600 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
|
| 6601 | }
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6602 | }
|
| 6603 |
|
| 6604 | void GL_APIENTRY glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
|
| 6605 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6606 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
|
| 6607 | "GLuint texture = %d, GLint level = %d, GLint zoffset = %d)", target, attachment, textarget, texture, level, zoffset);
|
| 6608 |
|
| 6609 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 6610 | {
|
| 6611 | return error(GL_INVALID_ENUM);
|
| 6612 | }
|
| 6613 |
|
| 6614 | switch(attachment)
|
| 6615 | {
|
| 6616 | case GL_COLOR_ATTACHMENT0:
|
| 6617 | case GL_DEPTH_ATTACHMENT:
|
| 6618 | case GL_STENCIL_ATTACHMENT:
|
| 6619 | break;
|
| 6620 | default:
|
| 6621 | return error(GL_INVALID_ENUM);
|
| 6622 | }
|
| 6623 |
|
| 6624 | es2::Context *context = es2::getContext();
|
| 6625 |
|
| 6626 | if(context)
|
| 6627 | {
|
| 6628 | if(texture == 0)
|
| 6629 | {
|
| 6630 | textarget = GL_NONE;
|
| 6631 | }
|
| 6632 | else
|
| 6633 | {
|
| 6634 | es2::Texture *tex = context->getTexture(texture);
|
| 6635 |
|
| 6636 | if(tex == NULL)
|
| 6637 | {
|
| 6638 | return error(GL_INVALID_OPERATION);
|
| 6639 | }
|
| 6640 |
|
| 6641 | if(tex->isCompressed(textarget, level))
|
| 6642 | {
|
| 6643 | return error(GL_INVALID_OPERATION);
|
| 6644 | }
|
| 6645 |
|
| 6646 | switch(textarget)
|
| 6647 | {
|
| 6648 | case GL_TEXTURE_3D_OES:
|
| 6649 | if(tex->getTarget() != GL_TEXTURE_3D_OES)
|
| 6650 | {
|
| 6651 | return error(GL_INVALID_OPERATION);
|
| 6652 | }
|
| 6653 | break;
|
| 6654 | default:
|
| 6655 | return error(GL_INVALID_ENUM);
|
| 6656 | }
|
| 6657 |
|
| 6658 | if(level != 0)
|
| 6659 | {
|
| 6660 | return error(GL_INVALID_VALUE);
|
| 6661 | }
|
| 6662 | }
|
| 6663 |
|
| 6664 | es2::Framebuffer *framebuffer = NULL;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6665 | GLuint framebufferName = 0;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6666 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 6667 | {
|
| 6668 | framebuffer = context->getReadFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6669 | framebufferName = context->getReadFramebufferName();
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6670 | }
|
| 6671 | else
|
| 6672 | {
|
| 6673 | framebuffer = context->getDrawFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6674 | framebufferName = context->getDrawFramebufferName();
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6675 | }
|
| 6676 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6677 | if(framebufferName == 0 || !framebuffer)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6678 | {
|
| 6679 | return error(GL_INVALID_OPERATION);
|
| 6680 | }
|
| 6681 |
|
| 6682 | switch(attachment)
|
| 6683 | {
|
| 6684 | case GL_COLOR_ATTACHMENT0: framebuffer->setColorbuffer(textarget, texture); break;
|
| 6685 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
|
| 6686 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
|
| 6687 | }
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6688 | }
|
| 6689 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6690 |
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6691 | void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
|
| 6692 | {
|
Nicolas Capens | d76b5df | 2014-10-28 15:54:46 -0400 | [diff] [blame] | 6693 | if(egl::getClientVersion() == 1)
|
| 6694 | {
|
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 6695 | return libGLES_CM->glEGLImageTargetTexture2DOES(target, image);
|
Nicolas Capens | d76b5df | 2014-10-28 15:54:46 -0400 | [diff] [blame] | 6696 | }
|
| 6697 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6698 | TRACE("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image);
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6699 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6700 | switch(target)
|
| 6701 | {
|
| 6702 | case GL_TEXTURE_2D:
|
| 6703 | case GL_TEXTURE_EXTERNAL_OES:
|
| 6704 | break;
|
| 6705 | default:
|
| 6706 | return error(GL_INVALID_ENUM);
|
| 6707 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6708 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6709 | if(!image)
|
| 6710 | {
|
| 6711 | return error(GL_INVALID_OPERATION);
|
| 6712 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6713 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6714 | es2::Context *context = es2::getContext();
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6715 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6716 | if(context)
|
| 6717 | {
|
| 6718 | es2::Texture2D *texture = 0;
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 6719 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6720 | switch(target)
|
| 6721 | {
|
| 6722 | case GL_TEXTURE_2D: texture = context->getTexture2D(); break;
|
| 6723 | case GL_TEXTURE_EXTERNAL_OES: texture = context->getTextureExternal(); break;
|
| 6724 | default: UNREACHABLE();
|
| 6725 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6726 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6727 | if(!texture)
|
| 6728 | {
|
| 6729 | return error(GL_INVALID_OPERATION);
|
| 6730 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6731 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6732 | egl::Image *glImage = static_cast<egl::Image*>(image);
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6733 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6734 | texture->setImage(glImage);
|
| 6735 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 6736 | }
|
| 6737 |
|
Nicolas Capens | 7e12ac6 | 2014-11-05 17:07:53 -0500 | [diff] [blame] | 6738 | void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
|
| 6739 | {
|
| 6740 | TRACE("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image);
|
| 6741 |
|
| 6742 | UNIMPLEMENTED();
|
| 6743 | }
|
| 6744 |
|
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 6745 | __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6746 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6747 | struct Extension
|
| 6748 | {
|
| 6749 | const char *name;
|
| 6750 | __eglMustCastToProperFunctionPointerType address;
|
| 6751 | };
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6752 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6753 | static const Extension glExtensions[] =
|
| 6754 | {
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 6755 | #define EXTENSION(name) {#name, (__eglMustCastToProperFunctionPointerType)name}
|
| 6756 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6757 | EXTENSION(glTexImage3DOES),
|
| 6758 | EXTENSION(glBlitFramebufferANGLE),
|
Alexis Hetu | e9233fb | 2015-02-11 10:31:58 -0500 | [diff] [blame] | 6759 | EXTENSION(glBlitFramebufferNV),
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6760 | EXTENSION(glRenderbufferStorageMultisampleANGLE),
|
| 6761 | EXTENSION(glDeleteFencesNV),
|
| 6762 | EXTENSION(glGenFencesNV),
|
| 6763 | EXTENSION(glIsFenceNV),
|
| 6764 | EXTENSION(glTestFenceNV),
|
| 6765 | EXTENSION(glGetFenceivNV),
|
| 6766 | EXTENSION(glFinishFenceNV),
|
| 6767 | EXTENSION(glSetFenceNV),
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 6768 | EXTENSION(glGetGraphicsResetStatusEXT),
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6769 | EXTENSION(glReadnPixelsEXT),
|
| 6770 | EXTENSION(glGetnUniformfvEXT),
|
| 6771 | EXTENSION(glGetnUniformivEXT),
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 6772 | EXTENSION(glGenQueriesEXT),
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6773 | EXTENSION(glDeleteQueriesEXT),
|
| 6774 | EXTENSION(glIsQueryEXT),
|
| 6775 | EXTENSION(glBeginQueryEXT),
|
| 6776 | EXTENSION(glEndQueryEXT),
|
| 6777 | EXTENSION(glGetQueryivEXT),
|
| 6778 | EXTENSION(glGetQueryObjectuivEXT),
|
| 6779 | EXTENSION(glEGLImageTargetTexture2DOES),
|
Nicolas Capens | 7e12ac6 | 2014-11-05 17:07:53 -0500 | [diff] [blame] | 6780 | EXTENSION(glEGLImageTargetRenderbufferStorageOES),
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 6781 |
|
| 6782 | #undef EXTENSION
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6783 | };
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6784 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6785 | for(int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)
|
| 6786 | {
|
| 6787 | if(strcmp(procname, glExtensions[ext].name) == 0)
|
| 6788 | {
|
| 6789 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
|
| 6790 | }
|
| 6791 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6792 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6793 | return NULL;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6794 | }
|
| 6795 |
|
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 6796 | void GL_APIENTRY Register(const char *licenseKey)
|
| 6797 | {
|
| 6798 | RegisterLicenseKey(licenseKey);
|
| 6799 | }
|
| 6800 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6801 | }
|