Esempio n. 1
0
    def __init__(self):
        if PLATFORM == PLATFORM_ANDROID:
            self.width, self.height = 320, 480  # put in some non-zero place-holders
        elif PLATFORM == PLATFORM_PI:
            b = bcm.bcm_host_init()
            #assert b >= 0 ## this assertion can fail with the pi camera running too

            # Get the width and height of the screen
            w = c_int()
            h = c_int()
            s = bcm.graphics_get_display_size(0, ctypes.byref(w),
                                              ctypes.byref(h))
            assert s >= 0
            self.width, self.height = w.value, h.value
        elif pi3d.USE_PYGAME:
            import pygame
            pygame.init()
            self.d = pygame.display.set_mode(
                (0, 0), pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
            info = pygame.display.Info()
            self.width, self.height = info.current_w, info.current_h

        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)
Esempio n. 2
0
    def __init__(self):
        #self.reset_depth = False # TODO find some better way
        if PLATFORM == PLATFORM_ANDROID:
            self.width, self.height = 320, 480  # put in some non-zero place-holders
        elif PLATFORM == PLATFORM_PI:
            b = bcm.bcm_host_init()
            assert b >= 0

            # Get the width and height of the screen
            w = c_int()
            h = c_int()
            s = bcm.graphics_get_display_size(0, ctypes.byref(w),
                                              ctypes.byref(h))
            assert s >= 0
            self.width, self.height = w.value, h.value
        elif PLATFORM == PLATFORM_WINDOWS:
            pygame.init()
            self.d = pygame.display.set_mode(
                (0, 0), pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
            info = pygame.display.Info()
            self.width, self.height = info.current_w, info.current_h

        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)
Esempio n. 3
0
  def __init__(self):
    if PLATFORM != PLATFORM_PI:
      self.d = xlib.XOpenDisplay(None)
      self.screen = xlib.XDefaultScreenOfDisplay(self.d)
      self.width, self.height = xlib.XWidthOfScreen(self.screen), xlib.XHeightOfScreen(self.screen)
    else:
      b = bcm.bcm_host_init()
      assert b >= 0

      # Get the width and height of the screen
      w = c_int()
      h = c_int()
      s = bcm.graphics_get_display_size(0, ctypes.byref(w), ctypes.byref(h))
      assert s >= 0
      self.width, self.height = w.value, h.value
Esempio n. 4
0
  def __init__(self):
    #self.reset_depth = False # TODO find some better way
    if PLATFORM == PLATFORM_ANDROID:
      self.width, self.height = 320, 480 # put in some non-zero place-holders
    elif PLATFORM == PLATFORM_PI:
      b = bcm.bcm_host_init()
      assert b >= 0

      # Get the width and height of the screen
      w = c_int()
      h = c_int()
      s = bcm.graphics_get_display_size(0, ctypes.byref(w), ctypes.byref(h))
      assert s >= 0
      self.width, self.height = w.value, h.value
    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)
Esempio n. 5
0
    def __init__(self):
        self.d = None  # display if x11 window or pygame used
        self.gl_id = b"GL"  # default. Needed for converting shaders
        if PLATFORM == PLATFORM_ANDROID:
            self.width, self.height = 320, 480  # put in some non-zero place-holders
        elif PLATFORM == PLATFORM_PI:
            b = bcm.bcm_host_init()
            #assert b >= 0 ## this assertion can fail with the pi camera running too

            # Get the width and height of the screen
            w = c_int()
            h = c_int()
            s = bcm.graphics_get_display_size(0, byref(w), byref(h))
            assert s >= 0
            self.width, self.height = w.value, h.value
        elif pi3d.USE_PYGAME:
            import pygame
            pygame.init()
            self.d = pygame.display.set_mode(
                (0, 0), pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
            info = pygame.display.Info()
            self.width, self.height = info.current_w, info.current_h

        else:  # use libX11
            #import subprocess # default name using XOpenDisplay(None) doesn't work on RPi4
            import os
            display_name = None  #previous to RPi4 this worked but now problems..
            for f in os.listdir('/tmp/.X11-unix'):
                display_name = b':' + f[1:].encode('utf-8')
                #if display_name == b':0':
                #  break # use X0 if this exist, else use last in list (which might work!)
                self.d = xlib.XOpenDisplay(
                    display_name
                )  # return NULL from X function or address if sucessful
                if self.d:
                    self.screen = xlib.XDefaultScreenOfDisplay(self.d)
                    self.width, self.height = xlib.XWidthOfScreen(
                        self.screen), xlib.XHeightOfScreen(self.screen)
                    break  # as soon as first valid display found. TODO mulitple displays?
            if not self.d:
                print(
                    '************************\nX11 needs to be running\n************************'
                )
                assert False, 'Couldnt open DISPLAY {}'.format(display_name)
    def __init__(self):
        self.d = None  # display if x11 window or pygame used
        self.gl_id = "GL"  # default. Needed for converting shaders
        if PLATFORM == PLATFORM_ANDROID:
            self.width, self.height = 320, 480  # put in some non-zero place-holders
        elif PLATFORM == PLATFORM_PI:
            b = bcm.bcm_host_init()
            #assert b >= 0 ## this assertion can fail with the pi camera running too

            # Get the width and height of the screen
            w = c_int()
            h = c_int()
            s = bcm.graphics_get_display_size(0, byref(w), byref(h))
            assert s >= 0
            self.width, self.height = w.value, h.value
        elif pi3d.USE_PYGAME:
            import pygame
            pygame.init()
            self.d = pygame.display.set_mode(
                (0, 0), pygame.DOUBLEBUF | pygame.RESIZABLE | pygame.OPENGL)
            info = pygame.display.Info()
            self.width, self.height = info.current_w, info.current_h

        else:  # use libX11
            #import subprocess # default name using XOpenDisplay(None) doesn't work on RPi4
            #display_name = subprocess.check_output(['printenv', 'DISPLAY']).split()[0]
            #display_name = b':' + subprocess.check_output([b'ls', b'/tmp/.X11-unix']).split(b'X')[1].trim()
            import os
            display_name = None
            for f in os.listdir('/tmp/.X11-unix'):
                display_name = b':' + f[1:].encode('utf-8')
                break  # just use the first one in the list if more than one
            self.d = xlib.XOpenDisplay(display_name)
            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, 'Couldnt open DISPLAY {}'.format(display_name)