home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / lib / site-packages / OpenGL / GLE / exceptional.py < prev   
Encoding:
Python Source  |  2008-12-07  |  1.5 KB  |  44 lines

  1. """GLE exceptional functions (specialised signatures"""
  2. from OpenGL.raw import GLE as raw
  3. from OpenGL.raw.GLE import annotations as simple
  4.  
  5. from OpenGL import wrapper, arrays
  6.  
  7. class _lengthOfArgname( object ):
  8.     """Calculates the length of a given argname over a divisor value"""
  9.     def __init__( self, arrayName, divisor, arrayType = arrays.GLdoubleArray ):
  10.         self.arrayName = arrayName
  11.         self.divisor = divisor
  12.         self.arrayType = arrayType
  13.     def finalise( self, wrapper ):
  14.         self.arrayIndex = wrapper.pyArgIndex( self.arrayName )
  15.     def __call__( self, pyArgs, index, wrappedOperation ):
  16.         """Get the length of pyArgs[2], a glDoubleArray"""
  17.         return self.arrayType.arraySize( pyArgs[self.arrayIndex] )//self.divisor
  18. def _baseWrap( base, lengthName='ncp', contourName='contour', divisor=2 ):
  19.     """Do the basic wrapping operation for a GLE function"""
  20.     return wrapper.wrapper( base ).setPyConverter(
  21.         lengthName,
  22.     ).setCConverter(
  23.         lengthName, _lengthOfArgname( contourName, divisor, arrays.GLdoubleArray ),
  24.     )
  25.  
  26. gleLathe = _baseWrap( simple.gleLathe )
  27. glePolyCone = _baseWrap( simple.glePolyCone, 'npoints', 'point_array', 3)
  28. glePolyCylinder = _baseWrap( simple.glePolyCylinder, 'npoints', 'point_array', 3)
  29. gleScrew = _baseWrap( simple.gleScrew )
  30. gleSpiral = _baseWrap( simple.gleSpiral )
  31.  
  32. gleExtrusion = _baseWrap( 
  33.     _baseWrap( simple.gleExtrusion ),
  34.     'npoints', 'point_array', 3
  35. )
  36. gleSuperExtrusion = _baseWrap( 
  37.     _baseWrap( simple.gleSuperExtrusion ),
  38.     'npoints', 'point_array', 3
  39. )
  40. gleTwistExtrusion = _baseWrap( 
  41.     _baseWrap( simple.gleTwistExtrusion ),
  42.     'npoints', 'point_array', 3
  43. )
  44.