Skip to content

Commit

Permalink
Default to EGL context with moderngl on Linux
Browse files Browse the repository at this point in the history
Also update custom window creation class setup for newer versions
  • Loading branch information
OKaluza committed Oct 8, 2024
1 parent 099a752 commit b95c9fe
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lavavu/lavavu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2319,29 +2319,29 @@ def _open(self):
if _LavaVuWrapper._ctx:
self.ctx = _LavaVuWrapper._ctx
else:
self.ctx = moderngl.create_standalone_context(require=330)
import platform
if platform.system() == 'Linux':
self.ctx = moderngl.create_context(standalone=True, require=330, backend='egl')
else:
self.ctx = moderngl.create_standalone_context(require=330)
#print(self.ctx.info)
_LavaVuWrapper._ctx = self.ctx

if self.use_moderngl_window and self.ctx:
# Activate the context
moderngl_window.activate_context(ctx=self.ctx)
if self.use_moderngl_window == 'window':
# Configure with default window class / settings
from moderngl_window.conf import settings
settings.WINDOW['gl_version'] = (3, 3)
settings.WINDOW['samples'] = 4
if self.resolution:
settings.WINDOW['size'] = self.resolution
# Creates the window instance and activates its context
self.wnd = moderngl_window.create_window_from_settings()
else:
# Configure to use provided window class
window_str = 'moderngl_window.context.' + self.use_moderngl_window + '.Window'
window_cls = moderngl_window.get_window_cls(window_str)
if self.resolution:
self.wnd = window_cls(title="LavaVu", gl_version=(3, 3), samples=4, vsync=True, cursor=True, size=self.resolution)
else:
self.wnd = window_cls(title="LavaVu", gl_version=(3, 3), samples=4, vsync=True, cursor=True)

# Configure with default window class / settings
from moderngl_window.conf import settings
settings.WINDOW['gl_version'] = (3, 3)
if self.use_moderngl_window != 'window':
#Use specified class
settings.WINDOW['class'] = f'moderngl_window.context.{self.use_moderngl_window}.Window'
settings.WINDOW['samples'] = 4
if self.resolution:
settings.WINDOW['size'] = self.resolution
# Creates the window instance and activates its context
self.wnd = moderngl_window.create_window_from_settings()

# register event methods
self.wnd.resize_func = self.resized
Expand Down

0 comments on commit b95c9fe

Please sign in to comment.