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"
|
| 27 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 28 | #include <GLES2/gl2.h>
|
| 29 | #include <GLES2/gl2ext.h>
|
Alexis Hetu | fceb183 | 2015-03-10 16:42:04 -0400 | [diff] [blame] | 30 | #include <GLES3/gl3.h>
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 31 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 32 | #include <limits>
|
| 33 |
|
Greg Hartman | 6074f12 | 2015-04-08 09:57:16 -0700 | [diff] [blame] | 34 | #ifdef ANDROID
|
| 35 | #include <cutils/log.h>
|
| 36 | #endif
|
| 37 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 38 | namespace es2
|
| 39 | {
|
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 40 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 41 | typedef std::pair<GLenum, GLenum> InternalFormatTypePair;
|
| 42 | typedef std::map<InternalFormatTypePair, GLenum> FormatMap;
|
| 43 |
|
| 44 | // A helper function to insert data into the format map with fewer characters.
|
| 45 | static void InsertFormatMapping(FormatMap& map, GLenum internalformat, GLenum format, GLenum type)
|
| 46 | {
|
| 47 | map[InternalFormatTypePair(internalformat, type)] = format;
|
| 48 | }
|
| 49 |
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 50 | static bool validImageSize(GLint level, GLsizei width, GLsizei height)
|
| 51 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 52 | if(level < 0 || level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0)
|
| 53 | {
|
| 54 | return false;
|
| 55 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 56 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 57 | return true;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 58 | }
|
| 59 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 60 | static bool validateColorBufferFormat(GLenum textureFormat, GLenum colorbufferFormat)
|
| 61 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 62 | GLenum validationError = ValidateCompressedFormat(textureFormat, egl::getClientVersion(), false);
|
| 63 | if(validationError != GL_NONE)
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 64 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 65 | return error(validationError, false);
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 66 | }
|
| 67 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 68 | // [OpenGL ES 2.0.24] table 3.9
|
| 69 | switch(textureFormat)
|
| 70 | {
|
| 71 | case GL_ALPHA:
|
| 72 | if(colorbufferFormat != GL_ALPHA &&
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 73 | colorbufferFormat != GL_RGBA &&
|
| 74 | colorbufferFormat != GL_RGBA4 &&
|
| 75 | colorbufferFormat != GL_RGB5_A1 &&
|
| 76 | colorbufferFormat != GL_RGBA8_OES)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 77 | {
|
| 78 | return error(GL_INVALID_OPERATION, false);
|
| 79 | }
|
| 80 | break;
|
| 81 | case GL_LUMINANCE:
|
| 82 | case GL_RGB:
|
| 83 | if(colorbufferFormat != GL_RGB &&
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 84 | colorbufferFormat != GL_RGB565 &&
|
| 85 | colorbufferFormat != GL_RGB8_OES &&
|
| 86 | colorbufferFormat != GL_RGBA &&
|
| 87 | colorbufferFormat != GL_RGBA4 &&
|
| 88 | colorbufferFormat != GL_RGB5_A1 &&
|
| 89 | colorbufferFormat != GL_RGBA8_OES)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 90 | {
|
| 91 | return error(GL_INVALID_OPERATION, false);
|
| 92 | }
|
| 93 | break;
|
| 94 | case GL_LUMINANCE_ALPHA:
|
| 95 | case GL_RGBA:
|
| 96 | if(colorbufferFormat != GL_RGBA &&
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 97 | colorbufferFormat != GL_RGBA4 &&
|
| 98 | colorbufferFormat != GL_RGB5_A1 &&
|
| 99 | colorbufferFormat != GL_RGBA8_OES)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 100 | {
|
| 101 | return error(GL_INVALID_OPERATION, false);
|
| 102 | }
|
| 103 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 104 | case GL_DEPTH_COMPONENT:
|
| 105 | case GL_DEPTH_STENCIL_OES:
|
| 106 | return error(GL_INVALID_OPERATION, false);
|
| 107 | default:
|
| 108 | return error(GL_INVALID_ENUM, false);
|
| 109 | }
|
| 110 | return true;
|
| 111 | }
|
| 112 |
|
| 113 | static FormatMap BuildFormatMap3D()
|
| 114 | {
|
| 115 | FormatMap map;
|
| 116 |
|
| 117 | // Internal format | Format | Type
|
| 118 | InsertFormatMapping(map, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE);
|
| 119 | InsertFormatMapping(map, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
|
| 120 | InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 121 | InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
|
| 122 | InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
|
| 123 | InsertFormatMapping(map, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
|
| 124 | InsertFormatMapping(map, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE);
|
| 125 | InsertFormatMapping(map, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE);
|
| 126 | InsertFormatMapping(map, GL_R8_EXT, GL_RED_EXT, GL_UNSIGNED_BYTE);
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 127 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_HALF_FLOAT);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 128 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_HALF_FLOAT_OES);
|
| 129 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_FLOAT);
|
| 130 | InsertFormatMapping(map, GL_R32F_EXT, GL_RED_EXT, GL_FLOAT);
|
| 131 | InsertFormatMapping(map, GL_RG8_EXT, GL_RG_EXT, GL_UNSIGNED_BYTE);
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 132 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_HALF_FLOAT);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 133 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_HALF_FLOAT_OES);
|
| 134 | InsertFormatMapping(map, GL_R16F_EXT, GL_RED_EXT, GL_FLOAT);
|
| 135 | InsertFormatMapping(map, GL_RG32F_EXT, GL_RG_EXT, GL_FLOAT);
|
| 136 | InsertFormatMapping(map, GL_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE);
|
| 137 | InsertFormatMapping(map, GL_SRGB8_NV, GL_RGB, GL_UNSIGNED_BYTE);
|
| 138 | InsertFormatMapping(map, GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE);
|
| 139 | InsertFormatMapping(map, GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 140 | InsertFormatMapping(map, GL_RGB16F_EXT, GL_RGB, GL_HALF_FLOAT);
|
Alexis Hetu | 0300e3c | 2015-03-12 17:33:07 -0400 | [diff] [blame] | 141 | InsertFormatMapping(map, GL_RGB16F_EXT, GL_RGB, GL_HALF_FLOAT_OES);
|
| 142 | InsertFormatMapping(map, GL_RGB16F_EXT, GL_RGB, GL_FLOAT);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 143 | InsertFormatMapping(map, GL_RGB32F_EXT, GL_RGB, GL_FLOAT);
|
| 144 | InsertFormatMapping(map, GL_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 145 | InsertFormatMapping(map, GL_SRGB8_ALPHA8_EXT, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 146 | InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 147 | InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
|
| 148 | InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV_EXT);
|
| 149 | InsertFormatMapping(map, GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE);
|
| 150 | InsertFormatMapping(map, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
|
| 151 | InsertFormatMapping(map, GL_RGB10_A2_EXT, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV_EXT);
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 152 | InsertFormatMapping(map, GL_RGBA16F_EXT, GL_RGBA, GL_HALF_FLOAT);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 153 | InsertFormatMapping(map, GL_RGBA16F_EXT, GL_RGBA, GL_HALF_FLOAT_OES);
|
| 154 | InsertFormatMapping(map, GL_RGBA16F_EXT, GL_RGBA, GL_FLOAT);
|
| 155 | InsertFormatMapping(map, GL_RGBA32F_EXT, GL_RGBA, GL_FLOAT);
|
| 156 |
|
| 157 | return map;
|
| 158 | }
|
| 159 |
|
| 160 | static bool ValidateType3D(GLenum type)
|
| 161 | {
|
| 162 | switch(type)
|
| 163 | {
|
| 164 | case GL_UNSIGNED_BYTE:
|
| 165 | case GL_BYTE:
|
| 166 | case GL_UNSIGNED_SHORT:
|
| 167 | case GL_SHORT:
|
| 168 | case GL_UNSIGNED_INT:
|
| 169 | case GL_INT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 170 | case GL_HALF_FLOAT:
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 171 | case GL_HALF_FLOAT_OES:
|
| 172 | case GL_FLOAT:
|
| 173 | case GL_UNSIGNED_SHORT_5_6_5:
|
| 174 | case GL_UNSIGNED_SHORT_4_4_4_4:
|
| 175 | case GL_UNSIGNED_SHORT_5_5_5_1:
|
| 176 | case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
|
| 177 | return true;
|
| 178 | default:
|
| 179 | break;
|
| 180 | }
|
| 181 | return false;
|
| 182 | }
|
| 183 |
|
| 184 | static bool ValidateFormat3D(GLenum format)
|
| 185 | {
|
| 186 | switch(format)
|
| 187 | {
|
| 188 | case GL_RED_EXT:
|
| 189 | case GL_RG_EXT:
|
| 190 | case GL_RGB:
|
| 191 | case GL_RGBA:
|
| 192 | case GL_DEPTH_COMPONENT:
|
| 193 | case GL_DEPTH_STENCIL_OES:
|
| 194 | case GL_LUMINANCE_ALPHA:
|
| 195 | case GL_LUMINANCE:
|
| 196 | case GL_ALPHA:
|
| 197 | return true;
|
| 198 | default:
|
| 199 | break;
|
| 200 | }
|
| 201 | return false;
|
| 202 | }
|
| 203 |
|
| 204 | static bool ValidateInternalFormat3D(GLenum internalformat, GLenum format, GLenum type)
|
| 205 | {
|
| 206 | static const FormatMap formatMap = BuildFormatMap3D();
|
| 207 | FormatMap::const_iterator iter = formatMap.find(InternalFormatTypePair(internalformat, type));
|
| 208 | if(iter != formatMap.end())
|
| 209 | {
|
| 210 | return iter->second == format;
|
| 211 | }
|
| 212 | return false;
|
| 213 | }
|
| 214 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 215 | void ActiveTexture(GLenum texture)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 216 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 217 | TRACE("(GLenum texture = 0x%X)", texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 218 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 219 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 220 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 221 | if(context)
|
| 222 | {
|
| 223 | if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + es2::MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)
|
| 224 | {
|
| 225 | return error(GL_INVALID_ENUM);
|
| 226 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 227 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 228 | context->setActiveSampler(texture - GL_TEXTURE0);
|
| 229 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 230 | }
|
| 231 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 232 | void AttachShader(GLuint program, GLuint shader)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 233 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 234 | TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 235 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 236 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 237 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 238 | if(context)
|
| 239 | {
|
| 240 | es2::Program *programObject = context->getProgram(program);
|
| 241 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 242 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 243 | if(!programObject)
|
| 244 | {
|
| 245 | if(context->getShader(program))
|
| 246 | {
|
| 247 | return error(GL_INVALID_OPERATION);
|
| 248 | }
|
| 249 | else
|
| 250 | {
|
| 251 | return error(GL_INVALID_VALUE);
|
| 252 | }
|
| 253 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 254 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 255 | if(!shaderObject)
|
| 256 | {
|
| 257 | if(context->getProgram(shader))
|
| 258 | {
|
| 259 | return error(GL_INVALID_OPERATION);
|
| 260 | }
|
| 261 | else
|
| 262 | {
|
| 263 | return error(GL_INVALID_VALUE);
|
| 264 | }
|
| 265 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 266 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 267 | if(!programObject->attachShader(shaderObject))
|
| 268 | {
|
| 269 | return error(GL_INVALID_OPERATION);
|
| 270 | }
|
| 271 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 272 | }
|
| 273 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 274 | void BeginQueryEXT(GLenum target, GLuint name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 275 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 276 | TRACE("(GLenum target = 0x%X, GLuint name = %d)", target, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 277 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 278 | switch(target)
|
| 279 | {
|
| 280 | case GL_ANY_SAMPLES_PASSED_EXT:
|
| 281 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
|
| 282 | break;
|
| 283 | default:
|
| 284 | return error(GL_INVALID_ENUM);
|
| 285 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 286 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 287 | if(name == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 288 | {
|
| 289 | return error(GL_INVALID_OPERATION);
|
| 290 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 291 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 292 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 293 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 294 | if(context)
|
| 295 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 296 | context->beginQuery(target, name);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 297 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 298 | }
|
| 299 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 300 | void BindAttribLocation(GLuint program, GLuint index, const GLchar* name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 301 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 302 | 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] | 303 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 304 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 305 | {
|
| 306 | return error(GL_INVALID_VALUE);
|
| 307 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 308 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 309 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 310 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 311 | if(context)
|
| 312 | {
|
| 313 | es2::Program *programObject = context->getProgram(program);
|
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 | if(!programObject)
|
| 316 | {
|
| 317 | if(context->getShader(program))
|
| 318 | {
|
| 319 | return error(GL_INVALID_OPERATION);
|
| 320 | }
|
| 321 | else
|
| 322 | {
|
| 323 | return error(GL_INVALID_VALUE);
|
| 324 | }
|
| 325 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 326 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 327 | if(strncmp(name, "gl_", 3) == 0)
|
| 328 | {
|
| 329 | return error(GL_INVALID_OPERATION);
|
| 330 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 331 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 332 | programObject->bindAttributeLocation(index, name);
|
| 333 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 334 | }
|
| 335 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 336 | void BindBuffer(GLenum target, GLuint buffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 337 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 338 | TRACE("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 339 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 340 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 341 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 342 | if(context)
|
| 343 | {
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 344 | egl::GLint clientVersion = egl::getClientVersion();
|
| 345 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 346 | switch(target)
|
| 347 | {
|
| 348 | case GL_ARRAY_BUFFER:
|
| 349 | context->bindArrayBuffer(buffer);
|
| 350 | return;
|
| 351 | case GL_ELEMENT_ARRAY_BUFFER:
|
| 352 | context->bindElementArrayBuffer(buffer);
|
| 353 | return;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 354 | case GL_COPY_READ_BUFFER:
|
| 355 | if(clientVersion >= 3)
|
| 356 | {
|
| 357 | context->bindCopyReadBuffer(buffer);
|
| 358 | return;
|
| 359 | }
|
| 360 | else return error(GL_INVALID_ENUM);
|
| 361 | case GL_COPY_WRITE_BUFFER:
|
| 362 | if(clientVersion >= 3)
|
| 363 | {
|
| 364 | context->bindCopyWriteBuffer(buffer);
|
| 365 | return;
|
| 366 | }
|
| 367 | else return error(GL_INVALID_ENUM);
|
| 368 | case GL_PIXEL_PACK_BUFFER:
|
| 369 | if(clientVersion >= 3)
|
| 370 | {
|
| 371 | context->bindPixelPackBuffer(buffer);
|
| 372 | return;
|
| 373 | }
|
| 374 | else return error(GL_INVALID_ENUM);
|
| 375 | case GL_PIXEL_UNPACK_BUFFER:
|
| 376 | if(clientVersion >= 3)
|
| 377 | {
|
| 378 | context->bindPixelUnpackBuffer(buffer);
|
| 379 | return;
|
| 380 | }
|
| 381 | else return error(GL_INVALID_ENUM);
|
| 382 | case GL_TRANSFORM_FEEDBACK_BUFFER:
|
| 383 | if(clientVersion >= 3)
|
| 384 | {
|
Alexis Hetu | bcac6ff | 2015-04-22 08:29:22 -0400 | [diff] [blame] | 385 | context->bindTransformFeedbackBuffer(buffer);
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 386 | return;
|
| 387 | }
|
| 388 | else return error(GL_INVALID_ENUM);
|
| 389 | case GL_UNIFORM_BUFFER:
|
| 390 | if(clientVersion >= 3)
|
| 391 | {
|
Alexis Hetu | c2632d2 | 2015-05-01 14:16:47 -0400 | [diff] [blame] | 392 | context->bindGenericUniformBuffer(buffer);
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 393 | return;
|
| 394 | }
|
| 395 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 396 | default:
|
| 397 | return error(GL_INVALID_ENUM);
|
| 398 | }
|
| 399 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 400 | }
|
| 401 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 402 | void BindFramebuffer(GLenum target, GLuint framebuffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 403 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 404 | TRACE("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
|
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(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 407 | {
|
| 408 | return error(GL_INVALID_ENUM);
|
| 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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 412 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 413 | if(context)
|
| 414 | {
|
| 415 | if(target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
|
| 416 | {
|
| 417 | context->bindReadFramebuffer(framebuffer);
|
| 418 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 419 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 420 | if(target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
|
| 421 | {
|
| 422 | context->bindDrawFramebuffer(framebuffer);
|
| 423 | }
|
| 424 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 425 | }
|
| 426 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 427 | void BindRenderbuffer(GLenum target, GLuint renderbuffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 428 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 429 | TRACE("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 430 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 431 | if(target != GL_RENDERBUFFER)
|
| 432 | {
|
| 433 | return error(GL_INVALID_ENUM);
|
| 434 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 435 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 436 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 437 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 438 | if(context)
|
| 439 | {
|
Alexis Hetu | c68dd27 | 2015-12-03 11:29:56 -0500 | [diff] [blame] | 440 | // [OpenGL ES 2.0.25] Section 4.4.3 page 110
|
Alexis Hetu | 2ea6f55 | 2015-12-02 11:49:37 -0500 | [diff] [blame] | 441 | // [OpenGL ES 3.0.4] Section 4.4.2 page 204
|
| 442 | // If renderbuffer is not zero, then the resulting renderbuffer object
|
| 443 | // is a new state vector, initialized with a zero-sized memory buffer.
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 444 | context->bindRenderbuffer(renderbuffer);
|
| 445 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 446 | }
|
| 447 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 448 | void BindTexture(GLenum target, GLuint texture)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 449 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 450 | TRACE("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 451 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 452 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 453 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 454 | if(context)
|
| 455 | {
|
| 456 | es2::Texture *textureObject = context->getTexture(texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 457 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 458 | if(textureObject && textureObject->getTarget() != target && texture != 0)
|
| 459 | {
|
| 460 | return error(GL_INVALID_OPERATION);
|
| 461 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 462 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 463 | egl::GLint clientVersion = context->getClientVersion();
|
| 464 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 465 | switch(target)
|
| 466 | {
|
| 467 | case GL_TEXTURE_2D:
|
| 468 | context->bindTexture2D(texture);
|
Alexis Hetu | 778c28f | 2015-05-11 16:32:19 -0400 | [diff] [blame] | 469 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 470 | case GL_TEXTURE_CUBE_MAP:
|
| 471 | context->bindTextureCubeMap(texture);
|
Alexis Hetu | 778c28f | 2015-05-11 16:32:19 -0400 | [diff] [blame] | 472 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 473 | case GL_TEXTURE_EXTERNAL_OES:
|
| 474 | context->bindTextureExternal(texture);
|
Alexis Hetu | 778c28f | 2015-05-11 16:32:19 -0400 | [diff] [blame] | 475 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 476 | case GL_TEXTURE_2D_ARRAY:
|
| 477 | if(clientVersion < 3)
|
| 478 | {
|
| 479 | return error(GL_INVALID_ENUM);
|
| 480 | }
|
Alexis Hetu | 778c28f | 2015-05-11 16:32:19 -0400 | [diff] [blame] | 481 | context->bindTexture2DArray(texture);
|
| 482 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 483 | case GL_TEXTURE_3D_OES:
|
| 484 | context->bindTexture3D(texture);
|
Alexis Hetu | 778c28f | 2015-05-11 16:32:19 -0400 | [diff] [blame] | 485 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 486 | default:
|
| 487 | return error(GL_INVALID_ENUM);
|
| 488 | }
|
| 489 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 490 | }
|
| 491 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 492 | void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 493 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 494 | TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
|
| 495 | red, green, blue, alpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 496 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 497 | es2::Context* context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 498 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 499 | if(context)
|
| 500 | {
|
| 501 | context->setBlendColor(es2::clamp01(red), es2::clamp01(green), es2::clamp01(blue), es2::clamp01(alpha));
|
| 502 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 503 | }
|
| 504 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 505 | void BlendEquation(GLenum mode)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 506 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 507 | glBlendEquationSeparate(mode, mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 508 | }
|
| 509 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 510 | void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 511 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 512 | TRACE("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 513 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 514 | switch(modeRGB)
|
| 515 | {
|
| 516 | case GL_FUNC_ADD:
|
| 517 | case GL_FUNC_SUBTRACT:
|
| 518 | case GL_FUNC_REVERSE_SUBTRACT:
|
| 519 | case GL_MIN_EXT:
|
| 520 | case GL_MAX_EXT:
|
| 521 | break;
|
| 522 | default:
|
| 523 | return error(GL_INVALID_ENUM);
|
| 524 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 525 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 526 | switch(modeAlpha)
|
| 527 | {
|
| 528 | case GL_FUNC_ADD:
|
| 529 | case GL_FUNC_SUBTRACT:
|
| 530 | case GL_FUNC_REVERSE_SUBTRACT:
|
| 531 | case GL_MIN_EXT:
|
| 532 | case GL_MAX_EXT:
|
| 533 | break;
|
| 534 | default:
|
| 535 | return error(GL_INVALID_ENUM);
|
| 536 | }
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 539 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 540 | if(context)
|
| 541 | {
|
| 542 | context->setBlendEquation(modeRGB, modeAlpha);
|
| 543 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 544 | }
|
| 545 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 546 | void BlendFunc(GLenum sfactor, GLenum dfactor)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 547 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 548 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 549 | }
|
| 550 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 551 | void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 552 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 553 | TRACE("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
|
| 554 | srcRGB, dstRGB, srcAlpha, dstAlpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 555 |
|
Alexis Hetu | ff5e052 | 2015-05-12 16:06:30 -0400 | [diff] [blame] | 556 | egl::GLint clientVersion = egl::getClientVersion();
|
| 557 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 558 | switch(srcRGB)
|
| 559 | {
|
| 560 | case GL_ZERO:
|
| 561 | case GL_ONE:
|
| 562 | case GL_SRC_COLOR:
|
| 563 | case GL_ONE_MINUS_SRC_COLOR:
|
| 564 | case GL_DST_COLOR:
|
| 565 | case GL_ONE_MINUS_DST_COLOR:
|
| 566 | case GL_SRC_ALPHA:
|
| 567 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 568 | case GL_DST_ALPHA:
|
| 569 | case GL_ONE_MINUS_DST_ALPHA:
|
| 570 | case GL_CONSTANT_COLOR:
|
| 571 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 572 | case GL_CONSTANT_ALPHA:
|
| 573 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 574 | case GL_SRC_ALPHA_SATURATE:
|
| 575 | break;
|
| 576 | default:
|
| 577 | return error(GL_INVALID_ENUM);
|
| 578 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 579 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 580 | switch(dstRGB)
|
| 581 | {
|
| 582 | case GL_ZERO:
|
| 583 | case GL_ONE:
|
| 584 | case GL_SRC_COLOR:
|
| 585 | case GL_ONE_MINUS_SRC_COLOR:
|
| 586 | case GL_DST_COLOR:
|
| 587 | case GL_ONE_MINUS_DST_COLOR:
|
| 588 | case GL_SRC_ALPHA:
|
| 589 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 590 | case GL_DST_ALPHA:
|
| 591 | case GL_ONE_MINUS_DST_ALPHA:
|
| 592 | case GL_CONSTANT_COLOR:
|
| 593 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 594 | case GL_CONSTANT_ALPHA:
|
| 595 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 596 | break;
|
Alexis Hetu | ff5e052 | 2015-05-12 16:06:30 -0400 | [diff] [blame] | 597 | case GL_SRC_ALPHA_SATURATE:
|
| 598 | if(clientVersion < 3)
|
| 599 | {
|
| 600 | return error(GL_INVALID_ENUM);
|
| 601 | }
|
| 602 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 603 | default:
|
| 604 | return error(GL_INVALID_ENUM);
|
| 605 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 606 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 607 | switch(srcAlpha)
|
| 608 | {
|
| 609 | case GL_ZERO:
|
| 610 | case GL_ONE:
|
| 611 | case GL_SRC_COLOR:
|
| 612 | case GL_ONE_MINUS_SRC_COLOR:
|
| 613 | case GL_DST_COLOR:
|
| 614 | case GL_ONE_MINUS_DST_COLOR:
|
| 615 | case GL_SRC_ALPHA:
|
| 616 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 617 | case GL_DST_ALPHA:
|
| 618 | case GL_ONE_MINUS_DST_ALPHA:
|
| 619 | case GL_CONSTANT_COLOR:
|
| 620 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 621 | case GL_CONSTANT_ALPHA:
|
| 622 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 623 | case GL_SRC_ALPHA_SATURATE:
|
| 624 | break;
|
| 625 | default:
|
| 626 | return error(GL_INVALID_ENUM);
|
| 627 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 628 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 629 | switch(dstAlpha)
|
| 630 | {
|
| 631 | case GL_ZERO:
|
| 632 | case GL_ONE:
|
| 633 | case GL_SRC_COLOR:
|
| 634 | case GL_ONE_MINUS_SRC_COLOR:
|
| 635 | case GL_DST_COLOR:
|
| 636 | case GL_ONE_MINUS_DST_COLOR:
|
| 637 | case GL_SRC_ALPHA:
|
| 638 | case GL_ONE_MINUS_SRC_ALPHA:
|
| 639 | case GL_DST_ALPHA:
|
| 640 | case GL_ONE_MINUS_DST_ALPHA:
|
| 641 | case GL_CONSTANT_COLOR:
|
| 642 | case GL_ONE_MINUS_CONSTANT_COLOR:
|
| 643 | case GL_CONSTANT_ALPHA:
|
| 644 | case GL_ONE_MINUS_CONSTANT_ALPHA:
|
| 645 | break;
|
Alexis Hetu | ff5e052 | 2015-05-12 16:06:30 -0400 | [diff] [blame] | 646 | case GL_SRC_ALPHA_SATURATE:
|
| 647 | if(clientVersion < 3)
|
| 648 | {
|
| 649 | return error(GL_INVALID_ENUM);
|
| 650 | }
|
| 651 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 652 | default:
|
| 653 | return error(GL_INVALID_ENUM);
|
| 654 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 655 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 656 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 657 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 658 | if(context)
|
| 659 | {
|
| 660 | context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
| 661 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 662 | }
|
| 663 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 664 | void BufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
|
Nicolas Capens | 54b721d | 2014-12-12 12:50:04 -0500 | [diff] [blame] | 665 | {
|
| 666 | 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] | 667 |
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 668 | TRACE("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = %p, GLenum usage = %d)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 669 | target, size, data, usage);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 670 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 671 | if(size < 0)
|
| 672 | {
|
| 673 | return error(GL_INVALID_VALUE);
|
| 674 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 675 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 676 | egl::GLint clientVersion = egl::getClientVersion();
|
| 677 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 678 | switch(usage)
|
| 679 | {
|
| 680 | case GL_STREAM_DRAW:
|
| 681 | case GL_STATIC_DRAW:
|
| 682 | case GL_DYNAMIC_DRAW:
|
| 683 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 684 | case GL_STREAM_READ:
|
| 685 | case GL_STREAM_COPY:
|
| 686 | case GL_STATIC_READ:
|
| 687 | case GL_STATIC_COPY:
|
| 688 | case GL_DYNAMIC_READ:
|
| 689 | case GL_DYNAMIC_COPY:
|
| 690 | if(clientVersion < 3)
|
| 691 | {
|
| 692 | return error(GL_INVALID_ENUM);
|
| 693 | }
|
| 694 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 695 | default:
|
| 696 | return error(GL_INVALID_ENUM);
|
| 697 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 698 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 699 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 700 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 701 | if(context)
|
| 702 | {
|
Nicolas Capens | b4d30d9 | 2015-12-04 12:09:28 -0500 | [diff] [blame] | 703 | es2::Buffer *buffer = nullptr;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 704 | if(!context->getBuffer(target, &buffer))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 705 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 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 | if(!buffer)
|
| 710 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 711 | // 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] | 712 | return error(GL_INVALID_OPERATION);
|
| 713 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 714 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 715 | buffer->bufferData(data, size, usage);
|
| 716 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 717 | }
|
| 718 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 719 | void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
|
Nicolas Capens | 54b721d | 2014-12-12 12:50:04 -0500 | [diff] [blame] | 720 | {
|
| 721 | size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
|
| 722 | offset = static_cast<GLint>(offset);
|
Nicolas Capens | 4cadfe3 | 2014-12-10 22:26:26 -0500 | [diff] [blame] | 723 |
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 724 | TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 725 | target, offset, size, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 726 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 727 | if(size < 0 || offset < 0)
|
| 728 | {
|
| 729 | return error(GL_INVALID_VALUE);
|
| 730 | }
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 733 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 734 | if(context)
|
| 735 | {
|
Nicolas Capens | b4d30d9 | 2015-12-04 12:09:28 -0500 | [diff] [blame] | 736 | es2::Buffer *buffer = nullptr;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 737 | if(!context->getBuffer(target, &buffer))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 738 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 739 | return error(GL_INVALID_ENUM);
|
| 740 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 741 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 742 | if(!buffer)
|
| 743 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 744 | // 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] | 745 | return error(GL_INVALID_OPERATION);
|
| 746 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 747 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 748 | if((size_t)size + offset > buffer->size())
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 749 | {
|
| 750 | return error(GL_INVALID_VALUE);
|
| 751 | }
|
| 752 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 753 | buffer->bufferSubData(data, size, offset);
|
| 754 | }
|
| 755 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 756 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 757 | GLenum CheckFramebufferStatus(GLenum target)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 758 | {
|
| 759 | TRACE("(GLenum target = 0x%X)", target);
|
| 760 |
|
| 761 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 762 | {
|
| 763 | return error(GL_INVALID_ENUM, 0);
|
| 764 | }
|
| 765 |
|
| 766 | es2::Context *context = es2::getContext();
|
| 767 |
|
| 768 | if(context)
|
| 769 | {
|
| 770 | es2::Framebuffer *framebuffer = NULL;
|
| 771 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 772 | {
|
| 773 | framebuffer = context->getReadFramebuffer();
|
| 774 | }
|
| 775 | else
|
| 776 | {
|
| 777 | framebuffer = context->getDrawFramebuffer();
|
| 778 | }
|
| 779 |
|
| 780 | return framebuffer->completeness();
|
| 781 | }
|
| 782 |
|
| 783 | return 0;
|
| 784 | }
|
| 785 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 786 | void Clear(GLbitfield mask)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 787 | {
|
| 788 | TRACE("(GLbitfield mask = %X)", mask);
|
| 789 |
|
| 790 | if((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
|
| 791 | {
|
| 792 | return error(GL_INVALID_VALUE);
|
| 793 | }
|
| 794 |
|
| 795 | es2::Context *context = es2::getContext();
|
| 796 |
|
| 797 | if(context)
|
| 798 | {
|
| 799 | context->clear(mask);
|
| 800 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 801 | }
|
| 802 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 803 | void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 804 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 805 | TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
|
| 806 | red, green, blue, alpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 807 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 808 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 809 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 810 | if(context)
|
| 811 | {
|
| 812 | context->setClearColor(red, green, blue, alpha);
|
| 813 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 814 | }
|
| 815 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 816 | void ClearDepthf(GLclampf depth)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 817 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 818 | TRACE("(GLclampf depth = %f)", depth);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 819 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 820 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 821 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 822 | if(context)
|
| 823 | {
|
| 824 | context->setClearDepth(depth);
|
| 825 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 826 | }
|
| 827 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 828 | void ClearStencil(GLint s)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 829 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 830 | TRACE("(GLint s = %d)", s);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 831 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 832 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 833 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 834 | if(context)
|
| 835 | {
|
| 836 | context->setClearStencil(s);
|
| 837 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 838 | }
|
| 839 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 840 | void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 841 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 842 | TRACE("(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)",
|
| 843 | red, green, blue, alpha);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 844 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 845 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 846 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 847 | if(context)
|
| 848 | {
|
| 849 | context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
|
| 850 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 851 | }
|
| 852 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 853 | void CompileShader(GLuint shader)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 854 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 855 | TRACE("(GLuint shader = %d)", shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 856 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 857 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 858 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 859 | if(context)
|
| 860 | {
|
| 861 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 862 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 863 | if(!shaderObject)
|
| 864 | {
|
| 865 | if(context->getProgram(shader))
|
| 866 | {
|
| 867 | return error(GL_INVALID_OPERATION);
|
| 868 | }
|
| 869 | else
|
| 870 | {
|
| 871 | return error(GL_INVALID_VALUE);
|
| 872 | }
|
| 873 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 874 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 875 | shaderObject->compile();
|
| 876 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 877 | }
|
| 878 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 879 | void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
|
| 880 | GLint border, GLsizei imageSize, const GLvoid* data)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 881 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 882 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 883 | "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 884 | target, level, internalformat, width, height, border, imageSize, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 885 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 886 | if(!validImageSize(level, width, height) || border != 0 || imageSize < 0)
|
| 887 | {
|
| 888 | return error(GL_INVALID_VALUE);
|
| 889 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 890 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 891 | switch(internalformat)
|
| 892 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 893 | case GL_DEPTH_COMPONENT:
|
| 894 | case GL_DEPTH_COMPONENT16:
|
| 895 | case GL_DEPTH_COMPONENT32_OES:
|
| 896 | case GL_DEPTH_STENCIL_OES:
|
| 897 | case GL_DEPTH24_STENCIL8_OES:
|
| 898 | return error(GL_INVALID_OPERATION);
|
| 899 | default:
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 900 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 901 | GLenum validationError = ValidateCompressedFormat(internalformat, egl::getClientVersion(), true);
|
| 902 | if(validationError != GL_NONE)
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 903 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 904 | return error(validationError);
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 905 | }
|
| 906 | }
|
| 907 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 908 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 909 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 910 | if(border != 0)
|
| 911 | {
|
| 912 | return error(GL_INVALID_VALUE);
|
| 913 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 914 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 915 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 916 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 917 | if(context)
|
| 918 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 919 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 920 | {
|
| 921 | return error(GL_INVALID_VALUE);
|
| 922 | }
|
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 | switch(target)
|
| 925 | {
|
| 926 | case GL_TEXTURE_2D:
|
| 927 | if(width > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
|
| 928 | height > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
|
| 929 | {
|
| 930 | return error(GL_INVALID_VALUE);
|
| 931 | }
|
| 932 | break;
|
| 933 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 934 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 935 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 936 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 937 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 938 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 939 | if(width != height)
|
| 940 | {
|
| 941 | return error(GL_INVALID_VALUE);
|
| 942 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 943 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 944 | if(width > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
|
| 945 | height > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
|
| 946 | {
|
| 947 | return error(GL_INVALID_VALUE);
|
| 948 | }
|
| 949 | break;
|
| 950 | default:
|
| 951 | return error(GL_INVALID_ENUM);
|
| 952 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 953 |
|
Nicolas Capens | deda34b | 2015-04-28 15:21:53 -0700 | [diff] [blame] | 954 | if(imageSize != egl::ComputeCompressedSize(width, height, internalformat))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 955 | {
|
| 956 | return error(GL_INVALID_VALUE);
|
| 957 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 958 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 959 | if(target == GL_TEXTURE_2D)
|
| 960 | {
|
| 961 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 962 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 963 | if(!texture)
|
| 964 | {
|
| 965 | return error(GL_INVALID_OPERATION);
|
| 966 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 967 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 968 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
|
| 969 | }
|
| 970 | else
|
| 971 | {
|
| 972 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 973 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 974 | if(!texture)
|
| 975 | {
|
| 976 | return error(GL_INVALID_OPERATION);
|
| 977 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 978 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 979 | switch(target)
|
| 980 | {
|
| 981 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 982 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 983 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 984 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 985 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 986 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 987 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
|
| 988 | break;
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 989 | default: UNREACHABLE(target);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 990 | }
|
| 991 | }
|
| 992 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 993 | }
|
| 994 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 995 | void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
| 996 | GLenum format, GLsizei imageSize, const GLvoid* data)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 997 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 998 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 999 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1000 | "GLsizei imageSize = %d, const GLvoid* data = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1001 | target, level, xoffset, yoffset, width, height, format, imageSize, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1002 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1003 | if(!es2::IsTextureTarget(target))
|
| 1004 | {
|
| 1005 | return error(GL_INVALID_ENUM);
|
| 1006 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1007 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1008 | if(xoffset < 0 || yoffset < 0 || !validImageSize(level, width, height) || imageSize < 0)
|
| 1009 | {
|
| 1010 | return error(GL_INVALID_VALUE);
|
| 1011 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1012 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1013 | GLenum validationError = ValidateCompressedFormat(format, egl::getClientVersion(), true);
|
| 1014 | if(validationError != GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1015 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1016 | return error(validationError);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1017 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1018 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1019 | if(width == 0 || height == 0 || data == NULL)
|
| 1020 | {
|
| 1021 | return;
|
| 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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1025 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1026 | if(context)
|
| 1027 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1028 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1029 | {
|
| 1030 | return error(GL_INVALID_VALUE);
|
| 1031 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1032 |
|
Nicolas Capens | deda34b | 2015-04-28 15:21:53 -0700 | [diff] [blame] | 1033 | if(imageSize != egl::ComputeCompressedSize(width, height, format))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1034 | {
|
| 1035 | return error(GL_INVALID_VALUE);
|
| 1036 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1037 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1038 | if(xoffset % 4 != 0 || yoffset % 4 != 0)
|
| 1039 | {
|
| 1040 | // We wait to check the offsets until this point, because the multiple-of-four restriction does not exist unless DXT1 textures are supported
|
| 1041 | return error(GL_INVALID_OPERATION);
|
| 1042 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1043 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1044 | GLenum sizedInternalFormat = GetSizedInternalFormat(format, GL_NONE);
|
| 1045 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1046 | if(target == GL_TEXTURE_2D)
|
| 1047 | {
|
| 1048 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1049 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1050 | GLenum validationError = ValidateSubImageParams(true, width, height, xoffset, yoffset, target, level, sizedInternalFormat, texture);
|
| 1051 |
|
| 1052 | if(validationError == GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1053 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1054 | texture->subImageCompressed(level, xoffset, yoffset, width, height, sizedInternalFormat, imageSize, data);
|
| 1055 | }
|
| 1056 | else
|
| 1057 | {
|
| 1058 | return error(validationError);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1059 | }
|
| 1060 | }
|
| 1061 | else if(es2::IsCubemapTextureTarget(target))
|
| 1062 | {
|
| 1063 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1064 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1065 | GLenum validationError = ValidateSubImageParams(true, width, height, xoffset, yoffset, target, level, sizedInternalFormat, texture);
|
| 1066 |
|
| 1067 | if(validationError == GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1068 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1069 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, sizedInternalFormat, imageSize, data);
|
| 1070 | }
|
| 1071 | else
|
| 1072 | {
|
| 1073 | return error(validationError);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1074 | }
|
| 1075 | }
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 1076 | else UNREACHABLE(target);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1077 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1078 | }
|
| 1079 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1080 | void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1081 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1082 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
|
| 1083 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
|
| 1084 | target, level, internalformat, x, y, width, height, border);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1085 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1086 | if(!validImageSize(level, width, height))
|
| 1087 | {
|
| 1088 | return error(GL_INVALID_VALUE);
|
| 1089 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1090 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1091 | if(border != 0)
|
| 1092 | {
|
| 1093 | return error(GL_INVALID_VALUE);
|
| 1094 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1095 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1096 | es2::Context *context = es2::getContext();
|
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 | if(context)
|
| 1099 | {
|
| 1100 | switch(target)
|
| 1101 | {
|
| 1102 | case GL_TEXTURE_2D:
|
| 1103 | if(width > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
|
| 1104 | height > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
|
| 1105 | {
|
| 1106 | return error(GL_INVALID_VALUE);
|
| 1107 | }
|
| 1108 | break;
|
| 1109 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 1110 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 1111 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 1112 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 1113 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 1114 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 1115 | if(width != height)
|
| 1116 | {
|
| 1117 | return error(GL_INVALID_VALUE);
|
| 1118 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1119 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1120 | if(width > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
|
| 1121 | height > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
|
| 1122 | {
|
| 1123 | return error(GL_INVALID_VALUE);
|
| 1124 | }
|
| 1125 | break;
|
| 1126 | default:
|
| 1127 | return error(GL_INVALID_ENUM);
|
| 1128 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1129 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1130 | es2::Framebuffer *framebuffer = context->getReadFramebuffer();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1131 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1132 | if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
|
| 1133 | {
|
| 1134 | return error(GL_INVALID_FRAMEBUFFER_OPERATION);
|
| 1135 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1136 |
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 1137 | es2::Renderbuffer *source = framebuffer->getReadColorbuffer();
|
| 1138 |
|
| 1139 | if(context->getReadFramebufferName() != 0 && (!source || source->getSamples() > 1))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1140 | {
|
| 1141 | return error(GL_INVALID_OPERATION);
|
| 1142 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1143 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1144 | GLenum colorbufferFormat = source->getFormat();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1145 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1146 | if(!validateColorBufferFormat(internalformat, colorbufferFormat))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1147 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1148 | return;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1149 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1150 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1151 | if(target == GL_TEXTURE_2D)
|
| 1152 | {
|
| 1153 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1154 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1155 | if(!texture)
|
| 1156 | {
|
| 1157 | return error(GL_INVALID_OPERATION);
|
| 1158 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1159 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1160 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
|
| 1161 | }
|
| 1162 | else if(es2::IsCubemapTextureTarget(target))
|
| 1163 | {
|
| 1164 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
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(!texture)
|
| 1167 | {
|
| 1168 | return error(GL_INVALID_OPERATION);
|
| 1169 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1170 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1171 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
|
| 1172 | }
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 1173 | else UNREACHABLE(target);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1174 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1175 | }
|
| 1176 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1177 | void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1178 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1179 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 1180 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
|
| 1181 | target, level, xoffset, yoffset, x, y, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1182 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1183 | if(!es2::IsTextureTarget(target))
|
| 1184 | {
|
| 1185 | return error(GL_INVALID_ENUM);
|
| 1186 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1187 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1188 | if(level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
|
| 1189 | {
|
| 1190 | return error(GL_INVALID_VALUE);
|
| 1191 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1192 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1193 | if(std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
|
| 1194 | {
|
| 1195 | return error(GL_INVALID_VALUE);
|
| 1196 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1197 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1198 | if(width == 0 || height == 0)
|
| 1199 | {
|
| 1200 | return;
|
| 1201 | }
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1204 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1205 | if(context)
|
| 1206 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1207 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1208 | {
|
| 1209 | return error(GL_INVALID_VALUE);
|
| 1210 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1211 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1212 | es2::Framebuffer *framebuffer = context->getReadFramebuffer();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1213 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1214 | if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
|
| 1215 | {
|
| 1216 | return error(GL_INVALID_FRAMEBUFFER_OPERATION);
|
| 1217 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1218 |
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 1219 | es2::Renderbuffer *source = framebuffer->getReadColorbuffer();
|
| 1220 |
|
| 1221 | if(context->getReadFramebufferName() != 0 && (!source || source->getSamples() > 1))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1222 | {
|
| 1223 | return error(GL_INVALID_OPERATION);
|
| 1224 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1225 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1226 | es2::Texture *texture = NULL;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1227 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1228 | if(target == GL_TEXTURE_2D)
|
| 1229 | {
|
| 1230 | texture = context->getTexture2D();
|
| 1231 | }
|
| 1232 | else if(es2::IsCubemapTextureTarget(target))
|
| 1233 | {
|
| 1234 | texture = context->getTextureCubeMap();
|
| 1235 | }
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 1236 | else UNREACHABLE(target);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1237 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1238 | GLenum validationError = ValidateSubImageParams(false, width, height, xoffset, yoffset, target, level, GL_NONE, texture);
|
| 1239 | if(validationError != GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1240 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 1241 | return error(validationError);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1242 | }
|
| 1243 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 1244 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1245 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1246 | }
|
| 1247 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1248 | GLuint CreateProgram(void)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1249 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1250 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1251 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1252 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1253 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1254 | if(context)
|
| 1255 | {
|
| 1256 | return context->createProgram();
|
| 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 | return 0;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1260 | }
|
| 1261 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1262 | GLuint CreateShader(GLenum type)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1263 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1264 | TRACE("(GLenum type = 0x%X)", type);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1265 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1266 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1267 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1268 | if(context)
|
| 1269 | {
|
| 1270 | switch(type)
|
| 1271 | {
|
| 1272 | case GL_FRAGMENT_SHADER:
|
| 1273 | case GL_VERTEX_SHADER:
|
| 1274 | return context->createShader(type);
|
| 1275 | default:
|
| 1276 | return error(GL_INVALID_ENUM, 0);
|
| 1277 | }
|
| 1278 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1279 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1280 | return 0;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1281 | }
|
| 1282 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1283 | void CullFace(GLenum mode)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1284 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1285 | TRACE("(GLenum mode = 0x%X)", mode);
|
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 | switch(mode)
|
| 1288 | {
|
| 1289 | case GL_FRONT:
|
| 1290 | case GL_BACK:
|
| 1291 | case GL_FRONT_AND_BACK:
|
| 1292 | {
|
| 1293 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1294 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1295 | if(context)
|
| 1296 | {
|
| 1297 | context->setCullMode(mode);
|
| 1298 | }
|
| 1299 | }
|
| 1300 | break;
|
| 1301 | default:
|
| 1302 | return error(GL_INVALID_ENUM);
|
| 1303 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1304 | }
|
| 1305 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1306 | void DeleteBuffers(GLsizei n, const GLuint* buffers)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1307 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1308 | TRACE("(GLsizei n = %d, const GLuint* buffers = %p)", n, buffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1309 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1310 | if(n < 0)
|
| 1311 | {
|
| 1312 | return error(GL_INVALID_VALUE);
|
| 1313 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1314 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1315 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1316 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1317 | if(context)
|
| 1318 | {
|
| 1319 | for(int i = 0; i < n; i++)
|
| 1320 | {
|
| 1321 | context->deleteBuffer(buffers[i]);
|
| 1322 | }
|
| 1323 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1324 | }
|
| 1325 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1326 | void DeleteFencesNV(GLsizei n, const GLuint* fences)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1327 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1328 | TRACE("(GLsizei n = %d, const GLuint* fences = %p)", n, fences);
|
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(n < 0)
|
| 1331 | {
|
| 1332 | return error(GL_INVALID_VALUE);
|
| 1333 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1334 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1335 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1336 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1337 | if(context)
|
| 1338 | {
|
| 1339 | for(int i = 0; i < n; i++)
|
| 1340 | {
|
| 1341 | context->deleteFence(fences[i]);
|
| 1342 | }
|
| 1343 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1344 | }
|
| 1345 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1346 | void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1347 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1348 | TRACE("(GLsizei n = %d, const GLuint* framebuffers = %p)", n, framebuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1349 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1350 | if(n < 0)
|
| 1351 | {
|
| 1352 | return error(GL_INVALID_VALUE);
|
| 1353 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1354 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1355 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1356 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1357 | if(context)
|
| 1358 | {
|
| 1359 | for(int i = 0; i < n; i++)
|
| 1360 | {
|
| 1361 | if(framebuffers[i] != 0)
|
| 1362 | {
|
| 1363 | context->deleteFramebuffer(framebuffers[i]);
|
| 1364 | }
|
| 1365 | }
|
| 1366 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1367 | }
|
| 1368 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1369 | void DeleteProgram(GLuint program)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1370 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1371 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1372 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1373 | if(program == 0)
|
| 1374 | {
|
| 1375 | return;
|
| 1376 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1377 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1378 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1379 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1380 | if(context)
|
| 1381 | {
|
| 1382 | if(!context->getProgram(program))
|
| 1383 | {
|
| 1384 | if(context->getShader(program))
|
| 1385 | {
|
| 1386 | return error(GL_INVALID_OPERATION);
|
| 1387 | }
|
| 1388 | else
|
| 1389 | {
|
| 1390 | return error(GL_INVALID_VALUE);
|
| 1391 | }
|
| 1392 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1393 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1394 | context->deleteProgram(program);
|
| 1395 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1396 | }
|
| 1397 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1398 | void DeleteQueriesEXT(GLsizei n, const GLuint *ids)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1399 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1400 | TRACE("(GLsizei n = %d, const GLuint *ids = %p)", n, ids);
|
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 | if(n < 0)
|
| 1403 | {
|
| 1404 | return error(GL_INVALID_VALUE);
|
| 1405 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1406 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1407 | es2::Context *context = es2::getContext();
|
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 | if(context)
|
| 1410 | {
|
| 1411 | for(int i = 0; i < n; i++)
|
| 1412 | {
|
| 1413 | context->deleteQuery(ids[i]);
|
| 1414 | }
|
| 1415 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1416 | }
|
| 1417 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1418 | void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1419 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1420 | TRACE("(GLsizei n = %d, const GLuint* renderbuffers = %p)", n, renderbuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1421 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1422 | if(n < 0)
|
| 1423 | {
|
| 1424 | return error(GL_INVALID_VALUE);
|
| 1425 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1426 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1427 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1428 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1429 | if(context)
|
| 1430 | {
|
| 1431 | for(int i = 0; i < n; i++)
|
| 1432 | {
|
| 1433 | context->deleteRenderbuffer(renderbuffers[i]);
|
| 1434 | }
|
| 1435 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1436 | }
|
| 1437 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1438 | void DeleteShader(GLuint shader)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1439 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1440 | TRACE("(GLuint shader = %d)", shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1441 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1442 | if(shader == 0)
|
| 1443 | {
|
| 1444 | return;
|
| 1445 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1446 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1447 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1448 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1449 | if(context)
|
| 1450 | {
|
| 1451 | if(!context->getShader(shader))
|
| 1452 | {
|
| 1453 | if(context->getProgram(shader))
|
| 1454 | {
|
| 1455 | return error(GL_INVALID_OPERATION);
|
| 1456 | }
|
| 1457 | else
|
| 1458 | {
|
| 1459 | return error(GL_INVALID_VALUE);
|
| 1460 | }
|
| 1461 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1462 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1463 | context->deleteShader(shader);
|
| 1464 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1465 | }
|
| 1466 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1467 | void DeleteTextures(GLsizei n, const GLuint* textures)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1468 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1469 | TRACE("(GLsizei n = %d, const GLuint* textures = %p)", n, textures);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1470 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1471 | if(n < 0)
|
| 1472 | {
|
| 1473 | return error(GL_INVALID_VALUE);
|
| 1474 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1475 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1476 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1477 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1478 | if(context)
|
| 1479 | {
|
| 1480 | for(int i = 0; i < n; i++)
|
| 1481 | {
|
| 1482 | if(textures[i] != 0)
|
| 1483 | {
|
| 1484 | context->deleteTexture(textures[i]);
|
| 1485 | }
|
| 1486 | }
|
| 1487 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1488 | }
|
| 1489 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1490 | void DepthFunc(GLenum func)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1491 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1492 | TRACE("(GLenum func = 0x%X)", func);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1493 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1494 | switch(func)
|
| 1495 | {
|
| 1496 | case GL_NEVER:
|
| 1497 | case GL_ALWAYS:
|
| 1498 | case GL_LESS:
|
| 1499 | case GL_LEQUAL:
|
| 1500 | case GL_EQUAL:
|
| 1501 | case GL_GREATER:
|
| 1502 | case GL_GEQUAL:
|
| 1503 | case GL_NOTEQUAL:
|
| 1504 | break;
|
| 1505 | default:
|
| 1506 | return error(GL_INVALID_ENUM);
|
| 1507 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1508 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1509 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1510 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1511 | if(context)
|
| 1512 | {
|
| 1513 | context->setDepthFunc(func);
|
| 1514 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1515 | }
|
| 1516 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1517 | void DepthMask(GLboolean flag)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1518 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1519 | TRACE("(GLboolean flag = %d)", flag);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1520 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1521 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1522 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1523 | if(context)
|
| 1524 | {
|
| 1525 | context->setDepthMask(flag != GL_FALSE);
|
| 1526 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1527 | }
|
| 1528 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1529 | void DepthRangef(GLclampf zNear, GLclampf zFar)
|
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 | TRACE("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1532 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1533 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1534 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1535 | if(context)
|
| 1536 | {
|
| 1537 | context->setDepthRange(zNear, zFar);
|
| 1538 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1539 | }
|
| 1540 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1541 | void DetachShader(GLuint program, GLuint shader)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1542 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1543 | TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1544 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1545 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1546 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1547 | if(context)
|
| 1548 | {
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1549 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1550 | es2::Program *programObject = context->getProgram(program);
|
| 1551 | es2::Shader *shaderObject = context->getShader(shader);
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 1552 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1553 | if(!programObject)
|
| 1554 | {
|
| 1555 | es2::Shader *shaderByProgramHandle;
|
| 1556 | shaderByProgramHandle = context->getShader(program);
|
| 1557 | if(!shaderByProgramHandle)
|
| 1558 | {
|
| 1559 | return error(GL_INVALID_VALUE);
|
| 1560 | }
|
| 1561 | else
|
| 1562 | {
|
| 1563 | return error(GL_INVALID_OPERATION);
|
| 1564 | }
|
| 1565 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1566 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1567 | if(!shaderObject)
|
| 1568 | {
|
| 1569 | es2::Program *programByShaderHandle = context->getProgram(shader);
|
| 1570 | if(!programByShaderHandle)
|
| 1571 | {
|
| 1572 | return error(GL_INVALID_VALUE);
|
| 1573 | }
|
| 1574 | else
|
| 1575 | {
|
| 1576 | return error(GL_INVALID_OPERATION);
|
| 1577 | }
|
| 1578 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1579 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1580 | if(!programObject->detachShader(shaderObject))
|
| 1581 | {
|
| 1582 | return error(GL_INVALID_OPERATION);
|
| 1583 | }
|
| 1584 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1585 | }
|
| 1586 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1587 | void Disable(GLenum cap)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1588 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1589 | TRACE("(GLenum cap = 0x%X)", cap);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1590 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1591 | es2::Context *context = es2::getContext();
|
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(context)
|
| 1594 | {
|
| 1595 | switch(cap)
|
| 1596 | {
|
Nicolas Capens | d55a095 | 2015-08-03 16:36:58 -0400 | [diff] [blame] | 1597 | case GL_CULL_FACE: context->setCullFaceEnabled(false); break;
|
| 1598 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFillEnabled(false); break;
|
| 1599 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverageEnabled(false); break;
|
| 1600 | case GL_SAMPLE_COVERAGE: context->setSampleCoverageEnabled(false); break;
|
| 1601 | case GL_SCISSOR_TEST: context->setScissorTestEnabled(false); break;
|
| 1602 | case GL_STENCIL_TEST: context->setStencilTestEnabled(false); break;
|
| 1603 | case GL_DEPTH_TEST: context->setDepthTestEnabled(false); break;
|
| 1604 | case GL_BLEND: context->setBlendEnabled(false); break;
|
| 1605 | case GL_DITHER: context->setDitherEnabled(false); break;
|
| 1606 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: context->setPrimitiveRestartFixedIndexEnabled(false); break;
|
| 1607 | case GL_RASTERIZER_DISCARD: context->setRasterizerDiscardEnabled(false); break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1608 | default:
|
| 1609 | return error(GL_INVALID_ENUM);
|
| 1610 | }
|
| 1611 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1612 | }
|
| 1613 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1614 | void DisableVertexAttribArray(GLuint index)
|
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 | TRACE("(GLuint index = %d)", index);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1617 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1618 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 1619 | {
|
| 1620 | return error(GL_INVALID_VALUE);
|
| 1621 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1622 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1623 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1624 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1625 | if(context)
|
| 1626 | {
|
Nicolas Capens | d55a095 | 2015-08-03 16:36:58 -0400 | [diff] [blame] | 1627 | context->setVertexAttribArrayEnabled(index, false);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1628 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1629 | }
|
| 1630 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1631 | void DrawArrays(GLenum mode, GLint first, GLsizei count)
|
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 | 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] | 1634 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 1635 | switch(mode)
|
| 1636 | {
|
| 1637 | case GL_POINTS:
|
| 1638 | case GL_LINES:
|
| 1639 | case GL_LINE_LOOP:
|
| 1640 | case GL_LINE_STRIP:
|
| 1641 | case GL_TRIANGLES:
|
| 1642 | case GL_TRIANGLE_FAN:
|
| 1643 | case GL_TRIANGLE_STRIP:
|
| 1644 | break;
|
| 1645 | default:
|
| 1646 | return error(GL_INVALID_ENUM);
|
| 1647 | }
|
| 1648 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1649 | if(count < 0 || first < 0)
|
| 1650 | {
|
| 1651 | return error(GL_INVALID_VALUE);
|
| 1652 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1653 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1654 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1655 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1656 | if(context)
|
| 1657 | {
|
Alexis Hetu | bcac6ff | 2015-04-22 08:29:22 -0400 | [diff] [blame] | 1658 | es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
|
| 1659 | if(transformFeedback && transformFeedback->isActive() && (mode != transformFeedback->primitiveMode()))
|
| 1660 | {
|
| 1661 | return error(GL_INVALID_OPERATION);
|
| 1662 | }
|
| 1663 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1664 | context->drawArrays(mode, first, count);
|
| 1665 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1666 | }
|
| 1667 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1668 | void DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1669 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1670 | TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1671 | mode, count, type, indices);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1672 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 1673 | switch(mode)
|
| 1674 | {
|
| 1675 | case GL_POINTS:
|
| 1676 | case GL_LINES:
|
| 1677 | case GL_LINE_LOOP:
|
| 1678 | case GL_LINE_STRIP:
|
| 1679 | case GL_TRIANGLES:
|
| 1680 | case GL_TRIANGLE_FAN:
|
| 1681 | case GL_TRIANGLE_STRIP:
|
| 1682 | break;
|
| 1683 | default:
|
| 1684 | return error(GL_INVALID_ENUM);
|
| 1685 | }
|
| 1686 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1687 | if(count < 0)
|
| 1688 | {
|
| 1689 | return error(GL_INVALID_VALUE);
|
| 1690 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1691 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1692 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1693 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1694 | if(context)
|
| 1695 | {
|
Alexis Hetu | bcac6ff | 2015-04-22 08:29:22 -0400 | [diff] [blame] | 1696 | es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
|
| 1697 | if(transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused())
|
| 1698 | {
|
| 1699 | return error(GL_INVALID_OPERATION);
|
| 1700 | }
|
| 1701 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1702 | switch(type)
|
| 1703 | {
|
| 1704 | case GL_UNSIGNED_BYTE:
|
| 1705 | case GL_UNSIGNED_SHORT:
|
| 1706 | case GL_UNSIGNED_INT:
|
| 1707 | break;
|
| 1708 | default:
|
| 1709 | return error(GL_INVALID_ENUM);
|
| 1710 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 1711 |
|
Nicolas Capens | 22d0766 | 2015-04-25 11:34:50 -0700 | [diff] [blame] | 1712 | context->drawElements(mode, 0, MAX_ELEMENT_INDEX, count, type, indices);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1713 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1714 | }
|
| 1715 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1716 | void DrawArraysInstancedEXT(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
|
Alexis Hetu | e8af6d1 | 2015-04-17 16:58:45 -0400 | [diff] [blame] | 1717 | {
|
| 1718 | TRACE("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
|
| 1719 | mode, first, count, instanceCount);
|
| 1720 |
|
| 1721 | switch(mode)
|
| 1722 | {
|
| 1723 | case GL_POINTS:
|
| 1724 | case GL_LINES:
|
| 1725 | case GL_LINE_LOOP:
|
| 1726 | case GL_LINE_STRIP:
|
| 1727 | case GL_TRIANGLES:
|
| 1728 | case GL_TRIANGLE_FAN:
|
| 1729 | case GL_TRIANGLE_STRIP:
|
| 1730 | break;
|
| 1731 | default:
|
| 1732 | return error(GL_INVALID_ENUM);
|
| 1733 | }
|
| 1734 |
|
| 1735 | if(count < 0 || instanceCount < 0)
|
| 1736 | {
|
| 1737 | return error(GL_INVALID_VALUE);
|
| 1738 | }
|
| 1739 |
|
| 1740 | es2::Context *context = es2::getContext();
|
| 1741 |
|
| 1742 | if(context)
|
| 1743 | {
|
| 1744 | es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
|
| 1745 | if(transformFeedback && transformFeedback->isActive() && (mode != transformFeedback->primitiveMode()))
|
| 1746 | {
|
| 1747 | return error(GL_INVALID_OPERATION);
|
| 1748 | }
|
| 1749 |
|
| 1750 | context->drawArrays(mode, first, count, instanceCount);
|
| 1751 | }
|
| 1752 | }
|
| 1753 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1754 | void DrawElementsInstancedEXT(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instanceCount)
|
Alexis Hetu | e8af6d1 | 2015-04-17 16:58:45 -0400 | [diff] [blame] | 1755 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1756 | TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const void *indices = %p, GLsizei instanceCount = %d)",
|
Alexis Hetu | e8af6d1 | 2015-04-17 16:58:45 -0400 | [diff] [blame] | 1757 | mode, count, type, indices, instanceCount);
|
| 1758 |
|
| 1759 | switch(mode)
|
| 1760 | {
|
| 1761 | case GL_POINTS:
|
| 1762 | case GL_LINES:
|
| 1763 | case GL_LINE_LOOP:
|
| 1764 | case GL_LINE_STRIP:
|
| 1765 | case GL_TRIANGLES:
|
| 1766 | case GL_TRIANGLE_FAN:
|
| 1767 | case GL_TRIANGLE_STRIP:
|
| 1768 | break;
|
| 1769 | default:
|
| 1770 | return error(GL_INVALID_ENUM);
|
| 1771 | }
|
| 1772 |
|
| 1773 | switch(type)
|
| 1774 | {
|
| 1775 | case GL_UNSIGNED_BYTE:
|
| 1776 | case GL_UNSIGNED_SHORT:
|
| 1777 | case GL_UNSIGNED_INT:
|
| 1778 | break;
|
| 1779 | default:
|
| 1780 | return error(GL_INVALID_ENUM);
|
| 1781 | }
|
| 1782 |
|
| 1783 | if(count < 0 || instanceCount < 0)
|
| 1784 | {
|
| 1785 | return error(GL_INVALID_VALUE);
|
| 1786 | }
|
| 1787 |
|
| 1788 | es2::Context *context = es2::getContext();
|
| 1789 |
|
| 1790 | if(context)
|
| 1791 | {
|
| 1792 | es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
|
| 1793 | if(transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused())
|
| 1794 | {
|
| 1795 | return error(GL_INVALID_OPERATION);
|
| 1796 | }
|
| 1797 |
|
Nicolas Capens | 22d0766 | 2015-04-25 11:34:50 -0700 | [diff] [blame] | 1798 | context->drawElements(mode, 0, MAX_ELEMENT_INDEX, count, type, indices, instanceCount);
|
Alexis Hetu | e8af6d1 | 2015-04-17 16:58:45 -0400 | [diff] [blame] | 1799 | }
|
| 1800 | }
|
| 1801 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1802 | void VertexAttribDivisorEXT(GLuint index, GLuint divisor)
|
Alexis Hetu | e8af6d1 | 2015-04-17 16:58:45 -0400 | [diff] [blame] | 1803 | {
|
| 1804 | TRACE("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
|
| 1805 |
|
| 1806 | es2::Context *context = es2::getContext();
|
| 1807 |
|
| 1808 | if(context)
|
| 1809 | {
|
| 1810 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 1811 | {
|
| 1812 | return error(GL_INVALID_VALUE);
|
| 1813 | }
|
| 1814 |
|
| 1815 | context->setVertexAttribDivisor(index, divisor);
|
| 1816 | }
|
| 1817 | }
|
| 1818 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1819 | void DrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 1820 | {
|
| 1821 | TRACE("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
|
| 1822 | mode, first, count, instanceCount);
|
| 1823 |
|
| 1824 | switch(mode)
|
| 1825 | {
|
| 1826 | case GL_POINTS:
|
| 1827 | case GL_LINES:
|
| 1828 | case GL_LINE_LOOP:
|
| 1829 | case GL_LINE_STRIP:
|
| 1830 | case GL_TRIANGLES:
|
| 1831 | case GL_TRIANGLE_FAN:
|
| 1832 | case GL_TRIANGLE_STRIP:
|
| 1833 | break;
|
| 1834 | default:
|
| 1835 | return error(GL_INVALID_ENUM);
|
| 1836 | }
|
| 1837 |
|
| 1838 | if(count < 0 || instanceCount < 0)
|
| 1839 | {
|
| 1840 | return error(GL_INVALID_VALUE);
|
| 1841 | }
|
| 1842 |
|
| 1843 | es2::Context *context = es2::getContext();
|
| 1844 |
|
| 1845 | if(context)
|
| 1846 | {
|
| 1847 | if(!context->hasZeroDivisor())
|
| 1848 | {
|
| 1849 | return error(GL_INVALID_OPERATION);
|
| 1850 | }
|
| 1851 |
|
| 1852 | es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
|
| 1853 | if(transformFeedback && transformFeedback->isActive() && (mode != transformFeedback->primitiveMode()))
|
| 1854 | {
|
| 1855 | return error(GL_INVALID_OPERATION);
|
| 1856 | }
|
| 1857 |
|
| 1858 | context->drawArrays(mode, first, count, instanceCount);
|
| 1859 | }
|
| 1860 | }
|
| 1861 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1862 | void DrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instanceCount)
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 1863 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 1864 | TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const void *indices = %p, GLsizei instanceCount = %d)",
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 1865 | mode, count, type, indices, instanceCount);
|
| 1866 |
|
| 1867 | switch(mode)
|
| 1868 | {
|
| 1869 | case GL_POINTS:
|
| 1870 | case GL_LINES:
|
| 1871 | case GL_LINE_LOOP:
|
| 1872 | case GL_LINE_STRIP:
|
| 1873 | case GL_TRIANGLES:
|
| 1874 | case GL_TRIANGLE_FAN:
|
| 1875 | case GL_TRIANGLE_STRIP:
|
| 1876 | break;
|
| 1877 | default:
|
| 1878 | return error(GL_INVALID_ENUM);
|
| 1879 | }
|
| 1880 |
|
| 1881 | switch(type)
|
| 1882 | {
|
| 1883 | case GL_UNSIGNED_BYTE:
|
| 1884 | case GL_UNSIGNED_SHORT:
|
| 1885 | case GL_UNSIGNED_INT:
|
| 1886 | break;
|
| 1887 | default:
|
| 1888 | return error(GL_INVALID_ENUM);
|
| 1889 | }
|
| 1890 |
|
| 1891 | if(count < 0 || instanceCount < 0)
|
| 1892 | {
|
| 1893 | return error(GL_INVALID_VALUE);
|
| 1894 | }
|
| 1895 |
|
| 1896 | es2::Context *context = es2::getContext();
|
| 1897 |
|
| 1898 | if(context)
|
| 1899 | {
|
| 1900 | if(!context->hasZeroDivisor())
|
| 1901 | {
|
| 1902 | return error(GL_INVALID_OPERATION);
|
| 1903 | }
|
| 1904 |
|
| 1905 | es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
|
| 1906 | if(transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused())
|
| 1907 | {
|
| 1908 | return error(GL_INVALID_OPERATION);
|
| 1909 | }
|
| 1910 |
|
Nicolas Capens | 0416e5c | 2015-04-28 15:30:28 -0700 | [diff] [blame] | 1911 | context->drawElements(mode, 0, MAX_ELEMENT_INDEX, count, type, indices, instanceCount);
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 1912 | }
|
| 1913 | }
|
| 1914 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1915 | void VertexAttribDivisorANGLE(GLuint index, GLuint divisor)
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 1916 | {
|
| 1917 | TRACE("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
|
| 1918 |
|
| 1919 | es2::Context *context = es2::getContext();
|
| 1920 |
|
| 1921 | if(context)
|
| 1922 | {
|
| 1923 | if(index >= MAX_VERTEX_ATTRIBS)
|
| 1924 | {
|
| 1925 | return error(GL_INVALID_VALUE);
|
| 1926 | }
|
| 1927 |
|
| 1928 | context->setVertexAttribDivisor(index, divisor);
|
| 1929 | }
|
| 1930 | }
|
| 1931 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1932 | void Enable(GLenum cap)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1933 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1934 | TRACE("(GLenum cap = 0x%X)", cap);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1935 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1936 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1937 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1938 | if(context)
|
| 1939 | {
|
| 1940 | switch(cap)
|
| 1941 | {
|
Nicolas Capens | d55a095 | 2015-08-03 16:36:58 -0400 | [diff] [blame] | 1942 | case GL_CULL_FACE: context->setCullFaceEnabled(true); break;
|
| 1943 | case GL_POLYGON_OFFSET_FILL: context->setPolygonOffsetFillEnabled(true); break;
|
| 1944 | case GL_SAMPLE_ALPHA_TO_COVERAGE: context->setSampleAlphaToCoverageEnabled(true); break;
|
| 1945 | case GL_SAMPLE_COVERAGE: context->setSampleCoverageEnabled(true); break;
|
| 1946 | case GL_SCISSOR_TEST: context->setScissorTestEnabled(true); break;
|
| 1947 | case GL_STENCIL_TEST: context->setStencilTestEnabled(true); break;
|
| 1948 | case GL_DEPTH_TEST: context->setDepthTestEnabled(true); break;
|
| 1949 | case GL_BLEND: context->setBlendEnabled(true); break;
|
| 1950 | case GL_DITHER: context->setDitherEnabled(true); break;
|
| 1951 | case GL_PRIMITIVE_RESTART_FIXED_INDEX: context->setPrimitiveRestartFixedIndexEnabled(true); break;
|
| 1952 | case GL_RASTERIZER_DISCARD: context->setRasterizerDiscardEnabled(true); break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1953 | default:
|
| 1954 | return error(GL_INVALID_ENUM);
|
| 1955 | }
|
| 1956 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1957 | }
|
| 1958 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1959 | void EnableVertexAttribArray(GLuint index)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1960 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1961 | TRACE("(GLuint index = %d)", index);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1962 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1963 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 1964 | {
|
| 1965 | return error(GL_INVALID_VALUE);
|
| 1966 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1967 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1968 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1969 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1970 | if(context)
|
| 1971 | {
|
Nicolas Capens | d55a095 | 2015-08-03 16:36:58 -0400 | [diff] [blame] | 1972 | context->setVertexAttribArrayEnabled(index, true);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1973 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1974 | }
|
| 1975 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1976 | void EndQueryEXT(GLenum target)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1977 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1978 | TRACE("GLenum target = 0x%X)", target);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1979 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1980 | switch(target)
|
| 1981 | {
|
| 1982 | case GL_ANY_SAMPLES_PASSED_EXT:
|
| 1983 | case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
|
| 1984 | break;
|
| 1985 | default:
|
| 1986 | return error(GL_INVALID_ENUM);
|
| 1987 | }
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1990 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1991 | if(context)
|
| 1992 | {
|
| 1993 | context->endQuery(target);
|
| 1994 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1995 | }
|
| 1996 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 1997 | void FinishFenceNV(GLuint fence)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1998 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 1999 | TRACE("(GLuint fence = %d)", fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2000 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2001 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2002 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2003 | if(context)
|
| 2004 | {
|
| 2005 | es2::Fence* fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2006 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2007 | if(fenceObject == NULL)
|
| 2008 | {
|
| 2009 | return error(GL_INVALID_OPERATION);
|
| 2010 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2011 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2012 | fenceObject->finishFence();
|
| 2013 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2014 | }
|
| 2015 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2016 | void Finish(void)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2017 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2018 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2019 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2020 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2021 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2022 | if(context)
|
| 2023 | {
|
| 2024 | context->finish();
|
| 2025 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2026 | }
|
| 2027 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2028 | void Flush(void)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2029 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2030 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2031 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2032 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2033 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2034 | if(context)
|
| 2035 | {
|
| 2036 | context->flush();
|
| 2037 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2038 | }
|
| 2039 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2040 | void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2041 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2042 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
|
| 2043 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2044 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2045 | if((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE) ||
|
| 2046 | (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
|
| 2047 | {
|
| 2048 | return error(GL_INVALID_ENUM);
|
| 2049 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2050 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2051 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2052 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2053 | if(context)
|
| 2054 | {
|
| 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(!framebuffer || (framebufferName == 0 && renderbuffer != 0))
|
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 |
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 2073 | // [OpenGL ES 2.0.25] Section 4.4.3 page 112
|
| 2074 | // [OpenGL ES 3.0.2] Section 4.4.2 page 201
|
| 2075 | // 'renderbuffer' must be either zero or the name of an existing renderbuffer object of
|
| 2076 | // type 'renderbuffertarget', otherwise an INVALID_OPERATION error is generated.
|
| 2077 | if(renderbuffer != 0)
|
| 2078 | {
|
| 2079 | if(!context->getRenderbuffer(renderbuffer))
|
| 2080 | {
|
| 2081 | return error(GL_INVALID_OPERATION);
|
| 2082 | }
|
| 2083 | }
|
| 2084 |
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2085 | egl::GLint clientVersion = context->getClientVersion();
|
| 2086 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2087 | switch(attachment)
|
| 2088 | {
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2089 | case GL_COLOR_ATTACHMENT1:
|
| 2090 | case GL_COLOR_ATTACHMENT2:
|
| 2091 | case GL_COLOR_ATTACHMENT3:
|
| 2092 | case GL_COLOR_ATTACHMENT4:
|
| 2093 | case GL_COLOR_ATTACHMENT5:
|
| 2094 | case GL_COLOR_ATTACHMENT6:
|
| 2095 | case GL_COLOR_ATTACHMENT7:
|
| 2096 | case GL_COLOR_ATTACHMENT8:
|
| 2097 | case GL_COLOR_ATTACHMENT9:
|
| 2098 | case GL_COLOR_ATTACHMENT10:
|
| 2099 | case GL_COLOR_ATTACHMENT11:
|
| 2100 | case GL_COLOR_ATTACHMENT12:
|
| 2101 | case GL_COLOR_ATTACHMENT13:
|
| 2102 | case GL_COLOR_ATTACHMENT14:
|
| 2103 | case GL_COLOR_ATTACHMENT15:
|
Alexis Hetu | 3e02f68 | 2015-12-02 12:53:42 -0500 | [diff] [blame] | 2104 | case GL_COLOR_ATTACHMENT16:
|
| 2105 | case GL_COLOR_ATTACHMENT17:
|
| 2106 | case GL_COLOR_ATTACHMENT18:
|
| 2107 | case GL_COLOR_ATTACHMENT19:
|
| 2108 | case GL_COLOR_ATTACHMENT20:
|
| 2109 | case GL_COLOR_ATTACHMENT21:
|
| 2110 | case GL_COLOR_ATTACHMENT22:
|
| 2111 | case GL_COLOR_ATTACHMENT23:
|
| 2112 | case GL_COLOR_ATTACHMENT24:
|
| 2113 | case GL_COLOR_ATTACHMENT25:
|
| 2114 | case GL_COLOR_ATTACHMENT26:
|
| 2115 | case GL_COLOR_ATTACHMENT27:
|
| 2116 | case GL_COLOR_ATTACHMENT28:
|
| 2117 | case GL_COLOR_ATTACHMENT29:
|
| 2118 | case GL_COLOR_ATTACHMENT30:
|
| 2119 | case GL_COLOR_ATTACHMENT31:
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2120 | if(clientVersion < 3)
|
| 2121 | {
|
| 2122 | return error(GL_INVALID_ENUM);
|
| 2123 | }
|
| 2124 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2125 | case GL_COLOR_ATTACHMENT0:
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2126 | if((attachment - GL_COLOR_ATTACHMENT0) >= es2::IMPLEMENTATION_MAX_COLOR_ATTACHMENTS)
|
| 2127 | {
|
| 2128 | return error(GL_INVALID_ENUM);
|
| 2129 | }
|
| 2130 | framebuffer->setColorbuffer(GL_RENDERBUFFER, renderbuffer, attachment - GL_COLOR_ATTACHMENT0);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2131 | break;
|
| 2132 | case GL_DEPTH_ATTACHMENT:
|
| 2133 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 2134 | break;
|
| 2135 | case GL_STENCIL_ATTACHMENT:
|
| 2136 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 2137 | break;
|
Alexis Hetu | 696a818 | 2015-06-23 11:18:17 -0400 | [diff] [blame] | 2138 | case GL_DEPTH_STENCIL_ATTACHMENT:
|
| 2139 | if(clientVersion >= 3)
|
| 2140 | {
|
| 2141 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 2142 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
|
| 2143 | break;
|
| 2144 | }
|
| 2145 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2146 | default:
|
| 2147 | return error(GL_INVALID_ENUM);
|
| 2148 | }
|
| 2149 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2150 | }
|
| 2151 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2152 | void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2153 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2154 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
|
| 2155 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2156 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2157 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 2158 | {
|
| 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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2163 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2164 | if(context)
|
| 2165 | {
|
| 2166 | if(texture == 0)
|
| 2167 | {
|
| 2168 | textarget = GL_NONE;
|
| 2169 | }
|
| 2170 | else
|
| 2171 | {
|
| 2172 | es2::Texture *tex = context->getTexture(texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2173 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2174 | if(tex == NULL)
|
| 2175 | {
|
| 2176 | return error(GL_INVALID_OPERATION);
|
| 2177 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2178 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2179 | switch(textarget)
|
| 2180 | {
|
| 2181 | case GL_TEXTURE_2D:
|
| 2182 | if(tex->getTarget() != GL_TEXTURE_2D)
|
| 2183 | {
|
| 2184 | return error(GL_INVALID_OPERATION);
|
| 2185 | }
|
| 2186 | break;
|
| 2187 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 2188 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 2189 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 2190 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 2191 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 2192 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
| 2193 | if(tex->getTarget() != GL_TEXTURE_CUBE_MAP)
|
| 2194 | {
|
| 2195 | return error(GL_INVALID_OPERATION);
|
| 2196 | }
|
| 2197 | break;
|
| 2198 | default:
|
| 2199 | return error(GL_INVALID_ENUM);
|
| 2200 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2201 |
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 2202 | if(tex->isCompressed(textarget, level))
|
| 2203 | {
|
| 2204 | return error(GL_INVALID_OPERATION);
|
| 2205 | }
|
| 2206 |
|
Alexis Hetu | 8af5007 | 2015-04-29 14:29:49 -0400 | [diff] [blame] | 2207 | if((level != 0) && (context->getClientVersion() < 3))
|
| 2208 | {
|
| 2209 | return error(GL_INVALID_VALUE);
|
| 2210 | }
|
| 2211 |
|
| 2212 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2213 | {
|
| 2214 | return error(GL_INVALID_VALUE);
|
| 2215 | }
|
| 2216 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2217 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2218 | es2::Framebuffer *framebuffer = NULL;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2219 | GLuint framebufferName = 0;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2220 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 2221 | {
|
| 2222 | framebuffer = context->getReadFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2223 | framebufferName = context->getReadFramebufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2224 | }
|
| 2225 | else
|
| 2226 | {
|
| 2227 | framebuffer = context->getDrawFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2228 | framebufferName = context->getDrawFramebufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2229 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2230 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2231 | if(framebufferName == 0 || !framebuffer)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2232 | {
|
| 2233 | return error(GL_INVALID_OPERATION);
|
| 2234 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2235 |
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2236 | egl::GLint clientVersion = context->getClientVersion();
|
| 2237 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2238 | switch(attachment)
|
| 2239 | {
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2240 | case GL_COLOR_ATTACHMENT1:
|
| 2241 | case GL_COLOR_ATTACHMENT2:
|
| 2242 | case GL_COLOR_ATTACHMENT3:
|
| 2243 | case GL_COLOR_ATTACHMENT4:
|
| 2244 | case GL_COLOR_ATTACHMENT5:
|
| 2245 | case GL_COLOR_ATTACHMENT6:
|
| 2246 | case GL_COLOR_ATTACHMENT7:
|
| 2247 | case GL_COLOR_ATTACHMENT8:
|
| 2248 | case GL_COLOR_ATTACHMENT9:
|
| 2249 | case GL_COLOR_ATTACHMENT10:
|
| 2250 | case GL_COLOR_ATTACHMENT11:
|
| 2251 | case GL_COLOR_ATTACHMENT12:
|
| 2252 | case GL_COLOR_ATTACHMENT13:
|
| 2253 | case GL_COLOR_ATTACHMENT14:
|
| 2254 | case GL_COLOR_ATTACHMENT15:
|
Alexis Hetu | 3e02f68 | 2015-12-02 12:53:42 -0500 | [diff] [blame] | 2255 | case GL_COLOR_ATTACHMENT16:
|
| 2256 | case GL_COLOR_ATTACHMENT17:
|
| 2257 | case GL_COLOR_ATTACHMENT18:
|
| 2258 | case GL_COLOR_ATTACHMENT19:
|
| 2259 | case GL_COLOR_ATTACHMENT20:
|
| 2260 | case GL_COLOR_ATTACHMENT21:
|
| 2261 | case GL_COLOR_ATTACHMENT22:
|
| 2262 | case GL_COLOR_ATTACHMENT23:
|
| 2263 | case GL_COLOR_ATTACHMENT24:
|
| 2264 | case GL_COLOR_ATTACHMENT25:
|
| 2265 | case GL_COLOR_ATTACHMENT26:
|
| 2266 | case GL_COLOR_ATTACHMENT27:
|
| 2267 | case GL_COLOR_ATTACHMENT28:
|
| 2268 | case GL_COLOR_ATTACHMENT29:
|
| 2269 | case GL_COLOR_ATTACHMENT30:
|
| 2270 | case GL_COLOR_ATTACHMENT31:
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2271 | if(clientVersion < 3)
|
| 2272 | {
|
| 2273 | return error(GL_INVALID_ENUM);
|
| 2274 | }
|
| 2275 | // fall through
|
| 2276 | case GL_COLOR_ATTACHMENT0:
|
| 2277 | if((attachment - GL_COLOR_ATTACHMENT0) >= es2::IMPLEMENTATION_MAX_COLOR_ATTACHMENTS)
|
| 2278 | {
|
| 2279 | return error(GL_INVALID_ENUM);
|
| 2280 | }
|
Alexis Hetu | 8af5007 | 2015-04-29 14:29:49 -0400 | [diff] [blame] | 2281 | framebuffer->setColorbuffer(textarget, texture, attachment - GL_COLOR_ATTACHMENT0, level);
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2282 | break;
|
Alexis Hetu | 8af5007 | 2015-04-29 14:29:49 -0400 | [diff] [blame] | 2283 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level); break;
|
| 2284 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level); break;
|
Alexis Hetu | dcbabfa | 2015-07-13 13:31:05 -0400 | [diff] [blame] | 2285 | default:
|
| 2286 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2287 | }
|
| 2288 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2289 | }
|
| 2290 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2291 | void FrontFace(GLenum mode)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2292 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2293 | TRACE("(GLenum mode = 0x%X)", mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2294 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2295 | switch(mode)
|
| 2296 | {
|
| 2297 | case GL_CW:
|
| 2298 | case GL_CCW:
|
| 2299 | {
|
| 2300 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2301 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2302 | if(context)
|
| 2303 | {
|
| 2304 | context->setFrontFace(mode);
|
| 2305 | }
|
| 2306 | }
|
| 2307 | break;
|
| 2308 | default:
|
| 2309 | return error(GL_INVALID_ENUM);
|
| 2310 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2311 | }
|
| 2312 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2313 | void GenBuffers(GLsizei n, GLuint* buffers)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2314 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2315 | TRACE("(GLsizei n = %d, GLuint* buffers = %p)", n, buffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2316 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2317 | if(n < 0)
|
| 2318 | {
|
| 2319 | return error(GL_INVALID_VALUE);
|
| 2320 | }
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2323 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2324 | if(context)
|
| 2325 | {
|
| 2326 | for(int i = 0; i < n; i++)
|
| 2327 | {
|
| 2328 | buffers[i] = context->createBuffer();
|
| 2329 | }
|
| 2330 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2331 | }
|
| 2332 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2333 | void GenerateMipmap(GLenum target)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2334 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2335 | TRACE("(GLenum target = 0x%X)", target);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2336 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2337 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2338 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2339 | if(context)
|
| 2340 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2341 | es2::Texture *texture = nullptr;
|
| 2342 |
|
| 2343 | egl::GLint clientVersion = context->getClientVersion();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2344 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2345 | switch(target)
|
| 2346 | {
|
| 2347 | case GL_TEXTURE_2D:
|
| 2348 | texture = context->getTexture2D();
|
| 2349 | break;
|
| 2350 | case GL_TEXTURE_CUBE_MAP:
|
| 2351 | texture = context->getTextureCubeMap();
|
| 2352 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2353 | case GL_TEXTURE_2D_ARRAY:
|
| 2354 | if(clientVersion < 3)
|
| 2355 | {
|
| 2356 | return error(GL_INVALID_ENUM);
|
| 2357 | }
|
| 2358 | else
|
| 2359 | {
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 2360 | texture = context->getTexture2DArray();
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2361 | }
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 2362 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2363 | case GL_TEXTURE_3D_OES:
|
| 2364 | texture = context->getTexture3D();
|
| 2365 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2366 | default:
|
| 2367 | return error(GL_INVALID_ENUM);
|
| 2368 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2369 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2370 | if(texture->isCompressed(target, 0) || texture->isDepth(target, 0))
|
| 2371 | {
|
| 2372 | return error(GL_INVALID_OPERATION);
|
| 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 | texture->generateMipmaps();
|
| 2376 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2377 | }
|
| 2378 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2379 | void GenFencesNV(GLsizei n, GLuint* fences)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2380 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2381 | TRACE("(GLsizei n = %d, GLuint* fences = %p)", n, fences);
|
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 | if(n < 0)
|
| 2384 | {
|
| 2385 | return error(GL_INVALID_VALUE);
|
| 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::Context *context = es2::getContext();
|
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(context)
|
| 2391 | {
|
| 2392 | for(int i = 0; i < n; i++)
|
| 2393 | {
|
| 2394 | fences[i] = context->createFence();
|
| 2395 | }
|
| 2396 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2397 | }
|
| 2398 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2399 | void GenFramebuffers(GLsizei n, GLuint* framebuffers)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2400 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2401 | TRACE("(GLsizei n = %d, GLuint* framebuffers = %p)", n, framebuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2402 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2403 | if(n < 0)
|
| 2404 | {
|
| 2405 | return error(GL_INVALID_VALUE);
|
| 2406 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2407 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2408 | es2::Context *context = es2::getContext();
|
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 | if(context)
|
| 2411 | {
|
| 2412 | for(int i = 0; i < n; i++)
|
| 2413 | {
|
| 2414 | framebuffers[i] = context->createFramebuffer();
|
| 2415 | }
|
| 2416 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2417 | }
|
| 2418 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2419 | void GenQueriesEXT(GLsizei n, GLuint* ids)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2420 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2421 | TRACE("(GLsizei n = %d, GLuint* ids = %p)", n, ids);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2422 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2423 | if(n < 0)
|
| 2424 | {
|
| 2425 | return error(GL_INVALID_VALUE);
|
| 2426 | }
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2429 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2430 | if(context)
|
| 2431 | {
|
| 2432 | for(int i = 0; i < n; i++)
|
| 2433 | {
|
| 2434 | ids[i] = context->createQuery();
|
| 2435 | }
|
| 2436 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2437 | }
|
| 2438 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2439 | void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2440 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2441 | TRACE("(GLsizei n = %d, GLuint* renderbuffers = %p)", n, renderbuffers);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2442 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2443 | if(n < 0)
|
| 2444 | {
|
| 2445 | return error(GL_INVALID_VALUE);
|
| 2446 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2447 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2448 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2449 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2450 | if(context)
|
| 2451 | {
|
| 2452 | for(int i = 0; i < n; i++)
|
| 2453 | {
|
| 2454 | renderbuffers[i] = context->createRenderbuffer();
|
| 2455 | }
|
| 2456 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2457 | }
|
| 2458 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2459 | void GenTextures(GLsizei n, GLuint* textures)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2460 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2461 | TRACE("(GLsizei n = %d, GLuint* textures = %p)", n, textures);
|
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 | if(n < 0)
|
| 2464 | {
|
| 2465 | return error(GL_INVALID_VALUE);
|
| 2466 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2467 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2468 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2469 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2470 | if(context)
|
| 2471 | {
|
| 2472 | for(int i = 0; i < n; i++)
|
| 2473 | {
|
| 2474 | textures[i] = context->createTexture();
|
| 2475 | }
|
| 2476 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2477 | }
|
| 2478 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2479 | void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2480 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2481 | TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = %p, "
|
| 2482 | "GLint *size = %p, GLenum *type = %p, GLchar *name = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2483 | program, index, bufsize, length, size, type, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2484 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2485 | if(bufsize < 0)
|
| 2486 | {
|
| 2487 | return error(GL_INVALID_VALUE);
|
| 2488 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2489 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2490 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2491 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2492 | if(context)
|
| 2493 | {
|
| 2494 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2495 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2496 | if(!programObject)
|
| 2497 | {
|
| 2498 | if(context->getShader(program))
|
| 2499 | {
|
| 2500 | return error(GL_INVALID_OPERATION);
|
| 2501 | }
|
| 2502 | else
|
| 2503 | {
|
| 2504 | return error(GL_INVALID_VALUE);
|
| 2505 | }
|
| 2506 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2507 |
|
Alexis Hetu | 0085c44 | 2015-06-12 15:19:20 -0400 | [diff] [blame] | 2508 | if(index >= programObject->getActiveAttributeCount())
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2509 | {
|
| 2510 | return error(GL_INVALID_VALUE);
|
| 2511 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2512 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2513 | programObject->getActiveAttribute(index, bufsize, length, size, type, name);
|
| 2514 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2515 | }
|
| 2516 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2517 | void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2518 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2519 | TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2520 | "GLsizei* length = %p, GLint* size = %p, GLenum* type = %p, GLchar* name = %s)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2521 | program, index, bufsize, length, size, type, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2522 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2523 | if(bufsize < 0)
|
| 2524 | {
|
| 2525 | return error(GL_INVALID_VALUE);
|
| 2526 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2527 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2528 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2529 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2530 | if(context)
|
| 2531 | {
|
| 2532 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2533 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2534 | if(!programObject)
|
| 2535 | {
|
| 2536 | if(context->getShader(program))
|
| 2537 | {
|
| 2538 | return error(GL_INVALID_OPERATION);
|
| 2539 | }
|
| 2540 | else
|
| 2541 | {
|
| 2542 | return error(GL_INVALID_VALUE);
|
| 2543 | }
|
| 2544 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2545 |
|
Alexis Hetu | 0085c44 | 2015-06-12 15:19:20 -0400 | [diff] [blame] | 2546 | if(index >= programObject->getActiveUniformCount())
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2547 | {
|
| 2548 | return error(GL_INVALID_VALUE);
|
| 2549 | }
|
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 | programObject->getActiveUniform(index, bufsize, length, size, type, name);
|
| 2552 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2553 | }
|
| 2554 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2555 | void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2556 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2557 | TRACE("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = %p, GLuint* shaders = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2558 | program, maxcount, count, shaders);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2559 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2560 | if(maxcount < 0)
|
| 2561 | {
|
| 2562 | return error(GL_INVALID_VALUE);
|
| 2563 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2564 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2565 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2566 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2567 | if(context)
|
| 2568 | {
|
| 2569 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2570 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2571 | if(!programObject)
|
| 2572 | {
|
| 2573 | if(context->getShader(program))
|
| 2574 | {
|
| 2575 | return error(GL_INVALID_OPERATION);
|
| 2576 | }
|
| 2577 | else
|
| 2578 | {
|
| 2579 | return error(GL_INVALID_VALUE);
|
| 2580 | }
|
| 2581 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2582 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2583 | return programObject->getAttachedShaders(maxcount, count, shaders);
|
| 2584 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2585 | }
|
| 2586 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2587 | int GetAttribLocation(GLuint program, const GLchar* name)
|
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 | TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2592 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2593 | if(context)
|
| 2594 | {
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2595 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2596 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2597 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2598 | if(!programObject)
|
| 2599 | {
|
| 2600 | if(context->getShader(program))
|
| 2601 | {
|
| 2602 | return error(GL_INVALID_OPERATION, -1);
|
| 2603 | }
|
| 2604 | else
|
| 2605 | {
|
| 2606 | return error(GL_INVALID_VALUE, -1);
|
| 2607 | }
|
| 2608 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2609 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2610 | if(!programObject->isLinked())
|
| 2611 | {
|
| 2612 | return error(GL_INVALID_OPERATION, -1);
|
| 2613 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2614 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2615 | return programObject->getAttributeLocation(name);
|
| 2616 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2617 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2618 | return -1;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2619 | }
|
| 2620 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2621 | void GetBooleanv(GLenum pname, GLboolean* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2622 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2623 | TRACE("(GLenum pname = 0x%X, GLboolean* params = %p)", pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2624 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2625 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2626 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2627 | if(context)
|
| 2628 | {
|
| 2629 | if(!(context->getBooleanv(pname, params)))
|
| 2630 | {
|
| 2631 | GLenum nativeType;
|
| 2632 | unsigned int numParams = 0;
|
| 2633 | if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
|
| 2634 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2635 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2636 | if(numParams == 0)
|
| 2637 | 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] | 2638 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2639 | if(nativeType == GL_FLOAT)
|
| 2640 | {
|
| 2641 | GLfloat *floatParams = NULL;
|
| 2642 | floatParams = new GLfloat[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2643 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2644 | context->getFloatv(pname, floatParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2645 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2646 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2647 | {
|
| 2648 | if(floatParams[i] == 0.0f)
|
| 2649 | params[i] = GL_FALSE;
|
| 2650 | else
|
| 2651 | params[i] = GL_TRUE;
|
| 2652 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2653 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2654 | delete [] floatParams;
|
| 2655 | }
|
| 2656 | else if(nativeType == GL_INT)
|
| 2657 | {
|
| 2658 | GLint *intParams = NULL;
|
| 2659 | intParams = new GLint[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2660 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2661 | context->getIntegerv(pname, intParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2662 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2663 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2664 | {
|
| 2665 | if(intParams[i] == 0)
|
| 2666 | params[i] = GL_FALSE;
|
| 2667 | else
|
| 2668 | params[i] = GL_TRUE;
|
| 2669 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2670 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2671 | delete [] intParams;
|
| 2672 | }
|
| 2673 | }
|
| 2674 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2675 | }
|
| 2676 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2677 | void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2678 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2679 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = %p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2680 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2681 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2682 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2683 | if(context)
|
| 2684 | {
|
| 2685 | es2::Buffer *buffer;
|
Alexis Hetu | f9b7cb1 | 2015-04-10 13:44:36 -0400 | [diff] [blame] | 2686 | if(!context->getBuffer(target, &buffer))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2687 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2688 | return error(GL_INVALID_ENUM);
|
| 2689 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2690 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2691 | if(!buffer)
|
| 2692 | {
|
| 2693 | // A null buffer means that "0" is bound to the requested buffer target
|
| 2694 | return error(GL_INVALID_OPERATION);
|
| 2695 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2696 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2697 | egl::GLint clientVersion = context->getClientVersion();
|
| 2698 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2699 | switch(pname)
|
| 2700 | {
|
| 2701 | case GL_BUFFER_USAGE:
|
| 2702 | *params = buffer->usage();
|
| 2703 | break;
|
| 2704 | case GL_BUFFER_SIZE:
|
| 2705 | *params = buffer->size();
|
| 2706 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 2707 | case GL_BUFFER_ACCESS_FLAGS:
|
| 2708 | if(clientVersion >= 3)
|
| 2709 | {
|
| 2710 | *params = buffer->access();
|
| 2711 | break;
|
| 2712 | }
|
| 2713 | else return error(GL_INVALID_ENUM);
|
| 2714 | case GL_BUFFER_MAPPED:
|
| 2715 | if(clientVersion >= 3)
|
| 2716 | {
|
| 2717 | *params = buffer->isMapped();
|
| 2718 | break;
|
| 2719 | }
|
| 2720 | else return error(GL_INVALID_ENUM);
|
| 2721 | case GL_BUFFER_MAP_LENGTH:
|
| 2722 | if(clientVersion >= 3)
|
| 2723 | {
|
| 2724 | *params = buffer->length();
|
| 2725 | break;
|
| 2726 | }
|
| 2727 | else return error(GL_INVALID_ENUM);
|
| 2728 | case GL_BUFFER_MAP_OFFSET:
|
| 2729 | if(clientVersion >= 3)
|
| 2730 | {
|
| 2731 | *params = buffer->offset();
|
| 2732 | break;
|
| 2733 | }
|
| 2734 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2735 | default:
|
| 2736 | return error(GL_INVALID_ENUM);
|
| 2737 | }
|
| 2738 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2739 | }
|
| 2740 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2741 | GLenum GetError(void)
|
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 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2744 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2745 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2746 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2747 | if(context)
|
| 2748 | {
|
| 2749 | return context->getError();
|
| 2750 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2751 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2752 | return GL_NO_ERROR;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2753 | }
|
| 2754 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2755 | void GetFenceivNV(GLuint fence, GLenum pname, GLint *params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2756 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2757 | TRACE("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = %p)", fence, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2758 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2759 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2760 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2761 | if(context)
|
| 2762 | {
|
| 2763 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2764 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2765 | if(fenceObject == NULL)
|
| 2766 | {
|
| 2767 | return error(GL_INVALID_OPERATION);
|
| 2768 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2769 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2770 | fenceObject->getFenceiv(pname, params);
|
| 2771 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2772 | }
|
| 2773 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2774 | void GetFloatv(GLenum pname, GLfloat* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2775 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2776 | TRACE("(GLenum pname = 0x%X, GLfloat* params = %p)", pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2777 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2778 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2779 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2780 | if(context)
|
| 2781 | {
|
| 2782 | if(!(context->getFloatv(pname, params)))
|
| 2783 | {
|
| 2784 | GLenum nativeType;
|
| 2785 | unsigned int numParams = 0;
|
| 2786 | if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
|
| 2787 | return error(GL_INVALID_ENUM);
|
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 | if(numParams == 0)
|
| 2790 | 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] | 2791 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2792 | if(nativeType == GL_BOOL)
|
| 2793 | {
|
| 2794 | GLboolean *boolParams = NULL;
|
| 2795 | boolParams = new GLboolean[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2796 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2797 | context->getBooleanv(pname, boolParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2798 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2799 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2800 | {
|
| 2801 | if(boolParams[i] == GL_FALSE)
|
| 2802 | params[i] = 0.0f;
|
| 2803 | else
|
| 2804 | params[i] = 1.0f;
|
| 2805 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2806 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2807 | delete [] boolParams;
|
| 2808 | }
|
| 2809 | else if(nativeType == GL_INT)
|
| 2810 | {
|
| 2811 | GLint *intParams = NULL;
|
| 2812 | intParams = new GLint[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2813 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2814 | context->getIntegerv(pname, intParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2815 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2816 | for(unsigned int i = 0; i < numParams; ++i)
|
| 2817 | {
|
| 2818 | params[i] = (GLfloat)intParams[i];
|
| 2819 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2820 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2821 | delete [] intParams;
|
| 2822 | }
|
| 2823 | }
|
| 2824 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2825 | }
|
| 2826 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 2827 | void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2828 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 2829 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2830 | target, attachment, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2831 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2832 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2833 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2834 | if(context)
|
| 2835 | {
|
| 2836 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 2837 | {
|
| 2838 | return error(GL_INVALID_ENUM);
|
| 2839 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2840 |
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2841 | egl::GLint clientVersion = context->getClientVersion();
|
| 2842 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2843 | es2::Framebuffer *framebuffer = NULL;
|
| 2844 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 2845 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2846 | if(context->getReadFramebufferName() == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2847 | {
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2848 | switch(attachment)
|
| 2849 | {
|
| 2850 | case GL_BACK:
|
| 2851 | case GL_DEPTH:
|
| 2852 | case GL_STENCIL:
|
| 2853 | if(clientVersion >= 3)
|
| 2854 | {
|
| 2855 | break;
|
| 2856 | }
|
| 2857 | // fall through
|
| 2858 | default:
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 2859 | return error(GL_INVALID_ENUM);
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2860 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2861 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2862 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2863 | framebuffer = context->getReadFramebuffer();
|
| 2864 | }
|
| 2865 | else
|
| 2866 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2867 | if(context->getDrawFramebufferName() == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2868 | {
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2869 | switch(attachment)
|
| 2870 | {
|
| 2871 | case GL_BACK:
|
| 2872 | case GL_DEPTH:
|
| 2873 | case GL_STENCIL:
|
| 2874 | if(clientVersion >= 3)
|
| 2875 | {
|
| 2876 | break;
|
| 2877 | }
|
| 2878 | // fall through
|
| 2879 | default:
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 2880 | return error(GL_INVALID_ENUM);
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2881 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2882 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2883 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2884 | framebuffer = context->getDrawFramebuffer();
|
| 2885 | }
|
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 | GLenum attachmentType;
|
| 2888 | GLuint attachmentHandle;
|
Alexis Hetu | 0fecd6f | 2015-07-22 16:49:31 -0400 | [diff] [blame] | 2889 | GLint attachmentLayer;
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2890 | Renderbuffer* renderbuffer = nullptr;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2891 | switch(attachment)
|
| 2892 | {
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2893 | case GL_BACK:
|
| 2894 | if(clientVersion >= 3)
|
| 2895 | {
|
| 2896 | attachmentType = framebuffer->getColorbufferType(0);
|
| 2897 | attachmentHandle = framebuffer->getColorbufferName(0);
|
Alexis Hetu | 0fecd6f | 2015-07-22 16:49:31 -0400 | [diff] [blame] | 2898 | attachmentLayer = framebuffer->getColorbufferLayer(0);
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2899 | renderbuffer = framebuffer->getColorbuffer(0);
|
| 2900 | }
|
| 2901 | else return error(GL_INVALID_ENUM);
|
| 2902 | break;
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2903 | case GL_COLOR_ATTACHMENT1:
|
| 2904 | case GL_COLOR_ATTACHMENT2:
|
| 2905 | case GL_COLOR_ATTACHMENT3:
|
| 2906 | case GL_COLOR_ATTACHMENT4:
|
| 2907 | case GL_COLOR_ATTACHMENT5:
|
| 2908 | case GL_COLOR_ATTACHMENT6:
|
| 2909 | case GL_COLOR_ATTACHMENT7:
|
| 2910 | case GL_COLOR_ATTACHMENT8:
|
| 2911 | case GL_COLOR_ATTACHMENT9:
|
| 2912 | case GL_COLOR_ATTACHMENT10:
|
| 2913 | case GL_COLOR_ATTACHMENT11:
|
| 2914 | case GL_COLOR_ATTACHMENT12:
|
| 2915 | case GL_COLOR_ATTACHMENT13:
|
| 2916 | case GL_COLOR_ATTACHMENT14:
|
| 2917 | case GL_COLOR_ATTACHMENT15:
|
Alexis Hetu | 3e02f68 | 2015-12-02 12:53:42 -0500 | [diff] [blame] | 2918 | case GL_COLOR_ATTACHMENT16:
|
| 2919 | case GL_COLOR_ATTACHMENT17:
|
| 2920 | case GL_COLOR_ATTACHMENT18:
|
| 2921 | case GL_COLOR_ATTACHMENT19:
|
| 2922 | case GL_COLOR_ATTACHMENT20:
|
| 2923 | case GL_COLOR_ATTACHMENT21:
|
| 2924 | case GL_COLOR_ATTACHMENT22:
|
| 2925 | case GL_COLOR_ATTACHMENT23:
|
| 2926 | case GL_COLOR_ATTACHMENT24:
|
| 2927 | case GL_COLOR_ATTACHMENT25:
|
| 2928 | case GL_COLOR_ATTACHMENT26:
|
| 2929 | case GL_COLOR_ATTACHMENT27:
|
| 2930 | case GL_COLOR_ATTACHMENT28:
|
| 2931 | case GL_COLOR_ATTACHMENT29:
|
| 2932 | case GL_COLOR_ATTACHMENT30:
|
| 2933 | case GL_COLOR_ATTACHMENT31:
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2934 | if(clientVersion < 3)
|
| 2935 | {
|
| 2936 | return error(GL_INVALID_ENUM);
|
| 2937 | }
|
| 2938 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2939 | case GL_COLOR_ATTACHMENT0:
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 2940 | if((attachment - GL_COLOR_ATTACHMENT0) >= es2::IMPLEMENTATION_MAX_COLOR_ATTACHMENTS)
|
| 2941 | {
|
| 2942 | return error(GL_INVALID_ENUM);
|
| 2943 | }
|
| 2944 | attachmentType = framebuffer->getColorbufferType(attachment - GL_COLOR_ATTACHMENT0);
|
| 2945 | attachmentHandle = framebuffer->getColorbufferName(attachment - GL_COLOR_ATTACHMENT0);
|
Alexis Hetu | 074c641 | 2015-06-22 15:57:27 -0400 | [diff] [blame] | 2946 | attachmentLayer = framebuffer->getColorbufferLayer(attachment - GL_COLOR_ATTACHMENT0);
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2947 | renderbuffer = framebuffer->getColorbuffer(attachment - GL_COLOR_ATTACHMENT0);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2948 | break;
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2949 | case GL_DEPTH:
|
| 2950 | if(clientVersion < 3)
|
| 2951 | {
|
| 2952 | return error(GL_INVALID_ENUM);
|
| 2953 | }
|
| 2954 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2955 | case GL_DEPTH_ATTACHMENT:
|
| 2956 | attachmentType = framebuffer->getDepthbufferType();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2957 | attachmentHandle = framebuffer->getDepthbufferName();
|
Alexis Hetu | 0fecd6f | 2015-07-22 16:49:31 -0400 | [diff] [blame] | 2958 | attachmentLayer = framebuffer->getDepthbufferLayer();
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2959 | renderbuffer = framebuffer->getDepthbuffer();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2960 | break;
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2961 | case GL_STENCIL:
|
| 2962 | if(clientVersion < 3)
|
| 2963 | {
|
| 2964 | return error(GL_INVALID_ENUM);
|
| 2965 | }
|
| 2966 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2967 | case GL_STENCIL_ATTACHMENT:
|
| 2968 | attachmentType = framebuffer->getStencilbufferType();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 2969 | attachmentHandle = framebuffer->getStencilbufferName();
|
Alexis Hetu | 0fecd6f | 2015-07-22 16:49:31 -0400 | [diff] [blame] | 2970 | attachmentLayer = framebuffer->getStencilbufferLayer();
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2971 | renderbuffer = framebuffer->getStencilbuffer();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2972 | break;
|
Alexis Hetu | 696a818 | 2015-06-23 11:18:17 -0400 | [diff] [blame] | 2973 | case GL_DEPTH_STENCIL_ATTACHMENT:
|
| 2974 | if(clientVersion >= 3)
|
| 2975 | {
|
| 2976 | attachmentType = framebuffer->getDepthbufferType();
|
| 2977 | attachmentHandle = framebuffer->getDepthbufferName();
|
Alexis Hetu | 0fecd6f | 2015-07-22 16:49:31 -0400 | [diff] [blame] | 2978 | attachmentLayer = framebuffer->getDepthbufferLayer();
|
Alexis Hetu | 696a818 | 2015-06-23 11:18:17 -0400 | [diff] [blame] | 2979 | if(attachmentHandle != framebuffer->getStencilbufferName())
|
| 2980 | {
|
| 2981 | // Different attachments to DEPTH and STENCIL, query fails
|
| 2982 | return error(GL_INVALID_OPERATION);
|
| 2983 | }
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2984 | renderbuffer = framebuffer->getDepthbuffer();
|
Alexis Hetu | 696a818 | 2015-06-23 11:18:17 -0400 | [diff] [blame] | 2985 | }
|
| 2986 | else return error(GL_INVALID_ENUM);
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 2987 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2988 | default:
|
| 2989 | return error(GL_INVALID_ENUM);
|
| 2990 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2991 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 2992 | GLenum attachmentObjectType; // Type category
|
| 2993 | if(attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
|
| 2994 | {
|
| 2995 | attachmentObjectType = attachmentType;
|
| 2996 | }
|
| 2997 | else if(es2::IsTextureTarget(attachmentType))
|
| 2998 | {
|
| 2999 | attachmentObjectType = GL_TEXTURE;
|
| 3000 | }
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 3001 | else UNREACHABLE(attachmentType);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3002 |
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3003 | if(attachmentObjectType != GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3004 | {
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3005 | switch(pname)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3006 | {
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3007 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
|
| 3008 | *params = attachmentObjectType;
|
| 3009 | break;
|
| 3010 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
|
| 3011 | if(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3012 | {
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3013 | *params = attachmentHandle;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3014 | }
|
| 3015 | else
|
| 3016 | {
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3017 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3018 | }
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3019 | break;
|
| 3020 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
|
| 3021 | if(attachmentObjectType == GL_TEXTURE)
|
| 3022 | {
|
| 3023 | *params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
|
| 3024 | }
|
| 3025 | else
|
| 3026 | {
|
| 3027 | return error(GL_INVALID_ENUM);
|
| 3028 | }
|
| 3029 | break;
|
| 3030 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
|
| 3031 | if(attachmentObjectType == GL_TEXTURE)
|
| 3032 | {
|
| 3033 | if(es2::IsCubemapTextureTarget(attachmentType))
|
| 3034 | {
|
| 3035 | *params = attachmentType;
|
| 3036 | }
|
| 3037 | else
|
| 3038 | {
|
| 3039 | *params = 0;
|
| 3040 | }
|
| 3041 | }
|
| 3042 | else
|
| 3043 | {
|
| 3044 | return error(GL_INVALID_ENUM);
|
| 3045 | }
|
| 3046 | break;
|
| 3047 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
|
| 3048 | if(clientVersion >= 3)
|
| 3049 | {
|
| 3050 | *params = attachmentLayer;
|
| 3051 | }
|
| 3052 | else return error(GL_INVALID_ENUM);
|
| 3053 | break;
|
| 3054 | case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
|
| 3055 | if(clientVersion >= 3)
|
| 3056 | {
|
| 3057 | *params = renderbuffer->getRedSize();
|
| 3058 | }
|
| 3059 | else return error(GL_INVALID_ENUM);
|
| 3060 | break;
|
| 3061 | case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
|
| 3062 | if(clientVersion >= 3)
|
| 3063 | {
|
| 3064 | *params = renderbuffer->getGreenSize();
|
| 3065 | }
|
| 3066 | else return error(GL_INVALID_ENUM);
|
| 3067 | break;
|
| 3068 | case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
|
| 3069 | if(clientVersion >= 3)
|
| 3070 | {
|
| 3071 | *params = renderbuffer->getBlueSize();
|
| 3072 | }
|
| 3073 | else return error(GL_INVALID_ENUM);
|
| 3074 | break;
|
| 3075 | case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
|
| 3076 | if(clientVersion >= 3)
|
| 3077 | {
|
| 3078 | *params = renderbuffer->getAlphaSize();
|
| 3079 | }
|
| 3080 | else return error(GL_INVALID_ENUM);
|
| 3081 | break;
|
| 3082 | case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
|
| 3083 | if(clientVersion >= 3)
|
| 3084 | {
|
| 3085 | *params = renderbuffer->getDepthSize();
|
| 3086 | }
|
| 3087 | else return error(GL_INVALID_ENUM);
|
| 3088 | break;
|
| 3089 | case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
|
| 3090 | if(clientVersion >= 3)
|
| 3091 | {
|
| 3092 | *params = renderbuffer->getStencilSize();
|
| 3093 | }
|
| 3094 | else return error(GL_INVALID_ENUM);
|
| 3095 | break;
|
| 3096 | case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
|
| 3097 | if(clientVersion >= 3)
|
| 3098 | {
|
| 3099 | if(attachment == GL_DEPTH_STENCIL_ATTACHMENT)
|
| 3100 | {
|
| 3101 | return error(GL_INVALID_OPERATION);
|
| 3102 | }
|
| 3103 |
|
| 3104 | *params = sw2es::GetComponentType(renderbuffer->getInternalFormat(), attachment);
|
| 3105 | }
|
| 3106 | else return error(GL_INVALID_ENUM);
|
| 3107 | break;
|
| 3108 | case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
|
| 3109 | if(clientVersion >= 3)
|
| 3110 | {
|
| 3111 | *params = GL_LINEAR; // FIXME: GL_SRGB will also be possible, when sRGB is added
|
| 3112 | }
|
| 3113 | else return error(GL_INVALID_ENUM);
|
| 3114 | break;
|
| 3115 | default:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3116 | return error(GL_INVALID_ENUM);
|
| 3117 | }
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3118 | }
|
| 3119 | else
|
| 3120 | {
|
| 3121 | // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
|
| 3122 | // is NONE, then querying any other pname will generate INVALID_ENUM.
|
| 3123 |
|
| 3124 | // ES 3.0.2 spec pg 235 states that if the attachment type is none,
|
| 3125 | // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
|
| 3126 | // INVALID_OPERATION for all other pnames
|
| 3127 |
|
| 3128 | switch(pname)
|
Alexis Hetu | 074c641 | 2015-06-22 15:57:27 -0400 | [diff] [blame] | 3129 | {
|
Alexis Hetu | 5dcf88b | 2015-12-02 15:29:43 -0500 | [diff] [blame] | 3130 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
|
| 3131 | *params = GL_NONE;
|
| 3132 | break;
|
| 3133 |
|
| 3134 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
|
| 3135 | if(clientVersion < 3)
|
| 3136 | {
|
| 3137 | return error(GL_INVALID_ENUM);
|
| 3138 | }
|
| 3139 | *params = 0;
|
| 3140 | break;
|
| 3141 |
|
| 3142 | default:
|
| 3143 | if(clientVersion < 3)
|
| 3144 | {
|
| 3145 | return error(GL_INVALID_ENUM);
|
| 3146 | }
|
| 3147 | else
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 3148 | {
|
| 3149 | return error(GL_INVALID_OPERATION);
|
| 3150 | }
|
Alexis Hetu | a734c0f | 2015-07-03 10:42:25 -0400 | [diff] [blame] | 3151 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3152 | }
|
| 3153 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3154 | }
|
| 3155 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3156 | GLenum GetGraphicsResetStatusEXT(void)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3157 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3158 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3159 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3160 | return GL_NO_ERROR;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3161 | }
|
| 3162 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3163 | void GetIntegerv(GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3164 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3165 | TRACE("(GLenum pname = 0x%X, GLint* params = %p)", pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3166 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3167 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3168 |
|
Nicolas Capens | 7ae353d | 2015-03-13 17:59:58 -0400 | [diff] [blame] | 3169 | if(!context)
|
| 3170 | {
|
Greg Hartman | 6074f12 | 2015-04-08 09:57:16 -0700 | [diff] [blame] | 3171 | // Not strictly an error, but probably unintended or attempting to rely on non-compliant behavior
|
| 3172 | #ifdef __ANDROID__
|
| 3173 | ALOGI("expected_badness glGetIntegerv() called without current context.");
|
| 3174 | #else
|
| 3175 | ERR("glGetIntegerv() called without current context.");
|
| 3176 | #endif
|
Nicolas Capens | 7ae353d | 2015-03-13 17:59:58 -0400 | [diff] [blame] | 3177 |
|
| 3178 | // This is not spec compliant! When there is no current GL context, functions should
|
| 3179 | // have no side effects. Google Maps queries these values before creating a context,
|
| 3180 | // so we need this as a bug-compatible workaround.
|
| 3181 | switch(pname)
|
| 3182 | {
|
| 3183 | case GL_MAX_TEXTURE_SIZE: *params = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE; return;
|
| 3184 | case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = es2::MAX_VERTEX_TEXTURE_IMAGE_UNITS; return;
|
| 3185 | case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = es2::MAX_COMBINED_TEXTURE_IMAGE_UNITS; return;
|
| 3186 | case GL_STENCIL_BITS: *params = 8; return;
|
| 3187 | case GL_ALIASED_LINE_WIDTH_RANGE:
|
| 3188 | params[0] = (GLint)es2::ALIASED_LINE_WIDTH_RANGE_MIN;
|
| 3189 | params[1] = (GLint)es2::ALIASED_LINE_WIDTH_RANGE_MAX;
|
| 3190 | return;
|
| 3191 | }
|
| 3192 | }
|
| 3193 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3194 | if(context)
|
| 3195 | {
|
| 3196 | if(!(context->getIntegerv(pname, params)))
|
| 3197 | {
|
| 3198 | GLenum nativeType;
|
| 3199 | unsigned int numParams = 0;
|
| 3200 | if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
|
| 3201 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3202 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3203 | if(numParams == 0)
|
| 3204 | 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] | 3205 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3206 | if(nativeType == GL_BOOL)
|
| 3207 | {
|
| 3208 | GLboolean *boolParams = NULL;
|
| 3209 | boolParams = new GLboolean[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3210 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3211 | context->getBooleanv(pname, boolParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3212 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3213 | for(unsigned int i = 0; i < numParams; ++i)
|
| 3214 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3215 | params[i] = (boolParams[i] == GL_FALSE) ? 0 : 1;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3216 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3217 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3218 | delete [] boolParams;
|
| 3219 | }
|
| 3220 | else if(nativeType == GL_FLOAT)
|
| 3221 | {
|
| 3222 | GLfloat *floatParams = NULL;
|
| 3223 | floatParams = new GLfloat[numParams];
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3224 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3225 | context->getFloatv(pname, floatParams);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3226 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3227 | for(unsigned int i = 0; i < numParams; ++i)
|
| 3228 | {
|
| 3229 | if(pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
|
| 3230 | {
|
Alexis Hetu | 5a01c18 | 2015-04-16 13:14:04 -0400 | [diff] [blame] | 3231 | params[i] = es2::floatToInt(floatParams[i]);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3232 | }
|
| 3233 | else
|
| 3234 | {
|
| 3235 | params[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
|
| 3236 | }
|
| 3237 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3238 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3239 | delete [] floatParams;
|
| 3240 | }
|
| 3241 | }
|
| 3242 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3243 | }
|
| 3244 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3245 | void GetProgramiv(GLuint program, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3246 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3247 | TRACE("(GLuint program = %d, GLenum pname = 0x%X, GLint* params = %p)", program, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3248 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3249 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3250 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3251 | if(context)
|
| 3252 | {
|
| 3253 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3254 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3255 | if(!programObject)
|
| 3256 | {
|
| 3257 | return error(GL_INVALID_VALUE);
|
| 3258 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3259 |
|
Alexis Hetu | d174674 | 2015-04-30 15:48:23 -0400 | [diff] [blame] | 3260 | egl::GLint clientVersion = egl::getClientVersion();
|
| 3261 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3262 | switch(pname)
|
| 3263 | {
|
| 3264 | case GL_DELETE_STATUS:
|
| 3265 | *params = programObject->isFlaggedForDeletion();
|
| 3266 | return;
|
| 3267 | case GL_LINK_STATUS:
|
| 3268 | *params = programObject->isLinked();
|
| 3269 | return;
|
| 3270 | case GL_VALIDATE_STATUS:
|
| 3271 | *params = programObject->isValidated();
|
| 3272 | return;
|
| 3273 | case GL_INFO_LOG_LENGTH:
|
| 3274 | *params = programObject->getInfoLogLength();
|
| 3275 | return;
|
| 3276 | case GL_ATTACHED_SHADERS:
|
| 3277 | *params = programObject->getAttachedShadersCount();
|
| 3278 | return;
|
| 3279 | case GL_ACTIVE_ATTRIBUTES:
|
| 3280 | *params = programObject->getActiveAttributeCount();
|
| 3281 | return;
|
| 3282 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
|
| 3283 | *params = programObject->getActiveAttributeMaxLength();
|
| 3284 | return;
|
| 3285 | case GL_ACTIVE_UNIFORMS:
|
| 3286 | *params = programObject->getActiveUniformCount();
|
| 3287 | return;
|
| 3288 | case GL_ACTIVE_UNIFORM_MAX_LENGTH:
|
| 3289 | *params = programObject->getActiveUniformMaxLength();
|
| 3290 | return;
|
Alexis Hetu | d174674 | 2015-04-30 15:48:23 -0400 | [diff] [blame] | 3291 | case GL_ACTIVE_UNIFORM_BLOCKS:
|
| 3292 | if(clientVersion >= 3)
|
| 3293 | {
|
| 3294 | *params = programObject->getActiveUniformBlockCount();
|
| 3295 | return;
|
| 3296 | }
|
| 3297 | else return error(GL_INVALID_ENUM);
|
| 3298 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
|
| 3299 | if(clientVersion >= 3)
|
| 3300 | {
|
| 3301 | *params = programObject->getActiveUniformBlockMaxLength();
|
| 3302 | return;
|
| 3303 | }
|
| 3304 | else return error(GL_INVALID_ENUM);
|
Alexis Hetu | 638e2ae | 2015-06-10 16:03:17 -0400 | [diff] [blame] | 3305 | case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
|
| 3306 | if(clientVersion >= 3)
|
| 3307 | {
|
| 3308 | *params = programObject->getTransformFeedbackBufferMode();
|
| 3309 | return;
|
| 3310 | }
|
| 3311 | else return error(GL_INVALID_ENUM);
|
| 3312 | case GL_TRANSFORM_FEEDBACK_VARYINGS:
|
| 3313 | if(clientVersion >= 3)
|
| 3314 | {
|
| 3315 | *params = programObject->getTransformFeedbackVaryingCount();
|
| 3316 | return;
|
| 3317 | }
|
| 3318 | else return error(GL_INVALID_ENUM);
|
| 3319 | case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
|
| 3320 | if(clientVersion >= 3)
|
| 3321 | {
|
| 3322 | *params = programObject->getTransformFeedbackVaryingMaxLength();
|
| 3323 | return;
|
| 3324 | }
|
| 3325 | else return error(GL_INVALID_ENUM);
|
| 3326 | case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
|
| 3327 | if(clientVersion >= 3)
|
| 3328 | {
|
Alexis Hetu | fef22a6 | 2015-06-30 17:03:10 -0400 | [diff] [blame] | 3329 | *params = programObject->getBinaryRetrievableHint();
|
| 3330 | return;
|
| 3331 | }
|
| 3332 | else return error(GL_INVALID_ENUM);
|
| 3333 | case GL_PROGRAM_BINARY_LENGTH:
|
| 3334 | if(clientVersion >= 3)
|
| 3335 | {
|
| 3336 | *params = programObject->getBinaryLength();
|
| 3337 | return;
|
Alexis Hetu | 638e2ae | 2015-06-10 16:03:17 -0400 | [diff] [blame] | 3338 | }
|
| 3339 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3340 | default:
|
| 3341 | return error(GL_INVALID_ENUM);
|
| 3342 | }
|
| 3343 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3344 | }
|
| 3345 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3346 | void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3347 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3348 | TRACE("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = %p, GLchar* infolog = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3349 | program, bufsize, length, infolog);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3350 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3351 | if(bufsize < 0)
|
| 3352 | {
|
| 3353 | return error(GL_INVALID_VALUE);
|
| 3354 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3355 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3356 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3357 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3358 | if(context)
|
| 3359 | {
|
| 3360 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3361 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3362 | if(!programObject)
|
| 3363 | {
|
| 3364 | return error(GL_INVALID_VALUE);
|
| 3365 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3366 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3367 | programObject->getInfoLog(bufsize, length, infolog);
|
| 3368 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3369 | }
|
| 3370 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3371 | void GetQueryivEXT(GLenum target, GLenum pname, GLint *params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3372 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3373 | TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = %p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3374 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3375 | switch(pname)
|
| 3376 | {
|
| 3377 | case GL_CURRENT_QUERY_EXT:
|
| 3378 | break;
|
| 3379 | default:
|
| 3380 | return error(GL_INVALID_ENUM);
|
| 3381 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3382 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3383 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3384 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3385 | if(context)
|
| 3386 | {
|
| 3387 | params[0] = context->getActiveQuery(target);
|
| 3388 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3389 | }
|
| 3390 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3391 | void GetQueryObjectuivEXT(GLuint name, GLenum pname, GLuint *params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3392 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3393 | TRACE("(GLuint name = %d, GLenum pname = 0x%X, GLuint *params = %p)", name, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3394 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3395 | switch(pname)
|
| 3396 | {
|
| 3397 | case GL_QUERY_RESULT_EXT:
|
| 3398 | case GL_QUERY_RESULT_AVAILABLE_EXT:
|
| 3399 | break;
|
| 3400 | default:
|
| 3401 | return error(GL_INVALID_ENUM);
|
| 3402 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3403 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3404 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3405 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3406 | if(context)
|
| 3407 | {
|
Alexis Hetu | 8e32f7b | 2015-04-28 09:59:09 -0400 | [diff] [blame] | 3408 | es2::Query *queryObject = context->getQuery(name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3409 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3410 | if(!queryObject)
|
| 3411 | {
|
| 3412 | return error(GL_INVALID_OPERATION);
|
| 3413 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3414 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3415 | if(context->getActiveQuery(queryObject->getType()) == name)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3416 | {
|
| 3417 | return error(GL_INVALID_OPERATION);
|
| 3418 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3419 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3420 | switch(pname)
|
| 3421 | {
|
| 3422 | case GL_QUERY_RESULT_EXT:
|
| 3423 | params[0] = queryObject->getResult();
|
| 3424 | break;
|
| 3425 | case GL_QUERY_RESULT_AVAILABLE_EXT:
|
| 3426 | params[0] = queryObject->isResultAvailable();
|
| 3427 | break;
|
| 3428 | default:
|
| 3429 | ASSERT(false);
|
| 3430 | }
|
| 3431 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3432 | }
|
| 3433 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3434 | void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3435 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3436 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = %p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3437 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3438 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3439 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3440 | if(context)
|
| 3441 | {
|
| 3442 | if(target != GL_RENDERBUFFER)
|
| 3443 | {
|
| 3444 | return error(GL_INVALID_ENUM);
|
| 3445 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3446 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3447 | if(context->getRenderbufferName() == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3448 | {
|
| 3449 | return error(GL_INVALID_OPERATION);
|
| 3450 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3451 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 3452 | es2::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferName());
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3453 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3454 | switch(pname)
|
| 3455 | {
|
| 3456 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
|
| 3457 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
|
| 3458 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getFormat(); break;
|
| 3459 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
|
| 3460 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
|
| 3461 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
|
| 3462 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
|
| 3463 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
|
| 3464 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
|
| 3465 | case GL_RENDERBUFFER_SAMPLES_ANGLE: *params = renderbuffer->getSamples(); break;
|
| 3466 | default:
|
| 3467 | return error(GL_INVALID_ENUM);
|
| 3468 | }
|
| 3469 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3470 | }
|
| 3471 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3472 | void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3473 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3474 | TRACE("(GLuint shader = %d, GLenum pname = %d, GLint* params = %p)", shader, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3475 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3476 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3477 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3478 | if(context)
|
| 3479 | {
|
| 3480 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3481 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3482 | if(!shaderObject)
|
| 3483 | {
|
| 3484 | return error(GL_INVALID_VALUE);
|
| 3485 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3486 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3487 | switch(pname)
|
| 3488 | {
|
| 3489 | case GL_SHADER_TYPE:
|
| 3490 | *params = shaderObject->getType();
|
| 3491 | return;
|
| 3492 | case GL_DELETE_STATUS:
|
| 3493 | *params = shaderObject->isFlaggedForDeletion();
|
| 3494 | return;
|
| 3495 | case GL_COMPILE_STATUS:
|
| 3496 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
|
| 3497 | return;
|
| 3498 | case GL_INFO_LOG_LENGTH:
|
| 3499 | *params = shaderObject->getInfoLogLength();
|
| 3500 | return;
|
| 3501 | case GL_SHADER_SOURCE_LENGTH:
|
| 3502 | *params = shaderObject->getSourceLength();
|
| 3503 | return;
|
| 3504 | default:
|
| 3505 | return error(GL_INVALID_ENUM);
|
| 3506 | }
|
| 3507 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3508 | }
|
| 3509 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3510 | void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3511 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3512 | TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = %p, GLchar* infolog = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3513 | shader, bufsize, length, infolog);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3514 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3515 | if(bufsize < 0)
|
| 3516 | {
|
| 3517 | return error(GL_INVALID_VALUE);
|
| 3518 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3519 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3520 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3521 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3522 | if(context)
|
| 3523 | {
|
| 3524 | es2::Shader *shaderObject = context->getShader(shader);
|
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(!shaderObject)
|
| 3527 | {
|
| 3528 | return error(GL_INVALID_VALUE);
|
| 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 | shaderObject->getInfoLog(bufsize, length, infolog);
|
| 3532 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3533 | }
|
| 3534 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3535 | void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3536 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3537 | TRACE("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = %p, GLint* precision = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3538 | shadertype, precisiontype, range, precision);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3539 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3540 | switch(shadertype)
|
| 3541 | {
|
| 3542 | case GL_VERTEX_SHADER:
|
| 3543 | case GL_FRAGMENT_SHADER:
|
| 3544 | break;
|
| 3545 | default:
|
| 3546 | return error(GL_INVALID_ENUM);
|
| 3547 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3548 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3549 | switch(precisiontype)
|
| 3550 | {
|
| 3551 | case GL_LOW_FLOAT:
|
| 3552 | case GL_MEDIUM_FLOAT:
|
| 3553 | case GL_HIGH_FLOAT:
|
| 3554 | // IEEE 754 single-precision
|
| 3555 | range[0] = 127;
|
| 3556 | range[1] = 127;
|
| 3557 | *precision = 23;
|
| 3558 | break;
|
| 3559 | case GL_LOW_INT:
|
| 3560 | case GL_MEDIUM_INT:
|
| 3561 | case GL_HIGH_INT:
|
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 3562 | // Full integer precision is supported
|
| 3563 | range[0] = 31;
|
| 3564 | range[1] = 30;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3565 | *precision = 0;
|
| 3566 | break;
|
| 3567 | default:
|
| 3568 | return error(GL_INVALID_ENUM);
|
| 3569 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3570 | }
|
| 3571 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3572 | void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3573 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3574 | TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = %p, GLchar* source = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3575 | shader, bufsize, length, source);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3576 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3577 | if(bufsize < 0)
|
| 3578 | {
|
| 3579 | return error(GL_INVALID_VALUE);
|
| 3580 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3581 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3582 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3583 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3584 | if(context)
|
| 3585 | {
|
| 3586 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3587 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3588 | if(!shaderObject)
|
| 3589 | {
|
| 3590 | return error(GL_INVALID_OPERATION);
|
| 3591 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3592 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3593 | shaderObject->getSource(bufsize, length, source);
|
| 3594 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3595 | }
|
| 3596 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3597 | const GLubyte* GetString(GLenum name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3598 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3599 | TRACE("(GLenum name = 0x%X)", name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3600 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3601 | switch(name)
|
| 3602 | {
|
| 3603 | case GL_VENDOR:
|
Alexis Hetu | 8141d7c | 2015-04-02 16:45:59 -0400 | [diff] [blame] | 3604 | return (GLubyte*)"Google Inc.";
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3605 | case GL_RENDERER:
|
Nicolas Capens | e3ae428 | 2015-11-12 22:47:30 -0500 | [diff] [blame] | 3606 | return (GLubyte*)"Google SwiftShader";
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3607 | case GL_VERSION:
|
Alexis Hetu | 18bcfcc | 2015-07-03 10:57:21 -0400 | [diff] [blame] | 3608 | {
|
| 3609 | es2::Context *context = es2::getContext();
|
| 3610 | return (context && (context->getClientVersion() >= 3)) ?
|
| 3611 | (GLubyte*)"OpenGL ES 3.0 SwiftShader " VERSION_STRING :
|
| 3612 | (GLubyte*)"OpenGL ES 2.0 SwiftShader " VERSION_STRING;
|
| 3613 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3614 | case GL_SHADING_LANGUAGE_VERSION:
|
Alexis Hetu | 18bcfcc | 2015-07-03 10:57:21 -0400 | [diff] [blame] | 3615 | {
|
| 3616 | es2::Context *context = es2::getContext();
|
| 3617 | return (context && (context->getClientVersion() >= 3)) ?
|
| 3618 | (GLubyte*)"OpenGL ES GLSL ES 3.00 SwiftShader " VERSION_STRING :
|
| 3619 | (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader " VERSION_STRING;
|
| 3620 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3621 | case GL_EXTENSIONS:
|
Alexis Hetu | 8141d7c | 2015-04-02 16:45:59 -0400 | [diff] [blame] | 3622 | {
|
| 3623 | es2::Context *context = es2::getContext();
|
| 3624 | return context ? context->getExtensions(GL_INVALID_INDEX) : (GLubyte*)NULL;
|
| 3625 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3626 | default:
|
| 3627 | return error(GL_INVALID_ENUM, (GLubyte*)NULL);
|
| 3628 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3629 | }
|
| 3630 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3631 | void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3632 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3633 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = %p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3634 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3635 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3636 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3637 | if(context)
|
| 3638 | {
|
| 3639 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3640 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3641 | egl::GLint clientVersion = context->getClientVersion();
|
| 3642 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3643 | switch(target)
|
| 3644 | {
|
| 3645 | case GL_TEXTURE_2D:
|
| 3646 | texture = context->getTexture2D();
|
| 3647 | break;
|
| 3648 | case GL_TEXTURE_CUBE_MAP:
|
| 3649 | texture = context->getTextureCubeMap();
|
| 3650 | break;
|
| 3651 | case GL_TEXTURE_EXTERNAL_OES:
|
| 3652 | texture = context->getTextureExternal();
|
| 3653 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3654 | case GL_TEXTURE_2D_ARRAY:
|
| 3655 | if(clientVersion < 3)
|
| 3656 | {
|
| 3657 | return error(GL_INVALID_ENUM);
|
| 3658 | }
|
| 3659 | else
|
| 3660 | {
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 3661 | texture = context->getTexture2DArray();
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3662 | }
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 3663 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3664 | case GL_TEXTURE_3D_OES:
|
| 3665 | texture = context->getTexture3D();
|
| 3666 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3667 | default:
|
| 3668 | return error(GL_INVALID_ENUM);
|
| 3669 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3670 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3671 | switch(pname)
|
| 3672 | {
|
| 3673 | case GL_TEXTURE_MAG_FILTER:
|
| 3674 | *params = (GLfloat)texture->getMagFilter();
|
| 3675 | break;
|
| 3676 | case GL_TEXTURE_MIN_FILTER:
|
| 3677 | *params = (GLfloat)texture->getMinFilter();
|
| 3678 | break;
|
| 3679 | case GL_TEXTURE_WRAP_S:
|
| 3680 | *params = (GLfloat)texture->getWrapS();
|
| 3681 | break;
|
| 3682 | case GL_TEXTURE_WRAP_T:
|
| 3683 | *params = (GLfloat)texture->getWrapT();
|
| 3684 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 3685 | case GL_TEXTURE_WRAP_R_OES:
|
| 3686 | *params = (GLfloat)texture->getWrapR();
|
| 3687 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3688 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 3689 | *params = texture->getMaxAnisotropy();
|
| 3690 | break;
|
| 3691 | case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
|
| 3692 | *params = (GLfloat)1;
|
| 3693 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3694 | case GL_TEXTURE_BASE_LEVEL:
|
| 3695 | if(clientVersion >= 3)
|
| 3696 | {
|
| 3697 | *params = (GLfloat)texture->getBaseLevel();
|
| 3698 | break;
|
| 3699 | }
|
| 3700 | else return error(GL_INVALID_ENUM);
|
| 3701 | case GL_TEXTURE_COMPARE_FUNC:
|
| 3702 | if(clientVersion >= 3)
|
| 3703 | {
|
| 3704 | *params = (GLfloat)texture->getCompareFunc();
|
| 3705 | break;
|
| 3706 | }
|
| 3707 | else return error(GL_INVALID_ENUM);
|
| 3708 | case GL_TEXTURE_COMPARE_MODE:
|
| 3709 | if(clientVersion >= 3)
|
| 3710 | {
|
| 3711 | *params = (GLfloat)texture->getCompareMode();
|
| 3712 | break;
|
| 3713 | }
|
| 3714 | else return error(GL_INVALID_ENUM);
|
| 3715 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
| 3716 | if(clientVersion >= 3)
|
| 3717 | {
|
| 3718 | *params = (GLfloat)texture->getImmutableFormat();
|
| 3719 | break;
|
| 3720 | }
|
| 3721 | else return error(GL_INVALID_ENUM);
|
| 3722 | case GL_TEXTURE_MAX_LEVEL:
|
| 3723 | if(clientVersion >= 3)
|
| 3724 | {
|
| 3725 | *params = (GLfloat)texture->getMaxLevel();
|
| 3726 | break;
|
| 3727 | }
|
| 3728 | else return error(GL_INVALID_ENUM);
|
| 3729 | case GL_TEXTURE_MAX_LOD:
|
| 3730 | if(clientVersion >= 3)
|
| 3731 | {
|
| 3732 | *params = texture->getMaxLOD();
|
| 3733 | break;
|
| 3734 | }
|
| 3735 | else return error(GL_INVALID_ENUM);
|
| 3736 | case GL_TEXTURE_MIN_LOD:
|
| 3737 | if(clientVersion >= 3)
|
| 3738 | {
|
| 3739 | *params = texture->getMinLOD();
|
| 3740 | break;
|
| 3741 | }
|
| 3742 | else return error(GL_INVALID_ENUM);
|
| 3743 | case GL_TEXTURE_SWIZZLE_R:
|
| 3744 | if(clientVersion >= 3)
|
| 3745 | {
|
| 3746 | *params = (GLfloat)texture->getSwizzleR();
|
| 3747 | break;
|
| 3748 | }
|
| 3749 | else return error(GL_INVALID_ENUM);
|
| 3750 | case GL_TEXTURE_SWIZZLE_G:
|
| 3751 | if(clientVersion >= 3)
|
| 3752 | {
|
| 3753 | *params = (GLfloat)texture->getSwizzleG();
|
| 3754 | break;
|
| 3755 | }
|
| 3756 | else return error(GL_INVALID_ENUM);
|
| 3757 | case GL_TEXTURE_SWIZZLE_B:
|
| 3758 | if(clientVersion >= 3)
|
| 3759 | {
|
| 3760 | *params = (GLfloat)texture->getSwizzleB();
|
| 3761 | break;
|
| 3762 | }
|
| 3763 | else return error(GL_INVALID_ENUM);
|
| 3764 | case GL_TEXTURE_SWIZZLE_A:
|
| 3765 | if(clientVersion >= 3)
|
| 3766 | {
|
| 3767 | *params = (GLfloat)texture->getSwizzleA();
|
| 3768 | break;
|
| 3769 | }
|
| 3770 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3771 | default:
|
| 3772 | return error(GL_INVALID_ENUM);
|
| 3773 | }
|
| 3774 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3775 | }
|
| 3776 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3777 | void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3778 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3779 | TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = %p)", target, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3780 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3781 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3782 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3783 | if(context)
|
| 3784 | {
|
| 3785 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3786 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3787 | egl::GLint clientVersion = context->getClientVersion();
|
| 3788 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3789 | switch(target)
|
| 3790 | {
|
| 3791 | case GL_TEXTURE_2D:
|
| 3792 | texture = context->getTexture2D();
|
| 3793 | break;
|
| 3794 | case GL_TEXTURE_CUBE_MAP:
|
| 3795 | texture = context->getTextureCubeMap();
|
| 3796 | break;
|
| 3797 | case GL_TEXTURE_EXTERNAL_OES:
|
| 3798 | texture = context->getTextureExternal();
|
| 3799 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3800 | case GL_TEXTURE_2D_ARRAY:
|
| 3801 | if(clientVersion < 3)
|
| 3802 | {
|
| 3803 | return error(GL_INVALID_ENUM);
|
| 3804 | }
|
| 3805 | else
|
| 3806 | {
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 3807 | texture = context->getTexture2DArray();
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3808 | }
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 3809 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3810 | case GL_TEXTURE_3D_OES:
|
| 3811 | texture = context->getTexture3D();
|
| 3812 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3813 | default:
|
| 3814 | return error(GL_INVALID_ENUM);
|
| 3815 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3816 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3817 | switch(pname)
|
| 3818 | {
|
| 3819 | case GL_TEXTURE_MAG_FILTER:
|
| 3820 | *params = texture->getMagFilter();
|
| 3821 | break;
|
| 3822 | case GL_TEXTURE_MIN_FILTER:
|
| 3823 | *params = texture->getMinFilter();
|
| 3824 | break;
|
| 3825 | case GL_TEXTURE_WRAP_S:
|
| 3826 | *params = texture->getWrapS();
|
| 3827 | break;
|
| 3828 | case GL_TEXTURE_WRAP_T:
|
| 3829 | *params = texture->getWrapT();
|
| 3830 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 3831 | case GL_TEXTURE_WRAP_R_OES:
|
| 3832 | *params = texture->getWrapR();
|
| 3833 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3834 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 3835 | *params = (GLint)texture->getMaxAnisotropy();
|
| 3836 | break;
|
| 3837 | case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
|
| 3838 | *params = 1;
|
| 3839 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3840 | case GL_TEXTURE_BASE_LEVEL:
|
| 3841 | if(clientVersion >= 3)
|
| 3842 | {
|
| 3843 | *params = texture->getBaseLevel();
|
| 3844 | break;
|
| 3845 | }
|
| 3846 | else return error(GL_INVALID_ENUM);
|
| 3847 | case GL_TEXTURE_COMPARE_FUNC:
|
| 3848 | if(clientVersion >= 3)
|
| 3849 | {
|
| 3850 | *params = (GLint)texture->getCompareFunc();
|
| 3851 | break;
|
| 3852 | }
|
| 3853 | else return error(GL_INVALID_ENUM);
|
| 3854 | case GL_TEXTURE_COMPARE_MODE:
|
| 3855 | if(clientVersion >= 3)
|
| 3856 | {
|
| 3857 | *params = (GLint)texture->getCompareMode();
|
| 3858 | break;
|
| 3859 | }
|
| 3860 | else return error(GL_INVALID_ENUM);
|
| 3861 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
| 3862 | if(clientVersion >= 3)
|
| 3863 | {
|
| 3864 | *params = (GLint)texture->getImmutableFormat();
|
| 3865 | break;
|
| 3866 | }
|
| 3867 | else return error(GL_INVALID_ENUM);
|
| 3868 | case GL_TEXTURE_MAX_LEVEL:
|
| 3869 | if(clientVersion >= 3)
|
| 3870 | {
|
| 3871 | *params = texture->getMaxLevel();
|
| 3872 | break;
|
| 3873 | }
|
| 3874 | else return error(GL_INVALID_ENUM);
|
| 3875 | case GL_TEXTURE_MAX_LOD:
|
| 3876 | if(clientVersion >= 3)
|
| 3877 | {
|
Alexis Hetu | b1a071f | 2015-07-03 15:46:32 -0400 | [diff] [blame] | 3878 | *params = (GLint)roundf(texture->getMaxLOD());
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3879 | break;
|
| 3880 | }
|
| 3881 | else return error(GL_INVALID_ENUM);
|
| 3882 | case GL_TEXTURE_MIN_LOD:
|
| 3883 | if(clientVersion >= 3)
|
| 3884 | {
|
Alexis Hetu | b1a071f | 2015-07-03 15:46:32 -0400 | [diff] [blame] | 3885 | *params = (GLint)roundf(texture->getMinLOD());
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 3886 | break;
|
| 3887 | }
|
| 3888 | else return error(GL_INVALID_ENUM);
|
| 3889 | case GL_TEXTURE_SWIZZLE_R:
|
| 3890 | if(clientVersion >= 3)
|
| 3891 | {
|
| 3892 | *params = (GLint)texture->getSwizzleR();
|
| 3893 | break;
|
| 3894 | }
|
| 3895 | else return error(GL_INVALID_ENUM);
|
| 3896 | case GL_TEXTURE_SWIZZLE_G:
|
| 3897 | if(clientVersion >= 3)
|
| 3898 | {
|
| 3899 | *params = (GLint)texture->getSwizzleG();
|
| 3900 | break;
|
| 3901 | }
|
| 3902 | else return error(GL_INVALID_ENUM);
|
| 3903 | case GL_TEXTURE_SWIZZLE_B:
|
| 3904 | if(clientVersion >= 3)
|
| 3905 | {
|
| 3906 | *params = (GLint)texture->getSwizzleB();
|
| 3907 | break;
|
| 3908 | }
|
| 3909 | else return error(GL_INVALID_ENUM);
|
| 3910 | case GL_TEXTURE_SWIZZLE_A:
|
| 3911 | if(clientVersion >= 3)
|
| 3912 | {
|
| 3913 | *params = (GLint)texture->getSwizzleA();
|
| 3914 | break;
|
| 3915 | }
|
| 3916 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3917 | default:
|
| 3918 | return error(GL_INVALID_ENUM);
|
| 3919 | }
|
| 3920 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3921 | }
|
| 3922 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3923 | void GetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3924 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3925 | TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3926 | program, location, bufSize, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3927 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3928 | if(bufSize < 0)
|
| 3929 | {
|
| 3930 | return error(GL_INVALID_VALUE);
|
| 3931 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3932 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3933 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3934 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3935 | if(context)
|
| 3936 | {
|
| 3937 | if(program == 0)
|
| 3938 | {
|
| 3939 | return error(GL_INVALID_VALUE);
|
| 3940 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3941 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3942 | es2::Program *programObject = context->getProgram(program);
|
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 | if(!programObject || !programObject->isLinked())
|
| 3945 | {
|
| 3946 | return error(GL_INVALID_OPERATION);
|
| 3947 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3948 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3949 | if(!programObject->getUniformfv(location, &bufSize, params))
|
| 3950 | {
|
| 3951 | return error(GL_INVALID_OPERATION);
|
| 3952 | }
|
| 3953 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3954 | }
|
| 3955 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3956 | void GetUniformfv(GLuint program, GLint location, GLfloat* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3957 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3958 | TRACE("(GLuint program = %d, GLint location = %d, GLfloat* params = %p)", program, location, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3959 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3960 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3961 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3962 | if(context)
|
| 3963 | {
|
| 3964 | if(program == 0)
|
| 3965 | {
|
| 3966 | return error(GL_INVALID_VALUE);
|
| 3967 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3968 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3969 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3970 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3971 | if(!programObject || !programObject->isLinked())
|
| 3972 | {
|
| 3973 | return error(GL_INVALID_OPERATION);
|
| 3974 | }
|
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(!programObject->getUniformfv(location, NULL, params))
|
| 3977 | {
|
| 3978 | return error(GL_INVALID_OPERATION);
|
| 3979 | }
|
| 3980 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3981 | }
|
| 3982 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 3983 | void GetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3984 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 3985 | TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3986 | program, location, bufSize, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3987 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3988 | if(bufSize < 0)
|
| 3989 | {
|
| 3990 | return error(GL_INVALID_VALUE);
|
| 3991 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3992 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3993 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3994 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 3995 | if(context)
|
| 3996 | {
|
| 3997 | if(program == 0)
|
| 3998 | {
|
| 3999 | return error(GL_INVALID_VALUE);
|
| 4000 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4001 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4002 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4003 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4004 | if(!programObject || !programObject->isLinked())
|
| 4005 | {
|
| 4006 | return error(GL_INVALID_OPERATION);
|
| 4007 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4008 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4009 | if(!programObject)
|
| 4010 | {
|
| 4011 | return error(GL_INVALID_OPERATION);
|
| 4012 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4013 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4014 | if(!programObject->getUniformiv(location, &bufSize, params))
|
| 4015 | {
|
| 4016 | return error(GL_INVALID_OPERATION);
|
| 4017 | }
|
| 4018 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4019 | }
|
| 4020 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4021 | void GetUniformiv(GLuint program, GLint location, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4022 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4023 | TRACE("(GLuint program = %d, GLint location = %d, GLint* params = %p)", program, location, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4024 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4025 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4026 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4027 | if(context)
|
| 4028 | {
|
| 4029 | if(program == 0)
|
| 4030 | {
|
| 4031 | return error(GL_INVALID_VALUE);
|
| 4032 | }
|
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 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4035 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4036 | if(!programObject || !programObject->isLinked())
|
| 4037 | {
|
| 4038 | return error(GL_INVALID_OPERATION);
|
| 4039 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4040 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4041 | if(!programObject)
|
| 4042 | {
|
| 4043 | return error(GL_INVALID_OPERATION);
|
| 4044 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4045 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4046 | if(!programObject->getUniformiv(location, NULL, params))
|
| 4047 | {
|
| 4048 | return error(GL_INVALID_OPERATION);
|
| 4049 | }
|
| 4050 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4051 | }
|
| 4052 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4053 | int GetUniformLocation(GLuint program, const GLchar* name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4054 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4055 | TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4056 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4057 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4058 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4059 | if(strstr(name, "gl_") == name)
|
| 4060 | {
|
| 4061 | return -1;
|
| 4062 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4063 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4064 | if(context)
|
| 4065 | {
|
| 4066 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4067 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4068 | if(!programObject)
|
| 4069 | {
|
| 4070 | if(context->getShader(program))
|
| 4071 | {
|
| 4072 | return error(GL_INVALID_OPERATION, -1);
|
| 4073 | }
|
| 4074 | else
|
| 4075 | {
|
| 4076 | return error(GL_INVALID_VALUE, -1);
|
| 4077 | }
|
| 4078 | }
|
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(!programObject->isLinked())
|
| 4081 | {
|
| 4082 | return error(GL_INVALID_OPERATION, -1);
|
| 4083 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4084 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4085 | return programObject->getUniformLocation(name);
|
| 4086 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4087 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4088 | return -1;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4089 | }
|
| 4090 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4091 | void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4092 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4093 | TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = %p)", index, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4094 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4095 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4096 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4097 | if(context)
|
| 4098 | {
|
| 4099 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 4100 | {
|
| 4101 | return error(GL_INVALID_VALUE);
|
| 4102 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4103 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4104 | const es2::VertexAttribute &attribState = context->getVertexAttribState(index);
|
Nicolas Capens | ccee6a8 | 2015-04-28 16:49:59 -0700 | [diff] [blame] | 4105 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4106 | egl::GLint clientVersion = context->getClientVersion();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4107 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4108 | switch(pname)
|
| 4109 | {
|
| 4110 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
|
| 4111 | *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
|
| 4112 | break;
|
| 4113 | case GL_VERTEX_ATTRIB_ARRAY_SIZE:
|
| 4114 | *params = (GLfloat)attribState.mSize;
|
| 4115 | break;
|
| 4116 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
|
| 4117 | *params = (GLfloat)attribState.mStride;
|
| 4118 | break;
|
| 4119 | case GL_VERTEX_ATTRIB_ARRAY_TYPE:
|
| 4120 | *params = (GLfloat)attribState.mType;
|
| 4121 | break;
|
| 4122 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
| 4123 | *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
|
| 4124 | break;
|
| 4125 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 4126 | *params = (GLfloat)attribState.mBoundBuffer.name();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4127 | break;
|
| 4128 | case GL_CURRENT_VERTEX_ATTRIB:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4129 | {
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 4130 | const VertexAttribute& attrib = context->getCurrentVertexAttributes()[index];
|
| 4131 | for(int i = 0; i < 4; ++i)
|
| 4132 | {
|
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 4133 | params[i] = attrib.getCurrentValueF(i);
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 4134 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4135 | }
|
| 4136 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4137 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
|
| 4138 | if(clientVersion >= 3)
|
| 4139 | {
|
| 4140 | switch(attribState.mType)
|
| 4141 | {
|
| 4142 | case GL_BYTE:
|
| 4143 | case GL_UNSIGNED_BYTE:
|
| 4144 | case GL_SHORT:
|
| 4145 | case GL_UNSIGNED_SHORT:
|
| 4146 | case GL_INT:
|
| 4147 | case GL_INT_2_10_10_10_REV:
|
| 4148 | case GL_UNSIGNED_INT:
|
| 4149 | case GL_FIXED:
|
| 4150 | *params = (GLfloat)GL_TRUE;
|
| 4151 | break;
|
| 4152 | default:
|
| 4153 | *params = (GLfloat)GL_FALSE;
|
| 4154 | break;
|
| 4155 | }
|
| 4156 | break;
|
| 4157 | }
|
| 4158 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4159 | default: return error(GL_INVALID_ENUM);
|
| 4160 | }
|
| 4161 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4162 | }
|
| 4163 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4164 | void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4165 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4166 | TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = %p)", index, pname, params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4167 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4168 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4169 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4170 | if(context)
|
| 4171 | {
|
| 4172 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 4173 | {
|
| 4174 | return error(GL_INVALID_VALUE);
|
| 4175 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4176 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4177 | const es2::VertexAttribute &attribState = context->getVertexAttribState(index);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4178 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4179 | egl::GLint clientVersion = context->getClientVersion();
|
| 4180 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4181 | switch(pname)
|
| 4182 | {
|
| 4183 | case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
|
| 4184 | *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
|
| 4185 | break;
|
| 4186 | case GL_VERTEX_ATTRIB_ARRAY_SIZE:
|
| 4187 | *params = attribState.mSize;
|
| 4188 | break;
|
| 4189 | case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
|
| 4190 | *params = attribState.mStride;
|
| 4191 | break;
|
| 4192 | case GL_VERTEX_ATTRIB_ARRAY_TYPE:
|
| 4193 | *params = attribState.mType;
|
| 4194 | break;
|
| 4195 | case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
| 4196 | *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
|
| 4197 | break;
|
| 4198 | case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 4199 | *params = attribState.mBoundBuffer.name();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4200 | break;
|
| 4201 | case GL_CURRENT_VERTEX_ATTRIB:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4202 | {
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 4203 | const VertexAttribute& attrib = context->getCurrentVertexAttributes()[index];
|
| 4204 | for(int i = 0; i < 4; ++i)
|
| 4205 | {
|
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 4206 | float currentValue = attrib.getCurrentValueF(i);
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 4207 | params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
|
| 4208 | }
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4209 | }
|
| 4210 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4211 | case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
|
| 4212 | if(clientVersion >= 3)
|
| 4213 | {
|
| 4214 | switch(attribState.mType)
|
| 4215 | {
|
| 4216 | case GL_BYTE:
|
| 4217 | case GL_UNSIGNED_BYTE:
|
| 4218 | case GL_SHORT:
|
| 4219 | case GL_UNSIGNED_SHORT:
|
| 4220 | case GL_INT:
|
| 4221 | case GL_INT_2_10_10_10_REV:
|
| 4222 | case GL_UNSIGNED_INT:
|
| 4223 | case GL_FIXED:
|
| 4224 | *params = GL_TRUE;
|
| 4225 | break;
|
| 4226 | default:
|
| 4227 | *params = GL_FALSE;
|
| 4228 | break;
|
| 4229 | }
|
| 4230 | break;
|
| 4231 | }
|
| 4232 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4233 | default: return error(GL_INVALID_ENUM);
|
| 4234 | }
|
| 4235 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4236 | }
|
| 4237 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4238 | void GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4239 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4240 | TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = %p)", index, pname, pointer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4241 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4242 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4243 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4244 | if(context)
|
| 4245 | {
|
| 4246 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 4247 | {
|
| 4248 | return error(GL_INVALID_VALUE);
|
| 4249 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4250 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4251 | if(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
|
| 4252 | {
|
| 4253 | return error(GL_INVALID_ENUM);
|
| 4254 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4255 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4256 | *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
|
| 4257 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4258 | }
|
| 4259 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4260 | void Hint(GLenum target, GLenum mode)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4261 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4262 | TRACE("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4263 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4264 | switch(mode)
|
| 4265 | {
|
| 4266 | case GL_FASTEST:
|
| 4267 | case GL_NICEST:
|
| 4268 | case GL_DONT_CARE:
|
| 4269 | break;
|
| 4270 | default:
|
| 4271 | return error(GL_INVALID_ENUM);
|
| 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();
|
| 4275 | switch(target)
|
| 4276 | {
|
| 4277 | case GL_GENERATE_MIPMAP_HINT:
|
| 4278 | if(context) context->setGenerateMipmapHint(mode);
|
| 4279 | break;
|
| 4280 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
|
| 4281 | if(context) context->setFragmentShaderDerivativeHint(mode);
|
| 4282 | break;
|
| 4283 | default:
|
| 4284 | return error(GL_INVALID_ENUM);
|
| 4285 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4286 | }
|
| 4287 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4288 | GLboolean IsBuffer(GLuint buffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4289 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4290 | TRACE("(GLuint buffer = %d)", buffer);
|
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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4293 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4294 | if(context && buffer)
|
| 4295 | {
|
| 4296 | es2::Buffer *bufferObject = context->getBuffer(buffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4297 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4298 | if(bufferObject)
|
| 4299 | {
|
| 4300 | return GL_TRUE;
|
| 4301 | }
|
| 4302 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4303 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4304 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4305 | }
|
| 4306 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4307 | GLboolean IsEnabled(GLenum cap)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4308 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4309 | TRACE("(GLenum cap = 0x%X)", cap);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4310 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4311 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4312 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4313 | if(context)
|
| 4314 | {
|
Alexis Hetu | 5bf8c17 | 2015-06-23 11:24:48 -0400 | [diff] [blame] | 4315 | egl::GLint clientVersion = context->getClientVersion();
|
| 4316 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4317 | switch(cap)
|
| 4318 | {
|
| 4319 | case GL_CULL_FACE: return context->isCullFaceEnabled();
|
| 4320 | case GL_POLYGON_OFFSET_FILL: return context->isPolygonOffsetFillEnabled();
|
| 4321 | case GL_SAMPLE_ALPHA_TO_COVERAGE: return context->isSampleAlphaToCoverageEnabled();
|
| 4322 | case GL_SAMPLE_COVERAGE: return context->isSampleCoverageEnabled();
|
| 4323 | case GL_SCISSOR_TEST: return context->isScissorTestEnabled();
|
| 4324 | case GL_STENCIL_TEST: return context->isStencilTestEnabled();
|
| 4325 | case GL_DEPTH_TEST: return context->isDepthTestEnabled();
|
| 4326 | case GL_BLEND: return context->isBlendEnabled();
|
| 4327 | case GL_DITHER: return context->isDitherEnabled();
|
Alexis Hetu | 5bf8c17 | 2015-06-23 11:24:48 -0400 | [diff] [blame] | 4328 | case GL_PRIMITIVE_RESTART_FIXED_INDEX:
|
| 4329 | if(clientVersion >= 3)
|
| 4330 | {
|
| 4331 | return context->isPrimitiveRestartFixedIndexEnabled();
|
| 4332 | }
|
| 4333 | else return error(GL_INVALID_ENUM, false);
|
| 4334 | case GL_RASTERIZER_DISCARD:
|
| 4335 | if(clientVersion >= 3)
|
| 4336 | {
|
| 4337 | return context->isRasterizerDiscardEnabled();
|
| 4338 | }
|
| 4339 | else return error(GL_INVALID_ENUM, false);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4340 | default:
|
| 4341 | return error(GL_INVALID_ENUM, false);
|
| 4342 | }
|
| 4343 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4344 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4345 | return false;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4346 | }
|
| 4347 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4348 | GLboolean IsFenceNV(GLuint fence)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4349 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4350 | TRACE("(GLuint fence = %d)", fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4351 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4352 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4353 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4354 | if(context)
|
| 4355 | {
|
| 4356 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4357 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4358 | if(fenceObject == NULL)
|
| 4359 | {
|
| 4360 | return GL_FALSE;
|
| 4361 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4362 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4363 | return fenceObject->isFence();
|
| 4364 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4365 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4366 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4367 | }
|
| 4368 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4369 | GLboolean IsFramebuffer(GLuint framebuffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4370 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4371 | TRACE("(GLuint framebuffer = %d)", framebuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4372 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4373 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4374 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4375 | if(context && framebuffer)
|
| 4376 | {
|
| 4377 | es2::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4378 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4379 | if(framebufferObject)
|
| 4380 | {
|
| 4381 | return GL_TRUE;
|
| 4382 | }
|
| 4383 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4384 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4385 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4386 | }
|
| 4387 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4388 | GLboolean IsProgram(GLuint program)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4389 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4390 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4391 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4392 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4393 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4394 | if(context && program)
|
| 4395 | {
|
| 4396 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4397 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4398 | if(programObject)
|
| 4399 | {
|
| 4400 | return GL_TRUE;
|
| 4401 | }
|
| 4402 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4403 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4404 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4405 | }
|
| 4406 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4407 | GLboolean IsQueryEXT(GLuint name)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4408 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 4409 | TRACE("(GLuint name = %d)", name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4410 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 4411 | if(name == 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4412 | {
|
| 4413 | return GL_FALSE;
|
| 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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4417 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4418 | if(context)
|
| 4419 | {
|
Alexis Hetu | 8e32f7b | 2015-04-28 09:59:09 -0400 | [diff] [blame] | 4420 | es2::Query *queryObject = context->getQuery(name);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4421 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4422 | if(queryObject)
|
| 4423 | {
|
| 4424 | return GL_TRUE;
|
| 4425 | }
|
| 4426 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4427 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4428 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4429 | }
|
| 4430 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4431 | GLboolean IsRenderbuffer(GLuint renderbuffer)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4432 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4433 | TRACE("(GLuint renderbuffer = %d)", renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4434 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4435 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4436 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4437 | if(context && renderbuffer)
|
| 4438 | {
|
| 4439 | es2::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4440 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4441 | if(renderbufferObject)
|
| 4442 | {
|
| 4443 | return GL_TRUE;
|
| 4444 | }
|
| 4445 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4446 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4447 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4448 | }
|
| 4449 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4450 | GLboolean IsShader(GLuint shader)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4451 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4452 | TRACE("(GLuint shader = %d)", shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4453 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4454 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4455 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4456 | if(context && shader)
|
| 4457 | {
|
| 4458 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4459 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4460 | if(shaderObject)
|
| 4461 | {
|
| 4462 | return GL_TRUE;
|
| 4463 | }
|
| 4464 | }
|
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 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4467 | }
|
| 4468 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4469 | GLboolean IsTexture(GLuint texture)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4470 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4471 | TRACE("(GLuint texture = %d)", texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4472 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4473 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4474 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4475 | if(context && texture)
|
| 4476 | {
|
| 4477 | es2::Texture *textureObject = context->getTexture(texture);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4478 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4479 | if(textureObject)
|
| 4480 | {
|
| 4481 | return GL_TRUE;
|
| 4482 | }
|
| 4483 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4484 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4485 | return GL_FALSE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4486 | }
|
| 4487 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4488 | void LineWidth(GLfloat width)
|
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 | TRACE("(GLfloat width = %f)", width);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4491 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4492 | if(width <= 0.0f)
|
| 4493 | {
|
| 4494 | return error(GL_INVALID_VALUE);
|
| 4495 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4496 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4497 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4498 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4499 | if(context)
|
| 4500 | {
|
| 4501 | context->setLineWidth(width);
|
| 4502 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4503 | }
|
| 4504 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4505 | void LinkProgram(GLuint program)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4506 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4507 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4508 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4509 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4510 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4511 | if(context)
|
| 4512 | {
|
| 4513 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4514 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4515 | if(!programObject)
|
| 4516 | {
|
| 4517 | if(context->getShader(program))
|
| 4518 | {
|
| 4519 | return error(GL_INVALID_OPERATION);
|
| 4520 | }
|
| 4521 | else
|
| 4522 | {
|
| 4523 | return error(GL_INVALID_VALUE);
|
| 4524 | }
|
| 4525 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4526 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4527 | programObject->link();
|
| 4528 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4529 | }
|
| 4530 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4531 | void PixelStorei(GLenum pname, GLint param)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4532 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4533 | TRACE("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4534 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4535 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4536 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4537 | if(context)
|
| 4538 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4539 | egl::GLint clientVersion = context->getClientVersion();
|
| 4540 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4541 | switch(pname)
|
| 4542 | {
|
| 4543 | case GL_UNPACK_ALIGNMENT:
|
| 4544 | if(param != 1 && param != 2 && param != 4 && param != 8)
|
| 4545 | {
|
| 4546 | return error(GL_INVALID_VALUE);
|
| 4547 | }
|
| 4548 | context->setUnpackAlignment(param);
|
| 4549 | break;
|
| 4550 | case GL_PACK_ALIGNMENT:
|
| 4551 | if(param != 1 && param != 2 && param != 4 && param != 8)
|
| 4552 | {
|
| 4553 | return error(GL_INVALID_VALUE);
|
| 4554 | }
|
| 4555 | context->setPackAlignment(param);
|
| 4556 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4557 | case GL_PACK_ROW_LENGTH:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4558 | if(clientVersion >= 3)
|
| 4559 | {
|
Alexis Hetu | c7b0510 | 2015-04-23 16:19:53 -0400 | [diff] [blame] | 4560 | if(param < 0)
|
| 4561 | {
|
| 4562 | return error(GL_INVALID_VALUE);
|
| 4563 | }
|
| 4564 | context->setPackRowLength(param);
|
| 4565 | break;
|
| 4566 | }
|
| 4567 | else return error(GL_INVALID_ENUM);
|
| 4568 | case GL_PACK_SKIP_PIXELS:
|
| 4569 | if(clientVersion >= 3)
|
| 4570 | {
|
| 4571 | if(param < 0)
|
| 4572 | {
|
| 4573 | return error(GL_INVALID_VALUE);
|
| 4574 | }
|
| 4575 | context->setPackSkipPixels(param);
|
| 4576 | break;
|
| 4577 | }
|
| 4578 | else return error(GL_INVALID_ENUM);
|
| 4579 | case GL_PACK_SKIP_ROWS:
|
| 4580 | if(clientVersion >= 3)
|
| 4581 | {
|
| 4582 | if(param < 0)
|
| 4583 | {
|
| 4584 | return error(GL_INVALID_VALUE);
|
| 4585 | }
|
| 4586 | context->setPackSkipRows(param);
|
| 4587 | break;
|
| 4588 | }
|
| 4589 | else return error(GL_INVALID_ENUM);
|
| 4590 | case GL_UNPACK_ROW_LENGTH:
|
| 4591 | if(clientVersion >= 3)
|
| 4592 | {
|
| 4593 | if(param < 0)
|
| 4594 | {
|
| 4595 | return error(GL_INVALID_VALUE);
|
| 4596 | }
|
| 4597 | context->setUnpackRowLength(param);
|
| 4598 | break;
|
| 4599 | }
|
| 4600 | else return error(GL_INVALID_ENUM);
|
| 4601 | case GL_UNPACK_IMAGE_HEIGHT:
|
| 4602 | if(clientVersion >= 3)
|
| 4603 | {
|
| 4604 | if(param < 0)
|
| 4605 | {
|
| 4606 | return error(GL_INVALID_VALUE);
|
| 4607 | }
|
| 4608 | context->setUnpackImageHeight(param);
|
| 4609 | break;
|
| 4610 | }
|
| 4611 | else return error(GL_INVALID_ENUM);
|
| 4612 | case GL_UNPACK_SKIP_PIXELS:
|
| 4613 | if(clientVersion >= 3)
|
| 4614 | {
|
| 4615 | if(param < 0)
|
| 4616 | {
|
| 4617 | return error(GL_INVALID_VALUE);
|
| 4618 | }
|
| 4619 | context->setUnpackSkipPixels(param);
|
| 4620 | break;
|
| 4621 | }
|
| 4622 | else return error(GL_INVALID_ENUM);
|
| 4623 | case GL_UNPACK_SKIP_ROWS:
|
| 4624 | if(clientVersion >= 3)
|
| 4625 | {
|
| 4626 | if(param < 0)
|
| 4627 | {
|
| 4628 | return error(GL_INVALID_VALUE);
|
| 4629 | }
|
| 4630 | context->setUnpackSkipRows(param);
|
| 4631 | break;
|
| 4632 | }
|
| 4633 | else return error(GL_INVALID_ENUM);
|
| 4634 | case GL_UNPACK_SKIP_IMAGES:
|
| 4635 | if(clientVersion >= 3) {
|
| 4636 | if(param < 0)
|
| 4637 | {
|
| 4638 | return error(GL_INVALID_VALUE);
|
| 4639 | }
|
| 4640 | context->setUnpackSkipImages(param);
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 4641 | break;
|
| 4642 | }
|
| 4643 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4644 | default:
|
| 4645 | return error(GL_INVALID_ENUM);
|
| 4646 | }
|
| 4647 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4648 | }
|
| 4649 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4650 | void PolygonOffset(GLfloat factor, GLfloat units)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4651 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4652 | TRACE("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4653 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4654 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4655 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4656 | if(context)
|
| 4657 | {
|
| 4658 | context->setPolygonOffsetParams(factor, units);
|
| 4659 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4660 | }
|
| 4661 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4662 | void ReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
|
| 4663 | GLenum format, GLenum type, GLsizei bufSize, GLvoid *data)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4664 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4665 | TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4666 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4667 | x, y, width, height, format, type, bufSize, data);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4668 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4669 | if(width < 0 || height < 0 || bufSize < 0)
|
| 4670 | {
|
| 4671 | return error(GL_INVALID_VALUE);
|
| 4672 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4673 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4674 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4675 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4676 | if(context)
|
| 4677 | {
|
| 4678 | context->readPixels(x, y, width, height, format, type, &bufSize, data);
|
| 4679 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4680 | }
|
| 4681 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4682 | void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4683 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4684 | TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4685 | "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4686 | x, y, width, height, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4687 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4688 | if(width < 0 || height < 0)
|
| 4689 | {
|
| 4690 | return error(GL_INVALID_VALUE);
|
| 4691 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4692 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4693 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4694 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4695 | if(context)
|
| 4696 | {
|
| 4697 | context->readPixels(x, y, width, height, format, type, NULL, pixels);
|
| 4698 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4699 | }
|
| 4700 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4701 | void ReleaseShaderCompiler(void)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4702 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4703 | TRACE("()");
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4704 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4705 | es2::Shader::releaseCompiler();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4706 | }
|
| 4707 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4708 | void RenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4709 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4710 | TRACE("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
|
| 4711 | target, samples, internalformat, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4712 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4713 | switch(target)
|
| 4714 | {
|
| 4715 | case GL_RENDERBUFFER:
|
| 4716 | break;
|
| 4717 | default:
|
| 4718 | return error(GL_INVALID_ENUM);
|
| 4719 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4720 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4721 | if(width < 0 || height < 0 || samples < 0)
|
| 4722 | {
|
| 4723 | return error(GL_INVALID_VALUE);
|
| 4724 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4725 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4726 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4727 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4728 | if(context)
|
| 4729 | {
|
| 4730 | if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
|
| 4731 | height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
|
| 4732 | samples > es2::IMPLEMENTATION_MAX_SAMPLES)
|
| 4733 | {
|
| 4734 | return error(GL_INVALID_VALUE);
|
| 4735 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4736 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 4737 | GLuint handle = context->getRenderbufferName();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4738 | if(handle == 0)
|
| 4739 | {
|
| 4740 | return error(GL_INVALID_OPERATION);
|
| 4741 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4742 |
|
Alexis Hetu | 8f60458 | 2015-05-27 16:58:29 -0400 | [diff] [blame] | 4743 | egl::GLint clientVersion = context->getClientVersion();
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4744 | switch(internalformat)
|
| 4745 | {
|
Alexis Hetu | 8f60458 | 2015-05-27 16:58:29 -0400 | [diff] [blame] | 4746 | case GL_DEPTH_COMPONENT32F:
|
| 4747 | if(clientVersion < 3)
|
| 4748 | {
|
| 4749 | return error(GL_INVALID_ENUM);
|
| 4750 | }
|
| 4751 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4752 | case GL_DEPTH_COMPONENT16:
|
Alexis Hetu | e727775 | 2015-12-04 11:16:35 -0500 | [diff] [blame] | 4753 | case GL_DEPTH_COMPONENT24:
|
| 4754 | case GL_DEPTH_COMPONENT32_OES:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4755 | context->setRenderbufferStorage(new es2::Depthbuffer(width, height, samples));
|
| 4756 | break;
|
Alexis Hetu | 8f60458 | 2015-05-27 16:58:29 -0400 | [diff] [blame] | 4757 | case GL_R8:
|
| 4758 | case GL_R8UI:
|
| 4759 | case GL_R8I:
|
| 4760 | case GL_R16UI:
|
| 4761 | case GL_R16I:
|
| 4762 | case GL_R32UI:
|
| 4763 | case GL_R32I:
|
| 4764 | case GL_RG8:
|
| 4765 | case GL_RG8UI:
|
| 4766 | case GL_RG8I:
|
| 4767 | case GL_RG16UI:
|
| 4768 | case GL_RG16I:
|
| 4769 | case GL_RG32UI:
|
| 4770 | case GL_RG32I:
|
| 4771 | case GL_SRGB8_ALPHA8:
|
| 4772 | case GL_RGB10_A2:
|
| 4773 | case GL_RGBA8UI:
|
| 4774 | case GL_RGBA8I:
|
| 4775 | case GL_RGB10_A2UI:
|
| 4776 | case GL_RGBA16UI:
|
| 4777 | case GL_RGBA16I:
|
| 4778 | case GL_RGBA32I:
|
| 4779 | case GL_RGBA32UI:
|
Alexis Hetu | c8f95e8 | 2015-11-12 16:36:34 -0500 | [diff] [blame] | 4780 | case GL_R16F:
|
| 4781 | case GL_RG16F:
|
| 4782 | case GL_R11F_G11F_B10F:
|
| 4783 | case GL_RGBA16F:
|
| 4784 | case GL_R32F:
|
| 4785 | case GL_RG32F:
|
| 4786 | case GL_RGB32F:
|
| 4787 | case GL_RGBA32F:
|
Alexis Hetu | 8f60458 | 2015-05-27 16:58:29 -0400 | [diff] [blame] | 4788 | if(clientVersion < 3)
|
| 4789 | {
|
| 4790 | return error(GL_INVALID_ENUM);
|
| 4791 | }
|
| 4792 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4793 | case GL_RGBA4:
|
| 4794 | case GL_RGB5_A1:
|
| 4795 | case GL_RGB565:
|
| 4796 | case GL_RGB8_OES:
|
| 4797 | case GL_RGBA8_OES:
|
| 4798 | context->setRenderbufferStorage(new es2::Colorbuffer(width, height, internalformat, samples));
|
| 4799 | break;
|
| 4800 | case GL_STENCIL_INDEX8:
|
| 4801 | context->setRenderbufferStorage(new es2::Stencilbuffer(width, height, samples));
|
| 4802 | break;
|
Alexis Hetu | 8f60458 | 2015-05-27 16:58:29 -0400 | [diff] [blame] | 4803 | case GL_DEPTH32F_STENCIL8:
|
| 4804 | if(clientVersion < 3)
|
| 4805 | {
|
| 4806 | return error(GL_INVALID_ENUM);
|
| 4807 | }
|
| 4808 | // fall through
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4809 | case GL_DEPTH24_STENCIL8_OES:
|
| 4810 | context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, samples));
|
| 4811 | break;
|
| 4812 | default:
|
| 4813 | return error(GL_INVALID_ENUM);
|
| 4814 | }
|
| 4815 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4816 | }
|
| 4817 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4818 | void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4819 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4820 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4821 | }
|
| 4822 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4823 | void SampleCoverage(GLclampf value, GLboolean invert)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4824 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4825 | TRACE("(GLclampf value = %f, GLboolean invert = %d)", value, invert);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4826 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4827 | es2::Context* context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4828 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4829 | if(context)
|
| 4830 | {
|
| 4831 | context->setSampleCoverageParams(es2::clamp01(value), invert == GL_TRUE);
|
| 4832 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4833 | }
|
| 4834 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4835 | void SetFenceNV(GLuint fence, GLenum condition)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4836 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4837 | TRACE("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4838 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4839 | if(condition != GL_ALL_COMPLETED_NV)
|
| 4840 | {
|
| 4841 | return error(GL_INVALID_ENUM);
|
| 4842 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4843 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4844 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4845 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4846 | if(context)
|
| 4847 | {
|
| 4848 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4849 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4850 | if(fenceObject == NULL)
|
| 4851 | {
|
| 4852 | return error(GL_INVALID_OPERATION);
|
| 4853 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4854 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4855 | fenceObject->setFence(condition);
|
| 4856 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4857 | }
|
| 4858 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4859 | void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4860 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4861 | 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] | 4862 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4863 | if(width < 0 || height < 0)
|
| 4864 | {
|
| 4865 | return error(GL_INVALID_VALUE);
|
| 4866 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4867 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4868 | es2::Context* context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4869 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4870 | if(context)
|
| 4871 | {
|
| 4872 | context->setScissorParams(x, y, width, height);
|
| 4873 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4874 | }
|
| 4875 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4876 | void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4877 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4878 | TRACE("(GLsizei n = %d, const GLuint* shaders = %p, GLenum binaryformat = 0x%X, "
|
| 4879 | "const GLvoid* binary = %p, GLsizei length = %d)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4880 | n, shaders, binaryformat, binary, length);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4881 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4882 | // No binary shader formats are supported.
|
| 4883 | return error(GL_INVALID_ENUM);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4884 | }
|
| 4885 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4886 | void ShaderSource(GLuint shader, GLsizei count, const GLchar *const *string, const GLint *length)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4887 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 4888 | TRACE("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = %p, const GLint* length = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4889 | shader, count, string, length);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4890 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4891 | if(count < 0)
|
| 4892 | {
|
| 4893 | return error(GL_INVALID_VALUE);
|
| 4894 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4895 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4896 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4897 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4898 | if(context)
|
| 4899 | {
|
| 4900 | es2::Shader *shaderObject = context->getShader(shader);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4901 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4902 | if(!shaderObject)
|
| 4903 | {
|
| 4904 | if(context->getProgram(shader))
|
| 4905 | {
|
| 4906 | return error(GL_INVALID_OPERATION);
|
| 4907 | }
|
| 4908 | else
|
| 4909 | {
|
| 4910 | return error(GL_INVALID_VALUE);
|
| 4911 | }
|
| 4912 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4913 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4914 | shaderObject->setSource(count, string, length);
|
| 4915 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4916 | }
|
| 4917 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4918 | void StencilFunc(GLenum func, GLint ref, GLuint mask)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4919 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4920 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4921 | }
|
| 4922 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4923 | void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4924 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4925 | 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] | 4926 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4927 | switch(face)
|
| 4928 | {
|
| 4929 | case GL_FRONT:
|
| 4930 | case GL_BACK:
|
| 4931 | case GL_FRONT_AND_BACK:
|
| 4932 | break;
|
| 4933 | default:
|
| 4934 | return error(GL_INVALID_ENUM);
|
| 4935 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4936 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4937 | switch(func)
|
| 4938 | {
|
| 4939 | case GL_NEVER:
|
| 4940 | case GL_ALWAYS:
|
| 4941 | case GL_LESS:
|
| 4942 | case GL_LEQUAL:
|
| 4943 | case GL_EQUAL:
|
| 4944 | case GL_GEQUAL:
|
| 4945 | case GL_GREATER:
|
| 4946 | case GL_NOTEQUAL:
|
| 4947 | break;
|
| 4948 | default:
|
| 4949 | return error(GL_INVALID_ENUM);
|
| 4950 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4951 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4952 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4953 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4954 | if(context)
|
| 4955 | {
|
| 4956 | if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
|
| 4957 | {
|
| 4958 | context->setStencilParams(func, ref, mask);
|
| 4959 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4960 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4961 | if(face == GL_BACK || face == GL_FRONT_AND_BACK)
|
| 4962 | {
|
| 4963 | context->setStencilBackParams(func, ref, mask);
|
| 4964 | }
|
| 4965 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4966 | }
|
| 4967 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4968 | void StencilMask(GLuint mask)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4969 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4970 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4971 | }
|
| 4972 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 4973 | void StencilMaskSeparate(GLenum face, GLuint mask)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4974 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4975 | TRACE("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4976 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4977 | switch(face)
|
| 4978 | {
|
| 4979 | case GL_FRONT:
|
| 4980 | case GL_BACK:
|
| 4981 | case GL_FRONT_AND_BACK:
|
| 4982 | break;
|
| 4983 | default:
|
| 4984 | return error(GL_INVALID_ENUM);
|
| 4985 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4986 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4987 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4988 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4989 | if(context)
|
| 4990 | {
|
| 4991 | if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
|
| 4992 | {
|
| 4993 | context->setStencilWritemask(mask);
|
| 4994 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 4995 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 4996 | if(face == GL_BACK || face == GL_FRONT_AND_BACK)
|
| 4997 | {
|
| 4998 | context->setStencilBackWritemask(mask);
|
| 4999 | }
|
| 5000 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5001 | }
|
| 5002 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 5003 | void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5004 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5005 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5006 | }
|
| 5007 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 5008 | void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5009 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5010 | TRACE("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
|
| 5011 | face, fail, zfail, zpass);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5012 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5013 | switch(face)
|
| 5014 | {
|
| 5015 | case GL_FRONT:
|
| 5016 | case GL_BACK:
|
| 5017 | case GL_FRONT_AND_BACK:
|
| 5018 | break;
|
| 5019 | default:
|
| 5020 | return error(GL_INVALID_ENUM);
|
| 5021 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5022 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5023 | switch(fail)
|
| 5024 | {
|
| 5025 | case GL_ZERO:
|
| 5026 | case GL_KEEP:
|
| 5027 | case GL_REPLACE:
|
| 5028 | case GL_INCR:
|
| 5029 | case GL_DECR:
|
| 5030 | case GL_INVERT:
|
| 5031 | case GL_INCR_WRAP:
|
| 5032 | case GL_DECR_WRAP:
|
| 5033 | break;
|
| 5034 | default:
|
| 5035 | return error(GL_INVALID_ENUM);
|
| 5036 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5037 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5038 | switch(zfail)
|
| 5039 | {
|
| 5040 | case GL_ZERO:
|
| 5041 | case GL_KEEP:
|
| 5042 | case GL_REPLACE:
|
| 5043 | case GL_INCR:
|
| 5044 | case GL_DECR:
|
| 5045 | case GL_INVERT:
|
| 5046 | case GL_INCR_WRAP:
|
| 5047 | case GL_DECR_WRAP:
|
| 5048 | break;
|
| 5049 | default:
|
| 5050 | return error(GL_INVALID_ENUM);
|
| 5051 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5052 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5053 | switch(zpass)
|
| 5054 | {
|
| 5055 | case GL_ZERO:
|
| 5056 | case GL_KEEP:
|
| 5057 | case GL_REPLACE:
|
| 5058 | case GL_INCR:
|
| 5059 | case GL_DECR:
|
| 5060 | case GL_INVERT:
|
| 5061 | case GL_INCR_WRAP:
|
| 5062 | case GL_DECR_WRAP:
|
| 5063 | break;
|
| 5064 | default:
|
| 5065 | return error(GL_INVALID_ENUM);
|
| 5066 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5067 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5068 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5069 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5070 | if(context)
|
| 5071 | {
|
| 5072 | if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
|
| 5073 | {
|
| 5074 | context->setStencilOperations(fail, zfail, zpass);
|
| 5075 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5076 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5077 | if(face == GL_BACK || face == GL_FRONT_AND_BACK)
|
| 5078 | {
|
| 5079 | context->setStencilBackOperations(fail, zfail, zpass);
|
| 5080 | }
|
| 5081 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5082 | }
|
| 5083 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 5084 | GLboolean TestFenceNV(GLuint fence)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5085 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5086 | TRACE("(GLuint fence = %d)", fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5087 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5088 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5089 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5090 | if(context)
|
| 5091 | {
|
| 5092 | es2::Fence *fenceObject = context->getFence(fence);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5093 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5094 | if(fenceObject == NULL)
|
| 5095 | {
|
| 5096 | return error(GL_INVALID_OPERATION, GL_TRUE);
|
| 5097 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5098 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5099 | return fenceObject->testFence();
|
| 5100 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 5101 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5102 | return GL_TRUE;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5103 | }
|
| 5104 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 5105 | void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
|
| 5106 | GLint border, GLenum format, GLenum type, const GLvoid* pixels)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5107 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5108 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 5109 | "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5110 | target, level, internalformat, width, height, border, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5111 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5112 | if(!validImageSize(level, width, height))
|
| 5113 | {
|
| 5114 | return error(GL_INVALID_VALUE);
|
| 5115 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5116 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5117 | es2::Context *context = es2::getContext();
|
| 5118 |
|
| 5119 | if(context)
|
| 5120 | {
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5121 | egl::GLint clientVersion = context->getClientVersion();
|
| 5122 | if(clientVersion < 3)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5123 | {
|
| 5124 | if(internalformat != format)
|
| 5125 | {
|
| 5126 | return error(GL_INVALID_OPERATION);
|
| 5127 | }
|
| 5128 | }
|
| 5129 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 5130 | GLenum validationError = ValidateCompressedFormat(format, clientVersion, false);
|
| 5131 | if(validationError != GL_NONE)
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 5132 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 5133 | return error(validationError);
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 5134 | }
|
| 5135 |
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5136 | switch(format)
|
| 5137 | {
|
| 5138 | case GL_ALPHA:
|
| 5139 | case GL_LUMINANCE:
|
| 5140 | case GL_LUMINANCE_ALPHA:
|
| 5141 | switch(type)
|
| 5142 | {
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5143 | case GL_HALF_FLOAT:
|
| 5144 | if(clientVersion < 3)
|
| 5145 | {
|
| 5146 | return error(GL_INVALID_ENUM);
|
| 5147 | }
|
| 5148 | break;
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5149 | case GL_UNSIGNED_BYTE:
|
| 5150 | case GL_FLOAT:
|
| 5151 | case GL_HALF_FLOAT_OES:
|
| 5152 | break;
|
| 5153 | default:
|
| 5154 | return error(GL_INVALID_ENUM);
|
| 5155 | }
|
| 5156 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5157 | case GL_RED:
|
| 5158 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5159 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5160 | case GL_R8:
|
| 5161 | switch(type)
|
| 5162 | {
|
| 5163 | case GL_UNSIGNED_BYTE:
|
| 5164 | break;
|
| 5165 | default:
|
| 5166 | return error(GL_INVALID_ENUM);
|
| 5167 | }
|
| 5168 | break;
|
| 5169 | case GL_R8_SNORM:
|
| 5170 | switch(type)
|
| 5171 | {
|
| 5172 | case GL_BYTE:
|
| 5173 | break;
|
| 5174 | default:
|
| 5175 | return error(GL_INVALID_ENUM);
|
| 5176 | }
|
| 5177 | break;
|
| 5178 | case GL_R16F:
|
| 5179 | switch(type)
|
| 5180 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5181 | case GL_HALF_FLOAT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5182 | if(clientVersion < 3)
|
| 5183 | {
|
| 5184 | return error(GL_INVALID_ENUM);
|
| 5185 | }
|
| 5186 | break;
|
| 5187 | case GL_FLOAT:
|
| 5188 | case GL_HALF_FLOAT_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5189 | break;
|
| 5190 | default:
|
| 5191 | return error(GL_INVALID_ENUM);
|
| 5192 | }
|
| 5193 | break;
|
| 5194 | case GL_R32F:
|
| 5195 | switch(type)
|
| 5196 | {
|
| 5197 | case GL_FLOAT:
|
| 5198 | break;
|
| 5199 | default:
|
| 5200 | return error(GL_INVALID_ENUM);
|
| 5201 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5202 | break;
|
| 5203 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5204 | return error(GL_INVALID_VALUE);
|
| 5205 | }
|
| 5206 | break;
|
| 5207 | case GL_RED_INTEGER:
|
| 5208 | switch(internalformat)
|
| 5209 | {
|
| 5210 | case GL_R8UI:
|
| 5211 | switch(type)
|
| 5212 | {
|
| 5213 | case GL_UNSIGNED_BYTE:
|
| 5214 | break;
|
| 5215 | default:
|
| 5216 | return error(GL_INVALID_ENUM);
|
| 5217 | }
|
| 5218 | break;
|
| 5219 | case GL_R8I:
|
| 5220 | switch(type)
|
| 5221 | {
|
| 5222 | case GL_BYTE:
|
| 5223 | break;
|
| 5224 | default:
|
| 5225 | return error(GL_INVALID_ENUM);
|
| 5226 | }
|
| 5227 | break;
|
| 5228 | case GL_R16UI:
|
| 5229 | switch(type)
|
| 5230 | {
|
| 5231 | case GL_UNSIGNED_SHORT:
|
| 5232 | break;
|
| 5233 | default:
|
| 5234 | return error(GL_INVALID_ENUM);
|
| 5235 | }
|
| 5236 | break;
|
| 5237 | case GL_R16I:
|
| 5238 | switch(type)
|
| 5239 | {
|
| 5240 | case GL_SHORT:
|
| 5241 | break;
|
| 5242 | default:
|
| 5243 | return error(GL_INVALID_ENUM);
|
| 5244 | }
|
| 5245 | break;
|
| 5246 | case GL_R32UI:
|
| 5247 | switch(type)
|
| 5248 | {
|
| 5249 | case GL_UNSIGNED_INT:
|
| 5250 | break;
|
| 5251 | default:
|
| 5252 | return error(GL_INVALID_ENUM);
|
| 5253 | }
|
| 5254 | break;
|
| 5255 | case GL_R32I:
|
| 5256 | switch(type)
|
| 5257 | {
|
| 5258 | case GL_INT:
|
| 5259 | break;
|
| 5260 | default:
|
| 5261 | return error(GL_INVALID_ENUM);
|
| 5262 | }
|
| 5263 | break;
|
| 5264 | default:
|
| 5265 | return error(GL_INVALID_VALUE);
|
| 5266 | }
|
| 5267 | break;
|
| 5268 | case GL_RG_INTEGER:
|
| 5269 | switch(internalformat)
|
| 5270 | {
|
| 5271 | case GL_RG8UI:
|
| 5272 | switch(type)
|
| 5273 | {
|
| 5274 | case GL_UNSIGNED_BYTE:
|
| 5275 | break;
|
| 5276 | default:
|
| 5277 | return error(GL_INVALID_ENUM);
|
| 5278 | }
|
| 5279 | break;
|
| 5280 | case GL_RG8I:
|
| 5281 | switch(type)
|
| 5282 | {
|
| 5283 | case GL_BYTE:
|
| 5284 | break;
|
| 5285 | default:
|
| 5286 | return error(GL_INVALID_ENUM);
|
| 5287 | }
|
| 5288 | break;
|
| 5289 | case GL_RG16UI:
|
| 5290 | switch(type)
|
| 5291 | {
|
| 5292 | case GL_UNSIGNED_SHORT:
|
| 5293 | break;
|
| 5294 | default:
|
| 5295 | return error(GL_INVALID_ENUM);
|
| 5296 | }
|
| 5297 | break;
|
| 5298 | case GL_RG16I:
|
| 5299 | switch(type)
|
| 5300 | {
|
| 5301 | case GL_SHORT:
|
| 5302 | break;
|
| 5303 | default:
|
| 5304 | return error(GL_INVALID_ENUM);
|
| 5305 | }
|
| 5306 | break;
|
| 5307 | case GL_RG32UI:
|
| 5308 | switch(type)
|
| 5309 | {
|
| 5310 | case GL_UNSIGNED_INT:
|
| 5311 | break;
|
| 5312 | default:
|
| 5313 | return error(GL_INVALID_ENUM);
|
| 5314 | }
|
| 5315 | break;
|
| 5316 | case GL_RG32I:
|
| 5317 | switch(type)
|
| 5318 | {
|
| 5319 | case GL_INT:
|
| 5320 | break;
|
| 5321 | default:
|
| 5322 | return error(GL_INVALID_ENUM);
|
| 5323 | }
|
| 5324 | break;
|
| 5325 | default:
|
| 5326 | return error(GL_INVALID_VALUE);
|
| 5327 | }
|
| 5328 | break;
|
| 5329 | case GL_RGB_INTEGER:
|
| 5330 | switch(internalformat)
|
| 5331 | {
|
| 5332 | case GL_RGB8UI:
|
| 5333 | switch(type)
|
| 5334 | {
|
| 5335 | case GL_UNSIGNED_BYTE:
|
| 5336 | break;
|
| 5337 | default:
|
| 5338 | return error(GL_INVALID_ENUM);
|
| 5339 | }
|
| 5340 | break;
|
| 5341 | case GL_RGB8I:
|
| 5342 | switch(type)
|
| 5343 | {
|
| 5344 | case GL_BYTE:
|
| 5345 | break;
|
| 5346 | default:
|
| 5347 | return error(GL_INVALID_ENUM);
|
| 5348 | }
|
| 5349 | break;
|
| 5350 | case GL_RGB16UI:
|
| 5351 | switch(type)
|
| 5352 | {
|
| 5353 | case GL_UNSIGNED_SHORT:
|
| 5354 | break;
|
| 5355 | default:
|
| 5356 | return error(GL_INVALID_ENUM);
|
| 5357 | }
|
| 5358 | break;
|
| 5359 | case GL_RGB16I:
|
| 5360 | switch(type)
|
| 5361 | {
|
| 5362 | case GL_SHORT:
|
| 5363 | break;
|
| 5364 | default:
|
| 5365 | return error(GL_INVALID_ENUM);
|
| 5366 | }
|
| 5367 | break;
|
| 5368 | case GL_RGB32UI:
|
| 5369 | switch(type)
|
| 5370 | {
|
| 5371 | case GL_UNSIGNED_INT:
|
| 5372 | break;
|
| 5373 | default:
|
| 5374 | return error(GL_INVALID_ENUM);
|
| 5375 | }
|
| 5376 | break;
|
| 5377 | case GL_RGB32I:
|
| 5378 | switch(type)
|
| 5379 | {
|
| 5380 | case GL_INT:
|
| 5381 | break;
|
| 5382 | default:
|
| 5383 | return error(GL_INVALID_ENUM);
|
| 5384 | }
|
| 5385 | break;
|
| 5386 | default:
|
| 5387 | return error(GL_INVALID_VALUE);
|
| 5388 | }
|
| 5389 | break;
|
| 5390 | case GL_RGBA_INTEGER:
|
| 5391 | switch(internalformat)
|
| 5392 | {
|
| 5393 | case GL_RGBA8UI:
|
| 5394 | switch(type)
|
| 5395 | {
|
| 5396 | case GL_UNSIGNED_BYTE:
|
| 5397 | break;
|
| 5398 | default:
|
| 5399 | return error(GL_INVALID_ENUM);
|
| 5400 | }
|
| 5401 | break;
|
| 5402 | case GL_RGBA8I:
|
| 5403 | switch(type)
|
| 5404 | {
|
| 5405 | case GL_BYTE:
|
| 5406 | break;
|
| 5407 | default:
|
| 5408 | return error(GL_INVALID_ENUM);
|
| 5409 | }
|
| 5410 | break;
|
| 5411 | case GL_RGB10_A2UI:
|
| 5412 | switch(type)
|
| 5413 | {
|
| 5414 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 5415 | break;
|
| 5416 | default:
|
| 5417 | return error(GL_INVALID_ENUM);
|
| 5418 | }
|
| 5419 | break;
|
| 5420 | case GL_RGBA16UI:
|
| 5421 | switch(type)
|
| 5422 | {
|
| 5423 | case GL_UNSIGNED_SHORT:
|
| 5424 | break;
|
| 5425 | default:
|
| 5426 | return error(GL_INVALID_ENUM);
|
| 5427 | }
|
| 5428 | break;
|
| 5429 | case GL_RGBA16I:
|
| 5430 | switch(type)
|
| 5431 | {
|
| 5432 | case GL_SHORT:
|
| 5433 | break;
|
| 5434 | default:
|
| 5435 | return error(GL_INVALID_ENUM);
|
| 5436 | }
|
| 5437 | break;
|
| 5438 | case GL_RGBA32UI:
|
| 5439 | switch(type)
|
| 5440 | {
|
Alexis Hetu | 8be7e3f | 2015-05-01 15:15:24 -0400 | [diff] [blame] | 5441 | case GL_UNSIGNED_INT:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5442 | break;
|
| 5443 | default:
|
| 5444 | return error(GL_INVALID_ENUM);
|
| 5445 | }
|
| 5446 | break;
|
| 5447 | case GL_RGBA32I:
|
| 5448 | switch(type)
|
| 5449 | {
|
Alexis Hetu | 8be7e3f | 2015-05-01 15:15:24 -0400 | [diff] [blame] | 5450 | case GL_INT:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5451 | break;
|
| 5452 | default:
|
| 5453 | return error(GL_INVALID_ENUM);
|
| 5454 | }
|
| 5455 | break;
|
| 5456 | default:
|
| 5457 | return error(GL_INVALID_VALUE);
|
| 5458 | }
|
| 5459 | break;
|
| 5460 | case GL_RG:
|
| 5461 | switch(internalformat)
|
| 5462 | {
|
| 5463 | case GL_RG8:
|
| 5464 | switch(type)
|
| 5465 | {
|
| 5466 | case GL_UNSIGNED_BYTE:
|
| 5467 | break;
|
| 5468 | default:
|
| 5469 | return error(GL_INVALID_ENUM);
|
| 5470 | }
|
| 5471 | break;
|
| 5472 | case GL_RG8_SNORM:
|
| 5473 | switch(type)
|
| 5474 | {
|
| 5475 | case GL_BYTE:
|
| 5476 | break;
|
| 5477 | default:
|
| 5478 | return error(GL_INVALID_ENUM);
|
| 5479 | }
|
| 5480 | break;
|
| 5481 | case GL_RG16F:
|
| 5482 | switch(type)
|
| 5483 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5484 | case GL_HALF_FLOAT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5485 | if(clientVersion < 3)
|
| 5486 | {
|
| 5487 | return error(GL_INVALID_ENUM);
|
| 5488 | }
|
| 5489 | break;
|
| 5490 | case GL_FLOAT:
|
| 5491 | case GL_HALF_FLOAT_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5492 | break;
|
| 5493 | default:
|
| 5494 | return error(GL_INVALID_ENUM);
|
| 5495 | }
|
| 5496 | break;
|
| 5497 | case GL_RG32F:
|
| 5498 | switch(type)
|
| 5499 | {
|
| 5500 | case GL_FLOAT:
|
| 5501 | break;
|
| 5502 | default:
|
| 5503 | return error(GL_INVALID_ENUM);
|
| 5504 | }
|
| 5505 | break;
|
| 5506 | default:
|
| 5507 | return error(GL_INVALID_VALUE);
|
| 5508 | }
|
| 5509 | break;
|
| 5510 | case GL_RGB:
|
| 5511 | switch(internalformat)
|
| 5512 | {
|
| 5513 | case GL_RGB:
|
| 5514 | switch(type)
|
| 5515 | {
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5516 | case GL_HALF_FLOAT:
|
| 5517 | if(clientVersion < 3)
|
| 5518 | {
|
| 5519 | return error(GL_INVALID_ENUM);
|
| 5520 | }
|
| 5521 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5522 | case GL_UNSIGNED_BYTE:
|
| 5523 | case GL_UNSIGNED_SHORT_5_6_5:
|
| 5524 | case GL_FLOAT:
|
| 5525 | case GL_HALF_FLOAT_OES:
|
| 5526 | break;
|
| 5527 | default:
|
| 5528 | return error(GL_INVALID_ENUM);
|
| 5529 | }
|
| 5530 | break;
|
| 5531 | case GL_RGB8:
|
| 5532 | switch(type)
|
| 5533 | {
|
| 5534 | case GL_UNSIGNED_BYTE:
|
| 5535 | break;
|
| 5536 | default:
|
| 5537 | return error(GL_INVALID_ENUM);
|
| 5538 | }
|
| 5539 | break;
|
| 5540 | case GL_SRGB8:
|
| 5541 | switch(type)
|
| 5542 | {
|
| 5543 | case GL_UNSIGNED_BYTE:
|
| 5544 | break;
|
| 5545 | default:
|
| 5546 | return error(GL_INVALID_ENUM);
|
| 5547 | }
|
| 5548 | break;
|
| 5549 | case GL_RGB565:
|
| 5550 | switch(type)
|
| 5551 | {
|
| 5552 | case GL_UNSIGNED_BYTE:
|
| 5553 | case GL_UNSIGNED_SHORT_5_6_5:
|
| 5554 | break;
|
| 5555 | default:
|
| 5556 | return error(GL_INVALID_ENUM);
|
| 5557 | }
|
| 5558 | break;
|
| 5559 | case GL_RGB8_SNORM:
|
| 5560 | switch(type)
|
| 5561 | {
|
| 5562 | case GL_BYTE:
|
| 5563 | break;
|
| 5564 | default:
|
| 5565 | return error(GL_INVALID_ENUM);
|
| 5566 | }
|
| 5567 | break;
|
| 5568 | case GL_R11F_G11F_B10F:
|
| 5569 | switch(type)
|
| 5570 | {
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5571 | case GL_HALF_FLOAT:
|
| 5572 | if(clientVersion < 3)
|
| 5573 | {
|
| 5574 | return error(GL_INVALID_ENUM);
|
| 5575 | }
|
| 5576 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5577 | case GL_UNSIGNED_INT_10F_11F_11F_REV:
|
| 5578 | case GL_FLOAT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5579 | case GL_HALF_FLOAT_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5580 | break;
|
| 5581 | default:
|
| 5582 | return error(GL_INVALID_ENUM);
|
| 5583 | }
|
| 5584 | break;
|
| 5585 | case GL_RGB9_E5:
|
| 5586 | switch(type)
|
| 5587 | {
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5588 | case GL_HALF_FLOAT:
|
| 5589 | if(clientVersion < 3)
|
| 5590 | {
|
| 5591 | return error(GL_INVALID_ENUM);
|
| 5592 | }
|
| 5593 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5594 | case GL_UNSIGNED_INT_5_9_9_9_REV:
|
| 5595 | case GL_FLOAT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5596 | case GL_HALF_FLOAT_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5597 | break;
|
| 5598 | default:
|
| 5599 | return error(GL_INVALID_ENUM);
|
| 5600 | }
|
| 5601 | break;
|
| 5602 | case GL_RGB16F:
|
| 5603 | switch(type)
|
| 5604 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5605 | case GL_HALF_FLOAT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5606 | if(clientVersion < 3)
|
| 5607 | {
|
| 5608 | return error(GL_INVALID_ENUM);
|
| 5609 | }
|
| 5610 | break;
|
| 5611 | case GL_FLOAT:
|
| 5612 | case GL_HALF_FLOAT_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5613 | break;
|
| 5614 | default:
|
| 5615 | return error(GL_INVALID_ENUM);
|
| 5616 | }
|
| 5617 | break;
|
| 5618 | case GL_RGB32F:
|
| 5619 | switch(type)
|
| 5620 | {
|
| 5621 | case GL_FLOAT:
|
| 5622 | break;
|
| 5623 | default:
|
| 5624 | return error(GL_INVALID_ENUM);
|
| 5625 | }
|
| 5626 | break;
|
| 5627 | default:
|
| 5628 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5629 | }
|
| 5630 | break;
|
| 5631 | case GL_RGBA:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5632 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5633 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5634 | case GL_RGBA:
|
| 5635 | switch(type)
|
| 5636 | {
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5637 | case GL_HALF_FLOAT:
|
| 5638 | if(clientVersion < 3)
|
| 5639 | {
|
| 5640 | return error(GL_INVALID_ENUM);
|
| 5641 | }
|
| 5642 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5643 | case GL_UNSIGNED_BYTE:
|
| 5644 | case GL_UNSIGNED_SHORT_4_4_4_4:
|
| 5645 | case GL_UNSIGNED_SHORT_5_5_5_1:
|
| 5646 | case GL_FLOAT:
|
| 5647 | case GL_HALF_FLOAT_OES:
|
| 5648 | break;
|
| 5649 | default:
|
| 5650 | return error(GL_INVALID_ENUM);
|
| 5651 | }
|
| 5652 | break;
|
| 5653 | case GL_RGBA8:
|
| 5654 | switch(type)
|
| 5655 | {
|
| 5656 | case GL_UNSIGNED_BYTE:
|
| 5657 | break;
|
| 5658 | default:
|
| 5659 | return error(GL_INVALID_ENUM);
|
| 5660 | }
|
| 5661 | break;
|
| 5662 | case GL_SRGB8_ALPHA8:
|
| 5663 | switch(type)
|
| 5664 | {
|
| 5665 | case GL_UNSIGNED_BYTE:
|
| 5666 | break;
|
| 5667 | default:
|
| 5668 | return error(GL_INVALID_ENUM);
|
| 5669 | }
|
| 5670 | break;
|
| 5671 | case GL_RGB5_A1:
|
| 5672 | switch(type)
|
| 5673 | {
|
| 5674 | case GL_UNSIGNED_BYTE:
|
| 5675 | case GL_UNSIGNED_SHORT_5_5_5_1:
|
| 5676 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 5677 | break;
|
| 5678 | default:
|
| 5679 | return error(GL_INVALID_ENUM);
|
| 5680 | }
|
| 5681 | break;
|
| 5682 | case GL_RGBA8_SNORM:
|
| 5683 | switch(type)
|
| 5684 | {
|
| 5685 | case GL_BYTE:
|
| 5686 | break;
|
| 5687 | default:
|
| 5688 | return error(GL_INVALID_ENUM);
|
| 5689 | }
|
| 5690 | break;
|
| 5691 | case GL_RGBA4:
|
| 5692 | switch(type)
|
| 5693 | {
|
| 5694 | case GL_UNSIGNED_BYTE:
|
| 5695 | case GL_UNSIGNED_SHORT_4_4_4_4:
|
| 5696 | break;
|
| 5697 | default:
|
| 5698 | return error(GL_INVALID_ENUM);
|
| 5699 | }
|
| 5700 | break;
|
| 5701 | case GL_RGB10_A2:
|
| 5702 | switch(type)
|
| 5703 | {
|
| 5704 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 5705 | break;
|
| 5706 | default:
|
| 5707 | return error(GL_INVALID_ENUM);
|
| 5708 | }
|
| 5709 | break;
|
| 5710 | case GL_RGBA16F:
|
| 5711 | switch(type)
|
| 5712 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5713 | case GL_HALF_FLOAT:
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 5714 | if(clientVersion < 3)
|
| 5715 | {
|
| 5716 | return error(GL_INVALID_ENUM);
|
| 5717 | }
|
| 5718 | break;
|
| 5719 | case GL_FLOAT:
|
| 5720 | case GL_HALF_FLOAT_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5721 | break;
|
| 5722 | default:
|
| 5723 | return error(GL_INVALID_ENUM);
|
| 5724 | }
|
| 5725 | break;
|
| 5726 | case GL_RGBA32F:
|
| 5727 | switch(type)
|
| 5728 | {
|
| 5729 | case GL_FLOAT:
|
| 5730 | break;
|
| 5731 | default:
|
| 5732 | return error(GL_INVALID_ENUM);
|
| 5733 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5734 | break;
|
| 5735 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5736 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5737 | }
|
| 5738 | break;
|
| 5739 | case GL_BGRA_EXT:
|
| 5740 | switch(type)
|
| 5741 | {
|
| 5742 | case GL_UNSIGNED_BYTE:
|
| 5743 | break;
|
| 5744 | default:
|
| 5745 | return error(GL_INVALID_ENUM);
|
| 5746 | }
|
| 5747 | break;
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5748 | case GL_DEPTH_COMPONENT:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5749 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5750 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5751 | case GL_DEPTH_COMPONENT:
|
| 5752 | case GL_DEPTH_COMPONENT16:
|
| 5753 | switch(type)
|
| 5754 | {
|
| 5755 | case GL_UNSIGNED_SHORT:
|
| 5756 | case GL_UNSIGNED_INT:
|
| 5757 | break;
|
| 5758 | default:
|
| 5759 | return error(GL_INVALID_ENUM);
|
| 5760 | }
|
| 5761 | break;
|
| 5762 | case GL_DEPTH_COMPONENT24:
|
Alexis Hetu | e727775 | 2015-12-04 11:16:35 -0500 | [diff] [blame] | 5763 | case GL_DEPTH_COMPONENT32_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5764 | switch(type)
|
| 5765 | {
|
| 5766 | case GL_UNSIGNED_INT:
|
| 5767 | break;
|
| 5768 | default:
|
| 5769 | return error(GL_INVALID_ENUM);
|
| 5770 | }
|
| 5771 | break;
|
| 5772 | case GL_DEPTH_COMPONENT32F:
|
| 5773 | switch(type)
|
| 5774 | {
|
Alexis Hetu | e479522 | 2015-09-18 11:44:23 -0400 | [diff] [blame] | 5775 | case GL_FLOAT:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5776 | break;
|
| 5777 | default:
|
| 5778 | return error(GL_INVALID_ENUM);
|
| 5779 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5780 | break;
|
| 5781 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5782 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5783 | }
|
| 5784 | break;
|
| 5785 | case GL_DEPTH_STENCIL_OES:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5786 | switch(internalformat)
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5787 | {
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5788 | case GL_DEPTH_STENCIL_OES:
|
| 5789 | case GL_DEPTH24_STENCIL8:
|
| 5790 | switch(type)
|
| 5791 | {
|
| 5792 | case GL_UNSIGNED_INT_24_8_OES:
|
| 5793 | break;
|
| 5794 | default:
|
| 5795 | return error(GL_INVALID_ENUM);
|
| 5796 | }
|
| 5797 | break;
|
| 5798 | case GL_DEPTH32F_STENCIL8:
|
| 5799 | switch(type)
|
| 5800 | {
|
| 5801 | case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
| 5802 | break;
|
| 5803 | default:
|
| 5804 | return error(GL_INVALID_ENUM);
|
| 5805 | }
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5806 | break;
|
| 5807 | default:
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5808 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | b97ad2e | 2015-02-11 17:40:30 -0500 | [diff] [blame] | 5809 | }
|
| 5810 | break;
|
| 5811 | default:
|
| 5812 | return error(GL_INVALID_VALUE);
|
| 5813 | }
|
| 5814 |
|
| 5815 | if(border != 0)
|
| 5816 | {
|
| 5817 | return error(GL_INVALID_VALUE);
|
| 5818 | }
|
| 5819 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5820 | switch(target)
|
| 5821 | {
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 5822 | case GL_TEXTURE_2D:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5823 | if(width > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level) ||
|
| 5824 | height > (es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level))
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5825 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5826 | return error(GL_INVALID_VALUE);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5827 | }
|
| 5828 | break;
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 5829 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
| 5830 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
| 5831 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
| 5832 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
| 5833 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
| 5834 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5835 | if(width != height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5836 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5837 | return error(GL_INVALID_VALUE);
|
| 5838 | }
|
| 5839 |
|
| 5840 | if(width > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
|
| 5841 | height > (es2::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
|
| 5842 | {
|
| 5843 | return error(GL_INVALID_VALUE);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5844 | }
|
| 5845 | break;
|
Nicolas Capens | 2265824 | 2014-11-29 00:31:41 -0500 | [diff] [blame] | 5846 | default:
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5847 | return error(GL_INVALID_ENUM);
|
| 5848 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5849 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 5850 | GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
|
| 5851 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5852 | if(target == GL_TEXTURE_2D)
|
| 5853 | {
|
| 5854 | es2::Texture2D *texture = context->getTexture2D();
|
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 | if(!texture)
|
| 5857 | {
|
| 5858 | return error(GL_INVALID_OPERATION);
|
| 5859 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5860 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 5861 | texture->setImage(level, width, height, sizedInternalFormat, type, context->getUnpackInfo(), pixels);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5862 | }
|
| 5863 | else
|
| 5864 | {
|
| 5865 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5866 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5867 | if(!texture)
|
| 5868 | {
|
| 5869 | return error(GL_INVALID_OPERATION);
|
| 5870 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 5871 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 5872 | texture->setImage(target, level, width, height, sizedInternalFormat, type, context->getUnpackInfo(), pixels);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5873 | }
|
| 5874 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5875 | }
|
| 5876 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 5877 | void TexParameterf(GLenum target, GLenum pname, GLfloat param)
|
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 | 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] | 5880 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5881 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5882 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5883 | if(context)
|
| 5884 | {
|
| 5885 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 5886 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5887 | egl::GLint clientVersion = context->getClientVersion();
|
| 5888 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5889 | switch(target)
|
| 5890 | {
|
| 5891 | case GL_TEXTURE_2D:
|
| 5892 | texture = context->getTexture2D();
|
| 5893 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5894 | case GL_TEXTURE_2D_ARRAY:
|
| 5895 | if(clientVersion < 3)
|
| 5896 | {
|
| 5897 | return error(GL_INVALID_ENUM);
|
| 5898 | }
|
| 5899 | else
|
| 5900 | {
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 5901 | texture = context->getTexture2DArray();
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5902 | }
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 5903 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5904 | case GL_TEXTURE_3D_OES:
|
| 5905 | texture = context->getTexture3D();
|
| 5906 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5907 | case GL_TEXTURE_CUBE_MAP:
|
| 5908 | texture = context->getTextureCubeMap();
|
| 5909 | break;
|
| 5910 | case GL_TEXTURE_EXTERNAL_OES:
|
| 5911 | texture = context->getTextureExternal();
|
| 5912 | break;
|
| 5913 | default:
|
| 5914 | return error(GL_INVALID_ENUM);
|
| 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 | switch(pname)
|
| 5918 | {
|
| 5919 | case GL_TEXTURE_WRAP_S:
|
| 5920 | if(!texture->setWrapS((GLenum)param))
|
| 5921 | {
|
| 5922 | return error(GL_INVALID_ENUM);
|
| 5923 | }
|
| 5924 | break;
|
| 5925 | case GL_TEXTURE_WRAP_T:
|
| 5926 | if(!texture->setWrapT((GLenum)param))
|
| 5927 | {
|
| 5928 | return error(GL_INVALID_ENUM);
|
| 5929 | }
|
| 5930 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 5931 | case GL_TEXTURE_WRAP_R_OES:
|
| 5932 | if(!texture->setWrapR((GLenum)param))
|
| 5933 | {
|
| 5934 | return error(GL_INVALID_ENUM);
|
| 5935 | }
|
| 5936 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 5937 | case GL_TEXTURE_MIN_FILTER:
|
| 5938 | if(!texture->setMinFilter((GLenum)param))
|
| 5939 | {
|
| 5940 | return error(GL_INVALID_ENUM);
|
| 5941 | }
|
| 5942 | break;
|
| 5943 | case GL_TEXTURE_MAG_FILTER:
|
| 5944 | if(!texture->setMagFilter((GLenum)param))
|
| 5945 | {
|
| 5946 | return error(GL_INVALID_ENUM);
|
| 5947 | }
|
| 5948 | break;
|
| 5949 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 5950 | if(!texture->setMaxAnisotropy(param))
|
| 5951 | {
|
| 5952 | return error(GL_INVALID_VALUE);
|
| 5953 | }
|
| 5954 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5955 | case GL_TEXTURE_BASE_LEVEL:
|
Alexis Hetu | 3ed1630 | 2015-09-10 16:57:44 -0400 | [diff] [blame] | 5956 | if(clientVersion < 3 || !texture->setBaseLevel((GLint)(roundf(param))))
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5957 | {
|
| 5958 | return error(GL_INVALID_VALUE);
|
| 5959 | }
|
| 5960 | break;
|
| 5961 | case GL_TEXTURE_COMPARE_FUNC:
|
| 5962 | if(clientVersion < 3 || !texture->setCompareFunc((GLenum)param))
|
| 5963 | {
|
| 5964 | return error(GL_INVALID_VALUE);
|
| 5965 | }
|
| 5966 | break;
|
| 5967 | case GL_TEXTURE_COMPARE_MODE:
|
| 5968 | if(clientVersion < 3 || !texture->setCompareMode((GLenum)param))
|
| 5969 | {
|
| 5970 | return error(GL_INVALID_VALUE);
|
| 5971 | }
|
| 5972 | break;
|
| 5973 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
Alexis Hetu | 8e09837 | 2015-09-28 10:59:11 -0400 | [diff] [blame] | 5974 | if(clientVersion < 3 || !texture->setImmutableFormat((GLboolean)param))
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5975 | {
|
| 5976 | return error(GL_INVALID_VALUE);
|
| 5977 | }
|
| 5978 | break;
|
| 5979 | case GL_TEXTURE_MAX_LEVEL:
|
Alexis Hetu | 3ed1630 | 2015-09-10 16:57:44 -0400 | [diff] [blame] | 5980 | if(clientVersion < 3 || !texture->setMaxLevel((GLint)(roundf(param))))
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 5981 | {
|
| 5982 | return error(GL_INVALID_VALUE);
|
| 5983 | }
|
| 5984 | break;
|
| 5985 | case GL_TEXTURE_MAX_LOD:
|
| 5986 | if(clientVersion < 3 || !texture->setMaxLOD(param))
|
| 5987 | {
|
| 5988 | return error(GL_INVALID_VALUE);
|
| 5989 | }
|
| 5990 | break;
|
| 5991 | case GL_TEXTURE_MIN_LOD:
|
| 5992 | if(clientVersion < 3 || !texture->setMinLOD(param))
|
| 5993 | {
|
| 5994 | return error(GL_INVALID_VALUE);
|
| 5995 | }
|
| 5996 | break;
|
| 5997 | case GL_TEXTURE_SWIZZLE_R:
|
| 5998 | if(clientVersion < 3 || !texture->setSwizzleR((GLenum)param))
|
| 5999 | {
|
| 6000 | return error(GL_INVALID_VALUE);
|
| 6001 | }
|
| 6002 | break;
|
| 6003 | case GL_TEXTURE_SWIZZLE_G:
|
| 6004 | if(clientVersion < 3 || !texture->setSwizzleG((GLenum)param))
|
| 6005 | {
|
| 6006 | return error(GL_INVALID_VALUE);
|
| 6007 | }
|
| 6008 | break;
|
| 6009 | case GL_TEXTURE_SWIZZLE_B:
|
| 6010 | if(clientVersion < 3 || !texture->setSwizzleB((GLenum)param))
|
| 6011 | {
|
| 6012 | return error(GL_INVALID_VALUE);
|
| 6013 | }
|
| 6014 | break;
|
| 6015 | case GL_TEXTURE_SWIZZLE_A:
|
| 6016 | if(clientVersion < 3 || !texture->setSwizzleA((GLenum)param))
|
| 6017 | {
|
| 6018 | return error(GL_INVALID_VALUE);
|
| 6019 | }
|
| 6020 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6021 | default:
|
| 6022 | return error(GL_INVALID_ENUM);
|
| 6023 | }
|
| 6024 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6025 | }
|
| 6026 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6027 | void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6028 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6029 | glTexParameterf(target, pname, *params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6030 | }
|
| 6031 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6032 | void TexParameteri(GLenum target, GLenum pname, GLint param)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6033 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6034 | 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] | 6035 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6036 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6037 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6038 | if(context)
|
| 6039 | {
|
| 6040 | es2::Texture *texture;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6041 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6042 | egl::GLint clientVersion = context->getClientVersion();
|
| 6043 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6044 | switch(target)
|
| 6045 | {
|
| 6046 | case GL_TEXTURE_2D:
|
| 6047 | texture = context->getTexture2D();
|
| 6048 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6049 | case GL_TEXTURE_2D_ARRAY:
|
| 6050 | if(clientVersion < 3)
|
| 6051 | {
|
| 6052 | return error(GL_INVALID_ENUM);
|
| 6053 | }
|
| 6054 | else
|
| 6055 | {
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 6056 | texture = context->getTexture2DArray();
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6057 | }
|
Alexis Hetu | f15e894 | 2015-12-01 15:13:23 -0500 | [diff] [blame] | 6058 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6059 | case GL_TEXTURE_3D_OES:
|
| 6060 | texture = context->getTexture3D();
|
| 6061 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6062 | case GL_TEXTURE_CUBE_MAP:
|
| 6063 | texture = context->getTextureCubeMap();
|
| 6064 | break;
|
| 6065 | case GL_TEXTURE_EXTERNAL_OES:
|
Alexis Hetu | f7be67f | 2015-02-11 16:11:07 -0500 | [diff] [blame] | 6066 | texture = context->getTextureExternal();
|
| 6067 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6068 | default:
|
| 6069 | return error(GL_INVALID_ENUM);
|
| 6070 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6071 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6072 | switch(pname)
|
| 6073 | {
|
| 6074 | case GL_TEXTURE_WRAP_S:
|
| 6075 | if(!texture->setWrapS((GLenum)param))
|
| 6076 | {
|
| 6077 | return error(GL_INVALID_ENUM);
|
| 6078 | }
|
| 6079 | break;
|
| 6080 | case GL_TEXTURE_WRAP_T:
|
| 6081 | if(!texture->setWrapT((GLenum)param))
|
| 6082 | {
|
| 6083 | return error(GL_INVALID_ENUM);
|
| 6084 | }
|
| 6085 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6086 | case GL_TEXTURE_WRAP_R_OES:
|
| 6087 | if(!texture->setWrapR((GLenum)param))
|
| 6088 | {
|
| 6089 | return error(GL_INVALID_ENUM);
|
| 6090 | }
|
| 6091 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6092 | case GL_TEXTURE_MIN_FILTER:
|
| 6093 | if(!texture->setMinFilter((GLenum)param))
|
| 6094 | {
|
| 6095 | return error(GL_INVALID_ENUM);
|
| 6096 | }
|
| 6097 | break;
|
| 6098 | case GL_TEXTURE_MAG_FILTER:
|
| 6099 | if(!texture->setMagFilter((GLenum)param))
|
| 6100 | {
|
| 6101 | return error(GL_INVALID_ENUM);
|
| 6102 | }
|
| 6103 | break;
|
| 6104 | case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
| 6105 | if(!texture->setMaxAnisotropy((GLfloat)param))
|
| 6106 | {
|
| 6107 | return error(GL_INVALID_VALUE);
|
| 6108 | }
|
| 6109 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6110 | case GL_TEXTURE_BASE_LEVEL:
|
| 6111 | if(clientVersion < 3 || !texture->setBaseLevel(param))
|
| 6112 | {
|
| 6113 | return error(GL_INVALID_VALUE);
|
| 6114 | }
|
| 6115 | break;
|
| 6116 | case GL_TEXTURE_COMPARE_FUNC:
|
| 6117 | if(clientVersion < 3 || !texture->setCompareFunc((GLenum)param))
|
| 6118 | {
|
| 6119 | return error(GL_INVALID_VALUE);
|
| 6120 | }
|
| 6121 | break;
|
| 6122 | case GL_TEXTURE_COMPARE_MODE:
|
| 6123 | if(clientVersion < 3 || !texture->setCompareMode((GLenum)param))
|
| 6124 | {
|
| 6125 | return error(GL_INVALID_VALUE);
|
| 6126 | }
|
Alexis Hetu | 8e09837 | 2015-09-28 10:59:11 -0400 | [diff] [blame] | 6127 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6128 | case GL_TEXTURE_IMMUTABLE_FORMAT:
|
Alexis Hetu | 8e09837 | 2015-09-28 10:59:11 -0400 | [diff] [blame] | 6129 | if(clientVersion < 3 || !texture->setImmutableFormat((GLboolean)param))
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6130 | {
|
| 6131 | return error(GL_INVALID_VALUE);
|
| 6132 | }
|
| 6133 | break;
|
| 6134 | case GL_TEXTURE_MAX_LEVEL:
|
| 6135 | if(clientVersion < 3 || !texture->setMaxLevel(param))
|
| 6136 | {
|
| 6137 | return error(GL_INVALID_VALUE);
|
| 6138 | }
|
| 6139 | break;
|
| 6140 | case GL_TEXTURE_MAX_LOD:
|
| 6141 | if(clientVersion < 3 || !texture->setMaxLOD((GLfloat)param))
|
| 6142 | {
|
| 6143 | return error(GL_INVALID_VALUE);
|
| 6144 | }
|
| 6145 | break;
|
| 6146 | case GL_TEXTURE_MIN_LOD:
|
| 6147 | if(clientVersion < 3 || !texture->setMinLOD((GLfloat)param))
|
| 6148 | {
|
| 6149 | return error(GL_INVALID_VALUE);
|
| 6150 | }
|
| 6151 | break;
|
| 6152 | case GL_TEXTURE_SWIZZLE_R:
|
| 6153 | if(clientVersion < 3 || !texture->setSwizzleR((GLenum)param))
|
| 6154 | {
|
| 6155 | return error(GL_INVALID_VALUE);
|
| 6156 | }
|
| 6157 | break;
|
| 6158 | case GL_TEXTURE_SWIZZLE_G:
|
| 6159 | if(clientVersion < 3 || !texture->setSwizzleG((GLenum)param))
|
| 6160 | {
|
| 6161 | return error(GL_INVALID_VALUE);
|
| 6162 | }
|
| 6163 | break;
|
| 6164 | case GL_TEXTURE_SWIZZLE_B:
|
| 6165 | if(clientVersion < 3 || !texture->setSwizzleB((GLenum)param))
|
| 6166 | {
|
| 6167 | return error(GL_INVALID_VALUE);
|
| 6168 | }
|
| 6169 | break;
|
| 6170 | case GL_TEXTURE_SWIZZLE_A:
|
| 6171 | if(clientVersion < 3 || !texture->setSwizzleA((GLenum)param))
|
| 6172 | {
|
| 6173 | return error(GL_INVALID_VALUE);
|
| 6174 | }
|
| 6175 | break;
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6176 | default:
|
| 6177 | return error(GL_INVALID_ENUM);
|
| 6178 | }
|
| 6179 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6180 | }
|
| 6181 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6182 | void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
|
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 | glTexParameteri(target, pname, *params);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6185 | }
|
| 6186 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6187 | void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
|
| 6188 | GLenum format, GLenum type, const GLvoid* pixels)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6189 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6190 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
| 6191 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6192 | "const GLvoid* pixels = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6193 | target, level, xoffset, yoffset, width, height, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6194 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6195 | if(!es2::IsTextureTarget(target))
|
| 6196 | {
|
| 6197 | return error(GL_INVALID_ENUM);
|
| 6198 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6199 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6200 | if(level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
|
| 6201 | {
|
| 6202 | return error(GL_INVALID_VALUE);
|
| 6203 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6204 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6205 | if(std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
|
| 6206 | {
|
| 6207 | return error(GL_INVALID_VALUE);
|
| 6208 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6209 |
|
Alexis Hetu | 6116150 | 2015-05-21 11:45:03 -0400 | [diff] [blame] | 6210 | if(!es2::CheckTextureFormatType(format, type, egl::getClientVersion()))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6211 | {
|
| 6212 | return error(GL_INVALID_ENUM);
|
| 6213 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6214 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6215 | if(width == 0 || height == 0 || pixels == NULL)
|
| 6216 | {
|
| 6217 | return;
|
| 6218 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6219 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6220 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6221 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6222 | if(context)
|
| 6223 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 6224 | if(level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6225 | {
|
| 6226 | return error(GL_INVALID_VALUE);
|
| 6227 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6228 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 6229 | GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
|
| 6230 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6231 | if(target == GL_TEXTURE_2D)
|
| 6232 | {
|
| 6233 | es2::Texture2D *texture = context->getTexture2D();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6234 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 6235 | GLenum validationError = ValidateSubImageParams(false, width, height, xoffset, yoffset, target, level, sizedInternalFormat, texture);
|
| 6236 |
|
| 6237 | if(validationError == GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6238 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 6239 | texture->subImage(level, xoffset, yoffset, width, height, sizedInternalFormat, type, context->getUnpackInfo(), pixels);
|
| 6240 | }
|
| 6241 | else
|
| 6242 | {
|
| 6243 | return error(validationError);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6244 | }
|
| 6245 | }
|
| 6246 | else if(es2::IsCubemapTextureTarget(target))
|
| 6247 | {
|
| 6248 | es2::TextureCubeMap *texture = context->getTextureCubeMap();
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 6249 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 6250 | GLenum validationError = ValidateSubImageParams(false, width, height, xoffset, yoffset, target, level, sizedInternalFormat, texture);
|
| 6251 |
|
| 6252 | if(validationError == GL_NONE)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6253 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 6254 | texture->subImage(target, level, xoffset, yoffset, width, height, sizedInternalFormat, type, context->getUnpackInfo(), pixels);
|
| 6255 | }
|
| 6256 | else
|
| 6257 | {
|
| 6258 | return error(validationError);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6259 | }
|
| 6260 | }
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 6261 | else UNREACHABLE(target);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6262 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6263 | }
|
| 6264 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6265 | void Uniform1f(GLint location, GLfloat x)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6266 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6267 | glUniform1fv(location, 1, &x);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6268 | }
|
| 6269 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6270 | void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6271 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6272 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6273 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6274 | if(count < 0)
|
| 6275 | {
|
| 6276 | return error(GL_INVALID_VALUE);
|
| 6277 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6278 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6279 | if(location == -1)
|
| 6280 | {
|
| 6281 | return;
|
| 6282 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6283 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6284 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6285 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6286 | if(context)
|
| 6287 | {
|
| 6288 | es2::Program *program = context->getCurrentProgram();
|
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 | if(!program)
|
| 6291 | {
|
| 6292 | return error(GL_INVALID_OPERATION);
|
| 6293 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6294 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6295 | if(!program->setUniform1fv(location, count, v))
|
| 6296 | {
|
| 6297 | return error(GL_INVALID_OPERATION);
|
| 6298 | }
|
| 6299 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6300 | }
|
| 6301 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6302 | void Uniform1i(GLint location, GLint x)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6303 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6304 | glUniform1iv(location, 1, &x);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6305 | }
|
| 6306 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6307 | void Uniform1iv(GLint location, GLsizei count, const GLint* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6308 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6309 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6310 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6311 | if(count < 0)
|
| 6312 | {
|
| 6313 | return error(GL_INVALID_VALUE);
|
| 6314 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6315 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6316 | if(location == -1)
|
| 6317 | {
|
| 6318 | return;
|
| 6319 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6320 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6321 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6322 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6323 | if(context)
|
| 6324 | {
|
| 6325 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6326 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6327 | if(!program)
|
| 6328 | {
|
| 6329 | return error(GL_INVALID_OPERATION);
|
| 6330 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6331 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6332 | if(!program->setUniform1iv(location, count, v))
|
| 6333 | {
|
| 6334 | return error(GL_INVALID_OPERATION);
|
| 6335 | }
|
| 6336 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6337 | }
|
| 6338 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6339 | void Uniform2f(GLint location, GLfloat x, GLfloat y)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6340 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6341 | GLfloat xy[2] = {x, y};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6342 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6343 | glUniform2fv(location, 1, (GLfloat*)&xy);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6344 | }
|
| 6345 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6346 | void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6347 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6348 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6349 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6350 | if(count < 0)
|
| 6351 | {
|
| 6352 | return error(GL_INVALID_VALUE);
|
| 6353 | }
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 6354 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6355 | if(location == -1)
|
| 6356 | {
|
| 6357 | return;
|
| 6358 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6359 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6360 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6361 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6362 | if(context)
|
| 6363 | {
|
| 6364 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6365 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6366 | if(!program)
|
| 6367 | {
|
| 6368 | return error(GL_INVALID_OPERATION);
|
| 6369 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6370 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6371 | if(!program->setUniform2fv(location, count, v))
|
| 6372 | {
|
| 6373 | return error(GL_INVALID_OPERATION);
|
| 6374 | }
|
| 6375 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6376 | }
|
| 6377 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6378 | void Uniform2i(GLint location, GLint x, GLint y)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6379 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6380 | GLint xy[4] = {x, y};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6381 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6382 | glUniform2iv(location, 1, (GLint*)&xy);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6383 | }
|
| 6384 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6385 | void Uniform2iv(GLint location, GLsizei count, const GLint* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6386 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6387 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6388 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6389 | if(count < 0)
|
| 6390 | {
|
| 6391 | return error(GL_INVALID_VALUE);
|
| 6392 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6393 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6394 | if(location == -1)
|
| 6395 | {
|
| 6396 | return;
|
| 6397 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6398 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6399 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6400 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6401 | if(context)
|
| 6402 | {
|
| 6403 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6404 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6405 | if(!program)
|
| 6406 | {
|
| 6407 | return error(GL_INVALID_OPERATION);
|
| 6408 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6409 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6410 | if(!program->setUniform2iv(location, count, v))
|
| 6411 | {
|
| 6412 | return error(GL_INVALID_OPERATION);
|
| 6413 | }
|
| 6414 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6415 | }
|
| 6416 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6417 | void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6418 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6419 | GLfloat xyz[3] = {x, y, z};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6420 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6421 | glUniform3fv(location, 1, (GLfloat*)&xyz);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6422 | }
|
| 6423 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6424 | void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6425 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6426 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6427 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6428 | if(count < 0)
|
| 6429 | {
|
| 6430 | return error(GL_INVALID_VALUE);
|
| 6431 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6432 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6433 | if(location == -1)
|
| 6434 | {
|
| 6435 | return;
|
| 6436 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6437 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6438 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6439 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6440 | if(context)
|
| 6441 | {
|
| 6442 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6443 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6444 | if(!program)
|
| 6445 | {
|
| 6446 | return error(GL_INVALID_OPERATION);
|
| 6447 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6448 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6449 | if(!program->setUniform3fv(location, count, v))
|
| 6450 | {
|
| 6451 | return error(GL_INVALID_OPERATION);
|
| 6452 | }
|
| 6453 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6454 | }
|
| 6455 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6456 | void Uniform3i(GLint location, GLint x, GLint y, GLint z)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6457 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6458 | GLint xyz[3] = {x, y, z};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6459 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6460 | glUniform3iv(location, 1, (GLint*)&xyz);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6461 | }
|
| 6462 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6463 | void Uniform3iv(GLint location, GLsizei count, const GLint* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6464 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6465 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6466 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6467 | if(count < 0)
|
| 6468 | {
|
| 6469 | return error(GL_INVALID_VALUE);
|
| 6470 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6471 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6472 | if(location == -1)
|
| 6473 | {
|
| 6474 | return;
|
| 6475 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6476 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6477 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6478 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6479 | if(context)
|
| 6480 | {
|
| 6481 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6482 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6483 | if(!program)
|
| 6484 | {
|
| 6485 | return error(GL_INVALID_OPERATION);
|
| 6486 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6487 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6488 | if(!program->setUniform3iv(location, count, v))
|
| 6489 | {
|
| 6490 | return error(GL_INVALID_OPERATION);
|
| 6491 | }
|
| 6492 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6493 | }
|
| 6494 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6495 | void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6496 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6497 | GLfloat xyzw[4] = {x, y, z, w};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6498 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6499 | glUniform4fv(location, 1, (GLfloat*)&xyzw);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6500 | }
|
| 6501 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6502 | void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6503 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6504 | TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6505 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6506 | if(count < 0)
|
| 6507 | {
|
| 6508 | return error(GL_INVALID_VALUE);
|
| 6509 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6510 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6511 | if(location == -1)
|
| 6512 | {
|
| 6513 | return;
|
| 6514 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6515 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6516 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6517 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6518 | if(context)
|
| 6519 | {
|
| 6520 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6521 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6522 | if(!program)
|
| 6523 | {
|
| 6524 | return error(GL_INVALID_OPERATION);
|
| 6525 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6526 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6527 | if(!program->setUniform4fv(location, count, v))
|
| 6528 | {
|
| 6529 | return error(GL_INVALID_OPERATION);
|
| 6530 | }
|
| 6531 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6532 | }
|
| 6533 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6534 | void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6535 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6536 | GLint xyzw[4] = {x, y, z, w};
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6537 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6538 | glUniform4iv(location, 1, (GLint*)&xyzw);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6539 | }
|
| 6540 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6541 | void Uniform4iv(GLint location, GLsizei count, const GLint* v)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6542 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6543 | TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = %p)", location, count, v);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6544 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6545 | if(count < 0)
|
| 6546 | {
|
| 6547 | return error(GL_INVALID_VALUE);
|
| 6548 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6549 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6550 | if(location == -1)
|
| 6551 | {
|
| 6552 | return;
|
| 6553 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6554 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6555 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6556 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6557 | if(context)
|
| 6558 | {
|
| 6559 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6560 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6561 | if(!program)
|
| 6562 | {
|
| 6563 | return error(GL_INVALID_OPERATION);
|
| 6564 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6565 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6566 | if(!program->setUniform4iv(location, count, v))
|
| 6567 | {
|
| 6568 | return error(GL_INVALID_OPERATION);
|
| 6569 | }
|
| 6570 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6571 | }
|
| 6572 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6573 | void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6574 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6575 | TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6576 | location, count, transpose, value);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6577 |
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6578 | if(count < 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6579 | {
|
| 6580 | return error(GL_INVALID_VALUE);
|
| 6581 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6582 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6583 | if(location == -1)
|
| 6584 | {
|
| 6585 | return;
|
| 6586 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6587 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6588 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6589 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6590 | if(context)
|
| 6591 | {
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6592 | if(context->getClientVersion() < 3 && transpose != GL_FALSE)
|
| 6593 | {
|
| 6594 | return error(GL_INVALID_VALUE);
|
| 6595 | }
|
| 6596 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6597 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6598 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6599 | if(!program)
|
| 6600 | {
|
| 6601 | return error(GL_INVALID_OPERATION);
|
| 6602 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6603 |
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6604 | if(!program->setUniformMatrix2fv(location, count, transpose, value))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6605 | {
|
| 6606 | return error(GL_INVALID_OPERATION);
|
| 6607 | }
|
| 6608 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6609 | }
|
| 6610 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6611 | void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6612 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6613 | TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6614 | location, count, transpose, value);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6615 |
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6616 | if(count < 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6617 | {
|
| 6618 | return error(GL_INVALID_VALUE);
|
| 6619 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6620 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6621 | if(location == -1)
|
| 6622 | {
|
| 6623 | return;
|
| 6624 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6625 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6626 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6627 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6628 | if(context)
|
| 6629 | {
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6630 | if(context->getClientVersion() < 3 && transpose != GL_FALSE)
|
| 6631 | {
|
| 6632 | return error(GL_INVALID_VALUE);
|
| 6633 | }
|
| 6634 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6635 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6636 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6637 | if(!program)
|
| 6638 | {
|
| 6639 | return error(GL_INVALID_OPERATION);
|
| 6640 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6641 |
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6642 | if(!program->setUniformMatrix3fv(location, count, transpose, value))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6643 | {
|
| 6644 | return error(GL_INVALID_OPERATION);
|
| 6645 | }
|
| 6646 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6647 | }
|
| 6648 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6649 | void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6650 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6651 | TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6652 | location, count, transpose, value);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6653 |
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6654 | if(count < 0)
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6655 | {
|
| 6656 | return error(GL_INVALID_VALUE);
|
| 6657 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6658 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6659 | if(location == -1)
|
| 6660 | {
|
| 6661 | return;
|
| 6662 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6663 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6664 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6665 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6666 | if(context)
|
| 6667 | {
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6668 | if(context->getClientVersion() < 3 && transpose != GL_FALSE)
|
| 6669 | {
|
| 6670 | return error(GL_INVALID_VALUE);
|
| 6671 | }
|
| 6672 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6673 | es2::Program *program = context->getCurrentProgram();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6674 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6675 | if(!program)
|
| 6676 | {
|
| 6677 | return error(GL_INVALID_OPERATION);
|
| 6678 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6679 |
|
Alexis Hetu | 4de7e2e | 2015-05-21 10:47:04 -0400 | [diff] [blame] | 6680 | if(!program->setUniformMatrix4fv(location, count, transpose, value))
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6681 | {
|
| 6682 | return error(GL_INVALID_OPERATION);
|
| 6683 | }
|
| 6684 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6685 | }
|
| 6686 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6687 | void UseProgram(GLuint program)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6688 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6689 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6690 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6691 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6692 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6693 | if(context)
|
| 6694 | {
|
| 6695 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6696 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6697 | if(!programObject && program != 0)
|
| 6698 | {
|
| 6699 | if(context->getShader(program))
|
| 6700 | {
|
| 6701 | return error(GL_INVALID_OPERATION);
|
| 6702 | }
|
| 6703 | else
|
| 6704 | {
|
| 6705 | return error(GL_INVALID_VALUE);
|
| 6706 | }
|
| 6707 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6708 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6709 | if(program != 0 && !programObject->isLinked())
|
| 6710 | {
|
| 6711 | return error(GL_INVALID_OPERATION);
|
| 6712 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6713 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6714 | context->useProgram(program);
|
| 6715 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6716 | }
|
| 6717 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6718 | void ValidateProgram(GLuint program)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6719 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6720 | TRACE("(GLuint program = %d)", program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6721 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6722 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6723 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6724 | if(context)
|
| 6725 | {
|
| 6726 | es2::Program *programObject = context->getProgram(program);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6727 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6728 | if(!programObject)
|
| 6729 | {
|
| 6730 | if(context->getShader(program))
|
| 6731 | {
|
| 6732 | return error(GL_INVALID_OPERATION);
|
| 6733 | }
|
| 6734 | else
|
| 6735 | {
|
| 6736 | return error(GL_INVALID_VALUE);
|
| 6737 | }
|
| 6738 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6739 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6740 | programObject->validate();
|
| 6741 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6742 | }
|
| 6743 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6744 | void VertexAttrib1f(GLuint index, GLfloat x)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6745 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6746 | TRACE("(GLuint index = %d, GLfloat x = %f)", index, x);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6747 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6748 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6749 | {
|
| 6750 | return error(GL_INVALID_VALUE);
|
| 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 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6754 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6755 | if(context)
|
| 6756 | {
|
| 6757 | GLfloat vals[4] = { x, 0, 0, 1 };
|
| 6758 | context->setVertexAttrib(index, vals);
|
| 6759 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6760 | }
|
| 6761 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6762 | void VertexAttrib1fv(GLuint index, const GLfloat* values)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6763 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6764 | TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6765 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6766 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6767 | {
|
| 6768 | return error(GL_INVALID_VALUE);
|
| 6769 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6770 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6771 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6772 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6773 | if(context)
|
| 6774 | {
|
| 6775 | GLfloat vals[4] = { values[0], 0, 0, 1 };
|
| 6776 | context->setVertexAttrib(index, vals);
|
| 6777 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6778 | }
|
| 6779 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6780 | void VertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6781 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6782 | 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] | 6783 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6784 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6785 | {
|
| 6786 | return error(GL_INVALID_VALUE);
|
| 6787 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6788 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6789 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6790 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6791 | if(context)
|
| 6792 | {
|
| 6793 | GLfloat vals[4] = { x, y, 0, 1 };
|
| 6794 | context->setVertexAttrib(index, vals);
|
| 6795 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6796 | }
|
| 6797 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6798 | void VertexAttrib2fv(GLuint index, const GLfloat* values)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6799 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6800 | TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6801 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6802 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6803 | {
|
| 6804 | return error(GL_INVALID_VALUE);
|
| 6805 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6806 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6807 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6808 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6809 | if(context)
|
| 6810 | {
|
| 6811 | GLfloat vals[4] = { values[0], values[1], 0, 1 };
|
| 6812 | context->setVertexAttrib(index, vals);
|
| 6813 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6814 | }
|
| 6815 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6816 | void VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6817 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6818 | 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] | 6819 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6820 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6821 | {
|
| 6822 | return error(GL_INVALID_VALUE);
|
| 6823 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6824 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6825 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6826 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6827 | if(context)
|
| 6828 | {
|
| 6829 | GLfloat vals[4] = { x, y, z, 1 };
|
| 6830 | context->setVertexAttrib(index, vals);
|
| 6831 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6832 | }
|
| 6833 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6834 | void VertexAttrib3fv(GLuint index, const GLfloat* values)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6835 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6836 | TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6837 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6838 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6839 | {
|
| 6840 | return error(GL_INVALID_VALUE);
|
| 6841 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6842 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6843 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6844 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6845 | if(context)
|
| 6846 | {
|
| 6847 | GLfloat vals[4] = { values[0], values[1], values[2], 1 };
|
| 6848 | context->setVertexAttrib(index, vals);
|
| 6849 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6850 | }
|
| 6851 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6852 | void VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6853 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6854 | 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] | 6855 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6856 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6857 | {
|
| 6858 | return error(GL_INVALID_VALUE);
|
| 6859 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6860 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6861 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6862 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6863 | if(context)
|
| 6864 | {
|
| 6865 | GLfloat vals[4] = { x, y, z, w };
|
| 6866 | context->setVertexAttrib(index, vals);
|
| 6867 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6868 | }
|
| 6869 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6870 | void VertexAttrib4fv(GLuint index, const GLfloat* values)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6871 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6872 | TRACE("(GLuint index = %d, const GLfloat* values = %p)", index, values);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6873 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6874 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6875 | {
|
| 6876 | return error(GL_INVALID_VALUE);
|
| 6877 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6878 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6879 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6880 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6881 | if(context)
|
| 6882 | {
|
| 6883 | context->setVertexAttrib(index, values);
|
| 6884 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6885 | }
|
| 6886 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6887 | void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6888 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6889 | TRACE("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 6890 | "GLboolean normalized = %d, GLsizei stride = %d, const GLvoid* ptr = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6891 | index, size, type, normalized, stride, ptr);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6892 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6893 | if(index >= es2::MAX_VERTEX_ATTRIBS)
|
| 6894 | {
|
| 6895 | return error(GL_INVALID_VALUE);
|
| 6896 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6897 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6898 | if(size < 1 || size > 4)
|
| 6899 | {
|
| 6900 | return error(GL_INVALID_VALUE);
|
| 6901 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6902 |
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6903 | egl::GLint clientVersion = egl::getClientVersion();
|
| 6904 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6905 | switch(type)
|
| 6906 | {
|
| 6907 | case GL_BYTE:
|
| 6908 | case GL_UNSIGNED_BYTE:
|
| 6909 | case GL_SHORT:
|
| 6910 | case GL_UNSIGNED_SHORT:
|
| 6911 | case GL_FIXED:
|
| 6912 | case GL_FLOAT:
|
| 6913 | break;
|
Alexis Hetu | ed30618 | 2015-04-02 12:02:28 -0400 | [diff] [blame] | 6914 | case GL_INT_2_10_10_10_REV:
|
| 6915 | case GL_UNSIGNED_INT_2_10_10_10_REV:
|
| 6916 | if(clientVersion >= 3)
|
| 6917 | {
|
| 6918 | if(size != 4)
|
| 6919 | {
|
| 6920 | return error(GL_INVALID_OPERATION);
|
| 6921 | }
|
| 6922 | break;
|
| 6923 | }
|
| 6924 | else return error(GL_INVALID_ENUM);
|
| 6925 | case GL_INT:
|
| 6926 | case GL_UNSIGNED_INT:
|
| 6927 | case GL_HALF_FLOAT:
|
| 6928 | if(clientVersion >= 3)
|
| 6929 | {
|
| 6930 | break;
|
| 6931 | }
|
| 6932 | else return error(GL_INVALID_ENUM);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6933 | default:
|
| 6934 | return error(GL_INVALID_ENUM);
|
| 6935 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6936 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6937 | if(stride < 0)
|
| 6938 | {
|
| 6939 | return error(GL_INVALID_VALUE);
|
| 6940 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6941 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6942 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6943 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6944 | if(context)
|
| 6945 | {
|
| 6946 | context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr);
|
| 6947 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6948 | }
|
| 6949 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6950 | void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6951 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6952 | 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] | 6953 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6954 | if(width < 0 || height < 0)
|
| 6955 | {
|
| 6956 | return error(GL_INVALID_VALUE);
|
| 6957 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6958 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6959 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6960 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6961 | if(context)
|
| 6962 | {
|
| 6963 | context->setViewportParams(x, y, width, height);
|
| 6964 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6965 | }
|
| 6966 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 6967 | void BlitFramebufferNV(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] | 6968 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6969 | TRACE("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
|
| 6970 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
|
| 6971 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
|
| 6972 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6973 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6974 | switch(filter)
|
| 6975 | {
|
| 6976 | case GL_NEAREST:
|
| 6977 | break;
|
| 6978 | default:
|
| 6979 | return error(GL_INVALID_ENUM);
|
| 6980 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6981 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6982 | if((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
|
| 6983 | {
|
| 6984 | return error(GL_INVALID_VALUE);
|
| 6985 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6986 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6987 | es2::Context *context = es2::getContext();
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6988 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6989 | if(context)
|
| 6990 | {
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 6991 | if(context->getReadFramebufferName() == context->getDrawFramebufferName())
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6992 | {
|
| 6993 | ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
|
| 6994 | return error(GL_INVALID_OPERATION);
|
| 6995 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6996 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 6997 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
|
| 6998 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6999 | }
|
| 7000 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7001 | void BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
| 7002 | GLbitfield mask, GLenum filter)
|
Alexis Hetu | e9233fb | 2015-02-11 10:31:58 -0500 | [diff] [blame] | 7003 | {
|
| 7004 | if(srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
|
| 7005 | {
|
| 7006 | ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
|
| 7007 | return error(GL_INVALID_OPERATION);
|
| 7008 | }
|
| 7009 |
|
| 7010 | glBlitFramebufferNV(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
| 7011 | }
|
| 7012 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7013 | void TexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
|
| 7014 | GLint border, GLenum format, GLenum type, const GLvoid* pixels)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7015 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7016 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
|
| 7017 | "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 7018 | "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = %p)",
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7019 | target, level, internalformat, width, height, depth, border, format, type, pixels);
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7020 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7021 | switch(target)
|
| 7022 | {
|
| 7023 | case GL_TEXTURE_3D_OES:
|
| 7024 | switch(format)
|
| 7025 | {
|
| 7026 | case GL_DEPTH_COMPONENT:
|
| 7027 | case GL_DEPTH_STENCIL_OES:
|
| 7028 | return error(GL_INVALID_OPERATION);
|
| 7029 | default:
|
| 7030 | break;
|
| 7031 | }
|
| 7032 | break;
|
| 7033 | default:
|
| 7034 | return error(GL_INVALID_ENUM);
|
| 7035 | }
|
| 7036 |
|
| 7037 | if(!ValidateType3D(type) || !ValidateFormat3D(format))
|
| 7038 | {
|
| 7039 | return error(GL_INVALID_ENUM);
|
| 7040 | }
|
| 7041 |
|
| 7042 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 7043 | {
|
| 7044 | return error(GL_INVALID_VALUE);
|
| 7045 | }
|
| 7046 |
|
| 7047 | const GLsizei maxSize3D = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level;
|
| 7048 | if((width < 0) || (height < 0) || (depth < 0) || (width > maxSize3D) || (height > maxSize3D) || (depth > maxSize3D))
|
| 7049 | {
|
| 7050 | return error(GL_INVALID_VALUE);
|
| 7051 | }
|
| 7052 |
|
| 7053 | if(border != 0)
|
| 7054 | {
|
| 7055 | return error(GL_INVALID_VALUE);
|
| 7056 | }
|
| 7057 |
|
| 7058 | if(!ValidateInternalFormat3D(internalformat, format, type))
|
| 7059 | {
|
| 7060 | return error(GL_INVALID_OPERATION);
|
| 7061 | }
|
| 7062 |
|
| 7063 | es2::Context *context = es2::getContext();
|
| 7064 |
|
| 7065 | if(context)
|
| 7066 | {
|
| 7067 | es2::Texture3D *texture = context->getTexture3D();
|
| 7068 |
|
| 7069 | if(!texture)
|
| 7070 | {
|
| 7071 | return error(GL_INVALID_OPERATION);
|
| 7072 | }
|
| 7073 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7074 | texture->setImage(level, width, height, depth, GetSizedInternalFormat(internalformat, type), type, context->getUnpackInfo(), pixels);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7075 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7076 | }
|
| 7077 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7078 | void TexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7079 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7080 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
Nicolas Capens | 5767099 | 2015-09-02 16:52:38 -0400 | [diff] [blame] | 7081 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
|
| 7082 | "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = %p)",
|
| 7083 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7084 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7085 | switch(target)
|
| 7086 | {
|
| 7087 | case GL_TEXTURE_3D_OES:
|
| 7088 | break;
|
| 7089 | default:
|
| 7090 | return error(GL_INVALID_ENUM);
|
| 7091 | }
|
| 7092 |
|
| 7093 | if(!ValidateType3D(type) || !ValidateFormat3D(format))
|
| 7094 | {
|
| 7095 | return error(GL_INVALID_ENUM);
|
| 7096 | }
|
| 7097 |
|
| 7098 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 7099 | {
|
| 7100 | return error(GL_INVALID_VALUE);
|
| 7101 | }
|
| 7102 |
|
| 7103 | if((width < 0) || (height < 0) || (depth < 0))
|
| 7104 | {
|
| 7105 | return error(GL_INVALID_VALUE);
|
| 7106 | }
|
| 7107 |
|
| 7108 | es2::Context *context = es2::getContext();
|
| 7109 |
|
| 7110 | if(context)
|
| 7111 | {
|
| 7112 | es2::Texture3D *texture = context->getTexture3D();
|
| 7113 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7114 | GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
|
| 7115 |
|
| 7116 | GLenum validationError = ValidateSubImageParams(false, width, height, depth, xoffset, yoffset, zoffset, target, level, sizedInternalFormat, texture);
|
| 7117 | if(validationError == GL_NONE)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7118 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7119 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, sizedInternalFormat, type, context->getUnpackInfo(), pixels);
|
| 7120 | }
|
| 7121 | else
|
| 7122 | {
|
| 7123 | return error(validationError);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7124 | }
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7125 | }
|
| 7126 | }
|
| 7127 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7128 | void CopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7129 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7130 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
Nicolas Capens | 5767099 | 2015-09-02 16:52:38 -0400 | [diff] [blame] | 7131 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
|
| 7132 | target, level, xoffset, yoffset, zoffset, x, y, width, height);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7133 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7134 | switch(target)
|
| 7135 | {
|
| 7136 | case GL_TEXTURE_3D_OES:
|
| 7137 | break;
|
| 7138 | default:
|
| 7139 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7140 | }
|
| 7141 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7142 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 7143 | {
|
| 7144 | return error(GL_INVALID_VALUE);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7145 | }
|
| 7146 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7147 | es2::Context *context = es2::getContext();
|
| 7148 |
|
| 7149 | if(context)
|
| 7150 | {
|
| 7151 | es2::Framebuffer *framebuffer = context->getReadFramebuffer();
|
| 7152 |
|
| 7153 | if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
|
| 7154 | {
|
| 7155 | return error(GL_INVALID_FRAMEBUFFER_OPERATION);
|
| 7156 | }
|
| 7157 |
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 7158 | es2::Renderbuffer *source = framebuffer->getReadColorbuffer();
|
| 7159 |
|
| 7160 | if(context->getReadFramebufferName() != 0 && (!source || source->getSamples() > 1))
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7161 | {
|
| 7162 | return error(GL_INVALID_OPERATION);
|
| 7163 | }
|
| 7164 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7165 | es2::Texture3D *texture = context->getTexture3D();
|
| 7166 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7167 | GLenum validationError = ValidateSubImageParams(false, width, height, 1, xoffset, yoffset, zoffset, target, level, GL_NONE, texture);
|
| 7168 |
|
| 7169 | if(validationError != GL_NONE)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7170 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7171 | return error(validationError);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7172 | }
|
| 7173 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7174 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7175 | }
|
| 7176 | }
|
| 7177 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7178 | void CompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7179 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7180 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
|
Nicolas Capens | 5767099 | 2015-09-02 16:52:38 -0400 | [diff] [blame] | 7181 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = %p)",
|
| 7182 | target, level, internalformat, width, height, depth, border, imageSize, data);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7183 |
|
| 7184 | switch(target)
|
| 7185 | {
|
| 7186 | case GL_TEXTURE_3D_OES:
|
| 7187 | break;
|
| 7188 | default:
|
| 7189 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7190 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7191 |
|
| 7192 | if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
|
| 7193 | {
|
| 7194 | return error(GL_INVALID_VALUE);
|
| 7195 | }
|
| 7196 |
|
| 7197 | const GLsizei maxSize3D = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level;
|
| 7198 | if((width < 0) || (height < 0) || (depth < 0) || (width > maxSize3D) || (height > maxSize3D) || (depth > maxSize3D) ||(border != 0) || (imageSize < 0))
|
| 7199 | {
|
| 7200 | return error(GL_INVALID_VALUE);
|
| 7201 | }
|
| 7202 |
|
| 7203 | switch(internalformat)
|
| 7204 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7205 | case GL_DEPTH_COMPONENT:
|
| 7206 | case GL_DEPTH_COMPONENT16:
|
| 7207 | case GL_DEPTH_COMPONENT32_OES:
|
| 7208 | case GL_DEPTH_STENCIL_OES:
|
| 7209 | case GL_DEPTH24_STENCIL8_OES:
|
| 7210 | return error(GL_INVALID_OPERATION);
|
| 7211 | default:
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 7212 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7213 | GLenum validationError = ValidateCompressedFormat(internalformat, egl::getClientVersion(), true);
|
| 7214 | if(validationError != GL_NONE)
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 7215 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7216 | return error(validationError);
|
Alexis Hetu | 460e41f | 2015-09-01 10:58:37 -0400 | [diff] [blame] | 7217 | }
|
| 7218 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7219 | }
|
| 7220 |
|
Nicolas Capens | deda34b | 2015-04-28 15:21:53 -0700 | [diff] [blame] | 7221 | if(imageSize != egl::ComputeCompressedSize(width, height, internalformat) * depth)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7222 | {
|
| 7223 | return error(GL_INVALID_VALUE);
|
| 7224 | }
|
| 7225 |
|
| 7226 | es2::Context *context = es2::getContext();
|
| 7227 |
|
| 7228 | if(context)
|
| 7229 | {
|
| 7230 | es2::Texture3D *texture = context->getTexture3D();
|
| 7231 |
|
| 7232 | if(!texture)
|
| 7233 | {
|
| 7234 | return error(GL_INVALID_OPERATION);
|
| 7235 | }
|
| 7236 |
|
| 7237 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7238 | }
|
| 7239 | }
|
| 7240 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7241 | void CompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7242 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7243 | TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
|
Nicolas Capens | 5767099 | 2015-09-02 16:52:38 -0400 | [diff] [blame] | 7244 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
|
| 7245 | "GLenum format = 0x%X, GLsizei imageSize = %d, const void *data = %p)",
|
| 7246 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7247 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7248 | switch(target)
|
| 7249 | {
|
| 7250 | case GL_TEXTURE_3D_OES:
|
| 7251 | break;
|
| 7252 | default:
|
| 7253 | return error(GL_INVALID_ENUM);
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7254 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7255 |
|
| 7256 | if(xoffset < 0 || yoffset < 0 || zoffset < 0 || !validImageSize(level, width, height) || depth < 0 || imageSize < 0)
|
| 7257 | {
|
| 7258 | return error(GL_INVALID_VALUE);
|
| 7259 | }
|
| 7260 |
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7261 | GLenum validationError = ValidateCompressedFormat(format, egl::getClientVersion(), true);
|
| 7262 | if(validationError != GL_NONE)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7263 | {
|
Alexis Hetu | d9a2e7b | 2015-10-15 17:22:57 -0400 | [diff] [blame^] | 7264 | return error(validationError);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7265 | }
|
| 7266 |
|
| 7267 | if(width == 0 || height == 0 || depth == 0 || data == NULL)
|
| 7268 | {
|
| 7269 | return;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7270 | }
|
| 7271 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7272 | es2::Context *context = es2::getContext();
|
| 7273 |
|
| 7274 | if(context)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7275 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7276 | es2::Texture3D *texture = context->getTexture3D();
|
| 7277 |
|
| 7278 | if(!texture)
|
| 7279 | {
|
| 7280 | return error(GL_INVALID_OPERATION);
|
| 7281 | }
|
| 7282 |
|
| 7283 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
|
| 7284 | }
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7285 | }
|
| 7286 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7287 | void FramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7288 | {
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7289 | TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
|
Nicolas Capens | 5767099 | 2015-09-02 16:52:38 -0400 | [diff] [blame] | 7290 | "GLuint texture = %d, GLint level = %d, GLint zoffset = %d)", target, attachment, textarget, texture, level, zoffset);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7291 |
|
| 7292 | if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
|
| 7293 | {
|
| 7294 | return error(GL_INVALID_ENUM);
|
| 7295 | }
|
| 7296 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7297 | es2::Context *context = es2::getContext();
|
| 7298 |
|
| 7299 | if(context)
|
| 7300 | {
|
| 7301 | if(texture == 0)
|
| 7302 | {
|
| 7303 | textarget = GL_NONE;
|
| 7304 | }
|
| 7305 | else
|
| 7306 | {
|
| 7307 | es2::Texture *tex = context->getTexture(texture);
|
| 7308 |
|
| 7309 | if(tex == NULL)
|
| 7310 | {
|
| 7311 | return error(GL_INVALID_OPERATION);
|
| 7312 | }
|
| 7313 |
|
| 7314 | if(tex->isCompressed(textarget, level))
|
| 7315 | {
|
| 7316 | return error(GL_INVALID_OPERATION);
|
| 7317 | }
|
| 7318 |
|
| 7319 | switch(textarget)
|
| 7320 | {
|
| 7321 | case GL_TEXTURE_3D_OES:
|
| 7322 | if(tex->getTarget() != GL_TEXTURE_3D_OES)
|
| 7323 | {
|
| 7324 | return error(GL_INVALID_OPERATION);
|
| 7325 | }
|
| 7326 | break;
|
| 7327 | default:
|
| 7328 | return error(GL_INVALID_ENUM);
|
| 7329 | }
|
| 7330 |
|
| 7331 | if(level != 0)
|
| 7332 | {
|
| 7333 | return error(GL_INVALID_VALUE);
|
| 7334 | }
|
| 7335 | }
|
| 7336 |
|
| 7337 | es2::Framebuffer *framebuffer = NULL;
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7338 | GLuint framebufferName = 0;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7339 | if(target == GL_READ_FRAMEBUFFER_ANGLE)
|
| 7340 | {
|
| 7341 | framebuffer = context->getReadFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7342 | framebufferName = context->getReadFramebufferName();
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7343 | }
|
| 7344 | else
|
| 7345 | {
|
| 7346 | framebuffer = context->getDrawFramebuffer();
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7347 | framebufferName = context->getDrawFramebufferName();
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7348 | }
|
| 7349 |
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7350 | if(framebufferName == 0 || !framebuffer)
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7351 | {
|
| 7352 | return error(GL_INVALID_OPERATION);
|
| 7353 | }
|
| 7354 |
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 7355 | egl::GLint clientVersion = context->getClientVersion();
|
| 7356 |
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7357 | switch(attachment)
|
| 7358 | {
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 7359 | case GL_COLOR_ATTACHMENT1:
|
| 7360 | case GL_COLOR_ATTACHMENT2:
|
| 7361 | case GL_COLOR_ATTACHMENT3:
|
| 7362 | case GL_COLOR_ATTACHMENT4:
|
| 7363 | case GL_COLOR_ATTACHMENT5:
|
| 7364 | case GL_COLOR_ATTACHMENT6:
|
| 7365 | case GL_COLOR_ATTACHMENT7:
|
| 7366 | case GL_COLOR_ATTACHMENT8:
|
| 7367 | case GL_COLOR_ATTACHMENT9:
|
| 7368 | case GL_COLOR_ATTACHMENT10:
|
| 7369 | case GL_COLOR_ATTACHMENT11:
|
| 7370 | case GL_COLOR_ATTACHMENT12:
|
| 7371 | case GL_COLOR_ATTACHMENT13:
|
| 7372 | case GL_COLOR_ATTACHMENT14:
|
| 7373 | case GL_COLOR_ATTACHMENT15:
|
Alexis Hetu | 3e02f68 | 2015-12-02 12:53:42 -0500 | [diff] [blame] | 7374 | case GL_COLOR_ATTACHMENT16:
|
| 7375 | case GL_COLOR_ATTACHMENT17:
|
| 7376 | case GL_COLOR_ATTACHMENT18:
|
| 7377 | case GL_COLOR_ATTACHMENT19:
|
| 7378 | case GL_COLOR_ATTACHMENT20:
|
| 7379 | case GL_COLOR_ATTACHMENT21:
|
| 7380 | case GL_COLOR_ATTACHMENT22:
|
| 7381 | case GL_COLOR_ATTACHMENT23:
|
| 7382 | case GL_COLOR_ATTACHMENT24:
|
| 7383 | case GL_COLOR_ATTACHMENT25:
|
| 7384 | case GL_COLOR_ATTACHMENT26:
|
| 7385 | case GL_COLOR_ATTACHMENT27:
|
| 7386 | case GL_COLOR_ATTACHMENT28:
|
| 7387 | case GL_COLOR_ATTACHMENT29:
|
| 7388 | case GL_COLOR_ATTACHMENT30:
|
| 7389 | case GL_COLOR_ATTACHMENT31:
|
Alexis Hetu | 1b2f628 | 2015-04-16 16:27:42 -0400 | [diff] [blame] | 7390 | if(clientVersion < 3)
|
| 7391 | {
|
| 7392 | return error(GL_INVALID_ENUM);
|
| 7393 | }
|
| 7394 | // fall through
|
| 7395 | case GL_COLOR_ATTACHMENT0:
|
| 7396 | if((attachment - GL_COLOR_ATTACHMENT0) >= es2::IMPLEMENTATION_MAX_COLOR_ATTACHMENTS)
|
| 7397 | {
|
| 7398 | return error(GL_INVALID_ENUM);
|
| 7399 | }
|
| 7400 | framebuffer->setColorbuffer(textarget, texture, attachment - GL_COLOR_ATTACHMENT0);
|
| 7401 | break;
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7402 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
|
| 7403 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
|
Alexis Hetu | dcbabfa | 2015-07-13 13:31:05 -0400 | [diff] [blame] | 7404 | default:
|
| 7405 | return error(GL_INVALID_ENUM);
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7406 | }
|
Nicolas Capens | 7cc75e1 | 2015-01-29 14:44:24 -0500 | [diff] [blame] | 7407 | }
|
| 7408 | }
|
Alexis Hetu | b027aa9 | 2015-01-19 15:56:12 -0500 | [diff] [blame] | 7409 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7410 | void EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7411 | {
|
Nicolas Capens | d76b5df | 2014-10-28 15:54:46 -0400 | [diff] [blame] | 7412 | if(egl::getClientVersion() == 1)
|
| 7413 | {
|
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 7414 | return libGLES_CM->glEGLImageTargetTexture2DOES(target, image);
|
Nicolas Capens | d76b5df | 2014-10-28 15:54:46 -0400 | [diff] [blame] | 7415 | }
|
| 7416 |
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 7417 | TRACE("(GLenum target = 0x%X, GLeglImageOES image = %p)", target, image);
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7418 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7419 | switch(target)
|
| 7420 | {
|
| 7421 | case GL_TEXTURE_2D:
|
| 7422 | case GL_TEXTURE_EXTERNAL_OES:
|
| 7423 | break;
|
| 7424 | default:
|
| 7425 | return error(GL_INVALID_ENUM);
|
| 7426 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7427 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7428 | if(!image)
|
| 7429 | {
|
| 7430 | return error(GL_INVALID_OPERATION);
|
| 7431 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7432 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7433 | es2::Context *context = es2::getContext();
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7434 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7435 | if(context)
|
| 7436 | {
|
| 7437 | es2::Texture2D *texture = 0;
|
Nicolas Capens | 08e90f0 | 2014-11-21 12:49:12 -0500 | [diff] [blame] | 7438 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7439 | switch(target)
|
| 7440 | {
|
| 7441 | case GL_TEXTURE_2D: texture = context->getTexture2D(); break;
|
| 7442 | case GL_TEXTURE_EXTERNAL_OES: texture = context->getTextureExternal(); break;
|
Nicolas Capens | 3713cd4 | 2015-06-22 10:41:54 -0400 | [diff] [blame] | 7443 | default: UNREACHABLE(target);
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7444 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7445 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7446 | if(!texture)
|
| 7447 | {
|
| 7448 | return error(GL_INVALID_OPERATION);
|
| 7449 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7450 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7451 | egl::Image *glImage = static_cast<egl::Image*>(image);
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7452 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7453 | texture->setImage(glImage);
|
| 7454 | }
|
Nicolas Capens | e9c5e4f | 2014-05-28 22:46:43 -0400 | [diff] [blame] | 7455 | }
|
| 7456 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7457 | void EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
|
Nicolas Capens | 7e12ac6 | 2014-11-05 17:07:53 -0500 | [diff] [blame] | 7458 | {
|
Nicolas Capens | 4be3370 | 2015-04-28 15:13:30 -0700 | [diff] [blame] | 7459 | TRACE("(GLenum target = 0x%X, GLeglImageOES image = %p)", target, image);
|
Nicolas Capens | 7e12ac6 | 2014-11-05 17:07:53 -0500 | [diff] [blame] | 7460 |
|
| 7461 | UNIMPLEMENTED();
|
| 7462 | }
|
| 7463 |
|
Alexis Hetu | e727775 | 2015-12-04 11:16:35 -0500 | [diff] [blame] | 7464 | GLboolean IsRenderbufferOES(GLuint renderbuffer)
|
| 7465 | {
|
| 7466 | return IsRenderbuffer(renderbuffer);
|
| 7467 | }
|
| 7468 |
|
| 7469 | void BindRenderbufferOES(GLenum target, GLuint renderbuffer)
|
| 7470 | {
|
| 7471 | BindRenderbuffer(target, renderbuffer);
|
| 7472 | }
|
| 7473 |
|
| 7474 | void DeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers)
|
| 7475 | {
|
| 7476 | DeleteRenderbuffers(n, renderbuffers);
|
| 7477 | }
|
| 7478 |
|
| 7479 | void GenRenderbuffersOES(GLsizei n, GLuint* renderbuffers)
|
| 7480 | {
|
| 7481 | GenRenderbuffers(n, renderbuffers);
|
| 7482 | }
|
| 7483 |
|
| 7484 | void RenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
|
| 7485 | {
|
| 7486 | RenderbufferStorage(target, internalformat, width, height);
|
| 7487 | }
|
| 7488 |
|
| 7489 | void GetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params)
|
| 7490 | {
|
| 7491 | GetRenderbufferParameteriv(target, pname, params);
|
| 7492 | }
|
| 7493 |
|
| 7494 | GLboolean IsFramebufferOES(GLuint framebuffer)
|
| 7495 | {
|
| 7496 | return IsFramebuffer(framebuffer);
|
| 7497 | }
|
| 7498 |
|
| 7499 | void BindFramebufferOES(GLenum target, GLuint framebuffer)
|
| 7500 | {
|
| 7501 | BindFramebuffer(target, framebuffer);
|
| 7502 | }
|
| 7503 |
|
| 7504 | void DeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers)
|
| 7505 | {
|
| 7506 | DeleteFramebuffers(n, framebuffers);
|
| 7507 | }
|
| 7508 |
|
| 7509 | void GenFramebuffersOES(GLsizei n, GLuint* framebuffers)
|
| 7510 | {
|
| 7511 | GenFramebuffers(n, framebuffers);
|
| 7512 | }
|
| 7513 |
|
| 7514 | GLenum CheckFramebufferStatusOES(GLenum target)
|
| 7515 | {
|
| 7516 | return CheckFramebufferStatus(target);
|
| 7517 | }
|
| 7518 |
|
| 7519 | void FramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
| 7520 | {
|
| 7521 | FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
|
| 7522 | }
|
| 7523 |
|
| 7524 | void FramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
| 7525 | {
|
| 7526 | FramebufferTexture2D(target, attachment, textarget, texture, level);
|
| 7527 | }
|
| 7528 |
|
| 7529 | void GetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params)
|
| 7530 | {
|
| 7531 | GetFramebufferAttachmentParameteriv(target, attachment, pname, params);
|
| 7532 | }
|
| 7533 |
|
| 7534 | void GenerateMipmapOES(GLenum target)
|
| 7535 | {
|
| 7536 | GenerateMipmap(target);
|
| 7537 | }
|
| 7538 |
|
Nicolas Capens | eb195b6 | 2015-04-28 17:18:42 -0700 | [diff] [blame] | 7539 | }
|
| 7540 |
|
| 7541 | extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname)
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7542 | {
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7543 | struct Extension
|
| 7544 | {
|
| 7545 | const char *name;
|
| 7546 | __eglMustCastToProperFunctionPointerType address;
|
| 7547 | };
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7548 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7549 | static const Extension glExtensions[] =
|
| 7550 | {
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 7551 | #define EXTENSION(name) {#name, (__eglMustCastToProperFunctionPointerType)name}
|
| 7552 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7553 | EXTENSION(glTexImage3DOES),
|
| 7554 | EXTENSION(glBlitFramebufferANGLE),
|
Alexis Hetu | e9233fb | 2015-02-11 10:31:58 -0500 | [diff] [blame] | 7555 | EXTENSION(glBlitFramebufferNV),
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7556 | EXTENSION(glRenderbufferStorageMultisampleANGLE),
|
| 7557 | EXTENSION(glDeleteFencesNV),
|
| 7558 | EXTENSION(glGenFencesNV),
|
| 7559 | EXTENSION(glIsFenceNV),
|
| 7560 | EXTENSION(glTestFenceNV),
|
| 7561 | EXTENSION(glGetFenceivNV),
|
| 7562 | EXTENSION(glFinishFenceNV),
|
| 7563 | EXTENSION(glSetFenceNV),
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 7564 | EXTENSION(glGetGraphicsResetStatusEXT),
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7565 | EXTENSION(glReadnPixelsEXT),
|
| 7566 | EXTENSION(glGetnUniformfvEXT),
|
| 7567 | EXTENSION(glGetnUniformivEXT),
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 7568 | EXTENSION(glGenQueriesEXT),
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7569 | EXTENSION(glDeleteQueriesEXT),
|
| 7570 | EXTENSION(glIsQueryEXT),
|
| 7571 | EXTENSION(glBeginQueryEXT),
|
| 7572 | EXTENSION(glEndQueryEXT),
|
| 7573 | EXTENSION(glGetQueryivEXT),
|
| 7574 | EXTENSION(glGetQueryObjectuivEXT),
|
| 7575 | EXTENSION(glEGLImageTargetTexture2DOES),
|
Nicolas Capens | 7e12ac6 | 2014-11-05 17:07:53 -0500 | [diff] [blame] | 7576 | EXTENSION(glEGLImageTargetRenderbufferStorageOES),
|
Alexis Hetu | e8af6d1 | 2015-04-17 16:58:45 -0400 | [diff] [blame] | 7577 | EXTENSION(glDrawElementsInstancedEXT),
|
| 7578 | EXTENSION(glDrawArraysInstancedEXT),
|
| 7579 | EXTENSION(glVertexAttribDivisorEXT),
|
Nicolas Capens | 0416e5c | 2015-04-28 15:30:28 -0700 | [diff] [blame] | 7580 | EXTENSION(glDrawArraysInstancedANGLE),
|
| 7581 | EXTENSION(glDrawElementsInstancedANGLE),
|
Alexis Hetu | b4d557d | 2015-04-24 17:25:10 -0400 | [diff] [blame] | 7582 | EXTENSION(glVertexAttribDivisorANGLE),
|
Alexis Hetu | e727775 | 2015-12-04 11:16:35 -0500 | [diff] [blame] | 7583 | EXTENSION(glIsRenderbufferOES),
|
| 7584 | EXTENSION(glBindRenderbufferOES),
|
| 7585 | EXTENSION(glDeleteRenderbuffersOES),
|
| 7586 | EXTENSION(glGenRenderbuffersOES),
|
| 7587 | EXTENSION(glRenderbufferStorageOES),
|
| 7588 | EXTENSION(glGetRenderbufferParameterivOES),
|
| 7589 | EXTENSION(glIsFramebufferOES),
|
| 7590 | EXTENSION(glBindFramebufferOES),
|
| 7591 | EXTENSION(glDeleteFramebuffersOES),
|
| 7592 | EXTENSION(glGenFramebuffersOES),
|
| 7593 | EXTENSION(glCheckFramebufferStatusOES),
|
| 7594 | EXTENSION(glFramebufferRenderbufferOES),
|
| 7595 | EXTENSION(glFramebufferTexture2DOES),
|
| 7596 | EXTENSION(glGetFramebufferAttachmentParameterivOES),
|
| 7597 | EXTENSION(glGenerateMipmapOES),
|
Nicolas Capens | f6b6d27 | 2014-11-03 11:11:08 -0500 | [diff] [blame] | 7598 |
|
| 7599 | #undef EXTENSION
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7600 | };
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7601 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7602 | for(int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)
|
| 7603 | {
|
| 7604 | if(strcmp(procname, glExtensions[ext].name) == 0)
|
| 7605 | {
|
| 7606 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
|
| 7607 | }
|
| 7608 | }
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7609 |
|
Nicolas Capens | f160b17 | 2014-11-26 11:58:23 -0500 | [diff] [blame] | 7610 | return NULL;
|
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 7611 | }
|