File: _lookupint.py

package info (click to toggle)
pyopengl 3.1.6%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,732 kB
  • sloc: python: 106,016; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Integer values looked up via glGetIntegerv( constant )"""
import ctypes
_get = None
_get_float = None

class LookupInt( object ):
    def __init__( self, lookup, format=ctypes.c_int, calculation=None ):
        self.lookup = lookup 
        self.format = format
        self.calculation = calculation
    def __int__( self ):
        global _get
        if _get is None:
            from OpenGL.GL import glGetIntegerv
            _get = glGetIntegerv
        output = self.format()
        _get( self.lookup, output )
        if self.calculation:
            return self.calculation( output.value )
        return output.value
    __long__ = __int__
    def __eq__( self, other ):
        return int(self) == other
    def __cmp__( self, other ):
        return cmp( int(self), other )
    def __str__(self):
        return str(int(self))
    __repr__ = __str__