Skip to content

Commit

Permalink
removed dependency on glxinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
paddywwoof committed Jun 25, 2019
1 parent 911678b commit 427e4c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Tim Skillman, Patrick Gaunt, Tom Ritchford

Date Amends

v2.31
2019-06-25 Improvement: Checking for new GL driver now not dependent on
glxinfo (mesa-utils)

v2.30
2019-06-24 Bug fix: New version of Raspbian no longer supports broadcom bcm_host
GL driver which is now detected and correct drivers loaded.
Expand Down
20 changes: 11 additions & 9 deletions pi3d/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
pi3d.constants contains constant values, mainly integers, from OpenGL ES 2.0.
"""
import time
import logging

__version__ = '2.30'
__version__ = '2.31'
year = time.localtime().tm_year

STARTUP_MESSAGE = """
Expand All @@ -30,6 +31,8 @@
from pi3d.constants.gl2ext import *
from pi3d.constants.gl import *

LOGGER = logging.getLogger(__name__)

# Define some extra constants that the automatic extraction misses.
EGL_DEFAULT_DISPLAY = 0
EGL_NO_CONTEXT = 0
Expand Down Expand Up @@ -73,23 +76,22 @@ def _load_library(name, dll_type="C"):
else:
return ctypes.CDLL(name)
except:
import logging
LOGGER = logging.getLogger(__name__)
LOGGER.error("Couldn't load library %s", name)

def _linux():
platform = PLATFORM_LINUX

from ctypes.util import find_library
from os import environ
import subprocess
acc = False
try:
txt = subprocess.check_output(['glxinfo']) # check if accelerated driver enabled
if b'Accelerated: yes' in txt:
acc = True
except Exception as e:
pass # many reasons why this might fail, all imply GL driver not to be used
with open('/proc/modules', 'r') as f:
for l in f.readlines():
if l.startswith('vc4'):
acc = True
break
except:
pass # main reason to fail is /proc/modules not there so acc False

bcm_name = find_library('bcm_host')
if bcm_name and not acc:
Expand Down
13 changes: 9 additions & 4 deletions pi3d/util/DisplayOpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ def __init__(self):

else: # use libX11
self.d = xlib.XOpenDisplay(None)
self.screen = xlib.XDefaultScreenOfDisplay(self.d)
self.width, self.height = xlib.XWidthOfScreen(self.screen), xlib.XHeightOfScreen(self.screen)
if self.d:
self.screen = xlib.XDefaultScreenOfDisplay(self.d)
self.width, self.height = xlib.XWidthOfScreen(self.screen), xlib.XHeightOfScreen(self.screen)
else:
print('************************\nX11 needs to be running\n************************')
assert False


def create_display(self, x=0, y=0, w=0, h=0, depth=24, samples=4, layer=0, display_config=DISPLAY_CONFIG_DEFAULT, window_title=''):
self.display = openegl.eglGetDisplay(EGL_DEFAULT_DISPLAY)
Expand Down Expand Up @@ -154,12 +159,12 @@ def create_surface(self, x=0, y=0, w=0, h=0, layer=0):
elif self.display_config & DISPLAY_CONFIG_MAXIMIZED:
flags |= pygame.FULLSCREEN
wsize = (0, 0)

self.width, self.height = w, h
self.d = pygame.display.set_mode(wsize, flags)
self.window = pygame.display.get_wm_info()["window"]
self.surface = openegl.eglCreateWindowSurface(self.display, self.config, self.window, 0)

else:
self.width, self.height = w, h

Expand Down

0 comments on commit 427e4c0

Please sign in to comment.