horde3d / Horde3D

Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.
http://horde3d.org/
1.55k stars 308 forks source link

sample app init not fully falling back to GL2 #209

Closed gwald closed 2 years ago

gwald commented 2 years ago

Hi, On my old laptop (GL2 only) it didn't fall back to GL2 in the samples (core dumps).

/Horde3D/Samples/Framework/sampleapp.cpp

Function init around 144, it should also handle GL2 init here also:

if ( ( _winHandle = _backend->createWindow( winParams ) ) == nullptr ) return false;

Here is what works for me, just a copy and paste from the GL2 check:

bool SampleApplication::init() { // Init params can be changed in derived user applications auto params = setupInitParameters( defaultRenderInterface() ); if ( !_backend->init( params ) ) return false;

auto winParams = setupWindowParameters();
if ( ( _winHandle = _backend->createWindow( winParams ) ) == nullptr ) 

{

if defined( H3D_USE_GL4 ) && defined ( H3D_USE_GL2 )

// Fallback to OpenGL2 backend _backend->logMessage( LogMessageLevel::Info, "Trying OpenGL2 render backend" );

    release();
    _backend->release();

    _renderInterface = H3DRenderDevice::OpenGL2;
    params = setupInitParameters( _renderInterface );

        if ( !_backend->init( params ) ) return false;

         winParams = setupWindowParameters();
        if ( ( _winHandle = _backend->createWindow( winParams ) ) == nullptr ) 
        {

    _backend->logMessage( LogMessageLevel::Error, "GL 2 failed" );

            return false;
        }
  #else
    return false;

endif

}

// Initialize engine
algts commented 2 years ago

Hello. Are you using master or develop branch?

gwald commented 2 years ago

I didn't know there was a branch thanks for letting me know! (I'm a noob!) I DL the dev branch and build it as per normal (cmake ..) and it failed on my old laptop, here's the out put

xp@xp-Vostro-3400:~/Downloads/Horde3D-develop/bin/Binaries/Linux/Release$ ./Chicago GLFW: level 65543 - GLX: Failed to create context: GLXBadFBConfig Unable to initialize window! Context parameters: API: OpenGL API version: Major - 4; Minor - 1 Compatibility profile: 0

Surface parameters: Bits: r - 8 g - 8 b - 8 a - 8 depth - 24 Sample count: 0 xp@xp-Vostro-3400:~/Downloads/Horde3D-develop/bin/Binaries/Linux/Release$

The code from first post results in correctly opening for me: xp@xp-Vostro-3400:~/Downloads/Horde3D-master/bin4/Binaries/Linux/Release$ ./Chicago Unable to initialize window! Context parameters: API: OpenGL API version: Major - 4; Minor - 0 Compatibility profile: 0

Surface parameters: Bits: r - 8 g - 8 b - 8 a - 8 depth - 24 Sample count: 0 Info: Trying OpenGL2 render backend [h3d] Initializing GL2 backend using OpenGL driver '2.1 Mesa 19.0.8' by 'Intel Open Source Technology Center' on 'Mesa DRI Intel(R) Ironlake Mobile ' [h3d] Loading resource 'pipelines/forward.pipeline.xml' [h3d] Loading resource 'pipelines/deferred.pipeline.particles.xml' [h3d] Loading resource 'pipelines/hdr.pipeline.xml'

I copied my changes to your develop branch sampleapp.cpp, rebuilt it and it worked.

I think this might be the reason why some VM's failed to run the samples, I know VBox has very limited GL support, so I will test it there also.

algts commented 2 years ago

Ok, can you make a pull request for develop branch with these changes? Otherwise I'll fix it later this week. Thanks.

gwald commented 2 years ago

Hi, that's my first pull request :) Sorry for making two, I wanted to see the changes before sending the pull request... I have tested the code and it works fine for me.

algts commented 2 years ago

I don't see a pull request in github interface. Did you push a "create pull request (or something like that)" button that should show above the branch selection? Update: ok, the pull request is here.

gwald commented 2 years ago

your right, I just saw that! thanks :)

Cool

algts commented 2 years ago

Merged. Reopen if the issue persists.