summaryrefslogtreecommitdiffstats
path: root/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp')
-rw-r--r--Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp1828
1 files changed, 1306 insertions, 522 deletions
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp
index 543c0d2..ee8eca9 100644
--- a/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp
+++ b/Source/ThirdParty/ANGLE/src/libGLESv2/libGLESv2.cpp
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -14,6 +14,7 @@
#include <limits>
#include "common/debug.h"
+#include "common/version.h"
#include "libGLESv2/main.h"
#include "libGLESv2/mathutil.h"
@@ -26,25 +27,126 @@
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/Shader.h"
#include "libGLESv2/Texture.h"
+#include "libGLESv2/Query.h"
-extern "C"
+bool validImageSize(GLint level, GLsizei width, GLsizei height)
{
+ if (level < 0 || width < 0 || height < 0)
+ {
+ return false;
+ }
-void __stdcall glActiveTexture(GLenum texture)
+ if (gl::getContext() && gl::getContext()->supportsNonPower2Texture())
+ {
+ return true;
+ }
+
+ if (level == 0)
+ {
+ return true;
+ }
+
+ if (gl::isPow2(width) && gl::isPow2(height))
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLint level, GLenum format, gl::Texture *texture)
{
- TRACE("(GLenum texture = 0x%X)", texture);
+ if (!texture)
+ {
+ return error(GL_INVALID_OPERATION, false);
+ }
- try
+ if (compressed != texture->isCompressed())
{
- if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + gl::MAX_TEXTURE_IMAGE_UNITS - 1)
+ return error(GL_INVALID_OPERATION, false);
+ }
+
+ if (format != GL_NONE && format != texture->getInternalFormat())
+ {
+ return error(GL_INVALID_OPERATION, false);
+ }
+
+ if (compressed)
+ {
+ if ((width % 4 != 0 && width != texture->getWidth(0)) ||
+ (height % 4 != 0 && height != texture->getHeight(0)))
{
- return error(GL_INVALID_ENUM);
+ return error(GL_INVALID_OPERATION, false);
}
+ }
- gl::Context *context = gl::getContext();
+ if (xoffset + width > texture->getWidth(level) ||
+ yoffset + height > texture->getHeight(level))
+ {
+ return error(GL_INVALID_VALUE, false);
+ }
+
+ return true;
+}
+
+// check for combinations of format and type that are valid for ReadPixels
+bool validReadFormatType(GLenum format, GLenum type)
+{
+ switch (format)
+ {
+ case GL_RGBA:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ break;
+ default:
+ return false;
+ }
+ break;
+ case GL_BGRA_EXT:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
+ break;
+ default:
+ return false;
+ }
+ break;
+ case gl::IMPLEMENTATION_COLOR_READ_FORMAT:
+ switch (type)
+ {
+ case gl::IMPLEMENTATION_COLOR_READ_TYPE:
+ break;
+ default:
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+extern "C"
+{
+
+void __stdcall glActiveTexture(GLenum texture)
+{
+ EVENT("(GLenum texture = 0x%X)", texture);
+
+ try
+ {
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
+ if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
+ {
+ return error(GL_INVALID_ENUM);
+ }
+
context->setActiveSampler(texture - GL_TEXTURE0);
}
}
@@ -56,11 +158,11 @@ void __stdcall glActiveTexture(GLenum texture)
void __stdcall glAttachShader(GLuint program, GLuint shader)
{
- TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
+ EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -103,9 +205,42 @@ void __stdcall glAttachShader(GLuint program, GLuint shader)
}
}
+void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
+{
+ EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
+
+ try
+ {
+ switch (target)
+ {
+ case GL_ANY_SAMPLES_PASSED_EXT:
+ case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
+
+ if (id == 0)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ context->beginQuery(target, id);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
{
- TRACE("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
+ EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
try
{
@@ -114,7 +249,7 @@ void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar*
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -148,11 +283,11 @@ void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar*
void __stdcall glBindBuffer(GLenum target, GLuint buffer)
{
- TRACE("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
+ EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -177,7 +312,7 @@ void __stdcall glBindBuffer(GLenum target, GLuint buffer)
void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
{
- TRACE("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
+ EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
try
{
@@ -186,7 +321,7 @@ void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -209,7 +344,7 @@ void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
{
- TRACE("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
+ EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
try
{
@@ -218,7 +353,7 @@ void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -233,11 +368,11 @@ void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
void __stdcall glBindTexture(GLenum target, GLuint texture)
{
- TRACE("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
+ EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -269,12 +404,12 @@ void __stdcall glBindTexture(GLenum target, GLuint texture)
void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
- TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
+ EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
red, green, blue, alpha);
try
{
- gl::Context* context = gl::getContext();
+ gl::Context* context = gl::getNonLostContext();
if (context)
{
@@ -294,7 +429,7 @@ void __stdcall glBlendEquation(GLenum mode)
void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
{
- TRACE("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
+ EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
try
{
@@ -318,7 +453,7 @@ void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -338,7 +473,7 @@ void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
{
- TRACE("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
+ EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
srcRGB, dstRGB, srcAlpha, dstAlpha);
try
@@ -441,7 +576,7 @@ void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha
return error(GL_INVALID_OPERATION);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -456,7 +591,7 @@ void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha
void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
{
- TRACE("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
+ EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
target, size, data, usage);
try
@@ -476,7 +611,7 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -510,7 +645,7 @@ void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
{
- TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
+ EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
target, offset, size, data);
try
@@ -525,7 +660,7 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -564,7 +699,7 @@ void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
GLenum __stdcall glCheckFramebufferStatus(GLenum target)
{
- TRACE("(GLenum target = 0x%X)", target);
+ EVENT("(GLenum target = 0x%X)", target);
try
{
@@ -573,7 +708,7 @@ GLenum __stdcall glCheckFramebufferStatus(GLenum target)
return error(GL_INVALID_ENUM, 0);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -600,11 +735,11 @@ GLenum __stdcall glCheckFramebufferStatus(GLenum target)
void __stdcall glClear(GLbitfield mask)
{
- TRACE("(GLbitfield mask = %X)", mask);
+ EVENT("(GLbitfield mask = %X)", mask);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -619,12 +754,12 @@ void __stdcall glClear(GLbitfield mask)
void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{
- TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
+ EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
red, green, blue, alpha);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -639,11 +774,11 @@ void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclamp
void __stdcall glClearDepthf(GLclampf depth)
{
- TRACE("(GLclampf depth = %f)", depth);
+ EVENT("(GLclampf depth = %f)", depth);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -658,11 +793,11 @@ void __stdcall glClearDepthf(GLclampf depth)
void __stdcall glClearStencil(GLint s)
{
- TRACE("(GLint s = %d)", s);
+ EVENT("(GLint s = %d)", s);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -677,12 +812,12 @@ void __stdcall glClearStencil(GLint s)
void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
{
- TRACE("(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)",
+ EVENT("(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)",
red, green, blue, alpha);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -697,11 +832,11 @@ void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboo
void __stdcall glCompileShader(GLuint shader)
{
- TRACE("(GLuint shader = %d)", shader);
+ EVENT("(GLuint shader = %d)", shader);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -731,18 +866,13 @@ void __stdcall glCompileShader(GLuint shader)
void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
GLint border, GLsizei imageSize, const GLvoid* data)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
"GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
target, level, internalformat, width, height, border, imageSize, data);
try
{
- if (level < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if (width < 0 || height < 0 || (level > 0 && !gl::isPow2(width)) || (level > 0 && !gl::isPow2(height)) || border != 0 || imageSize < 0)
+ if (!validImageSize(level, width, height) || border != 0 || imageSize < 0)
{
return error(GL_INVALID_VALUE);
}
@@ -751,6 +881,8 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
default:
return error(GL_INVALID_ENUM);
@@ -761,7 +893,7 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -800,9 +932,27 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
return error(GL_INVALID_ENUM);
}
- if (!context->supportsCompressedTextures())
- {
- return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ switch (internalformat) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ if (!context->supportsDXT1Textures())
+ {
+ return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ if (!context->supportsDXT3Textures())
+ {
+ return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
+ if (!context->supportsDXT5Textures())
+ {
+ return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ }
+ break;
+ default: UNREACHABLE();
}
if (imageSize != gl::ComputeCompressedSize(width, height, internalformat))
@@ -819,6 +969,11 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
return error(GL_INVALID_OPERATION);
}
+ if (texture->isImmutable())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
}
else
@@ -830,6 +985,11 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
return error(GL_INVALID_OPERATION);
}
+ if (texture->isImmutable())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
switch (target)
{
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
@@ -855,25 +1015,19 @@ void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum interna
void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLsizei imageSize, const GLvoid* data)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
"GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
"GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
target, level, xoffset, yoffset, width, height, format, imageSize, data);
try
{
- if (!gl::IsTextureTarget(target))
+ if (!gl::IsInternalTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
- if (level < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if (xoffset < 0 || yoffset < 0 || width < 0 || height < 0 ||
- (level > 0 && !gl::isPow2(width)) || (level > 0 && !gl::isPow2(height)) || imageSize < 0)
+ if (xoffset < 0 || yoffset < 0 || !validImageSize(level, width, height) || imageSize < 0)
{
return error(GL_INVALID_VALUE);
}
@@ -882,6 +1036,8 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
default:
return error(GL_INVALID_ENUM);
@@ -892,7 +1048,7 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -901,9 +1057,27 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
return error(GL_INVALID_VALUE);
}
- if (!context->supportsCompressedTextures())
- {
- return error(GL_INVALID_ENUM); // in this case, it's as though the format switch has failed.
+ switch (format) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ if (!context->supportsDXT1Textures())
+ {
+ return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ if (!context->supportsDXT3Textures())
+ {
+ return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
+ if (!context->supportsDXT5Textures())
+ {
+ return error(GL_INVALID_ENUM); // in this case, it's as though the internal format switch failed
+ }
+ break;
+ default: UNREACHABLE();
}
if (imageSize != gl::ComputeCompressedSize(width, height, format))
@@ -914,52 +1088,24 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
if (xoffset % 4 != 0 || yoffset % 4 != 0)
{
return error(GL_INVALID_OPERATION); // we wait to check the offsets until this point, because the multiple-of-four restriction
- // does not exist unless DXT1 textures are supported.
+ // does not exist unless DXT textures are supported.
}
if (target == GL_TEXTURE_2D)
{
gl::Texture2D *texture = context->getTexture2D();
-
- if (!texture)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if (!texture->isCompressed())
+ if (validateSubImageParams(true, width, height, xoffset, yoffset, level, GL_NONE, texture))
{
- return error(GL_INVALID_OPERATION);
+ texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
}
-
- if ((width % 4 != 0 && width != texture->getWidth()) ||
- (height % 4 != 0 && height != texture->getHeight()))
- {
- return error(GL_INVALID_OPERATION);
- }
-
- texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
}
else if (gl::IsCubemapTextureTarget(target))
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
-
- if (!texture)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if (!texture->isCompressed())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if ((width % 4 != 0 && width != texture->getWidth()) ||
- (height % 4 != 0 && height != texture->getHeight()))
+ if (validateSubImageParams(true, width, height, xoffset, yoffset, level, GL_NONE, texture))
{
- return error(GL_INVALID_OPERATION);
+ texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
-
- texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
else
{
@@ -975,18 +1121,13 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
"GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
target, level, internalformat, x, y, width, height, border);
try
{
- if (level < 0 || width < 0 || height < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if (level > 0 && (!gl::isPow2(width) || !gl::isPow2(height)))
+ if (!validImageSize(level, width, height))
{
return error(GL_INVALID_VALUE);
}
@@ -996,10 +1137,15 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
+ if (level > context->getMaximumTextureLevel())
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
switch (target)
{
case GL_TEXTURE_2D:
@@ -1042,8 +1188,8 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
return error(GL_INVALID_OPERATION);
}
- gl::Colorbuffer *source = framebuffer->getColorbuffer();
- GLenum colorbufferFormat = source->getFormat();
+ gl::Renderbuffer *source = framebuffer->getColorbuffer();
+ GLenum colorbufferFormat = source->getInternalFormat();
// [OpenGL ES 2.0.24] table 3.9
switch (internalformat)
@@ -1083,7 +1229,27 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if (context->supportsCompressedTextures())
+ if (context->supportsDXT1Textures())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+ else
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ if (context->supportsDXT3Textures())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+ else
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
+ if (context->supportsDXT5Textures())
{
return error(GL_INVALID_OPERATION);
}
@@ -1105,7 +1271,12 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
return error(GL_INVALID_OPERATION);
}
- texture->copyImage(level, internalformat, x, y, width, height, source);
+ if (texture->isImmutable())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
}
else if (gl::IsCubemapTextureTarget(target))
{
@@ -1116,7 +1287,12 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
return error(GL_INVALID_OPERATION);
}
- texture->copyImage(target, level, internalformat, x, y, width, height, source);
+ if (texture->isImmutable())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
}
else UNREACHABLE();
}
@@ -1129,13 +1305,13 @@ void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalforma
void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
"GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
target, level, xoffset, yoffset, x, y, width, height);
try
{
- if (!gl::IsTextureTarget(target))
+ if (!gl::IsInternalTextureTarget(target))
{
return error(GL_INVALID_ENUM);
}
@@ -1155,7 +1331,7 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1176,8 +1352,8 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
return error(GL_INVALID_OPERATION);
}
- gl::Colorbuffer *source = framebuffer->getColorbuffer();
- GLenum colorbufferFormat = source->getFormat();
+ gl::Renderbuffer *source = framebuffer->getColorbuffer();
+ GLenum colorbufferFormat = source->getInternalFormat();
gl::Texture *texture = NULL;
if (target == GL_TEXTURE_2D)
@@ -1190,12 +1366,12 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
}
else UNREACHABLE();
- if (!texture)
+ if (!validateSubImageParams(false, width, height, xoffset, yoffset, level, GL_NONE, texture))
{
- return error(GL_INVALID_OPERATION);
+ return; // error already registered by validateSubImageParams
}
- GLenum textureFormat = texture->getFormat();
+ GLenum textureFormat = texture->getInternalFormat();
// [OpenGL ES 2.0.24] table 3.9
switch (textureFormat)
@@ -1235,12 +1411,14 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return error(GL_INVALID_OPERATION);
default:
return error(GL_INVALID_OPERATION);
}
- texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, source);
+ texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
}
}
@@ -1252,11 +1430,11 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
GLuint __stdcall glCreateProgram(void)
{
- TRACE("()");
+ EVENT("()");
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1273,11 +1451,11 @@ GLuint __stdcall glCreateProgram(void)
GLuint __stdcall glCreateShader(GLenum type)
{
- TRACE("(GLenum type = 0x%X)", type);
+ EVENT("(GLenum type = 0x%X)", type);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1301,7 +1479,7 @@ GLuint __stdcall glCreateShader(GLenum type)
void __stdcall glCullFace(GLenum mode)
{
- TRACE("(GLenum mode = 0x%X)", mode);
+ EVENT("(GLenum mode = 0x%X)", mode);
try
{
@@ -1311,7 +1489,7 @@ void __stdcall glCullFace(GLenum mode)
case GL_BACK:
case GL_FRONT_AND_BACK:
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1331,7 +1509,7 @@ void __stdcall glCullFace(GLenum mode)
void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
{
- TRACE("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
+ EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
try
{
@@ -1340,7 +1518,7 @@ void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1358,7 +1536,7 @@ void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
{
- TRACE("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
+ EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
try
{
@@ -1367,7 +1545,7 @@ void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1385,7 +1563,7 @@ void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
{
- TRACE("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
+ EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
try
{
@@ -1394,7 +1572,7 @@ void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1415,7 +1593,7 @@ void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
void __stdcall glDeleteProgram(GLuint program)
{
- TRACE("(GLuint program = %d)", program);
+ EVENT("(GLuint program = %d)", program);
try
{
@@ -1424,7 +1602,7 @@ void __stdcall glDeleteProgram(GLuint program)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1449,9 +1627,36 @@ void __stdcall glDeleteProgram(GLuint program)
}
}
+void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
+{
+ EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
+
+ try
+ {
+ if (n < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ for (int i = 0; i < n; i++)
+ {
+ context->deleteQuery(ids[i]);
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
{
- TRACE("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
+ EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
try
{
@@ -1460,7 +1665,7 @@ void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1478,7 +1683,7 @@ void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
void __stdcall glDeleteShader(GLuint shader)
{
- TRACE("(GLuint shader = %d)", shader);
+ EVENT("(GLuint shader = %d)", shader);
try
{
@@ -1487,7 +1692,7 @@ void __stdcall glDeleteShader(GLuint shader)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1514,7 +1719,7 @@ void __stdcall glDeleteShader(GLuint shader)
void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
{
- TRACE("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
+ EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
try
{
@@ -1523,7 +1728,7 @@ void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1544,7 +1749,7 @@ void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
void __stdcall glDepthFunc(GLenum func)
{
- TRACE("(GLenum func = 0x%X)", func);
+ EVENT("(GLenum func = 0x%X)", func);
try
{
@@ -1563,7 +1768,7 @@ void __stdcall glDepthFunc(GLenum func)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1578,11 +1783,11 @@ void __stdcall glDepthFunc(GLenum func)
void __stdcall glDepthMask(GLboolean flag)
{
- TRACE("(GLboolean flag = %d)", flag);
+ EVENT("(GLboolean flag = %d)", flag);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1597,11 +1802,11 @@ void __stdcall glDepthMask(GLboolean flag)
void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
{
- TRACE("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
+ EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1616,11 +1821,11 @@ void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
void __stdcall glDetachShader(GLuint program, GLuint shader)
{
- TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
+ EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1669,11 +1874,11 @@ void __stdcall glDetachShader(GLuint program, GLuint shader)
void __stdcall glDisable(GLenum cap)
{
- TRACE("(GLenum cap = 0x%X)", cap);
+ EVENT("(GLenum cap = 0x%X)", cap);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1701,7 +1906,7 @@ void __stdcall glDisable(GLenum cap)
void __stdcall glDisableVertexAttribArray(GLuint index)
{
- TRACE("(GLuint index = %d)", index);
+ EVENT("(GLuint index = %d)", index);
try
{
@@ -1710,7 +1915,7 @@ void __stdcall glDisableVertexAttribArray(GLuint index)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1725,7 +1930,7 @@ void __stdcall glDisableVertexAttribArray(GLuint index)
void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
- TRACE("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
+ EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
try
{
@@ -1734,11 +1939,38 @@ void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
- context->drawArrays(mode, first, count);
+ context->drawArrays(mode, first, count, 0);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
+{
+ EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
+
+ try
+ {
+ if (count < 0 || first < 0 || primcount < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if (primcount > 0)
+ {
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ context->drawArrays(mode, first, count, primcount);
+ }
}
}
catch(std::bad_alloc&)
@@ -1749,7 +1981,7 @@ void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
{
- TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
+ EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
mode, count, type, indices);
try
@@ -1759,7 +1991,7 @@ void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLv
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1778,7 +2010,50 @@ void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLv
return error(GL_INVALID_ENUM);
}
- context->drawElements(mode, count, type, indices);
+ context->drawElements(mode, count, type, indices, 0);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
+{
+ EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
+ mode, count, type, indices, primcount);
+
+ try
+ {
+ if (count < 0 || primcount < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if (primcount > 0)
+ {
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_SHORT:
+ break;
+ case GL_UNSIGNED_INT:
+ if (!context->supports32bitIndices())
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
+
+ context->drawElements(mode, count, type, indices, primcount);
+ }
}
}
catch(std::bad_alloc&)
@@ -1789,11 +2064,11 @@ void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLv
void __stdcall glEnable(GLenum cap)
{
- TRACE("(GLenum cap = 0x%X)", cap);
+ EVENT("(GLenum cap = 0x%X)", cap);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1821,7 +2096,7 @@ void __stdcall glEnable(GLenum cap)
void __stdcall glEnableVertexAttribArray(GLuint index)
{
- TRACE("(GLuint index = %d)", index);
+ EVENT("(GLuint index = %d)", index);
try
{
@@ -1830,7 +2105,7 @@ void __stdcall glEnableVertexAttribArray(GLuint index)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1843,13 +2118,41 @@ void __stdcall glEnableVertexAttribArray(GLuint index)
}
}
+void __stdcall glEndQueryEXT(GLenum target)
+{
+ EVENT("GLenum target = 0x%X)", target);
+
+ try
+ {
+ switch (target)
+ {
+ case GL_ANY_SAMPLES_PASSED_EXT:
+ case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ context->endQuery(target);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glFinishFenceNV(GLuint fence)
{
- TRACE("(GLuint fence = %d)", fence);
+ EVENT("(GLuint fence = %d)", fence);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1871,15 +2174,15 @@ void __stdcall glFinishFenceNV(GLuint fence)
void __stdcall glFinish(void)
{
- TRACE("()");
+ EVENT("()");
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
- context->finish();
+ context->sync(true);
}
}
catch(std::bad_alloc&)
@@ -1890,15 +2193,15 @@ void __stdcall glFinish(void)
void __stdcall glFlush(void)
{
- TRACE("()");
+ EVENT("()");
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
- context->flush();
+ context->sync(false);
}
}
catch(std::bad_alloc&)
@@ -1909,18 +2212,18 @@ void __stdcall glFlush(void)
void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
{
- TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
"GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
try
{
if ((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
- || renderbuffertarget != GL_RENDERBUFFER)
+ || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
{
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -1931,13 +2234,13 @@ void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenu
framebuffer = context->getReadFramebuffer();
framebufferHandle = context->getReadFramebufferHandle();
}
- else
+ else
{
framebuffer = context->getDrawFramebuffer();
framebufferHandle = context->getDrawFramebufferHandle();
}
- if (framebufferHandle == 0 || !framebuffer)
+ if (!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
{
return error(GL_INVALID_OPERATION);
}
@@ -1966,7 +2269,7 @@ void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenu
void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
{
- TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
"GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
try
@@ -1986,7 +2289,7 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2073,7 +2376,7 @@ void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
void __stdcall glFrontFace(GLenum mode)
{
- TRACE("(GLenum mode = 0x%X)", mode);
+ EVENT("(GLenum mode = 0x%X)", mode);
try
{
@@ -2082,7 +2385,7 @@ void __stdcall glFrontFace(GLenum mode)
case GL_CW:
case GL_CCW:
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2102,7 +2405,7 @@ void __stdcall glFrontFace(GLenum mode)
void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
{
- TRACE("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
+ EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
try
{
@@ -2111,7 +2414,7 @@ void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2129,11 +2432,11 @@ void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
void __stdcall glGenerateMipmap(GLenum target)
{
- TRACE("(GLenum target = 0x%X)", target);
+ EVENT("(GLenum target = 0x%X)", target);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2169,7 +2472,7 @@ void __stdcall glGenerateMipmap(GLenum target)
void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
{
- TRACE("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
+ EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
try
{
@@ -2178,7 +2481,7 @@ void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2196,7 +2499,7 @@ void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
{
- TRACE("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
+ EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
try
{
@@ -2205,7 +2508,7 @@ void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2221,9 +2524,36 @@ void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
}
}
+void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
+{
+ EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
+
+ try
+ {
+ if (n < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ for (int i = 0; i < n; i++)
+ {
+ ids[i] = context->createQuery();
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
{
- TRACE("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
+ EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
try
{
@@ -2232,7 +2562,7 @@ void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2250,7 +2580,7 @@ void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
void __stdcall glGenTextures(GLsizei n, GLuint* textures)
{
- TRACE("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
+ EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
try
{
@@ -2259,7 +2589,7 @@ void __stdcall glGenTextures(GLsizei n, GLuint* textures)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2277,7 +2607,7 @@ void __stdcall glGenTextures(GLsizei n, GLuint* textures)
void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
{
- TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
+ EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
"GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
program, index, bufsize, length, size, type, name);
@@ -2288,7 +2618,7 @@ void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize,
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2322,7 +2652,7 @@ void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize,
void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
{
- TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
+ EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
"GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
program, index, bufsize, length, size, type, name);
@@ -2333,7 +2663,7 @@ void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize,
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2367,7 +2697,7 @@ void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize,
void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
{
- TRACE("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
+ EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
program, maxcount, count, shaders);
try
@@ -2377,7 +2707,7 @@ void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* c
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2406,11 +2736,11 @@ void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* c
int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
{
- TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
+ EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2447,11 +2777,11 @@ int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
{
- TRACE("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
+ EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2510,11 +2840,11 @@ void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
{
- TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2557,7 +2887,7 @@ void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params
GLenum __stdcall glGetError(void)
{
- TRACE("()");
+ EVENT("()");
gl::Context *context = gl::getContext();
@@ -2571,12 +2901,12 @@ GLenum __stdcall glGetError(void)
void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
{
- TRACE("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
+ EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2598,11 +2928,11 @@ void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
{
- TRACE("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
+ EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2658,12 +2988,12 @@ void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
{
- TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
+ EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
target, attachment, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2716,11 +3046,15 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
{
attachmentObjectType = attachmentType;
}
- else if (gl::IsTextureTarget(attachmentType))
+ else if (gl::IsInternalTextureTarget(attachmentType))
{
attachmentObjectType = GL_TEXTURE;
}
- else UNREACHABLE();
+ else
+ {
+ UNREACHABLE();
+ return;
+ }
switch (pname)
{
@@ -2775,9 +3109,9 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
}
}
-void __stdcall glGetIntegerv(GLenum pname, GLint* params)
+GLenum __stdcall glGetGraphicsResetStatusEXT(void)
{
- TRACE("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
+ EVENT("()");
try
{
@@ -2785,6 +3119,27 @@ void __stdcall glGetIntegerv(GLenum pname, GLint* params)
if (context)
{
+ return context->getResetStatus();
+ }
+
+ return GL_NO_ERROR;
+ }
+ catch(std::bad_alloc&)
+ {
+ return GL_OUT_OF_MEMORY;
+ }
+}
+
+void __stdcall glGetIntegerv(GLenum pname, GLint* params)
+{
+ EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
+
+ try
+ {
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
if (!(context->getIntegerv(pname, params)))
{
GLenum nativeType;
@@ -2842,11 +3197,11 @@ void __stdcall glGetIntegerv(GLenum pname, GLint* params)
void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
{
- TRACE("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
+ EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2899,7 +3254,7 @@ void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
{
- TRACE("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
+ EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
program, bufsize, length, infolog);
try
@@ -2909,7 +3264,7 @@ void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* len
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2929,13 +3284,89 @@ void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* len
}
}
+void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
+{
+ EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
+
+ try
+ {
+ switch (pname)
+ {
+ case GL_CURRENT_QUERY_EXT:
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ params[0] = context->getActiveQuery(target);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
+{
+ EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
+
+ try
+ {
+ switch (pname)
+ {
+ case GL_QUERY_RESULT_EXT:
+ case GL_QUERY_RESULT_AVAILABLE_EXT:
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
+
+ if (!queryObject)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ if (context->getActiveQuery(queryObject->getType()) == id)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ switch(pname)
+ {
+ case GL_QUERY_RESULT_EXT:
+ params[0] = queryObject->getResult();
+ break;
+ case GL_QUERY_RESULT_AVAILABLE_EXT:
+ params[0] = queryObject->isResultAvailable();
+ break;
+ default:
+ ASSERT(false);
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
{
- TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -2953,85 +3384,23 @@ void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint*
switch (pname)
{
- case GL_RENDERBUFFER_WIDTH:
- *params = renderbuffer->getWidth();
- break;
- case GL_RENDERBUFFER_HEIGHT:
- *params = renderbuffer->getHeight();
- break;
- case GL_RENDERBUFFER_INTERNAL_FORMAT:
- *params = renderbuffer->getFormat();
- break;
- case GL_RENDERBUFFER_RED_SIZE:
- if (renderbuffer->isColorbuffer())
- {
- *params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getRedSize();
- }
- else
- {
- *params = 0;
- }
- break;
- case GL_RENDERBUFFER_GREEN_SIZE:
- if (renderbuffer->isColorbuffer())
- {
- *params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getGreenSize();
- }
- else
- {
- *params = 0;
- }
- break;
- case GL_RENDERBUFFER_BLUE_SIZE:
- if (renderbuffer->isColorbuffer())
- {
- *params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getBlueSize();
- }
- else
- {
- *params = 0;
- }
- break;
- case GL_RENDERBUFFER_ALPHA_SIZE:
- if (renderbuffer->isColorbuffer())
- {
- *params = static_cast<gl::Colorbuffer*>(renderbuffer->getStorage())->getAlphaSize();
- }
- else
- {
- *params = 0;
- }
- break;
- case GL_RENDERBUFFER_DEPTH_SIZE:
- if (renderbuffer->isDepthbuffer())
- {
- *params = static_cast<gl::Depthbuffer*>(renderbuffer->getStorage())->getDepthSize();
- }
- else
- {
- *params = 0;
- }
- break;
- case GL_RENDERBUFFER_STENCIL_SIZE:
- if (renderbuffer->isStencilbuffer())
+ case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
+ case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
+ case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
+ case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
+ case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
+ case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
+ case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
+ case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
+ case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
+ case GL_RENDERBUFFER_SAMPLES_ANGLE:
+ if (context->getMaxSupportedSamples() != 0)
{
- *params = static_cast<gl::Stencilbuffer*>(renderbuffer->getStorage())->getStencilSize();
+ *params = renderbuffer->getSamples();
}
else
{
- *params = 0;
- }
- break;
- case GL_RENDERBUFFER_SAMPLES_ANGLE:
- {
- if (context->getMaxSupportedSamples() != 0)
- {
- *params = renderbuffer->getStorage()->getSamples();
- }
- else
- {
- return error(GL_INVALID_ENUM);
- }
+ return error(GL_INVALID_ENUM);
}
break;
default:
@@ -3047,11 +3416,11 @@ void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint*
void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
{
- TRACE("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
+ EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3079,6 +3448,9 @@ void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
case GL_SHADER_SOURCE_LENGTH:
*params = shaderObject->getSourceLength();
return;
+ case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
+ *params = shaderObject->getTranslatedSourceLength();
+ return;
default:
return error(GL_INVALID_ENUM);
}
@@ -3092,7 +3464,7 @@ void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
{
- TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
+ EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
shader, bufsize, length, infolog);
try
@@ -3102,7 +3474,7 @@ void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* lengt
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3124,7 +3496,7 @@ void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* lengt
void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
{
- TRACE("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
+ EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
shadertype, precisiontype, range, precision);
try
@@ -3169,7 +3541,7 @@ void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontyp
void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
{
- TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
+ EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
shader, bufsize, length, source);
try
@@ -3179,7 +3551,7 @@ void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3199,24 +3571,56 @@ void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length
}
}
+void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
+{
+ EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
+ shader, bufsize, length, source);
+
+ try
+ {
+ if (bufsize < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ gl::Shader *shaderObject = context->getShader(shader);
+
+ if (!shaderObject)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ shaderObject->getTranslatedSource(bufsize, length, source);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
const GLubyte* __stdcall glGetString(GLenum name)
{
- TRACE("(GLenum name = 0x%X)", name);
+ EVENT("(GLenum name = 0x%X)", name);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
switch (name)
{
case GL_VENDOR:
- return (GLubyte*)"TransGaming Inc.";
+ return (GLubyte*)"Google Inc.";
case GL_RENDERER:
- return (GLubyte*)"ANGLE";
+ return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
case GL_VERSION:
- return (GLubyte*)"OpenGL ES 2.0 (git-devel "__DATE__ " " __TIME__")";
+ return (GLubyte*)"OpenGL ES 2.0 (ANGLE "VERSION_STRING")";
case GL_SHADING_LANGUAGE_VERSION:
- return (GLubyte*)"OpenGL ES GLSL ES 1.00 (git-devel "__DATE__ " " __TIME__")";
+ return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE "VERSION_STRING")";
case GL_EXTENSIONS:
return (GLubyte*)((context != NULL) ? context->getExtensionString() : "");
default:
@@ -3227,17 +3631,15 @@ const GLubyte* __stdcall glGetString(GLenum name)
{
return error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
}
-
- return NULL;
}
void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
{
- TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3269,6 +3671,12 @@ void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
case GL_TEXTURE_WRAP_T:
*params = (GLfloat)texture->getWrapT();
break;
+ case GL_TEXTURE_IMMUTABLE_FORMAT_EXT:
+ *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
+ break;
+ case GL_TEXTURE_USAGE_ANGLE:
+ *params = (GLfloat)texture->getUsage();
+ break;
default:
return error(GL_INVALID_ENUM);
}
@@ -3282,11 +3690,11 @@ void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
{
- TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3318,6 +3726,12 @@ void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
case GL_TEXTURE_WRAP_T:
*params = texture->getWrapT();
break;
+ case GL_TEXTURE_IMMUTABLE_FORMAT_EXT:
+ *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_TEXTURE_USAGE_ANGLE:
+ *params = texture->getUsage();
+ break;
default:
return error(GL_INVALID_ENUM);
}
@@ -3329,13 +3743,93 @@ void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
}
}
+void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
+{
+ EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
+ program, location, bufSize, params);
+
+ try
+ {
+ if (bufSize < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ if (program == 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ if (!programObject->getUniformfv(location, &bufSize, params))
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
{
- TRACE("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
+ EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ if (program == 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ if (!programObject->getUniformfv(location, NULL, params))
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
+{
+ EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
+ program, location, bufSize, params);
+
+ try
+ {
+ if (bufSize < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3351,7 +3845,12 @@ void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
return error(GL_INVALID_OPERATION);
}
- if (!programObject->getUniformfv(location, params))
+ if (!programObject)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ if (!programObject->getUniformiv(location, &bufSize, params))
{
return error(GL_INVALID_OPERATION);
}
@@ -3365,11 +3864,11 @@ void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
{
- TRACE("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
+ EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3390,7 +3889,7 @@ void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
return error(GL_INVALID_OPERATION);
}
- if (!programObject->getUniformiv(location, params))
+ if (!programObject->getUniformiv(location, NULL, params))
{
return error(GL_INVALID_OPERATION);
}
@@ -3404,11 +3903,11 @@ void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
{
- TRACE("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
+ EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (strstr(name, "gl_") == name)
{
@@ -3436,7 +3935,7 @@ int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
return error(GL_INVALID_OPERATION, -1);
}
- return programObject->getUniformLocation(name, false);
+ return programObject->getUniformLocation(name);
}
}
catch(std::bad_alloc&)
@@ -3449,11 +3948,11 @@ int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
{
- TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
+ EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3490,6 +3989,9 @@ void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
params[i] = attribState.mCurrentValue[i];
}
break;
+ case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:
+ *params = (GLfloat)attribState.mDivisor;
+ break;
default: return error(GL_INVALID_ENUM);
}
}
@@ -3502,11 +4004,11 @@ void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
{
- TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
+ EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3544,6 +4046,9 @@ void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
}
break;
+ case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:
+ *params = (GLint)attribState.mDivisor;
+ break;
default: return error(GL_INVALID_ENUM);
}
}
@@ -3556,11 +4061,11 @@ void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
{
- TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
+ EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3585,7 +4090,7 @@ void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** po
void __stdcall glHint(GLenum target, GLenum mode)
{
- TRACE("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
+ EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
try
{
@@ -3599,7 +4104,7 @@ void __stdcall glHint(GLenum target, GLenum mode)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
switch (target)
{
case GL_GENERATE_MIPMAP_HINT:
@@ -3620,11 +4125,11 @@ void __stdcall glHint(GLenum target, GLenum mode)
GLboolean __stdcall glIsBuffer(GLuint buffer)
{
- TRACE("(GLuint buffer = %d)", buffer);
+ EVENT("(GLuint buffer = %d)", buffer);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context && buffer)
{
@@ -3646,11 +4151,11 @@ GLboolean __stdcall glIsBuffer(GLuint buffer)
GLboolean __stdcall glIsEnabled(GLenum cap)
{
- TRACE("(GLenum cap = 0x%X)", cap);
+ EVENT("(GLenum cap = 0x%X)", cap);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3680,11 +4185,11 @@ GLboolean __stdcall glIsEnabled(GLenum cap)
GLboolean __stdcall glIsFenceNV(GLuint fence)
{
- TRACE("(GLuint fence = %d)", fence);
+ EVENT("(GLuint fence = %d)", fence);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3708,11 +4213,11 @@ GLboolean __stdcall glIsFenceNV(GLuint fence)
GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
{
- TRACE("(GLuint framebuffer = %d)", framebuffer);
+ EVENT("(GLuint framebuffer = %d)", framebuffer);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context && framebuffer)
{
@@ -3734,11 +4239,11 @@ GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
GLboolean __stdcall glIsProgram(GLuint program)
{
- TRACE("(GLuint program = %d)", program);
+ EVENT("(GLuint program = %d)", program);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context && program)
{
@@ -3758,13 +4263,44 @@ GLboolean __stdcall glIsProgram(GLuint program)
return GL_FALSE;
}
+GLboolean __stdcall glIsQueryEXT(GLuint id)
+{
+ EVENT("(GLuint id = %d)", id);
+
+ try
+ {
+ if (id == 0)
+ {
+ return GL_FALSE;
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
+
+ if (queryObject)
+ {
+ return GL_TRUE;
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY, GL_FALSE);
+ }
+
+ return GL_FALSE;
+}
+
GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
{
- TRACE("(GLuint renderbuffer = %d)", renderbuffer);
+ EVENT("(GLuint renderbuffer = %d)", renderbuffer);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context && renderbuffer)
{
@@ -3786,11 +4322,11 @@ GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
GLboolean __stdcall glIsShader(GLuint shader)
{
- TRACE("(GLuint shader = %d)", shader);
+ EVENT("(GLuint shader = %d)", shader);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context && shader)
{
@@ -3812,11 +4348,11 @@ GLboolean __stdcall glIsShader(GLuint shader)
GLboolean __stdcall glIsTexture(GLuint texture)
{
- TRACE("(GLuint texture = %d)", texture);
+ EVENT("(GLuint texture = %d)", texture);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context && texture)
{
@@ -3838,7 +4374,7 @@ GLboolean __stdcall glIsTexture(GLuint texture)
void __stdcall glLineWidth(GLfloat width)
{
- TRACE("(GLfloat width = %f)", width);
+ EVENT("(GLfloat width = %f)", width);
try
{
@@ -3847,7 +4383,7 @@ void __stdcall glLineWidth(GLfloat width)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3862,11 +4398,11 @@ void __stdcall glLineWidth(GLfloat width)
void __stdcall glLinkProgram(GLuint program)
{
- TRACE("(GLuint program = %d)", program);
+ EVENT("(GLuint program = %d)", program);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3895,11 +4431,11 @@ void __stdcall glLinkProgram(GLuint program)
void __stdcall glPixelStorei(GLenum pname, GLint param)
{
- TRACE("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
+ EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3923,6 +4459,10 @@ void __stdcall glPixelStorei(GLenum pname, GLint param)
context->setPackAlignment(param);
break;
+ case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
+ context->setPackReverseRowOrder(param != 0);
+ break;
+
default:
return error(GL_INVALID_ENUM);
}
@@ -3936,11 +4476,11 @@ void __stdcall glPixelStorei(GLenum pname, GLint param)
void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
{
- TRACE("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
+ EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -3953,9 +4493,43 @@ void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
}
}
-void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLsizei bufSize,
+ GLvoid *data)
+{
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
+ "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
+ x, y, width, height, format, type, bufSize, data);
+
+ try
+ {
+ if (width < 0 || height < 0 || bufSize < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if (!validReadFormatType(format, type))
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ context->readPixels(x, y, width, height, format, type, &bufSize, data);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid* pixels)
{
- TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
"GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
x, y, width, height, format, type, pixels);
@@ -3966,46 +4540,16 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLe
return error(GL_INVALID_VALUE);
}
- switch (format)
+ if (!validReadFormatType(format, type))
{
- case GL_RGBA:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- break;
- default:
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_BGRA_EXT:
- switch (type)
- {
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
- break;
- default:
- return error(GL_INVALID_OPERATION);
- }
- break;
- case gl::IMPLEMENTATION_COLOR_READ_FORMAT:
- switch (type)
- {
- case gl::IMPLEMENTATION_COLOR_READ_TYPE:
- break;
- default:
- return error(GL_INVALID_OPERATION);
- }
- break;
- default:
return error(GL_INVALID_OPERATION);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
- context->readPixels(x, y, width, height, format, type, pixels);
+ context->readPixels(x, y, width, height, format, type, NULL, pixels);
}
}
catch(std::bad_alloc&)
@@ -4016,7 +4560,7 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLe
void __stdcall glReleaseShaderCompiler(void)
{
- TRACE("()");
+ EVENT("()");
try
{
@@ -4030,7 +4574,7 @@ void __stdcall glReleaseShaderCompiler(void)
void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
{
- TRACE("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
target, samples, internalformat, width, height);
try
@@ -4053,7 +4597,7 @@ void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samp
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4106,11 +4650,11 @@ void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsiz
void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
{
- TRACE("(GLclampf value = %f, GLboolean invert = %d)", value, invert);
+ EVENT("(GLclampf value = %f, GLboolean invert = %d)", value, invert);
try
{
- gl::Context* context = gl::getContext();
+ gl::Context* context = gl::getNonLostContext();
if (context)
{
@@ -4125,7 +4669,7 @@ void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
{
- TRACE("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
+ EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
try
{
@@ -4134,7 +4678,7 @@ void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4156,7 +4700,7 @@ void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
{
- TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
try
{
@@ -4165,7 +4709,7 @@ void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
return error(GL_INVALID_VALUE);
}
- gl::Context* context = gl::getContext();
+ gl::Context* context = gl::getNonLostContext();
if (context)
{
@@ -4180,7 +4724,7 @@ void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
{
- TRACE("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
+ EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
"const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
n, shaders, binaryformat, binary, length);
@@ -4197,7 +4741,7 @@ void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryfor
void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
{
- TRACE("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
+ EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
shader, count, string, length);
try
@@ -4207,7 +4751,7 @@ void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar** strin
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4241,7 +4785,7 @@ void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
{
- TRACE("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
+ EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
try
{
@@ -4270,7 +4814,7 @@ void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4298,7 +4842,7 @@ void __stdcall glStencilMask(GLuint mask)
void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
{
- TRACE("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
+ EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
try
{
@@ -4312,7 +4856,7 @@ void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4340,7 +4884,7 @@ void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
{
- TRACE("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
+ EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
face, fail, zfail, zpass);
try
@@ -4400,7 +4944,7 @@ void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu
return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4423,11 +4967,11 @@ void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenu
GLboolean __stdcall glTestFenceNV(GLuint fence)
{
- TRACE("(GLuint fence = %d)", fence);
+ EVENT("(GLuint fence = %d)", fence);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4452,28 +4996,23 @@ GLboolean __stdcall glTestFenceNV(GLuint fence)
void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type, const GLvoid* pixels)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
"GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
target, level, internalformat, width, height, border, format, type, pixels);
try
{
- if (level < 0 || width < 0 || height < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if (level > 0 && (!gl::isPow2(width) || !gl::isPow2(height)))
+ if (!validImageSize(level, width, height))
{
return error(GL_INVALID_VALUE);
}
- if (internalformat != format)
+ if (internalformat != GLint(format))
{
return error(GL_INVALID_OPERATION);
}
- switch (internalformat)
+ switch (format)
{
case GL_ALPHA:
case GL_LUMINANCE:
@@ -4524,6 +5063,8 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
default:
return error(GL_INVALID_VALUE);
@@ -4534,10 +5075,15 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
+ if (level > context->getMaximumTextureLevel())
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
switch (target)
{
case GL_TEXTURE_2D:
@@ -4568,10 +5114,30 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
return error(GL_INVALID_ENUM);
}
- if (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
- internalformat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
- {
- if (context->supportsCompressedTextures())
+ switch (format) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ if (context->supportsDXT1Textures())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+ else
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ if (context->supportsDXT3Textures())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+ else
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
+ if (context->supportsDXT5Textures())
{
return error(GL_INVALID_OPERATION);
}
@@ -4579,18 +5145,21 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
{
return error(GL_INVALID_ENUM);
}
+ break;
+ default:
+ break;
}
if (type == GL_FLOAT)
{
- if (!context->supportsFloatTextures())
+ if (!context->supportsFloat32Textures())
{
return error(GL_INVALID_ENUM);
}
}
else if (type == GL_HALF_FLOAT_OES)
{
- if (!context->supportsHalfFloatTextures())
+ if (!context->supportsFloat16Textures())
{
return error(GL_INVALID_ENUM);
}
@@ -4605,7 +5174,12 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
return error(GL_INVALID_OPERATION);
}
- texture->setImage(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ if (texture->isImmutable())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ texture->setImage(level, width, height, format, type, context->getUnpackAlignment(), pixels);
}
else
{
@@ -4616,25 +5190,30 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
return error(GL_INVALID_OPERATION);
}
+ if (texture->isImmutable())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
switch (target)
{
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- texture->setImagePosX(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImagePosX(level, width, height, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- texture->setImageNegX(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImageNegX(level, width, height, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- texture->setImagePosY(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImagePosY(level, width, height, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- texture->setImageNegY(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImageNegY(level, width, height, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- texture->setImagePosZ(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImagePosZ(level, width, height, format, type, context->getUnpackAlignment(), pixels);
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- texture->setImageNegZ(level, internalformat, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->setImageNegZ(level, width, height, format, type, context->getUnpackAlignment(), pixels);
break;
default: UNREACHABLE();
}
@@ -4659,11 +5238,11 @@ void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* para
void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
{
- TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
+ EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4707,6 +5286,12 @@ void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
return error(GL_INVALID_ENUM);
}
break;
+ case GL_TEXTURE_USAGE_ANGLE:
+ if (!texture->setUsage((GLenum)param))
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
default:
return error(GL_INVALID_ENUM);
}
@@ -4723,106 +5308,231 @@ void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params
glTexParameteri(target, pname, *params);
}
-void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid* pixels)
+void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
- "const GLvoid* pixels = 0x%0.8p)",
- target, level, xoffset, yoffset, width, height, format, type, pixels);
+ EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, levels, internalformat, width, height);
try
{
- if (!gl::IsTextureTarget(target))
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_CUBE_MAP)
{
return error(GL_INVALID_ENUM);
}
- if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
+ if (width < 1 || height < 1 || levels < 1)
{
return error(GL_INVALID_VALUE);
}
- if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
+ if (target == GL_TEXTURE_CUBE_MAP && width != height)
{
return error(GL_INVALID_VALUE);
}
- if (!gl::CheckTextureFormatType(format, type))
+ if (levels != 1 && levels != gl::log2(std::max(width, height)) + 1)
{
- return error(GL_INVALID_ENUM);
+ return error(GL_INVALID_OPERATION);
}
- if (width == 0 || height == 0 || pixels == NULL)
+ GLenum format = gl::ExtractFormat(internalformat);
+ GLenum type = gl::ExtractType(internalformat);
+
+ if (format == GL_NONE || type == GL_NONE)
{
- return;
+ return error(GL_INVALID_ENUM);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (level > context->getMaximumTextureLevel())
+ switch (target)
{
- return error(GL_INVALID_VALUE);
+ case GL_TEXTURE_2D:
+ if (width > context->getMaximumTextureDimension() ||
+ height > context->getMaximumTextureDimension())
+ {
+ return error(GL_INVALID_VALUE);
+ }
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ if (width > context->getMaximumCubeTextureDimension() ||
+ height > context->getMaximumCubeTextureDimension())
+ {
+ return error(GL_INVALID_VALUE);
+ }
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
}
- if (format == GL_FLOAT)
+ if (levels != 1 && !context->supportsNonPower2Texture())
{
- if (!context->supportsFloatTextures())
+ if (!gl::isPow2(width) || !gl::isPow2(height))
{
- return error(GL_INVALID_ENUM);
+ return error(GL_INVALID_OPERATION);
}
}
- else if (format == GL_HALF_FLOAT_OES)
+
+ switch (internalformat)
{
- if (!context->supportsHalfFloatTextures())
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ if (!context->supportsDXT1Textures())
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
+ if (!context->supportsDXT3Textures())
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
+ if (!context->supportsDXT5Textures())
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_RGBA32F_EXT:
+ case GL_RGB32F_EXT:
+ case GL_ALPHA32F_EXT:
+ case GL_LUMINANCE32F_EXT:
+ case GL_LUMINANCE_ALPHA32F_EXT:
+ if (!context->supportsFloat32Textures())
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ break;
+ case GL_RGBA16F_EXT:
+ case GL_RGB16F_EXT:
+ case GL_ALPHA16F_EXT:
+ case GL_LUMINANCE16F_EXT:
+ case GL_LUMINANCE_ALPHA16F_EXT:
+ if (!context->supportsFloat16Textures())
{
return error(GL_INVALID_ENUM);
}
+ break;
}
if (target == GL_TEXTURE_2D)
{
gl::Texture2D *texture = context->getTexture2D();
- if (!texture)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if (texture->isCompressed())
+ if (!texture || texture->id() == 0)
{
return error(GL_INVALID_OPERATION);
}
- if (format != texture->getFormat())
+ if (texture->isImmutable())
{
return error(GL_INVALID_OPERATION);
}
- texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
+ texture->storage(levels, internalformat, width, height);
}
- else if (gl::IsCubemapTextureTarget(target))
+ else if (target == GL_TEXTURE_CUBE_MAP)
{
gl::TextureCubeMap *texture = context->getTextureCubeMap();
- if (!texture)
+ if (!texture || texture->id() == 0)
{
return error(GL_INVALID_OPERATION);
}
- if (texture->isCompressed())
+ if (texture->isImmutable())
{
return error(GL_INVALID_OPERATION);
}
- if (format != texture->getFormat())
+ texture->storage(levels, internalformat, width);
+ }
+ else UNREACHABLE();
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid* pixels)
+{
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
+ "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
+ "const GLvoid* pixels = 0x%0.8p)",
+ target, level, xoffset, yoffset, width, height, format, type, pixels);
+
+ try
+ {
+ if (!gl::IsInternalTextureTarget(target))
+ {
+ return error(GL_INVALID_ENUM);
+ }
+
+ if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if (std::numeric_limits<GLsizei>::max() - xoffset < width || std::numeric_limits<GLsizei>::max() - yoffset < height)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if (!gl::CheckTextureFormatType(format, type))
+ {
+ return error(GL_INVALID_ENUM);
+ }
+
+ if (width == 0 || height == 0 || pixels == NULL)
+ {
+ return;
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ if (level > context->getMaximumTextureLevel())
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if (format == GL_FLOAT)
+ {
+ if (!context->supportsFloat32Textures())
{
- return error(GL_INVALID_OPERATION);
+ return error(GL_INVALID_ENUM);
}
+ }
+ else if (format == GL_HALF_FLOAT_OES)
+ {
+ if (!context->supportsFloat16Textures())
+ {
+ return error(GL_INVALID_ENUM);
+ }
+ }
- texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
+ if (target == GL_TEXTURE_2D)
+ {
+ gl::Texture2D *texture = context->getTexture2D();
+ if (validateSubImageParams(false, width, height, xoffset, yoffset, level, format, texture))
+ {
+ texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
+ }
+ }
+ else if (gl::IsCubemapTextureTarget(target))
+ {
+ gl::TextureCubeMap *texture = context->getTextureCubeMap();
+ if (validateSubImageParams(false, width, height, xoffset, yoffset, level, format, texture))
+ {
+ texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
+ }
}
else
{
@@ -4843,7 +5553,7 @@ void __stdcall glUniform1f(GLint location, GLfloat x)
void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
try
{
@@ -4857,7 +5567,7 @@ void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4887,7 +5597,7 @@ void __stdcall glUniform1i(GLint location, GLint x)
void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
try
{
@@ -4901,7 +5611,7 @@ void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4933,7 +5643,7 @@ void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
try
{
@@ -4947,7 +5657,7 @@ void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -4979,7 +5689,7 @@ void __stdcall glUniform2i(GLint location, GLint x, GLint y)
void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
try
{
@@ -4993,7 +5703,7 @@ void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5025,7 +5735,7 @@ void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
try
{
@@ -5039,7 +5749,7 @@ void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5071,7 +5781,7 @@ void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
try
{
@@ -5085,7 +5795,7 @@ void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5117,7 +5827,7 @@ void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfl
void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
try
{
@@ -5131,7 +5841,7 @@ void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5163,7 +5873,7 @@ void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
+ EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
try
{
@@ -5177,7 +5887,7 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5202,7 +5912,7 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
location, count, transpose, value);
try
@@ -5217,7 +5927,7 @@ void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean trans
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5242,7 +5952,7 @@ void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean trans
void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
location, count, transpose, value);
try
@@ -5257,7 +5967,7 @@ void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean trans
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5282,7 +5992,7 @@ void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean trans
void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
- TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
+ EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
location, count, transpose, value);
try
@@ -5297,7 +6007,7 @@ void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean trans
return;
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5322,11 +6032,11 @@ void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean trans
void __stdcall glUseProgram(GLuint program)
{
- TRACE("(GLuint program = %d)", program);
+ EVENT("(GLuint program = %d)", program);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5360,11 +6070,11 @@ void __stdcall glUseProgram(GLuint program)
void __stdcall glValidateProgram(GLuint program)
{
- TRACE("(GLuint program = %d)", program);
+ EVENT("(GLuint program = %d)", program);
try
{
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5393,7 +6103,7 @@ void __stdcall glValidateProgram(GLuint program)
void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
{
- TRACE("(GLuint index = %d, GLfloat x = %f)", index, x);
+ EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
try
{
@@ -5402,7 +6112,7 @@ void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5418,7 +6128,7 @@ void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
try
{
@@ -5427,7 +6137,7 @@ void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5443,7 +6153,7 @@ void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
{
- TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
+ EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
try
{
@@ -5452,7 +6162,7 @@ void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5468,7 +6178,7 @@ void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
try
{
@@ -5477,7 +6187,7 @@ void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5493,7 +6203,7 @@ void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
{
- TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
+ EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
try
{
@@ -5502,7 +6212,7 @@ void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5518,7 +6228,7 @@ void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
try
{
@@ -5527,7 +6237,7 @@ void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5543,7 +6253,7 @@ void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
- TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
+ EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
try
{
@@ -5552,7 +6262,7 @@ void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, G
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5568,7 +6278,7 @@ void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, G
void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
+ EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
try
{
@@ -5577,7 +6287,7 @@ void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5590,9 +6300,33 @@ void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
}
}
+void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
+{
+ EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
+
+ try
+ {
+ if (index >= gl::MAX_VERTEX_ATTRIBS)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ context->setVertexAttribDivisor(index, divisor);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
{
- TRACE("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
+ EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
"GLboolean normalized = %d, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
index, size, type, normalized, stride, ptr);
@@ -5626,7 +6360,7 @@ void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5641,7 +6375,7 @@ void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLbo
void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
- TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
+ EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
try
{
@@ -5650,7 +6384,7 @@ void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
return error(GL_INVALID_VALUE);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5666,7 +6400,7 @@ void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
{
- TRACE("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
+ EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
"GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
"GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
@@ -5692,7 +6426,7 @@ void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLi
return error(GL_INVALID_OPERATION);
}
- gl::Context *context = gl::getContext();
+ gl::Context *context = gl::getNonLostContext();
if (context)
{
@@ -5714,7 +6448,7 @@ void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLi
void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type, const GLvoid* pixels)
{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
+ EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
"GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
"GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
target, level, internalformat, width, height, depth, border, format, type, pixels);
@@ -5749,6 +6483,22 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *
{"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
{"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
{"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
+ {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
+ {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
+ {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
+ {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
+ {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
+ {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
+ {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
+ {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
+ {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
+ {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
+ {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
+ {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
+ {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
+ {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
+ {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
+ {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
};
for (int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)
@@ -5762,4 +6512,38 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *
return NULL;
}
+// Non-public functions used by EGL
+
+bool __stdcall glBindTexImage(egl::Surface *surface)
+{
+ EVENT("(egl::Surface* surface = 0x%0.8p)",
+ surface);
+
+ try
+ {
+ gl::Context *context = gl::getNonLostContext();
+
+ if (context)
+ {
+ gl::Texture2D *textureObject = context->getTexture2D();
+
+ if (textureObject->isImmutable())
+ {
+ return false;
+ }
+
+ if (textureObject)
+ {
+ textureObject->bindTexImage(surface);
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY, false);
+ }
+
+ return true;
+}
+
}