cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
539 stars 59 forks source link

Unable to use legacy implementation for AbstractBufferImplementation #370

Closed caseymcc closed 6 years ago

caseymcc commented 6 years ago

The below code will select EXT implementation even if legacy is requested in globjects::init(). The legacy id is greater than the EXT id, so if the card supports EXT then it is selected. Is this the expected behavior?

AbstractBufferImplementation * AbstractBufferImplementation::get(const Buffer::BindlessImplementation impl)
{
    if(impl==Buffer::BindlessImplementation::DirectStateAccessARB
        && hasExtension(GLextension::GL_ARB_direct_state_access))
    {
        return BufferImplementation_DirectStateAccessARB::instance();
    }
    else if(impl >= Buffer::BindlessImplementation::DirectStateAccessEXT  //<-- offending line
        && hasExtension(GLextension::GL_EXT_direct_state_access))
    {
        return BufferImplementation_DirectStateAccessEXT::instance();
    }
    else
    {
        return BufferImplementation_Legacy::instance();
    }
scheibel commented 6 years ago

The designated strategy selection algorithm is as follows:

From most desired to least desired:
* Test if user has explicitly chosen this strategy or a more desired one (currently lower in value) and the current strategy is available by testing for an OpenGL extension
* If both extension is available and strategy is chosen, return
* If either one fails, forward to next strategy

So yeah, the order of all implementation enumerations seems to be in reversed order. I'll fix it.