当前位置: 首页>>代码示例>>Python>>正文


Python arraydatatype.ArrayDatatype类代码示例

本文整理汇总了Python中OpenGL.arrays.arraydatatype.ArrayDatatype的典型用法代码示例。如果您正苦于以下问题:Python ArrayDatatype类的具体用法?Python ArrayDatatype怎么用?Python ArrayDatatype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArrayDatatype类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copy_data

 def copy_data( self ):
     """Copy our data into the buffer on the GL side (if required)
     
     Ensures that the GL's version of the data in the VBO matches our 
     internal view of the data, either by copying the entire data-set 
     over with glBufferData or by updating the already-transferred 
     data with glBufferSubData.
     """
     assert self.buffers, """Should do create_buffers before copy_data"""
     if self.copied:
         if self._copy_segments:
             while self._copy_segments:
                 start,size,data  = self._copy_segments.pop(0)
                 dataptr = ArrayDatatype.voidDataPointer( data )
                 self.implementation.glBufferSubData(self.target, start, size, dataptr)
     else:
         if self.data is not None and self.size is None:
             self.size = ArrayDatatype.arrayByteCount( self.data )
         self.implementation.glBufferData(
             self.target,
             self.size,
             self.data,
             self.usage,
         )
         self.copied = True
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:25,代码来源:vbo.py

示例2: glVertexAttribPointer

def glVertexAttribPointer(
    baseOperation, index, size, type,
    normalized, stride, pointer,
):
    """Set an attribute pointer for a given shader (index)

    index -- the index of the generic vertex to bind, see
        glGetAttribLocation for retrieval of the value,
        note that index is a global variable, not per-shader
    size -- number of basic elements per record, 1,2,3, or 4
    type -- enum constant for data-type
    normalized -- whether to perform int to float
        normalization on integer-type values
    stride -- stride in machine units (bytes) between
        consecutive records, normally used to create
        "interleaved" arrays
    pointer -- data-pointer which provides the data-values,
        normally a vertex-buffer-object or offset into the
        same.

    This implementation stores a copy of the data-pointer
    in the contextdata structure in order to prevent null-
    reference errors in the renderer.
    """
    array = ArrayDatatype.asArray( pointer, type )
    key = ('vertex-attrib',index)
    contextdata.setValue( key, array )
    return baseOperation(
        index, size, type,
        normalized, stride,
        ArrayDatatype.voidDataPointer( array )
    )
开发者ID:Kupoman,项目名称:conceptparticles,代码行数:32,代码来源:GL_2_0.py

示例3: __setitem__

        def __setitem__( self, slice, array):
            """Set slice of data on the array and vbo (if copied already)

            slice -- the Python slice object determining how the data should
                be copied into the vbo/array
            array -- something array-compatible that will be used as the
                source of the data, note that the data-format will have to
                be the same as the internal data-array to work properly, if
                not, the amount of data copied will be wrong.

            This is a reasonably complex operation, it has to have all sorts
            of state-aware changes to correctly map the source into the low-level
            OpenGL view of the buffer (which is just bytes as far as the GL
            is concerned).
            """
            if slice.step and not slice.step == 1:
                raise NotImplemented( """Don't know how to map stepped arrays yet""" )
            # TODO: handle e.g. mapping character data into an integer data-set
            data = ArrayDatatype.asArray( array )
            start = (slice.start or 0)
            stop = (slice.stop or len(self.data))
            if start < 0:
                start += len(self.data)
                start = max((start,0))
            if stop < 0:
                stop += len(self.data)
                stop = max((stop,0))
            self.data[ slice ] = data
            if self.copied and self.buffers:
                if start-stop != len(data):
                    self.copied = False
                elif start-stop == len(self.data):
                    # re-copy the whole data-set
                    self.copied = False
                elif len(data):
                    # now the fun part, we need to make the array match the
                    # structure of the array we're going to copy into and make
                    # the "size" parameter match the value we're going to copy in,
                    # note that a 2D array (rather than a 1D array) may require
                    # multiple mappings to copy into the memory area...

                    # find the step size from the dimensions and base size...
                    size = ArrayDatatype.arrayByteCount( data ) / len(array)
                    #baseSize = ArrayDatatype.unitSize( data )
                    # now create the start and distance values...
                    start *= size
                    stop *= size
                    # wait until the last moment (bind) to copy the data...
                    self._copy_segments.append(
                        (start,(stop-start), data)
                    )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:51,代码来源:vbo.py

示例4: set_array

 def set_array( self, data, size=None ):
     """Update our entire array with new data"""
     self.data = data 
     self.copied = False
     if size is not None:
         self.size = size
     elif self.data is not None:
         self.size = ArrayDatatype.arrayByteCount( self.data )
开发者ID:AJMartel,项目名称:3DPrinter,代码行数:8,代码来源:vbo.py

示例5: copy_data

 def copy_data( self ):
     """Copy our data into the buffer on the GL side"""
     assert self.buffers, """Should do create_buffers before copy_data"""
     if self.copied:
         if self._copy_segments:
             while self._copy_segments:
                 start,size,data  = self._copy_segments.pop(0)
                 dataptr = ArrayDatatype.voidDataPointer( data )
                 self.implementation.glBufferSubData(self.target, start, size, dataptr)
     else:
         if self.data is not None and self.size is None:
             self.size = ArrayDatatype.arrayByteCount( self.data )
         self.implementation.glBufferData(
             self.target, 
             self.size,
             self.data,
             self.usage,
         )
         self.copied = True
开发者ID:AJMartel,项目名称:3DPrinter,代码行数:19,代码来源:vbo.py

示例6: typeLookup

 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,))
开发者ID:Kupoman,项目名称:conceptparticles,代码行数:12,代码来源:formathandler.py

示例7: set_array

 def set_array( self, data, size=None ):
     """Update our entire array with new data
     
     data -- PyOpenGL-compatible array-data structure, numpy arrays, ctypes arrays, etc.
     size -- if not provided, will use arrayByteCount to determine the size of the data-array,
         thus this value (number of bytes) is required when using opaque data-structures,
         (such as ctypes pointers) as the array data-source.
     """
     self.data = data
     self.copied = False
     if size is not None:
         self.size = size
     elif self.data is not None:
         self.size = ArrayDatatype.arrayByteCount( self.data )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:14,代码来源:vbo.py

示例8: loadPlugin

 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
开发者ID:AJMartel,项目名称:3DPrinter,代码行数:22,代码来源:formathandler.py

示例9: do_check_GL_support

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:
#.........这里部分代码省略.........
开发者ID:svn2github,项目名称:Xpra,代码行数:101,代码来源:gl_check.py

示例10: dimensions

 def dimensions( self, value, typeCode=None ):
     """Determine dimensions of the passed array value (if possible)"""
     return ArrayDatatype.dimensions( value.data )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:3,代码来源:vbo.py

示例11: unitSize

 def unitSize( self, value, typeCode=None ):
     """Determine unit size of an array (if possible)"""
     return ArrayDatatype.unitSize( value.data )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:3,代码来源:vbo.py

示例12: arraySize

 def arraySize( self, value, typeCode = None ):
     """Given a data-value, calculate dimensions for the array"""
     return ArrayDatatype.arraySize( value.data )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:3,代码来源:vbo.py

示例13: arrayByteCount

 def arrayByteCount( self, value ):
     return ArrayDatatype.arrayByteCount( value.data )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:2,代码来源:vbo.py

示例14: arrayToGLType

 def arrayToGLType( self, value ):
     """Given a value, guess OpenGL type of the corresponding pointer"""
     return ArrayDatatype.arrayToGLType( value.data )
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:3,代码来源:vbo.py

示例15: setSlice

 def setSlice(self, start, size, data):
     """
     sets a slice of data.
     """
     dataptr = ArrayDatatype.voidDataPointer( data )
     gl.glBufferSubData( self.target, start, size, dataptr )
开发者ID:daniel-,项目名称:python-gl-engine,代码行数:6,代码来源:vbo.py


注:本文中的OpenGL.arrays.arraydatatype.ArrayDatatype类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。