本文整理汇总了Python中OpenGL.arrays.arraydatatype.ArrayDatatype.getRegistry方法的典型用法代码示例。如果您正苦于以下问题:Python ArrayDatatype.getRegistry方法的具体用法?Python ArrayDatatype.getRegistry怎么用?Python ArrayDatatype.getRegistry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL.arrays.arraydatatype.ArrayDatatype
的用法示例。
在下文中一共展示了ArrayDatatype.getRegistry方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: typeLookup
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
def typeLookup( cls, type ):
"""Lookup handler by data-type"""
registry = ArrayDatatype.getRegistry()
try:
return registry[ type ]
except KeyError as err:
key = '%s.%s'%(type.__module__,type.__name__)
plugin = cls.LAZY_TYPE_REGISTRY.get( key )
if plugin:
cls.loadPlugin( plugin )
return registry[ type ]
raise KeyError( """Unable to find data-format handler for %s"""%( type,))
示例2: loadPlugin
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
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
示例3: do_check_GL_support
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
def do_check_GL_support(force_enable):
props = {}
try:
#log redirection:
def redirect_log(logger_name):
logger = logging.getLogger(logger_name)
assert logger is not None
logger.saved_handlers = logger.handlers
logger.saved_propagate = logger.propagate
logger.handlers = [CaptureHandler()]
logger.propagate = 0
return logger
fhlogger = redirect_log('OpenGL.formathandler')
elogger = redirect_log('OpenGL.extensions')
alogger = redirect_log('OpenGL.acceleratesupport')
arlogger = redirect_log('OpenGL.arrays')
clogger = redirect_log('OpenGL.converters')
import OpenGL
props["pyopengl"] = OpenGL.__version__
from OpenGL.GL import GL_VERSION, GL_EXTENSIONS
from OpenGL.GL import glGetString, glGetInteger, glGetIntegerv
gl_version_str = glGetString(GL_VERSION)
if gl_version_str is None:
gl_check_error("OpenGL version is missing - cannot continue")
return {}
gl_major = int(gl_version_str[0])
gl_minor = int(gl_version_str[2])
props["opengl"] = gl_major, gl_minor
MIN_VERSION = (1,1)
if (gl_major, gl_minor) < MIN_VERSION:
gl_check_error("OpenGL output requires version %s or greater, not %s.%s" %
(".".join([str(x) for x in MIN_VERSION]), gl_major, gl_minor))
else:
log("found valid OpenGL version: %s.%s", gl_major, gl_minor)
from OpenGL import version as OpenGL_version
pyopengl_version = OpenGL_version.__version__
try:
import OpenGL_accelerate
accel_version = OpenGL_accelerate.__version__
props["accelerate"] = accel_version
log("OpenGL_accelerate version %s", accel_version)
except:
log("OpenGL_accelerate not found")
OpenGL_accelerate = None
accel_version = None
if accel_version is not None and pyopengl_version!=accel_version:
global _version_warning_shown
if not _version_warning_shown:
log.warn("Warning: version mismatch between PyOpenGL and PyOpenGL-accelerate")
log.warn(" this may cause crashes")
_version_warning_shown = True
vsplit = pyopengl_version.split('.')
#we now require PyOpenGL 3.1 or later
if vsplit[:2]<['3','1'] and not force_enable:
gl_check_error("PyOpenGL version 3.1 or later is required (found version %s)" % pyopengl_version)
return {}
props["zerocopy"] = bool(OpenGL_accelerate) and is_pyopengl_memoryview_safe(pyopengl_version, accel_version)
try:
extensions = glGetString(GL_EXTENSIONS).decode().split(" ")
except:
log("error querying extensions", exc_info=True)
extensions = []
gl_check_error("OpenGL could not find the list of GL extensions - does the graphics driver support OpenGL?")
log("OpenGL extensions found: %s", ", ".join(extensions))
props["extensions"] = extensions
from OpenGL.arrays.arraydatatype import ArrayDatatype
try:
log("found the following array handlers: %s", set(ArrayDatatype.getRegistry().values()))
except:
pass
from OpenGL.GL import GL_RENDERER, GL_VENDOR, GL_SHADING_LANGUAGE_VERSION
def fixstring(v):
try:
return str(v).strip()
except:
return str(v)
for d,s,fatal in (("vendor", GL_VENDOR, True),
("renderer", GL_RENDERER, True),
("shading language version", GL_SHADING_LANGUAGE_VERSION, False)):
try:
v = glGetString(s)
v = fixstring(v.decode())
log("%s: %s", d, v)
except:
if fatal:
gl_check_error("OpenGL property '%s' is missing" % d)
else:
log("OpenGL property '%s' is missing", d)
v = ""
props[d] = v
vendor = props["vendor"]
version_req = VERSION_REQ.get(vendor)
if version_req:
#.........这里部分代码省略.........
示例4: registerReturn
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
def registerReturn( self ):
"""Register this handler as the default return-type handler"""
from OpenGL.arrays.arraydatatype import ArrayDatatype
ArrayDatatype.getRegistry().registerReturn( self )
示例5: register
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
def register( self, types=None ):
"""Register this class as handler for given set of types"""
from OpenGL.arrays.arraydatatype import ArrayDatatype
ArrayDatatype.getRegistry().register( self, types )
示例6: check_GL_support
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
def check_GL_support(gldrawable, glcontext, min_texture_size=0, force_enable=False):
if not gldrawable.gl_begin(glcontext):
raise ImportError("gl_begin failed on %s" % gldrawable)
props = {}
try:
if SILENCE_FORMAT_HANDLER_LOGGER:
debug("silencing formathandler warnings")
logging.getLogger('OpenGL.formathandler').setLevel(logging.WARN)
import OpenGL
props["pyopengl"] = OpenGL.__version__
from OpenGL.GL import GL_VERSION, GL_EXTENSIONS
from OpenGL.GL import glGetString, glGetInteger
gl_version_str = glGetString(GL_VERSION)
if gl_version_str is None:
gl_check_error("OpenGL version is missing - cannot continue")
return {}
gl_major = int(gl_version_str[0])
gl_minor = int(gl_version_str[2])
props["opengl"] = gl_major, gl_minor
MIN_VERSION = (1,1)
if (gl_major, gl_minor) < MIN_VERSION:
gl_check_error("OpenGL output requires version %s or greater, not %s.%s" %
(".".join([str(x) for x in MIN_VERSION]), gl_major, gl_minor))
else:
debug("found valid OpenGL version: %s.%s", gl_major, gl_minor)
try:
extensions = glGetString(GL_EXTENSIONS).split(" ")
except:
gl_check_error("OpenGL could not find the list of GL extensions - does the graphics driver support OpenGL?")
debug("OpenGL extensions found: %s", ", ".join(extensions))
props["extensions"] = extensions
from OpenGL.arrays.arraydatatype import ArrayDatatype
try:
debug("found the following array handlers: %s", set(ArrayDatatype.getRegistry().values()))
except:
pass
from OpenGL.GL import GL_RENDERER, GL_VENDOR, GL_SHADING_LANGUAGE_VERSION
for d,s,fatal in (("vendor", GL_VENDOR, True),
("renderer", GL_RENDERER, True),
("shading language version", GL_SHADING_LANGUAGE_VERSION, False)):
try:
v = glGetString(s)
debug("%s: %s", d, v)
except:
if fatal:
gl_check_error("OpenGL property '%s' is missing" % d)
else:
log.warn("OpenGL property '%s' is missing" % d)
v = ""
props[d] = v
from OpenGL.GLU import gluGetString, GLU_VERSION, GLU_EXTENSIONS
for d,s in {"GLU version": GLU_VERSION, "GLU extensions":GLU_EXTENSIONS}.items():
v = gluGetString(s)
debug("%s: %s", d, v)
props[d] = v
for k,vlist in BLACKLIST.items():
v = props.get(k)
if v in vlist:
if force_enable:
log.warn("Warning: %s '%s' is blacklisted!", k, v)
else:
gl_check_error("%s '%s' is blacklisted!" % (k, v))
#check for specific functions we need:
from OpenGL.GL import glActiveTexture, glTexSubImage2D, glTexCoord2i, \
glViewport, glMatrixMode, glLoadIdentity, glOrtho, \
glEnableClientState, glGenTextures, glDisable, \
glBindTexture, glPixelStorei, glEnable, glBegin, glFlush, \
glTexParameteri, \
glTexImage2D, \
glMultiTexCoord2i, \
glVertex2i, glEnd
check_functions(glActiveTexture, glTexSubImage2D, glTexCoord2i, \
glViewport, glMatrixMode, glLoadIdentity, glOrtho, \
glEnableClientState, glGenTextures, glDisable, \
glBindTexture, glPixelStorei, glEnable, glBegin, glFlush, \
glTexParameteri, \
glTexImage2D, \
glMultiTexCoord2i, \
glVertex2i, glEnd)
#check for framebuffer functions we need:
from OpenGL.GL.ARB.framebuffer_object import GL_FRAMEBUFFER, \
GL_COLOR_ATTACHMENT0, glGenFramebuffers, glBindFramebuffer, glFramebufferTexture2D
check_functions(GL_FRAMEBUFFER, \
GL_COLOR_ATTACHMENT0, glGenFramebuffers, glBindFramebuffer, glFramebufferTexture2D)
for ext in required_extensions:
if ext not in extensions:
gl_check_error("OpenGL driver lacks support for extension: %s" % ext)
else:
debug("Extension %s is present", ext)
#this allows us to do CSC via OpenGL:
#see http://www.opengl.org/registry/specs/ARB/fragment_program.txt
from OpenGL.GL.ARB.fragment_program import glInitFragmentProgramARB
#.........这里部分代码省略.........
示例7: check_GL_support
# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import getRegistry [as 别名]
def check_GL_support(gldrawable, glcontext, min_texture_size=0, force_enable=False):
if not gldrawable.gl_begin(glcontext):
raise ImportError("gl_begin failed on %s" % gldrawable)
props = {}
try:
#log redirection:
def redirect_log(logger_name):
logger = logging.getLogger(logger_name)
assert logger is not None
logger.saved_handlers = logger.handlers
logger.saved_propagate = logger.propagate
logger.handlers = [CaptureHandler()]
logger.propagate = 0
return logger
fhlogger = redirect_log('OpenGL.formathandler')
elogger = redirect_log('OpenGL.extensions')
alogger = redirect_log('OpenGL.acceleratesupport')
arlogger = redirect_log('OpenGL.arrays')
clogger = redirect_log('OpenGL.converters')
import OpenGL
props["pyopengl"] = OpenGL.__version__
from OpenGL.GL import GL_VERSION, GL_EXTENSIONS
from OpenGL.GL import glGetString, glGetInteger
gl_version_str = glGetString(GL_VERSION)
if gl_version_str is None:
gl_check_error("OpenGL version is missing - cannot continue")
return {}
gl_major = int(gl_version_str[0])
gl_minor = int(gl_version_str[2])
props["opengl"] = gl_major, gl_minor
MIN_VERSION = (1,1)
if (gl_major, gl_minor) < MIN_VERSION:
gl_check_error("OpenGL output requires version %s or greater, not %s.%s" %
(".".join([str(x) for x in MIN_VERSION]), gl_major, gl_minor))
else:
log("found valid OpenGL version: %s.%s", gl_major, gl_minor)
from OpenGL import version as OpenGL_version
try:
import OpenGL_accelerate
except:
OpenGL_accelerate = None
props["zerocopy"] = is_pyopengl_memoryview_safe(OpenGL_version.__version__) and bool(OpenGL_accelerate)
try:
extensions = glGetString(GL_EXTENSIONS).split(" ")
except:
extensions = []
gl_check_error("OpenGL could not find the list of GL extensions - does the graphics driver support OpenGL?")
log("OpenGL extensions found: %s", ", ".join(extensions))
props["extensions"] = extensions
from OpenGL.arrays.arraydatatype import ArrayDatatype
try:
log("found the following array handlers: %s", set(ArrayDatatype.getRegistry().values()))
except:
pass
from OpenGL.GL import GL_RENDERER, GL_VENDOR, GL_SHADING_LANGUAGE_VERSION
for d,s,fatal in (("vendor", GL_VENDOR, True),
("renderer", GL_RENDERER, True),
("shading language version", GL_SHADING_LANGUAGE_VERSION, False)):
try:
v = glGetString(s)
log("%s: %s", d, v)
except:
if fatal:
gl_check_error("OpenGL property '%s' is missing" % d)
else:
log("OpenGL property '%s' is missing", d)
v = ""
props[d] = v
from OpenGL.GLU import gluGetString, GLU_VERSION, GLU_EXTENSIONS
for d,s in {"GLU version": GLU_VERSION, "GLU extensions":GLU_EXTENSIONS}.items():
v = gluGetString(s)
log("%s: %s", d, v)
props[d] = v
blacklisted = None
whitelisted = None
for k,vlist in BLACKLIST.items():
v = props.get(k)
if v in vlist:
log("%s '%s' found in blacklist: %s", k, v, vlist)
blacklisted = k, v
for k,vlist in WHITELIST.items():
v = props.get(k)
if v in vlist:
log("%s '%s' found in whitelist: %s", k, v, vlist)
whitelisted = k, v
if blacklisted:
if whitelisted:
log.info("%s '%s' enabled (found in both blacklist and whitelist)", *whitelisted)
elif force_enable:
log.warn("Warning: %s '%s' is blacklisted!", *blacklisted)
else:
gl_check_error("%s '%s' is blacklisted!" % (blacklisted))
#.........这里部分代码省略.........