Browse Source

Abort the application on attempt to use any ES extension function.

We don't have extension loader for ES yet, thus we need to abort on
these to avoid undefined behavior. The only exception is NaCl, which
provides _some_ extensions without the need for extension loader. These
extensions are implemented in particular:

    CHROMIUM_map_sub
    EXT_occlusion_query_boolean
pull/51/head
Vladimír Vondruš 13 years ago
parent
commit
8c0257e6e8
  1. 35
      src/AbstractFramebuffer.cpp
  2. 9
      src/AbstractObject.cpp
  3. 26
      src/AbstractTexture.cpp
  4. 22
      src/Buffer.cpp
  5. 39
      src/Context.cpp
  6. 2
      src/DebugMessage.cpp
  7. 4
      src/Framebuffer.cpp
  8. 15
      src/Mesh.cpp
  9. 46
      src/Query.cpp
  10. 2
      src/Renderbuffer.cpp
  11. 4
      src/Renderer.cpp

35
src/AbstractFramebuffer.cpp

@ -142,7 +142,7 @@ FramebufferTarget AbstractFramebuffer::bindInternal() {
void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter) {
source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw);
/** @todo Get some extension wrangler instead to avoid undeclared glBlitFramebuffer() on ES2 */
/** @todo Re-enable when extension loader is available for ES, add also ANGLE version */
#ifndef MAGNUM_TARGET_GLES2
glBlitFramebuffer(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
@ -150,6 +150,8 @@ void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer&
static_cast<void>(destinationRectangle);
static_cast<void>(mask);
static_cast<void>(filter);
//glBlitFramebufferNV(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
CORRADE_INTERNAL_ASSERT(false);
#endif
}
@ -217,25 +219,27 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf
#endif
void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments) {
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments);
#else
//glDiscardFramebufferEXT(GLenum(bindInternal()), count, attachments);
static_cast<void>(count);
static_cast<void>(attachments);
CORRADE_INTERNAL_ASSERT(false);
//glDiscardFramebufferEXT(GLenum(bindInternal()), count, attachments);
#endif
}
void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle) {
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY());
#else
//glDiscardSubFramebufferEXT(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.width(), rectangle.height());
static_cast<void>(count);
static_cast<void>(attachments);
static_cast<void>(rectangle);
CORRADE_INTERNAL_ASSERT(false);
//glDiscardSubFramebufferEXT(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.width(), rectangle.height());
#endif
}
@ -286,13 +290,10 @@ void AbstractFramebuffer::initializeContextBasedFunctionality(Context& context)
#ifndef MAGNUM_TARGET_GLES
Debug() << "AbstractFramebuffer: using" << Extensions::GL::ARB::robustness::string() << "features";
#else
//Debug() << "AbstractFramebuffer: using" << Extensions::GL::EXT::robustness::string() << "features";
Debug() << "AbstractFramebuffer: using" << Extensions::GL::EXT::robustness::string() << "features";
#endif
/** @todo Enable when extension wrangler for ES is available */
#ifndef MAGNUM_TARGET_GLES
readImplementation = &AbstractFramebuffer::readImplementationRobustness;
#endif
}
}
@ -308,7 +309,7 @@ GLenum AbstractFramebuffer::checkStatusImplementationDSA(const FramebufferTarget
#endif
void AbstractFramebuffer::drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers) {
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Draw);
@ -329,7 +330,7 @@ void AbstractFramebuffer::drawBuffersImplementationDSA(GLsizei count, const GLen
#endif
void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) {
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Draw);
@ -343,6 +344,8 @@ void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) {
#endif
#else
static_cast<void>(buffer);
CORRADE_INTERNAL_ASSERT(false);
//glDrawBuffersNV(1, &buffer);
#endif
}
@ -353,7 +356,7 @@ void AbstractFramebuffer::drawBufferImplementationDSA(GLenum buffer) {
#endif
void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) {
/** @todo Get some extension wrangler instead to avoid undeclared glReadBuffer() on ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Read);
@ -363,6 +366,8 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) {
glReadBuffer(buffer);
#else
static_cast<void>(buffer);
CORRADE_INTERNAL_ASSERT(false);
//glReadBufferNV(buffer);
#endif
}
@ -377,18 +382,18 @@ void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, cons
}
void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
/** @todo Enable when extension wrangler for ES is available */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), dataSize, data);
#else
CORRADE_INTERNAL_ASSERT(false);
//glReadnPixelsEXT(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
static_cast<void>(offset);
static_cast<void>(size);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(dataSize);
static_cast<void>(data);
CORRADE_INTERNAL_ASSERT(false);
//glReadnPixelsEXT(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
#endif
}

9
src/AbstractObject.cpp

@ -118,6 +118,7 @@ Int AbstractObject::maxLabelLength() {
void AbstractObject::labelImplementationNoOp(GLenum, GLuint, const std::string&) {}
void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const std::string& label) {
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glObjectLabel(identifier, name, label.size(), label.data());
#else
@ -131,7 +132,7 @@ void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuin
void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const std::string& label) {
const GLenum type = extTypeFromKhrIdentifier(identifier);
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glLabelObjectEXT(type, name, label.size(), label.data());
#else
@ -174,7 +175,7 @@ std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, c
GLsizei size;
std::string label;
label.resize(maxLabelLength());
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glGetObjectLabel(identifier, name, label.size(), &size, &label[0]);
#else
@ -192,7 +193,7 @@ std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, c
/* Get label size (w/o null terminator) */
GLsizei size;
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glGetObjectLabelEXT(type, name, 0, &size, nullptr);
#else
@ -204,7 +205,7 @@ std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, c
/* Make place also for the null terminator */
std::string label;
label.resize(size+1);
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glGetObjectLabelEXT(identifier, name, size+1, nullptr, &label[0]);
#endif

26
src/AbstractTexture.cpp

@ -714,15 +714,16 @@ void AbstractTexture::storageImplementationFallback(const GLenum target, const G
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glTexStorage1D(target, levels, GLenum(internalFormat), size[0]);
#else
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
static_cast<void>(target);
static_cast<void>(levels);
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_INTERNAL_ASSERT(false);
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
#endif
}
@ -772,15 +773,16 @@ void AbstractTexture::storageImplementationFallback(const GLenum target, const G
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glTexStorage2D(target, levels, GLenum(internalFormat), size.x(), size.y());
#else
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
static_cast<void>(target);
static_cast<void>(levels);
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_INTERNAL_ASSERT(false);
//glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
#endif
}
@ -825,15 +827,16 @@ void AbstractTexture::storageImplementationFallback(GLenum target, GLsizei level
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
bindInternal();
/** @todo Re-enable when extension wrangler is available for ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glTexStorage3D(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
#else
//glTexStorage3DEXT(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
static_cast<void>(target);
static_cast<void>(levels);
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_INTERNAL_ASSERT(false);
//glTexStorage3DEXT(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
#endif
}
@ -854,17 +857,18 @@ void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint
}
void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
bindInternal();
glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data);
#else
CORRADE_INTERNAL_ASSERT(false);
static_cast<void>(target);
static_cast<void>(level);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(dataSize);
static_cast<void>(data);
CORRADE_INTERNAL_ASSERT(false);
#endif
}
#endif
@ -893,7 +897,7 @@ void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, Texture
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glTexImage3D(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
#else
@ -904,6 +908,8 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(data);
CORRADE_INTERNAL_ASSERT(false);
//glTexImage3DOES(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
#endif
}
@ -937,7 +943,7 @@ void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, cons
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
/** @todo Get some extension wrangler instead to avoid linker errors to glTexSubImage3D() on ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
#else
@ -948,6 +954,8 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(data);
CORRADE_INTERNAL_ASSERT(false);
//glTexSubImage3DOES(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
#endif
}

22
src/Buffer.cpp

@ -219,7 +219,7 @@ Int Buffer::size() {
#ifdef MAGNUM_TARGET_GLES2
void* Buffer::mapSub(const GLintptr offset, const GLsizeiptr length, const MapAccess access) {
/** @todo Enable also in Emscripten (?) when extension wrangler is available */
/** @todo Enable also in Emscripten (?) when extension loader is available */
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(!_mappedBuffer, "Buffer::mapSub(): the buffer is already mapped", nullptr);
return _mappedBuffer = glMapBufferSubDataCHROMIUM(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access));
@ -232,6 +232,7 @@ void* Buffer::mapSub(const GLintptr offset, const GLsizeiptr length, const MapAc
}
void Buffer::unmapSub() {
/** @todo Enable also in Emscripten (?) when extension loader is available */
#ifdef CORRADE_TARGET_NACL
CORRADE_ASSERT(_mappedBuffer, "Buffer::unmapSub(): the buffer is not mapped", );
glUnmapBufferSubDataCHROMIUM(_mappedBuffer);
@ -311,12 +312,13 @@ void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length)
#endif
void* Buffer::mapImplementationDefault(MapAccess access) {
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
return glMapBuffer(GLenum(bindInternal(_targetHint)), GLenum(access));
#else
static_cast<void>(access);
return nullptr;
CORRADE_INTERNAL_ASSERT(false);
//return glMapBufferOES(GLenum(bindInternal(_targetHint)), GLenum(access));
#endif
}
@ -327,14 +329,15 @@ void* Buffer::mapImplementationDSA(MapAccess access) {
#endif
void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) {
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
return glMapBufferRange(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access));
#else
static_cast<void>(offset);
static_cast<void>(length);
static_cast<void>(access);
return nullptr;
CORRADE_INTERNAL_ASSERT(false);
//return glMapBufferRangeEXT(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access));
#endif
}
@ -345,12 +348,14 @@ void* Buffer::mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapF
#endif
void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) {
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glFlushMappedBufferRange(GLenum(bindInternal(_targetHint)), offset, length);
#else
static_cast<void>(offset);
static_cast<void>(length);
CORRADE_INTERNAL_ASSERT(false);
//glFlushMappedBufferRangeEXT(GLenum(bindInternal(_targetHint)), offset, length);
#endif
}
@ -361,11 +366,12 @@ void Buffer::flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr lengt
#endif
bool Buffer::unmapImplementationDefault() {
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
return glUnmapBuffer(GLenum(bindInternal(_targetHint)));
#else
return false;
CORRADE_INTERNAL_ASSERT(false);
//return glUnmapBufferOES(GLenum(bindInternal(_targetHint)));
#endif
}

39
src/Context.cpp

@ -415,6 +415,45 @@ Context::Context() {
}
#endif
/* Disable extensions for which we need extension loader, as they would
crash otherwise. */
/** @todo Remove this when extension loader for ES is available */
#ifdef MAGNUM_TARGET_GLES
#define _disable(prefix, vendor, extension) \
extensionStatus.reset(Extensions::prefix::vendor::extension::Index);
#ifndef CORRADE_TARGET_NACL
_disable(GL,CHROMIUM,map_sub)
#endif
_disable(GL,EXT,debug_label)
_disable(GL,EXT,debug_marker)
_disable(GL,EXT,disjoint_timer_query)
_disable(GL,EXT,separate_shader_objects)
_disable(GL,EXT,multisampled_render_to_texture)
_disable(GL,EXT,robustness)
_disable(GL,KHR,debug)
_disable(GL,NV,read_buffer_front)
_disable(GL,OES,mapbuffer)
_disable(GL,OES,texture_3D)
#ifdef MAGNUM_TARGET_GLES2
_disable(GL,ANGLE,framebuffer_blit)
_disable(GL,ANGLE,framebuffer_multisample)
_disable(GL,APPLE,framebuffer_multisample)
_disable(GL,EXT,discard_framebuffer)
_disable(GL,EXT,blend_minmax)
#ifndef CORRADE_TARGET_NACL
_disable(GL,EXT,occlusion_query_boolean)
#endif
_disable(GL,EXT,texture_storage)
_disable(GL,EXT,map_buffer_range)
_disable(GL,NV,draw_buffers)
_disable(GL,NV,fbo_color_attachments) // ??
_disable(GL,NV,read_buffer)
_disable(GL,NV,framebuffer_multisample)
_disable(GL,OES,vertex_array_object)
#endif
#undef _disable
#endif
/* Set this context as current */
CORRADE_ASSERT(!_current, "Context: Another context currently active", );
_current = this;

2
src/DebugMessage.cpp

@ -144,6 +144,7 @@ void DebugMessage::callbackImplementationKhr(const Callback callback, const void
/* Adding callback */
if(!original && callback) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES
glDebugMessageCallback(callbackWrapper, userParam);
#else
@ -154,6 +155,7 @@ void DebugMessage::callbackImplementationKhr(const Callback callback, const void
/* Deleting callback */
} else if(original && !callback) {
/** @todo Re-enable when extension wrangler is available for ES */
#ifndef MAGNUM_TARGET_GLES
glDebugMessageCallback(nullptr, nullptr);
#else

4
src/Framebuffer.cpp

@ -185,7 +185,7 @@ void Framebuffer::texture2DImplementationDSA(BufferAttachment attachment, GLenum
void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Texture3D& texture, GLint mipLevel, GLint layer) {
/** @todo Check for texture target compatibility */
/** @todo Get some extension wrangler for glFramebufferTexture3D() (extension only) */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer);
#else
@ -193,6 +193,8 @@ void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Te
static_cast<void>(texture);
static_cast<void>(mipLevel);
static_cast<void>(layer);
CORRADE_INTERNAL_ASSERT(false);
//glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer);
#endif
}

15
src/Mesh.cpp

@ -206,13 +206,16 @@ void Mesh::drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset,
}
void Mesh::bindVAO(GLuint vao) {
/** @todo Get some extension wrangler instead to avoid linker errors to glBindVertexArray() on ES2 */
#ifndef MAGNUM_TARGET_GLES2
/** @todo Re-enable when extension loader is available for ES */
GLuint& current = Context::current()->state().mesh->currentVAO;
if(current != vao) glBindVertexArray(current = vao);
#else
static_cast<void>(vao);
#endif
if(current != vao) {
#ifndef MAGNUM_TARGET_GLES2
glBindVertexArray(current = vao);
#else
CORRADE_INTERNAL_ASSERT(false);
//glBindVertexArrayOES(current = vao);
#endif
}
}
void Mesh::vertexAttribPointer(const Attribute& attribute) {

46
src/Query.cpp

@ -33,12 +33,13 @@
namespace Magnum {
AbstractQuery::AbstractQuery(): target() {
/** @todo Get some extension wrangler instead to avoid undeclared glGenQueries() on ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glGenQueries(1, &_id);
#elif defined(CORRADE_TARGET_NACL)
glGenQueriesEXT(1, &_id);
#else
CORRADE_INTERNAL_ASSERT(false);
//glGenQueriesEXT(1, &_id);
#endif
}
@ -46,12 +47,13 @@ AbstractQuery::~AbstractQuery() {
/* Moved out, nothing to do */
if(!_id) return;
/** @todo Get some extension wrangler instead to avoid undeclared glGenQueries() on ES2 */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glDeleteQueries(1, &_id);
#elif defined(CORRADE_TARGET_NACL)
glDeleteQueriesEXT(1, &_id);
#else
CORRADE_INTERNAL_ASSERT(false);
//glDeleteQueriesEXT(1, &_id);
#endif
}
@ -75,13 +77,14 @@ AbstractQuery& AbstractQuery::setLabel(const std::string& label) {
bool AbstractQuery::resultAvailable() {
CORRADE_ASSERT(!target, "AbstractQuery::resultAvailable(): the query is currently running", false);
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
GLuint result;
#ifndef MAGNUM_TARGET_GLES2
glGetQueryObjectuiv(_id, GL_QUERY_RESULT_AVAILABLE, &result);
#elif defined(CORRADE_TARGET_NACL)
glGetQueryObjectuivEXT(_id, GL_QUERY_RESULT_AVAILABLE, &result);
#else
CORRADE_INTERNAL_ASSERT(false);
//glGetQueryObjectuivEXT(_id, GL_QUERY_RESULT_AVAILABLE, &result);
#endif
return result == GL_TRUE;
}
@ -90,13 +93,14 @@ bool AbstractQuery::resultAvailable() {
template<> bool AbstractQuery::result<bool>() {
CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
GLuint result;
#ifndef MAGNUM_TARGET_GLES2
glGetQueryObjectuiv(_id, GL_QUERY_RESULT, &result);
#elif defined(CORRADE_TARGET_NACL)
glGetQueryObjectuivEXT(_id, GL_QUERY_RESULT, &result);
#else
CORRADE_INTERNAL_ASSERT(false);
//glGetQueryObjectuivEXT(_id, GL_QUERY_RESULT, &result);
#endif
return result == GL_TRUE;
}
@ -104,13 +108,14 @@ template<> bool AbstractQuery::result<bool>() {
template<> UnsignedInt AbstractQuery::result<UnsignedInt>() {
CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
UnsignedInt result;
#ifndef MAGNUM_TARGET_GLES2
glGetQueryObjectuiv(_id, GL_QUERY_RESULT, &result);
#elif defined(CORRADE_TARGET_NACL)
glGetQueryObjectuivEXT(_id, GL_QUERY_RESULT, &result);
#else
CORRADE_INTERNAL_ASSERT(false);
//glGetQueryObjectuivEXT(_id, GL_QUERY_RESULT, &result);
#endif
return result;
}
@ -118,13 +123,14 @@ template<> UnsignedInt AbstractQuery::result<UnsignedInt>() {
template<> Int AbstractQuery::result<Int>() {
CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
Int result;
#ifndef MAGNUM_TARGET_GLES
glGetQueryObjectiv(_id, GL_QUERY_RESULT, &result);
#elif defined(CORRADE_TARGET_NACL)
glGetQueryObjectivEXT(_id, GL_QUERY_RESULT, &result);
#else
CORRADE_INTERNAL_ASSERT(false);
//glGetQueryObjectivEXT(_id, GL_QUERY_RESULT, &result);
#endif
return result;
}
@ -132,7 +138,7 @@ template<> Int AbstractQuery::result<Int>() {
template<> UnsignedLong AbstractQuery::result<UnsignedLong>() {
CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
UnsignedLong result;
#ifndef MAGNUM_TARGET_GLES
glGetQueryObjectui64v(_id, GL_QUERY_RESULT, &result);
@ -146,7 +152,7 @@ template<> UnsignedLong AbstractQuery::result<UnsignedLong>() {
template<> Long AbstractQuery::result<Long>() {
CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
Long result;
#ifndef MAGNUM_TARGET_GLES
glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result);
@ -161,25 +167,27 @@ template<> Long AbstractQuery::result<Long>() {
void AbstractQuery::begin(GLenum target) {
CORRADE_ASSERT(!this->target, "AbstractQuery::begin(): the query is already running", );
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glBeginQuery(this->target = target, id());
#elif defined(CORRADE_TARGET_NACL)
glBeginQueryEXT(this->target = target, id());
#else
CORRADE_INTERNAL_ASSERT(false);
static_cast<void>(target);
//glBeginQueryEXT(this->target = target, id());
CORRADE_INTERNAL_ASSERT(false);
#endif
}
void AbstractQuery::end() {
CORRADE_ASSERT(target, "AbstractQuery::end(): the query is not running", );
/** @todo Re-enable when extension wrangler is available for ES */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
glEndQuery(target);
#elif defined(CORRADE_TARGET_NACL)
glEndQueryEXT(target);
#else
CORRADE_INTERNAL_ASSERT(false);
//glEndQueryEXT(target);
#endif
target = {};
}

2
src/Renderbuffer.cpp

@ -136,7 +136,7 @@ void Renderbuffer::storageImplementationDSA(RenderbufferFormat internalFormat, c
}
#endif
/** @todo Enable when extension wrangler for ES is done */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES2
void Renderbuffer::storageMultisampleImplementationDefault(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) {

4
src/Renderer.cpp

@ -217,12 +217,12 @@ Renderer::GraphicsResetStatus Renderer::graphicsResetStatusImplementationDefault
}
Renderer::GraphicsResetStatus Renderer::graphicsResetStatusImplementationRobustness() {
/** @todo Enable when extension wrangler for ES is available */
/** @todo Re-enable when extension loader is available for ES */
#ifndef MAGNUM_TARGET_GLES
return GraphicsResetStatus(glGetGraphicsResetStatusARB());
#else
//return GraphicsResetStatus(glGetGraphicsResetStatusEXT());
CORRADE_INTERNAL_ASSERT(false);
//return GraphicsResetStatus(glGetGraphicsResetStatusEXT());
#endif
}

Loading…
Cancel
Save