How to use ANGLE library on old machines

Hi,

I am working on a framework that uses GL to render special effects with frame buffer objects. But on old machines where drivers are buggy, the application will crash. I have heard that the Chrome browser is using ANGLE for OpenGL compatibility with old hardware by rendering using DirectX. In this thread Application crashes on Intel GMA 3150 I have also heard that it is possible to include ANGLE in OpenFL project.

I would like to know the steps to include ANGLE and to enable it. I am also wondering if it is possible to detect when the hardware OpenGL version is low, and manually switch to OpenGL ES mode instead of hard coding it before running the application.

Thanks.

There are some details here:

https://hg.libsdl.org/SDL/file/1c41db87ce20/docs/README-windows.md

If we can sort it out for SDL2, that gives us support in Lime 2, which can then be used with the newer OpenFL code, or with the new -Dhybrid system I made, which uses Lime 2 underneath OpenFL legacy

Thanks for the reply, and OMG a hybrid system is EXACTLY what I needed.

If the ANGLE library is integrated, will it only be used when the hardware is old, or will it be an option in project.xml or something?

We might consider enabling it for all Windows builds. This would help with older system support, as well as better support on some graphics cards (which otherwise do support GL2 features). The difficulty is that SDL2 will enable a GLES context on newer cards that support it without going through ANGLE. I have one of those cards, so I might not be able to test if ANGLE is working

Will enabling OpenGL ES makes the performance worse on newer cards compare to using a GL context?

And also I can help you with the testing if you want. My FBOs will never work if ANGLE is not used.

Subscribe to the topic.
Maybe even better option would be setting like -Dangle (and more simple for implement), which will just make builds with ANGLE renderer only.

Since ANGLE is a library for old hardware compatibility, I suspect using it on newer hardware will causes unnecessary limitations. Also since SDL2 will choose ANGLE only when a GL ES context is not supported, there is no way and no reason to force the usage.

And please make it available to lime legacy as well. Thanks a lot

I just realized that even my laptop (with the Intel GPU) has support for the OpenGL ES 2 context, so it does not use ANGLE. However, I think I got it to use the ES context properly.

If you would not mind, try editing “lime/project/Build.xml”, at around line 139 (in the if=“LIME_SDL” section) add this define:

<compilerflag value="-DSDL_VIDEO_OPENGL_ES2" if="windows" />

Then edit “lime/project/src/backend/SDLWindow.cpp” and at around line 24 add:

#ifdef HX_WINDOWS
SDL_GL_SetAttribute (SDL_GL_CONTEXT_EGL, 1); 
SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); 
SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 2); 
SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 0); 
#endif

I believe this causes SDL2 to create an OpenGL ES context. If your GPU does not support WGL_EXT_create_context_es2_profile then it should look for ANGLE.

https://hg.libsdl.org/SDL/file/4bab88dd387e/docs/README-windows.md

If it succeeds (and you do not have the extension) then it should not run, probably, perhaps with an error about not finding those additional DLL files. Then you could try copying those files into the same directory as the executable. If all goes well, we’ll know this is working and can include those DLL files in the Windows project template by default

Roger that. What are the steps for testing on lime legacy? There is only if=“LEGACY_SDL1” and if=“LEGACY_SDL2” sections in legacy build.xml, and apparently legacy does not have project/src/backend folder.

I’d recommend trying to get this working with the newer code, first. If we get that working, it sets us up for backporting

Okay then, will test ASAP.

Alrighty, here’s some changes I made, recording them here for now as I’m not good at working with git submodules. This was in standard/next, for the record:

lime\project\src\backend\sdl\SDLWindow.cpp:
Line 24, inserted:

        #ifdef HX_WINDOWS
        SDL_GL_SetAttribute (SDL_GL_CONTEXT_EGL, 1); 
        SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); 
        SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 2); 
        SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 0); 
        #endif

lime\project\lib\sdl\include\configs\windows\SDL_config.h
Line 191, changed to read:

/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL    1
#endif
#ifndef SDL_VIDEO_OPENGL_WGL
#define SDL_VIDEO_OPENGL_WGL    0
#endif
#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL    0
#endif
#ifndef SDL_VIDEO_RENDER_OGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2    1
#endif
#ifndef SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_OPENGL_ES2    1
#endif
#ifndef SDL_VIDEO_OPENGL_EGL
#define SDL_VIDEO_OPENGL_EGL    1
#endif

lime\project\Build.xml
Line 140, inserted:

<compilerflag value="-DSDL_VIDEO_OPENGL_ES2" if="windows"/>

a clean rebuild worked. Then, a lime test neko of bunnymark produced:

INFO: WARNING: Ignoring SDL_GL_SetSwapInterval call due to ANGLE bug
INFO: WARNING: Ignoring SDL_GL_SetSwapInterval call due to ANGLE bug

Then crash.

Which seems like some kind of progress?

1 Like

I think the key is for us to find the correct version of ANGLE that matches what SDL expects, or there’s a possibility that ANGLE just is not happy about something in how the rendering is done. Perhaps we could try the SimpleOpenGLView or something like that, which might demand less (or even better, the Lime HelloWorld sample)

Another possibility is updating to a newer source version of SDL, which I believe was updated to work with newer versions of ANGLE, which may work better

1 Like

Build.xml doesn’t need to be modified. Why do we need to define a macro that is already defined by SDL_config.h?

The crash was easy to fix. Lime was failing to initialize OpenGL bindings because it always uses wglGetProcAddress instead of SDL_GL_GetProcAddress.

HelloWorld example launched, but nothing renders on the screen…

Shaders from HerokuShaders and SimpleImage won’t compile on ANGLE. It seems difficult to get these things work.

I tested again with lasted SDL in https://github.com/spurious/SDL-mirror.
This time HelloWorld and HerokuShaders worked, but without ANGLE.

1 Like

This was because WGL was enabled in config file…
I disabled WGL again, and saw that egl failed to create OpenGL context.

SDL’s testgles2 works even with ANGLE so there should be something wrong in Lime… But I’m not sure what we are missing. Should we create OpenGL context without using SDL’s Renderer?

It finally worked! I should have compiled lime with “-DDYNAMIC_OGL” to dynamically load basic OpenGL functions like glClear from libGLESv2.dll.

If you disable WGL in SDL_config.h, SDL does not look for WGL_EXT_create_context_es2_profile extension since it cannot create WGL context without that. So you can always use ANGLE if you want.

2 Likes