Compiling and running engine with GL ES 2 for Raspberry Pi 3

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
saldavonschwartz
Posts: 2
Joined: Mon Mar 20, 2017 5:42 am

Compiling and running engine with GL ES 2 for Raspberry Pi 3

Post by saldavonschwartz »

I'm new to Irrlicht and I've been trying to compile the engine to use it with GL ES 2 on a Pi 3 running Raspbian 8, unsuccessfully.

What I tried so far:

1. Cloned the source from here https://github.com/zaki/irrlicht
2. Ran make on the ogl-es branch. Had to do the following changes for it to compile:
a- COGLESExtensionHandler.cpp and CEGLManager.h: change #include <GLES/egl.h> to #include <EGL/egl.h>
b- -I/opt/vc/include and -L/opt/vc/lib on the Makefile.

At this point I got the engine to compile into a static lib.
I then tried making and running example01 (loads a simple model: sydney.md2). By default the example renders with the software renderer (E_DRIVER_TYPE::EDT_SOFTWARE).
This worked: it created a new window and rendered the 3d model.

I then tried recompiling and running with E_DRIVER_TYPE::EDT_OGLES2. Does not work. Fails in CEGLManager.cpp:

Code: Select all

 
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
    EglWindow = (NativeWindowType)Data.OpenGLWin32.HWnd;
    Data.OpenGLWin32.HDc = GetDC((HWND)EglWindow);
    EglDisplay = eglGetDisplay((NativeDisplayType)Data.OpenGLWin32.HDc);
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
    EglWindow = (NativeWindowType)Data.OpenGLLinux.X11Window;
    EglDisplay = eglGetDisplay((NativeDisplayType)Data.OpenGLLinux.X11Display);
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
    EglWindow = (ANativeWindow*)Data.OGLESAndroid.Window;
    EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#elif defined(_IRR_COMPILE_WITH_FB_DEVICE_)
    EglWindow = (NativeWindowType)Data.OpenGLFB.Window;
    EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#endif
 
    // We must check if EGL display is valid.
    if (EglDisplay == EGL_NO_DISPLAY)
    {
        os::Printer::log("Could not get EGL display.");
        terminate();
        return false;
    }
 
It specifically executes the code in the X11 elif and does not get a display back from eglGetDisplay.
I've been searching for a while online but have not found information on this. So any help would be greatly appreciated.

In case it matters, I am trying to do this because my ultimate goal is to run Minetest on the Pi, which is built on top of Irrlicht. And I want to run it on GL ES 2 because the alternative, the experimental desktop GL 2.1 drivers for Pi, seem to perform worse than using GL ES 2.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Compiling and running engine with GL ES 2 for Raspberry

Post by hendu »

Minetest very likely uses shaders. GL and GLES shaders are not interchangeable, so even if it compiled and ran, it would likely display corruption or black.
saldavonschwartz
Posts: 2
Joined: Mon Mar 20, 2017 5:42 am

Re: Compiling and running engine with GL ES 2 for Raspberry

Post by saldavonschwartz »

The shaders is not the issue (I am definitely using shaders). My issue is that I do not know if the Pi can run GLES 2 with a context generated from X11. I have experience with GL/GLES in general and I have done similar work in Windows, OS X and iOS. Just not on Linux with X11. So I don't know if in theory irrlicht should be able to create the display, surface, context from x11 or if the Pi can only use GL ES 2 writing directly to the frame buffer.
jdonald
Posts: 1
Joined: Thu Dec 14, 2017 12:59 am

Re: Compiling and running engine with GL ES 2 for Raspberry

Post by jdonald »

Hey saldavonschwartz,

I responded to your post on the Raspberry Pi forums: https://www.raspberrypi.org/forums/view ... p?t=177925

There I've detailed a procedure for building and running Irrlicht+Minetest with GLES1 on the Broadcom VC4 driver. I have not attempted GLES2, but that might be possible depending on which effects you're trying to get out of it.
Post Reply