xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #147: gl-frozen-path.patch

File gl-frozen-path.patch, 2.7 KB (added by Antoine Martin, 9 years ago)

if we do manage to get opengl working on win32, this deals with opengl libraries located in the frozen path

  • src/xpra/gl_client_window.py

    ### Eclipse Workspace Patch 1.0
    #P Xpra
     
    1313import gtk.gdkgl, gtk.gtkgl         #@UnresolvedImport
    1414assert gtk.gdkgl is not None and gtk.gtkgl is not None
    1515
    16 from OpenGL.GL import GL_VERSION, glGetString
    17 from OpenGL.GL.ARB.fragment_program import glInitFragmentProgramARB
    18 
    1916#sanity checks: OpenGL version
    2017try:
    2118    from gtk import gdk
    22     glconfig = gtk.gdkgl.Config(mode=gtk.gdkgl.MODE_RGB|gtk.gdkgl.MODE_SINGLE)
    23     glext = gtk.gdkgl.ext(gdk.Pixmap(gdk.get_default_root_window(), 1, 1))
    24     gldrawable = glext.set_gl_capability(glconfig)
     19    #trick to get py2exe to include what we need:
     20    import sys
     21    if sys.platform.startswith("win"):
     22        log("has frozen: %s" % hasattr( sys, "frozen" ))
     23        if hasattr( sys, "frozen" ):
     24            log("frozen: %s" % sys.frozen)
     25            if sys.frozen in ("windows_exe", "console_exe"):
     26                import os
     27                main_dir = os.path.dirname( unicode( sys.executable, sys.getfilesystemencoding() ) )
     28                log("main_dir=%s" % main_dir)
     29                sys.path.insert( 0, main_dir )
     30                os.chdir( main_dir )
     31            else:
     32                sys.path.insert(0, ".")
     33        from ctypes import util             #@UnusedImport
     34        log("ctypes loaded")
     35        from OpenGL.platform import win32   #@UnusedImport
     36        log("OpenGL.platform loaded")
     37        from OpenGL.GL import GL_VERSION
     38        log("GL_VERSION=%s" % str(GL_VERSION))
     39
     40    log("loading OpenGL.GL")
     41    from OpenGL.GL import GL_VERSION, glGetString
     42    from OpenGL.GL.ARB.fragment_program import glInitFragmentProgramARB
     43
     44    glconfig = gtk.gdkgl.Config(mode=gtk.gdkgl.MODE_RGB | gtk.gdkgl.MODE_DOUBLE | gtk.gdkgl.MODE_DEPTH)
     45    log("glconfig=%s" % glconfig)
     46    pixmap = gdk.Pixmap(gdk.get_default_root_window(), 1, 1)
     47    gldrawable = gtk.gdkgl.Pixmap(glconfig, pixmap)
     48    log("gldrawable=%s" % gldrawable)
     49    glext = gtk.gdkgl.ext(pixmap)
     50    log("glext=%s" % glext)
     51    log("set_gl_capability=%s" % glext.set_gl_capability(glconfig))
     52    if gldrawable is None:
     53        raise ImportError("failed to initialize")
    2554    glcontext = gtk.gdkgl.Context(gldrawable, direct=True)
    2655    if not gldrawable.gl_begin(glcontext):
    2756        raise ImportError("gl_begin failed on %s" % gldrawable)
     
    3968        gldrawable.gl_end()
    4069        del glcontext, gldrawable, glext, glconfig
    4170except Exception, e:
     71    log.error("error: %s" % e, exc_info=True)
    4272    raise ImportError("** OpenGL initialization error: %s" % e)
    4373
    4474