The mobile version Aspect_RenderingContext got created on ubuntu

Hello, I am using ubuntu 24.04, when starting a occ+qt base app,and debugging goes into a mobile branch,namely in

OpenGl_Context.cxx from line 954

Standard_Boolean OpenGl_Context::Init (const Standard_Boolean theIsCoreProfile)
{
......
#if defined(HAVE_EGL)
......Debugging goes into here......
......Debugging goes into here......
......Debugging goes into here......
#elif defined(_WIN32)
......
#elif defined(HAVE_XLIB)
....
#else
//
#endif
....
}

Based on occ doc, "HAVE_EGL" means "GLES based systems like iOS or Android". I have tried to add below two lines before creating OpenGL_Context

#def HAVE_EGL
#define HAVE_XLIB

but debugging still goes to the first branch.

And in the same machine, another occ base app runs fine and the debugging goes into the third branch which is guarded by "HAVE_XLIB".

Would you please give me some hints about how to fix this issue?

Attachments: 
gkv311 n's picture

Based on occ doc, "HAVE_EGL" means "GLES based systems like iOS or Android".

This is not precisely correct. On mobile systems there is just no alternative to EGL and GLES.

On desktop platforms, it is possible activating USE_GLES which would activate building TKOpenGles library and implicitly rely on EGL (there is no useful alternative for creating GLES context using GLX, WGL or whatever).

On desktop Linux system you may specify USE_XLIB to use Xw_Window and rely on GLX for TKOpenGl toolkit, otherwise it will use EGL for creating desktop OpenGL context (but you will need creating window yourself; DRAWEXE will be able to create only offscreen EGL context for creating screenshots).

Note that both TKOpenGl and TKOpenGles export classes like OpenGl_GraphicDriver with the same name, hence which implementation to use will depend on which library your application is linked against.

I don't quite understand what you're trying to achieve by redefining some macros locally, as these should depend on OCCT building configuration (and will vary depending on TKOpenGl or TKOpenGles target, as both reuse common source code - hence you may experience weird behavior in debugger, if you have linked another toolkit that you don't expect).

AlexLuya's picture

Thanks for helping, the three branches are like this:

#if defined(HAVE_EGL)
myDisplay = (Aspect_Display )eglGetCurrentDisplay();
myGContext = (Aspect_RenderingContext )eglGetCurrentContext();
myWindow = (Aspect_Drawable )eglGetCurrentSurface(EGL_DRAW);
#elif defined(_WIN32)
.....
#elif defined(HAVE_XLIB)
myDisplay = (Aspect_Display )glXGetCurrentDisplay();
myGContext = (Aspect_RenderingContext )glXGetCurrentContext();
myWindow = (Aspect_Drawable )glXGetCurrentDrawable();
#else

And if debugging goes into the first branch(HAVE_EGL),

myGContext will be a nullptr

And in the same machine with same IDE and same building steps, using same OCC libs, another OCC based app's debugging thread will go to the third branch(HAVE_XLIB),and runs fine, so I doubt that other libs or cmake entries interfered OCC lib,so I tried to redefining some macros locally.

AlexLuya's picture

Seems like after removing the TKOpengles,everything worked