void SampleQueryGLTest::wrap() {
    #ifdef MAGNUM_TARGET_GLES2
    if(!Context::current()->isExtensionSupported<Extensions::GL::EXT::occlusion_query_boolean>())
        CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not available."));
    #endif

    GLuint id;
    #ifndef MAGNUM_TARGET_GLES2
    glGenQueries(1, &id);
    #else
    glGenQueriesEXT(1, &id);
    #endif

    /* Releasing won't delete anything */
    {
        auto query = SampleQuery::wrap(id, SampleQuery::Target::AnySamplesPassed, ObjectFlag::DeleteOnDestruction);
        CORRADE_COMPARE(query.release(), id);
    }

    /* ...so we can wrap it again */
    SampleQuery::wrap(id, SampleQuery::Target::AnySamplesPassed);
    #ifndef MAGNUM_TARGET_GLES2
    glDeleteQueries(1, &id);
    #else
    glDeleteQueriesEXT(1, &id);
    #endif
}
void AbstractQuery::createImplementationDefault() {
#ifndef MAGNUM_TARGET_GLES2
    glGenQueries(1, &_id);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN)
    glGenQueriesEXT(1, &_id);
#else
    CORRADE_ASSERT_UNREACHABLE();
#endif
}
Example #3
0
AbstractQuery::AbstractQuery(): target() {
    /** @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);
    #endif
}
/**
  * Default object constructor
  * 
  */
GLES2HardwareOcclusionQuery::GLES2HardwareOcclusionQuery() 
{ 
	// Check for hardware occlusion support
#ifdef GL_EXT_occlusion_query_boolean
    glGenQueriesEXT(1, &mQueryID );
    GL_CHECK_ERROR;
#else
    OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, 
                "Cannot allocate a Hardware query. This video card doesn't support it, sorry.", 
                "GLES2HardwareOcclusionQuery::GLES2HardwareOcclusionQuery" );
#endif
}
//------------------------------------------------------------------
void GLES2HardwareOcclusionQuery::createQuery()
{
	// Check for hardware occlusion support
#ifdef GL_EXT_occlusion_query_boolean
    OGRE_IF_IOS_VERSION_IS_GREATER_THAN(5.0)
        OGRE_CHECK_GL_ERROR(glGenQueriesEXT(1, &mQueryID ));
#else
    OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, 
                "Cannot allocate a Hardware query. This video card doesn't support it, sorry.", 
                "GLES2HardwareOcclusionQuery::GLES2HardwareOcclusionQuery" );
#endif        
}
//------------------------------------------------------------------
void GLES2HardwareOcclusionQuery::createQuery()
{
	// Check for hardware occlusion support
    
    if(getGLSupport()->checkExtension("GL_EXT_occlusion_query_boolean") || gleswIsSupported(3, 0))
    {
        OGRE_CHECK_GL_ERROR(glGenQueriesEXT(1, &mQueryID));
    }
    else
    {
        OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR,
                    "Cannot allocate a Hardware query. This video card doesn't support it, sorry.",
                    "GLES2HardwareOcclusionQuery::GLES2HardwareOcclusionQuery" );

    }
}