~ubuntu-branches/ubuntu/vivid/debtags/vivid

« back to all changes in this revision

Viewing changes to debtagshw/opengl.py

  • Committer: Package Import Robot
  • Author(s): Enrico Zini, Michael Vogt, Enrico Zini
  • Date: 2013-10-25 12:41:25 UTC
  • Revision ID: package-import@ubuntu.com-20131025124125-ytl4xarlmdyiuzjb
Tags: 1.12
[ Michael Vogt ]
* Install files in python3-debtagshw

[ Enrico Zini ]
* Build with new wibble

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# along with this program; if not, write to the Free Software
20
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
21
 
 
22
from __future__ import print_function
 
23
 
22
24
import logging
23
25
import multiprocessing
24
26
import os
 
27
import sys
25
28
 
26
29
LOG=logging.getLogger(__name__)
27
30
 
56
59
    GLX_VERSION=2
57
60
    GLX_EXTENSIONS=3
58
61
 
59
 
    # for the visinfo 
 
62
    # for the visinfo
60
63
    GLX_RGBA = 4
61
64
    GLX_RED_SIZE = 8
62
65
    GLX_GREEN_SIZE = 9
122
125
            visinfo = glx.glXChooseVisual(display, 0, attribDouble)
123
126
        if not visinfo:
124
127
            raise OpenGLError("Can not get visinfo")
125
 
        # create context etc 
 
128
        # create context etc
126
129
        context = glx.glXCreateContext (display, visinfo, None, self.direct)
127
130
        if not context:
128
131
            raise OpenGLError("Can not create glx context")
130
133
        glx.glXMakeCurrent(display, root, context)
131
134
        # and get the actual useful gl data
132
135
        glx.glGetString.restype = c_char_p
133
 
        vendor = glx.glGetString(self.GL_VENDOR)
134
 
        renderer = glx.glGetString(self.GL_RENDERER)
135
 
        version = glx.glGetString(self.GL_VERSION)
136
 
        extensions = glx.glGetString(self.GL_EXTENSIONS)
137
 
        LOG.info("gl vendor: %s" % vendor)
138
 
        LOG.info("gl renderer: %s" % renderer)
139
 
        LOG.info("gl version: %s" % version)
140
 
        LOG.debug("gl extenstions: %s" % extensions)
141
 
        return vendor, renderer, version
 
136
 
 
137
        opengl_tuple = []
 
138
        for gl_item in ["vendor", "renderer", "version", "extensions"]:
 
139
            gl_hex = getattr(self, "GL_%s" % gl_item.upper())
 
140
            gl_string = glx.glGetString(gl_hex)
 
141
            if sys.version > '3':
 
142
                gl_string = gl_string.decode()
 
143
            if gl_item == "extensions":
 
144
                LOG.debug("gl %s: %s" % (gl_item, gl_string))
 
145
            else:
 
146
                LOG.info("gl %s: %s" % (gl_item, gl_string))
 
147
            opengl_tuple.append(gl_string)
 
148
        return opengl_tuple[:3]
142
149
 
143
150
    def opengl_driver(self):
144
151
        vendor, renderer, version = self._get_opengl_vendor_renderer_version_tuple()
171
178
 
172
179
 
173
180
# private helpers
174
 
   
 
181
 
175
182
def _apply_in_multiprocessing_pool(func):
176
183
    """ private helper to run the given func in a multiprocessing env
177
184
        to protect against segfaults in the ctypes code """
231
238
        return _apply_in_multiprocessing_pool(_do_get_version)
232
239
    except OSError:
233
240
        return None
234
 
    
 
241
 
235
242
if __name__ == "__main__":
236
243
    logging.basicConfig(level=logging.INFO)
237
244
    supported = run_check()
238
245
    driver = get_driver()
239
246
    version = get_version()
240
 
    print "opengl_supported: ", supported
241
 
    print "opengl_driver: ", driver
242
 
    print "opengl_version: ", version
243
 
 
 
247
    print("opengl_supported: ", supported)
 
248
    print("opengl_driver: ", driver)
 
249
    print("opengl_version: ", version)