def loadPlugin(cls, entrypoint): """Load a single entry-point via plugins module""" if not entrypoint.loaded: try: plugin_class = entrypoint.load() except ImportError, err: from OpenGL import logs log = logs.getLog('OpenGL.formathandler') log.warn( 'Unable to load registered array format handler %s:\n%s', entrypoint.name, log.getException(err)) print log.getException(err) else: handler = plugin_class() handler.register(handler.HANDLED_TYPES) cls.HANDLER_REGISTRY[entrypoint.name] = handler if handler.isOutput: cls.ALL_OUTPUT_HANDLERS.append(handler) entrypoint.loaded = True
def loadPlugin( cls, entrypoint ): """Load a single entry-point via plugins module""" if not entrypoint.loaded: try: plugin_class = entrypoint.load() except ImportError, err: from OpenGL import logs log = logs.getLog( 'OpenGL.formathandler' ) log.warn( 'Unable to load registered array format handler %s:\n%s', entrypoint.name, log.getException( err ) ) print log.getException( err ) else: handler = plugin_class() handler.register( handler.HANDLED_TYPES ) cls.HANDLER_REGISTRY[ entrypoint.name ] = handler if handler.isOutput: cls.ALL_OUTPUT_HANDLERS.append( handler ) entrypoint.loaded = True
def loadPlugin(cls, entrypoint): """Load a single entry-point via plugins module""" if not entrypoint.loaded: from OpenGL.arrays.arraydatatype import ArrayDatatype try: plugin_class = entrypoint.load() except ImportError, err: from OpenGL import logs, WARN_ON_FORMAT_UNAVAILABLE log = logs.getLog('OpenGL.formathandler') if WARN_ON_FORMAT_UNAVAILABLE: logFunc = log.warn else: logFunc = log.info logFunc( 'Unable to load registered array format handler %s:\n%s', entrypoint.name, log.getException(err)) else: handler = plugin_class() handler.register(handler.HANDLED_TYPES) ArrayDatatype.getRegistry()[entrypoint.name] = handler entrypoint.loaded = True
def loadPlugin( cls, entrypoint ): """Load a single entry-point via plugins module""" if not entrypoint.loaded: from OpenGL.arrays.arraydatatype import ArrayDatatype try: plugin_class = entrypoint.load() except ImportError, err: from OpenGL import logs,WARN_ON_FORMAT_UNAVAILABLE log = logs.getLog( 'OpenGL.formathandler' ) if WARN_ON_FORMAT_UNAVAILABLE: logFunc = log.warn else: logFunc = log.info logFunc( 'Unable to load registered array format handler %s:\n%s', entrypoint.name, log.getException( err ) ) else: handler = plugin_class() handler.register( handler.HANDLED_TYPES ) ArrayDatatype.getRegistry()[ entrypoint.name ] = handler entrypoint.loaded = True
def wrapLogging(self, func): """Wrap function with logging operations if appropriate""" return logs.logOnFail(func, logs.getLog('OpenGL.errors'))
"""Array data-type implementations (abstraction points for GL array types""" import ctypes import OpenGL from OpenGL import constants, plugins from OpenGL.arrays import formathandler from OpenGL import logs log = logs.getLog( 'OpenGL.arrays.arraydatatype' ) from OpenGL import acceleratesupport ADT = None if acceleratesupport.ACCELERATE_AVAILABLE: try: from OpenGL_accelerate.arraydatatype import ArrayDatatype as ADT except ImportError, err: log.warn( "Unable to load ArrayDatatype accelerator from OpenGL_accelerate" ) if ADT is None: # Python-coded version class HandlerRegistry( dict ): GENERIC_OUTPUT_PREFERENCES = ['numpy','numeric','ctypesarrays'] def __init__( self, plugin_match ): self.match = plugin_match self.output_handler = None self.preferredOutput = None self.all_output_handlers = [] def __call__( self, value ): """Lookup of handler for given value""" try: typ = value.__class__
being triggered. I.e. if you create a GLUT program that doesn't explicitly call exit and doesn't call display or the like in a timer then your app will hang on exit on Win32. XXX the platform-specific stuff should be getting done in the platform module *not* in the module here! """ from OpenGL.platform import GLUT, CurrentContextIsValid, GLUT_GUARD_CALLBACKS from OpenGL import contextdata, error, platform, logs from OpenGL.raw import GLUT as simple from OpenGL._bytes import bytes, _NULL_8_BYTE, as_8_bit import ctypes, os, sys, traceback PLATFORM = platform.PLATFORM FUNCTION_TYPE = simple.CALLBACK_FUNCTION_TYPE log = logs.getLog( 'OpenGL.GLUT.special' ) if os.name == "nt": log.info( """Using NT-specific GLUT calls with exit callbacks""" ) _exitfunctype = FUNCTION_TYPE( None, ctypes.c_int ) __glutInitWithExit = platform.createBaseFunction( '__glutInitWithExit', dll=platform.GLUT, resultType=None, argTypes=[ctypes.POINTER(ctypes.c_int),ctypes.POINTER(ctypes.c_char_p),_exitfunctype], doc='glutInit( POINTER(c_int)(pargc), POINTER(STRING)(argv) ) -> None', argNames=('pargc', 'argv'), ) __glutCreateWindowWithExit = platform.createBaseFunction( '__glutCreateWindowWithExit', dll=platform.GLUT, resultType=ctypes.c_int, argTypes=[ctypes.c_char_p,_exitfunctype], doc='glutCreateWindow( STRING(title) ) -> c_int', argNames=('title',),
def wrapLogging( self, func ): """Wrap function with logging operations if appropriate""" return logs.logOnFail( func, logs.getLog( 'OpenGL.errors' ))
"""Array data-type implementations (abstraction points for GL array types""" import ctypes import OpenGL assert OpenGL from OpenGL.raw.GL import _types from OpenGL import plugins from OpenGL.arrays import formathandler, _arrayconstants as GL_1_1 from OpenGL import logs _log = logs.getLog("OpenGL.arrays.arraydatatype") try: unicode except NameError: unicode = str from OpenGL import acceleratesupport ADT = None if acceleratesupport.ACCELERATE_AVAILABLE: try: from OpenGL_accelerate.arraydatatype import ArrayDatatype as ADT except ImportError as err: _log.warning( "Unable to load ArrayDatatype accelerator from OpenGL_accelerate") if ADT is None: # Python-coded version class HandlerRegistry(dict): GENERIC_OUTPUT_PREFERENCES = ["numpy", "ctypesarrays"] def __init__(self, plugin_match): self.match = plugin_match self.output_handler = None self.preferredOutput = None
then your app will hang on exit on Win32. XXX the platform-specific stuff should be getting done in the platform module *not* in the module here! """ from OpenGL.platform import CurrentContextIsValid, GLUT_GUARD_CALLBACKS, PLATFORM GLUT = PLATFORM.GLUT from OpenGL import contextdata, error, platform, logs from OpenGL.raw import GLUT as _simple from OpenGL._bytes import bytes, unicode,as_8_bit import ctypes, os, sys, traceback PLATFORM = platform.PLATFORM FUNCTION_TYPE = _simple.CALLBACK_FUNCTION_TYPE from OpenGL._bytes import long, integer_types _log = logs.getLog("OpenGL.GLUT.special") if os.name == "nt": _log.info("""Using NT-specific GLUT calls with exit callbacks""") _exitfunctype = FUNCTION_TYPE(None, ctypes.c_int) __glutInitWithExit = platform.createBaseFunction( "__glutInitWithExit", dll=platform.PLATFORM.GLUT, resultType=None, argTypes=[ctypes.POINTER(ctypes.c_int),ctypes.POINTER(ctypes.c_char_p),_exitfunctype], doc="glutInit(POINTER(c_int)(pargc), POINTER(STRING)(argv)) -> None", argNames=("pargc", "argv"), ) __glutCreateWindowWithExit = platform.createBaseFunction( "__glutCreateWindowWithExit", dll=platform.PLATFORM.GLUT, resultType=ctypes.c_int, argTypes=[ctypes.c_char_p,_exitfunctype], doc="glutCreateWindow(STRING(title)) -> c_int", argNames=("title",),