Exemplo n.º 1
0
 def create_context(self, share):
     # Workaround for issue on certain Intel cards/drivers.
     # TODO: Find out if there is a way to query for this problem
     if wgl_info.have_extension('WGL_ARB_create_context') and gl_info.get_vendor() != 'Intel':
         return Win32ARBContext(self, share)
     else:
         return Win32Context(self, share)
Exemplo n.º 2
0
 def create_context(self, share):
     # Workaround for issue on certain Intel cards/drivers.
     # TODO: Find out if there is a way to query for this problem
     if wgl_info.have_extension('WGL_ARB_create_context') and gl_info.get_vendor() != 'Intel':
         return Win32ARBContext(self, share)
     else:
         return Win32Context(self, share)
Exemplo n.º 3
0
def graphics_test():
    from pyglet.gl import gl_info
    win = visual.Window([100, 100])  # some drivers want a window open first
    print("\nOpenGL info:")
    # get info about the graphics card and drivers
    print("vendor:", gl_info.get_vendor())
    print("rendering engine:", gl_info.get_renderer())
    print("OpenGL version:", gl_info.get_version())
Exemplo n.º 4
0
 def _setOpenGLInfo(self):
     # OpenGL info:
     self['openGLVendor'] = gl_info.get_vendor()
     self['openGLRenderingEngine'] = gl_info.get_renderer()
     self['openGLVersion'] = gl_info.get_version()
     GLextensionsOfInterest=['GL_ARB_multitexture', 'GL_EXT_framebuffer_object','GL_ARB_fragment_program',
         'GL_ARB_shader_objects','GL_ARB_vertex_shader', 'GL_ARB_texture_non_power_of_two','GL_ARB_texture_float']
 
     for ext in GLextensionsOfInterest:
         self['openGLext.'+ext] = bool(gl_info.have_extension(ext))
Exemplo n.º 5
0
Arquivo: info.py Projeto: Aang/sympy
def dump_gl():
    '''Dump GL info.'''
    from pyglet.gl import gl_info
    print 'gl_info.get_version():',  gl_info.get_version()
    print 'gl_info.get_vendor():',  gl_info.get_vendor()
    print 'gl_info.get_renderer():',  gl_info.get_renderer()
    print 'gl_info.get_extensions():'
    extensions = list(gl_info.get_extensions())
    extensions.sort()
    for name in extensions:
        print '  ', name
Exemplo n.º 6
0
def dump_gl():
    '''Dump GL info.'''
    from pyglet.gl import gl_info
    _print('gl_info.get_version():', gl_info.get_version())
    _print('gl_info.get_vendor():', gl_info.get_vendor())
    _print('gl_info.get_renderer():', gl_info.get_renderer())
    _print('gl_info.get_extensions():')
    extensions = list(gl_info.get_extensions())
    extensions.sort()
    for name in extensions:
        _print('  ', name)
Exemplo n.º 7
0
def dump_gl(context=None):
    """Dump GL info."""
    if context is not None:
        info = context.get_info()
    else:
        from pyglet.gl import gl_info as info
    print('gl_info.get_version():', info.get_version())
    print('gl_info.get_vendor():', info.get_vendor())
    print('gl_info.get_renderer():', info.get_renderer())
    print('gl_info.get_extensions():')
    extensions = list(info.get_extensions())
    extensions.sort()
    for name in extensions:
        print('  ', name)
Exemplo n.º 8
0
    def _setOpenGLInfo(self):
        # OpenGL info:
        self['openGLVendor'] = gl_info.get_vendor()
        self['openGLRenderingEngine'] = gl_info.get_renderer()
        self['openGLVersion'] = gl_info.get_version()
        GLextensionsOfInterest = [
            'GL_ARB_multitexture', 'GL_EXT_framebuffer_object',
            'GL_ARB_fragment_program', 'GL_ARB_shader_objects',
            'GL_ARB_vertex_shader', 'GL_ARB_texture_non_power_of_two',
            'GL_ARB_texture_float'
        ]

        for ext in GLextensionsOfInterest:
            self['openGLext.' + ext] = bool(gl_info.have_extension(ext))
Exemplo n.º 9
0
def dump_gl(context=None):
    '''Dump GL info.'''
    if context is not None:
        info = context.get_info()
    else:
        from pyglet.gl import gl_info as info
    print 'gl_info.get_version():',  info.get_version()
    print 'gl_info.get_vendor():',  info.get_vendor()
    print 'gl_info.get_renderer():',  info.get_renderer()
    print 'gl_info.get_extensions():'
    extensions = list(info.get_extensions())
    extensions.sort()
    for name in extensions:
        print '  ', name
Exemplo n.º 10
0
def dump_gl(context=None):
    """Dump GL info."""
    if context is not None:
        info = context.get_info()
    else:
        from pyglet.gl import gl_info as info
    print("gl_info.get_version():", info.get_version())
    print("gl_info.get_vendor():", info.get_vendor())
    print("gl_info.get_renderer():", info.get_renderer())
    print("gl_info.get_extensions():")
    extensions = list(info.get_extensions())
    extensions.sort()
    for name in extensions:
        print("  ", name)
Exemplo n.º 11
0
    def _setOpenGLInfo(self):
        # OpenGL info:
        self['openGLVendor'] = gl_info.get_vendor()
        self['openGLRenderingEngine'] = gl_info.get_renderer()
        self['openGLVersion'] = gl_info.get_version()
        GLextensionsOfInterest = ['GL_ARB_multitexture', 'GL_EXT_framebuffer_object',
             'GL_ARB_fragment_program', 'GL_ARB_shader_objects', 'GL_ARB_vertex_shader',
             'GL_ARB_texture_non_power_of_two', 'GL_ARB_texture_float', 'GL_STEREO']

        for ext in GLextensionsOfInterest:
            self['openGLext.'+ext] = bool(gl_info.have_extension(ext))

        maxVerts = GLint()
        glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
        self['openGLmaxVerticesInVertexArray'] = maxVerts.value
Exemplo n.º 12
0
    def _setOpenGLInfo(self):
        # OpenGL info:
        self['openGLVendor'] = gl_info.get_vendor()
        self['openGLRenderingEngine'] = gl_info.get_renderer()
        self['openGLVersion'] = gl_info.get_version()
        GLextensionsOfInterest = ['GL_ARB_multitexture', 'GL_EXT_framebuffer_object',
             'GL_ARB_fragment_program', 'GL_ARB_shader_objects', 'GL_ARB_vertex_shader',
             'GL_ARB_texture_non_power_of_two', 'GL_ARB_texture_float', 'GL_STEREO']

        for ext in GLextensionsOfInterest:
            self['openGLext.'+ext] = bool(gl_info.have_extension(ext))

        maxVerts = GLint()
        glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
        self['openGLmaxVerticesInVertexArray'] = maxVerts.value
Exemplo n.º 13
0
def getSysInfo(win):
    try:
        from collections import OrderedDict
    except:
        from psychopy.iohub import OrderedDict
    # based on sysInfo.py
    from pyglet.gl import gl_info, GLint, glGetIntegerv, GL_MAX_ELEMENTS_VERTICES
    import sys, platform

    sys_info = OrderedDict()
    sys_info["OS"] = OrderedDict()
    sys_info["OS"]["Name"] = platform.platform()
    if sys.platform == "darwin":
        OSXver, _, architecture = platform.mac_ver()
        sys_info["OS"]["OSX Version"] = OSXver
        sys_info["OS"]["OSX Architecture"] = architecture

    sys_info["Computer Hardware"] = OrderedDict()
    try:
        import psutil

        def getMemoryInfo():
            rdict = dict()
            nt = psutil.virtual_memory()
            for name in nt._fields:
                value = getattr(nt, name)
                if name != "percent":
                    value = bytes2human(value)
                rdict[name.capitalize()] = value  #'%s%s%-10s : %7s\n'%(rstr,'\t'*indent,name.capitalize(), value)
            return rdict

        core_count = psutil.cpu_count(logical=False)
        logical_psu_count = psutil.cpu_count()
        memory_info = getMemoryInfo()
        sys_info["Computer Hardware"]["CPUs (cores / logical)"] = (core_count, logical_psu_count)
        sys_info["Computer Hardware"]["System Memory"] = memory_info

    except:
        sys_info["Computer Hardware"]["Failed"] = "psutil 2.x + is required."

    sys_info["Python"] = OrderedDict()
    sys_info["Python"]["exe"] = sys.executable
    sys_info["Python"]["version"] = sys.version

    sys_info["Packages"] = OrderedDict()
    try:
        import numpy

        sys_info["Packages"]["numpy"] = numpy.__version__
    except:
        sys_info["Packages"]["numpy"] = "Not Installed"
    try:
        import pyglet

        sys_info["Packages"]["pyglet"] = pyglet.version
    except:
        sys_info["Packages"]["pyglet"] = "Not Installed"
    try:
        import cv2

        sys_info["Packages"]["cv2"] = cv2.__version__
    except:
        sys_info["Packages"]["cv2"] = "Not Installed"
    try:
        import psychopy

        sys_info["Packages"]["PsychoPy"] = psychopy.__version__
    except:
        sys_info["Packages"]["PsychoPy"] = "Not Installed"

    sys_info["Graphics"] = OrderedDict()
    sys_info["Graphics"]["shaders"] = win._haveShaders
    sys_info["Graphics"]["opengl"] = OrderedDict()
    sys_info["Graphics"]["opengl"]["version"] = gl_info.get_version()
    sys_info["Graphics"]["opengl"]["vendor"] = gl_info.get_vendor()
    sys_info["Graphics"]["opengl"]["engine"] = gl_info.get_renderer()
    maxVerts = GLint()
    glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
    sys_info["Graphics"]["opengl"]["Max vert in VA"] = maxVerts.value
    sys_info["Graphics"]["opengl"]["extensions"] = OrderedDict()
    extensionsOfInterest = [
        "GL_ARB_multitexture",
        "GL_EXT_framebuffer_object",
        "GL_ARB_fragment_program",
        "GL_ARB_shader_objects",
        "GL_ARB_vertex_shader",
        "GL_ARB_texture_non_power_of_two",
        "GL_ARB_texture_float",
        "GL_STEREO",
    ]
    for ext in extensionsOfInterest:
        sys_info["Graphics"]["opengl"]["extensions"][ext] = bool(gl_info.have_extension(ext))

    sys_info["Processes"] = OrderedDict()
    if sys.platform == "darwin":
        sys_info["Processes"]["Failed"] = "Not Supported on OSX."
    elif SAVE_PER_PROCESS_DATA:
        try:
            import psutil

            for proc in psutil.process_iter():
                pkey = proc.pid
                vattrs = [
                    "name",
                    "exe",
                    "ppid",
                    "num_threads",
                    "memory_percent",
                    "cpu_percent",
                    "cpu_affinity",
                    "nice",
                    "num_ctx_switches",
                ]
                procinfo = proc.as_dict(attrs=vattrs, ad_value=u"Access Denied")
                if procinfo["exe"] is not u"Access Denied" and (
                    SAVE_PER_PROCESS_DATA is True or SAVE_PER_PROCESS_DATA == procinfo["name"]
                ):
                    sys_info["Processes"][pkey] = procinfo
        except:
            sys_info["Processes"]["Failed"] = "psutil 2.x + is required."
    else:
        sys_info["Processes"]["Disabled"] = "Per Process details disabled by user."

    return sys_info
Exemplo n.º 14
0
    def getInfoText(self):
        """Get system information text."""
        outputText = ""  # text to return

        # show the PsychoPy version
        from psychopy import __version__
        outputText += self.getLine("PsychoPy", __version__)

        # get system paths
        outputText += self.getLine("\nPaths to files on the system:")
        for key in ['userPrefsFile', 'appDataFile', 'demos', 'appFile']:
            outputText += self.getLine(
                "    %s: %s" % (key, preferences.prefs.paths[key]))

        # system information such as OS, CPU and memory
        outputText += self.getLine("\nSystem Info:")
        outputText += self.getLine(
            ' '*4, 'Operating System: {}'.format(platform.platform()))
        outputText += self.getLine(
            ' ' * 4, 'Processor: {}'.format(platform.processor()))

        # requires psutil
        try:
            import psutil
            outputText += self.getLine(
                ' ' * 4, 'CPU freq (MHz): {}'.format(psutil.cpu_freq().max))
            outputText += self.getLine(
                ' ' * 4, 'CPU cores: {} (physical), {} (logical)'.format(
                    psutil.cpu_count(False), psutil.cpu_count()))
            outputText += self.getLine(
                ' ' * 4, 'Installed memory: {} (Total), {} (Available)'.format(
                    *psutil.virtual_memory()))
        except ImportError:
            outputText += self.getLine(' ' * 4, 'CPU freq (MHz): N/A')
            outputText += self.getLine(
                ' ' * 4, 'CPU cores: {} (logical)'.format(os.cpu_count()))
            outputText += self.getLine(' ' * 4, 'Installed memory: N/A')

        # if on MacOS
        if sys.platform == 'darwin':
            OSXver, junk, architecture = platform.mac_ver()
            outputText += self.getLine(
                ' ' * 4, "macOS %s running on %s" % (OSXver, architecture))

        # Python information
        outputText += self.getLine("\nPython info:")
        outputText += self.getLine(' '*4, 'Executable path:', sys.executable)
        outputText += self.getLine(' '*4, 'Version:', sys.version)
        outputText += self.getLine(' ' * 4, '(Selected) Installed Packages:')
        import numpy
        outputText += self.getLine(' '*8, "numpy ({})".format(
            numpy.__version__))
        import scipy
        outputText += self.getLine(' '*8, "scipy ({})".format(
            scipy.__version__))
        import matplotlib
        outputText += self.getLine(' '*8, "matplotlib ({})".format(
            matplotlib.__version__))
        import pyglet
        outputText += self.getLine(' '*8, "pyglet ({})".format(pyglet.version))
        try:
            import glfw
            outputText += self.getLine(' '*8, "PyGLFW ({})".format(
                glfw.__version__))
        except Exception:
            outputText += self.getLine(' '*8, 'PyGLFW [not installed]')

        # sound related
        try:
            import pyo
            outputText += self.getLine(
                ' '*8, "pyo", ('%i.%i.%i' % pyo.getVersion()))
        except Exception:
            outputText += self.getLine(' '*8, 'pyo [not installed]')
        try:
            import psychtoolbox
            outputText += self.getLine(' '*8, "psychtoolbox ({})".format(
                psychtoolbox._version.__version__))
        except Exception:
            outputText += self.getLine(' '*8, 'psychtoolbox [not installed]')

        # wxpython version
        try:
            import wx
            outputText += self.getLine(' '*8, "wxPython ({})".format(
                wx.__version__))
        except Exception:
            outputText += self.getLine(' '*8, 'wxPython [not installed]')

        # get OpenGL details
        win = visual.Window([100, 100])  # some drivers want a window open first

        outputText += self.getLine("\nOpenGL Info:")
        # # get info about the graphics card and drivers
        outputText += self.getLine(
            ' '*4, "Vendor:", gl_info.get_vendor())
        outputText += self.getLine(
            ' '*4, "Rendering engine:", gl_info.get_renderer())
        outputText += self.getLine(
            ' '*4, "OpenGL version:", gl_info.get_version())
        outputText += self.getLine(
            ' '*4, "Shaders supported: ", win._haveShaders)

        # get opengl extensions
        outputText += self.getLine(' '*4, "(Selected) Extensions:")
        extensionsOfInterest = [
            'GL_ARB_multitexture',
            'GL_EXT_framebuffer_object',
            'GL_ARB_fragment_program',
            'GL_ARB_shader_objects',
            'GL_ARB_vertex_shader',
            'GL_ARB_texture_non_power_of_two',
            'GL_ARB_texture_float',
            'GL_STEREO']

        for ext in extensionsOfInterest:
            outputText += self.getLine(
                ' '*8, ext + ':', bool(gl_info.have_extension(ext)))

        # also determine nVertices that can be used in vertex arrays
        maxVerts = GLint()
        glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
        outputText += self.getLine(
            ' '*4, 'max vertices in vertex array:', maxVerts.value)

        win.close()

        return outputText
Exemplo n.º 15
0
def driversOkay():
    """Returns True if drivers should be okay for PsychoPy"""
    return not 'microsoft' in gl_info.get_vendor().lower()
Exemplo n.º 16
0
import pyglet
print("pyglet", pyglet.version)
# pyo is a new dependency, for sound:
try:
    import pyo
    print("pyo", '%i.%i.%i' % pyo.getVersion())
except Exception:
    print('pyo [not installed]')

from psychopy import __version__
print("\nPsychoPy", __version__)

win = visual.Window([100, 100])  # some drivers want a window open first
print("have shaders:", win._haveShaders)
print("\nOpenGL info:")
# get info about the graphics card and drivers
print("vendor:", gl_info.get_vendor())
print("rendering engine:", gl_info.get_renderer())
print("OpenGL version:", gl_info.get_version())
print("(Selected) Extensions:")
extensionsOfInterest = ['GL_ARB_multitexture',
                        'GL_EXT_framebuffer_object', 'GL_ARB_fragment_program',
                        'GL_ARB_shader_objects', 'GL_ARB_vertex_shader',
                        'GL_ARB_texture_non_power_of_two', 'GL_ARB_texture_float', 'GL_STEREO']
for ext in extensionsOfInterest:
    print("\t", bool(gl_info.have_extension(ext)), ext)
# also determine nVertices that can be used in vertex arrays
maxVerts = GLint()
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
print('\tmax vertices in vertex array:', maxVerts.value)
Exemplo n.º 17
0
        return self.message

class DriverError(Exception):
    pass

class GLSLError(Exception):
    pass

def require_extension(ext):
    """Ensure that the given graphics extension is supported.

    """
    if not gl.gl_info.have_extension('GL_' + ext):
        raise HardwareSupportError("the %s extension" % ext)

hardware_info = {'vendor': gli.get_vendor(),
                 'renderer': gli.get_renderer(),
                 'version': gli.get_version()}

# Check hardware support

_opengl_version = hardware_info['version'].split(' ')[0]
if _opengl_version < "2.0":
    raise DriverError("This package requires OpenGL v2.0 or higher. "
                      "Your version is %s." % _opengl_version)

# This extension is required to return floats outside [0, 1]
# in gl_FragColor
require_extension('ARB_color_buffer_float')
require_extension('ARB_texture_float')
Exemplo n.º 18
0
def init_gui():
    global main_window, sched_queue, current_time, fps_limit

    config = pyglet.gl.Config(
        double_buffer=True,
        buffer_size=32,
        aux_buffers=0,
        sample_buffers=0,
        samples=0,
        red_size=8,
        green_size=8,
        blue_size=8,
        alpha_size=8,
        depth_size=0,
        stencil_size=0,
        accum_red_size=0,
        accum_green_size=0,
        accum_blue_size=0,
        accum_alpha_size=0,
    )

    from options import options
    z = options.zoom
    main_window = pyglet.window.Window(
        width=int(WINDOW_WIDTH * z), height=int(WINDOW_HEIGHT * z), caption=u'东方符斗祭',
        config=config, visible=False
    )
    sched_queue = []

    from pyglet.gl import gl_info
    vendor = gl_info.get_vendor().lower()
    if 'amd' in vendor or 'ati' in vendor:
        pyglet.options['graphics_vbo'] = False  # AMD: Do you have QA team for your OpenGL driver ????
        from pyglet.graphics import vertexbuffer
        assert not vertexbuffer._enable_vbo

    # custom font renderer
    from .font import AncientPixFont
    pyglet.font._font_class = AncientPixFont

    # main window setup {{
    glClearColor(1, 1, 1, 1)
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    # glEnable(GL_SCISSOR_TEST)
    glPolygonMode(GL_FRONT, GL_FILL)
    glPolygonMode(GL_BACK, GL_LINE)

    def_overlay = Overlay()
    def_overlay.name = 'Overlay'
    def_overlay.switch()
    # }} main window setup

    fps = pyglet.clock.ClockDisplay()
    fps_limit = 60
    delay = 1. / fps_limit
    current_time = time()

    @main_window.event
    def on_draw():
        global current_time
        current_time = time()
        Overlay.cur_overlay.draw()
        fps.draw()

    @main_window.event
    def on_close():
        # HACK: suppress exceptions,
        # dont want to explain....
        pyglet.clock.tick = lambda a: 0.0
        pyglet.app.exit()

    @hook(main_window)
    def on_key_press(ori, symbol, modifiers):
        if symbol == pyglet.window.key.ESCAPE:
            return pyglet.event.EVENT_HANDLED
        return ori(symbol, modifiers)

    def _dispatch_msg(dt):
        global sched_queue
        import gevent

        # give logics a chance to run
        gevent.sleep(0.001)

        if not sched_queue: return

        for func in sched_queue:
            func()

        sched_queue = []

    pyglet.clock.schedule_interval(_dispatch_msg, delay)
Exemplo n.º 19
0
def getSysInfo(win):
    from collections import OrderedDict
    # based on sysInfo.py
    from pyglet.gl import gl_info, GLint, glGetIntegerv, GL_MAX_ELEMENTS_VERTICES
    import sys, platform

    sys_info = OrderedDict()
    sys_info['OS'] = OrderedDict()
    sys_info['OS']['Name'] = platform.platform()
    if sys.platform == 'darwin':
        OSXver, _, architecture = platform.mac_ver()
        sys_info['OS']['OSX Version'] = OSXver
        sys_info['OS']['OSX Architecture'] = architecture

    sys_info['Computer Hardware'] = OrderedDict()
    try:
        import psutil

        def getMemoryInfo():
            rdict = dict()
            nt = psutil.virtual_memory()
            for name in nt._fields:
                value = getattr(nt, name)
                if name != 'percent':
                    value = bytes2human(value)
                rdict[name.capitalize()] = value  # '%s%s%-10s : %7s\n'%(rstr, '\t' * indent, name.capitalize(), value)
            return rdict

        core_count = psutil.cpu_count(logical=False)
        logical_psu_count = psutil.cpu_count()
        memory_info = getMemoryInfo()
        sys_info['Computer Hardware']['CPUs (cores / logical)'] = (core_count, logical_psu_count)
        sys_info['Computer Hardware']['System Memory'] = memory_info

    except Exception:
        sys_info['Computer Hardware']['Failed'] = 'psutil 2.x + is required.'

    sys_info['Python'] = OrderedDict()
    sys_info['Python']['exe'] = sys.executable
    sys_info['Python']['version'] = sys.version

    sys_info['Packages'] = OrderedDict()
    try:
        import numpy
        sys_info['Packages']['numpy'] = numpy.__version__
    except ImportError:
        sys_info['Packages']['numpy'] = "Not Installed"
    try:
        import pyglet
        sys_info['Packages']['pyglet'] = pyglet.version
    except ImportError:
        sys_info['Packages']['pyglet'] = "Not Installed"
    try:
        import cv2
        sys_info['Packages']['cv2'] = cv2.__version__
    except ImportError:
        sys_info['Packages']['cv2'] = "Not Installed"
    try:
        import psychopy
        sys_info['Packages']['PsychoPy'] = psychopy.__version__
    except ImportError:
        sys_info['Packages']['PsychoPy'] = "Not Installed"

    sys_info['Graphics'] = OrderedDict()
    sys_info['Graphics']['shaders'] = win._haveShaders
    sys_info['Graphics']['opengl'] = OrderedDict()
    sys_info['Graphics']['opengl']['version'] = gl_info.get_version()
    sys_info['Graphics']['opengl']['vendor'] = gl_info.get_vendor()
    sys_info['Graphics']['opengl']['engine'] = gl_info.get_renderer()
    maxVerts = GLint()
    glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
    sys_info['Graphics']['opengl']['Max vert in VA'] = maxVerts.value
    sys_info['Graphics']['opengl']['extensions'] = OrderedDict()
    extensionsOfInterest = ['GL_ARB_multitexture',
                            'GL_EXT_framebuffer_object', 'GL_ARB_fragment_program',
                            'GL_ARB_shader_objects', 'GL_ARB_vertex_shader',
                            'GL_ARB_texture_non_power_of_two', 'GL_ARB_texture_float', 'GL_STEREO']
    for ext in extensionsOfInterest:
        sys_info['Graphics']['opengl']['extensions'][ext] = bool(gl_info.have_extension(ext))

    sys_info['Processes'] = OrderedDict()
    if sys.platform == 'darwin':
        sys_info['Processes']['Failed'] = 'Not Supported on OSX.'
    elif SAVE_PER_PROCESS_DATA:
        try:
            import psutil

            for proc in psutil.process_iter():
                pkey = proc.pid
                vattrs = ['name', 'exe', 'ppid', 'num_threads', 'memory_percent', 'cpu_percent', 'cpu_affinity', 'nice',
                          'num_ctx_switches']
                procinfo = proc.as_dict(attrs=vattrs, ad_value=u"Access Denied")
                if procinfo['exe'] is not u"Access Denied" and (SAVE_PER_PROCESS_DATA is True or SAVE_PER_PROCESS_DATA == procinfo['name']):
                    sys_info['Processes'][pkey] = procinfo
        except ImportError:
            sys_info['Processes']['Failed'] = 'psutil 2.x + is required.'
    else:
        sys_info['Processes']['Disabled'] = 'Per Process details disabled by user.'

    return sys_info
Exemplo n.º 20
0
display = platform.get_default_display()
print 'Display instance is %r' % display
print 'Screens:'
for screen in display.get_screens():
    print '  %r' % screen

print 'Creating default context...'
w = pyglet.window.Window(1, 1, visible=True)

print 'GL attributes:'
attrs = w.config.get_gl_attributes()
attrs = ' '.join(['%s=%s'%(name, value) for name, value in attrs])
print '\n'.join(textwrap.wrap(attrs))

print 'GL version:', gl_info.get_version()
print 'GL vendor:', gl_info.get_vendor()
print 'GL renderer:', gl_info.get_renderer()
print 'GL extensions:'
exts = ' '.join(gl_info.get_extensions())
print ' ', '\n  '.join(textwrap.wrap(exts))

print 'GLU version:', glu_info.get_version()
print 'GLU extensions:'
exts = ' '.join(glu_info.get_extensions())
print ' ', '\n  '.join(textwrap.wrap(exts))

print

context = w.context
print 'Context is', context
Exemplo n.º 21
0
def driversOkay():
    """Returns True if drivers should be okay for PsychoPy"""
    return not "microsoft" in gl_info.get_vendor().lower()
Exemplo n.º 22
0
def main():
    macos = sys.platform == 'darwin'

    parser = argparse.ArgumentParser(prog='punyverse', description='''
            Python simulator of a puny universe.
        ''')
    parser.set_defaults(sky=not macos)
    parser.add_argument('-D', '--debug', help='Enable pyglet OpenGL debugging', action='store_true')
    parser.add_argument('-d', '--high-depth', help='Use a larger depth buffer',
                        const=32, default=24, dest='depth', nargs='?', type=int)
    parser.add_argument('-m', '--multisample', help='Use multisampled image, optional samples',
                        const=2, default=0, nargs='?', type=int)
    parser.add_argument('-v', '--no-vsync', help='Disables vsync',
                        action='store_false', dest='vsync')
    parser.add_argument('-n', '--normal', help='Enables the use of normal maps',
                        action='store_true')
    parser.add_argument('-s', '--sky', help='Enables the sky', dest='sky',
                        action='store_true')
    parser.add_argument('-S', '--no-sky', help='Disables the sky', dest='sky',
                        action='store_false')
    args = parser.parse_args()

    versioning = dict(major_version=3, minor_version=3)
    pyglet.options['debug_gl'] = args.debug
    if macos:
        pyglet.options['shadow_window'] = False
        versioning = dict(major_version=4, minor_version=1, forward_compatible=True)

    template = pyglet.gl.Config(depth_size=args.depth, double_buffer=True,
                                sample_buffers=args.multisample > 1,
                                samples=args.multisample, **versioning)

    platform = pyglet.window.get_platform()
    display = platform.get_default_display()
    screen = display.get_default_screen()
    try:
        config = screen.get_best_config(template)
    except pyglet.window.NoSuchConfigException:
        raise SystemExit('Graphics configuration not supported.')

    create_args = dict(width=INITIAL_WIN_WIDTH, height=INITIAL_WIN_HEIGHT,
                       caption='Punyverse', resizable=True, vsync=args.vsync, visible=False)

    from pyglet.gl import gl_info

    from punyverse.loader import LoaderWindow, LoaderConsole
    from punyverse.ui import Punyverse

    if pyglet.compat_platform in ('win32', 'cygwin') and gl_info.get_vendor() == 'Intel':
        # pyglet has some code that tries to create without ARB on Intel.
        # Of course, all that achieves is the message that you can't create OpenGL 3 contexts.
        # So we force create an ARB context.
        from pyglet.gl.win32 import Win32ARBContext
        context = Win32ARBContext(config, None)

        # We use the console loader since using the GUI loader makes all sorts of wonderful things happen on Intel:
        # Access violations, mouse events going nowhere, you name it.
        loader = LoaderConsole()
        punyverse = Punyverse(context=context, **create_args)
    else:
        context = config.create_context(None)
        loader = LoaderWindow(width=INITIAL_WIN_WIDTH, height=INITIAL_WIN_HEIGHT,
                              caption='Punyverse is loading...')
        punyverse = Punyverse(context=context, **create_args)
        loader.context.set_current()

    loader.set_main_context(punyverse.context)
    world = loader.load(sky=args.sky)
    punyverse.context.set_current()
    punyverse.initialize(world)
    loader.close()
    punyverse.set_visible(True)
    pyglet.app.run()
Exemplo n.º 23
0
def driversOkay():
    """Returns True if drivers should be okay for PsychoPy"""
    return gl_info.get_vendor().lower().find('microsoft') == -1
Exemplo n.º 24
0
def getSysInfo(win):
    try:
        from collections import OrderedDict
    except Exception:
        from psychopy.iohub import OrderedDict
    # based on sysInfo.py
    from pyglet.gl import gl_info, GLint, glGetIntegerv, GL_MAX_ELEMENTS_VERTICES
    import sys, platform

    sys_info = OrderedDict()
    sys_info['OS'] = OrderedDict()
    sys_info['OS']['Name'] = platform.platform()
    if sys.platform == 'darwin':
        OSXver, _, architecture = platform.mac_ver()
        sys_info['OS']['OSX Version'] = OSXver
        sys_info['OS']['OSX Architecture'] = architecture

    sys_info['Computer Hardware'] = OrderedDict()
    try:
        import psutil

        def getMemoryInfo():
            rdict = dict()
            nt = psutil.virtual_memory()
            for name in nt._fields:
                value = getattr(nt, name)
                if name != 'percent':
                    value = bytes2human(value)
                rdict[name.capitalize(
                )] = value  # '%s%s%-10s : %7s\n'%(rstr, '\t' * indent, name.capitalize(), value)
            return rdict

        core_count = psutil.cpu_count(logical=False)
        logical_psu_count = psutil.cpu_count()
        memory_info = getMemoryInfo()
        sys_info['Computer Hardware']['CPUs (cores / logical)'] = (
            core_count, logical_psu_count)
        sys_info['Computer Hardware']['System Memory'] = memory_info

    except Exception:
        sys_info['Computer Hardware']['Failed'] = 'psutil 2.x + is required.'

    sys_info['Python'] = OrderedDict()
    sys_info['Python']['exe'] = sys.executable
    sys_info['Python']['version'] = sys.version

    sys_info['Packages'] = OrderedDict()
    try:
        import numpy
        sys_info['Packages']['numpy'] = numpy.__version__
    except ImportError:
        sys_info['Packages']['numpy'] = "Not Installed"
    try:
        import pyglet
        sys_info['Packages']['pyglet'] = pyglet.version
    except ImportError:
        sys_info['Packages']['pyglet'] = "Not Installed"
    try:
        import cv2
        sys_info['Packages']['cv2'] = cv2.__version__
    except ImportError:
        sys_info['Packages']['cv2'] = "Not Installed"
    try:
        import psychopy
        sys_info['Packages']['PsychoPy'] = psychopy.__version__
    except ImportError:
        sys_info['Packages']['PsychoPy'] = "Not Installed"

    sys_info['Graphics'] = OrderedDict()
    sys_info['Graphics']['shaders'] = win._haveShaders
    sys_info['Graphics']['opengl'] = OrderedDict()
    sys_info['Graphics']['opengl']['version'] = gl_info.get_version()
    sys_info['Graphics']['opengl']['vendor'] = gl_info.get_vendor()
    sys_info['Graphics']['opengl']['engine'] = gl_info.get_renderer()
    maxVerts = GLint()
    glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, maxVerts)
    sys_info['Graphics']['opengl']['Max vert in VA'] = maxVerts.value
    sys_info['Graphics']['opengl']['extensions'] = OrderedDict()
    extensionsOfInterest = [
        'GL_ARB_multitexture', 'GL_EXT_framebuffer_object',
        'GL_ARB_fragment_program', 'GL_ARB_shader_objects',
        'GL_ARB_vertex_shader', 'GL_ARB_texture_non_power_of_two',
        'GL_ARB_texture_float', 'GL_STEREO'
    ]
    for ext in extensionsOfInterest:
        sys_info['Graphics']['opengl']['extensions'][ext] = bool(
            gl_info.have_extension(ext))

    sys_info['Processes'] = OrderedDict()
    if sys.platform == 'darwin':
        sys_info['Processes']['Failed'] = 'Not Supported on OSX.'
    elif SAVE_PER_PROCESS_DATA:
        try:
            import psutil

            for proc in psutil.process_iter():
                pkey = proc.pid
                vattrs = [
                    'name', 'exe', 'ppid', 'num_threads', 'memory_percent',
                    'cpu_percent', 'cpu_affinity', 'nice', 'num_ctx_switches'
                ]
                procinfo = proc.as_dict(attrs=vattrs,
                                        ad_value=u"Access Denied")
                if procinfo['exe'] is not u"Access Denied" and (
                        SAVE_PER_PROCESS_DATA is True
                        or SAVE_PER_PROCESS_DATA == procinfo['name']):
                    sys_info['Processes'][pkey] = procinfo
        except ImportError:
            sys_info['Processes']['Failed'] = 'psutil 2.x + is required.'
    else:
        sys_info['Processes'][
            'Disabled'] = 'Per Process details disabled by user.'

    return sys_info
Exemplo n.º 25
0
for screen in display.get_screens():
    print('  %r' % screen)

print()
print('Creating default context...')
w = pyglet.window.Window(1, 1, visible=True)
print('Window:')
print('  %s' % w)

print('GL attributes:')
attrs = w.config.get_gl_attributes()
attrs = ' '.join(['%s=%s' % (name, value) for name, value in attrs])
print(' ', '\n  '.join(textwrap.wrap(attrs)))

print('GL version:', gl_info.get_version())
print('GL vendor:', gl_info.get_vendor())
print('GL renderer:', gl_info.get_renderer())
print('GL extensions:')
exts = ' '.join(gl_info.get_extensions())
print(' ', '\n  '.join(textwrap.wrap(exts)))

print()

context = w.context
print('Context is', context)

if "xlib" in globals() and isinstance(context, xlib.BaseXlibContext):
    from pyglet.gl import glx_info
    print('GLX %s direct' % (context.is_direct() and 'is' or 'is not'))
    if not glx_info.have_version(1, 1):
        print("GLX server version: 1.0")