Skip to content

Commit

Permalink
Enable OpenGL by default.
Browse files Browse the repository at this point in the history
Use a fake 1x1 window to be able to initialize opengl and get to the version number, also check for glInitFragmentProgramARB.
And if, for whatever reason, we decide not to load the OpenGL code, log why.

git-svn-id: https://xpra.org/svn/Xpra/trunk@929 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 17, 2012
1 parent 2e70a39 commit fa43fc6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/xpra/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def set_windows_cursor(gtkwindows, new_cursor):

from xpra.client_window import ClientWindow
ClientWindowClass = ClientWindow
#the GL backend only works with gtk2 (and is disabled by default)
USE_OPENGL = False
#the GL backend only works with gtk2
USE_OPENGL = True
if USE_OPENGL and not is_gtk3():
try:
from xpra.gl_client_window import GLClientWindow
ClientWindowClass = GLClientWindow
except ImportError, e:
pass #GL not available
log.info("Disabled OpenGL output: %s" % e)

def nn(x):
if x is None:
Expand Down
31 changes: 25 additions & 6 deletions src/xpra/gl_client_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,33 @@
glDrawArrays, glMultiTexCoord2i, \
glVertex2i, glEnd
from OpenGL.GL.ARB.vertex_program import glGenProgramsARB, glBindProgramARB, glProgramStringARB
from OpenGL.GL.ARB.fragment_program import glInitFragmentProgramARB
from xpra.gl_colorspace_conversions import GL_COLORSPACE_CONVERSIONS

#This check would be nice to have,
#but crashes python on some intel chipsets.. so we can't have it.
#gl_major = glGetString(GL_VERSION)[0]
#gl_minor = glGetString(GL_VERSION)[2]
#if gl_major<=1 and gl_minor<1:
# raise ImportError("** OpenGL output requires OpenGL version 1.1 or greater, not %s.%s" % (gl_major, gl_minor))
#sanity checks: OpenGL version
try:
from gtk import gdk
glconfig = gtk.gdkgl.Config(mode=gtk.gdkgl.MODE_RGB|gtk.gdkgl.MODE_SINGLE)
glext = gtk.gdkgl.ext(gdk.Pixmap(gdk.get_default_root_window(), 1, 1))
gldrawable = glext.set_gl_capability(glconfig)
glcontext = gtk.gdkgl.Context(gldrawable, direct=True)
if not gldrawable.gl_begin(glcontext):
raise ImportError("gl_begin failed on %s" % gldrawable)
try:
gl_major = int(glGetString(GL_VERSION)[0])
gl_minor = int(glGetString(GL_VERSION)[2])
if gl_major<=1 and gl_minor<1:
raise ImportError("** OpenGL output requires OpenGL version 1.1 or greater, not %s.%s" % (gl_major, gl_minor))
log.info("found valid OpenGL: %s.%s", gl_major, gl_minor)

if not glInitFragmentProgramARB():
#see http://www.opengl.org/registry/specs/ARB/fragment_program.txt
raise ImportError("** OpenGL output requires the ARB_fragment_program extension")
finally:
gldrawable.gl_end()
del glcontext, gldrawable, glext, glconfig
except Exception, e:
raise ImportError("** OpenGL initialization error: %s" % e)


class GLClientWindow(ClientWindow):
Expand Down

0 comments on commit fa43fc6

Please sign in to comment.