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


Python ArrayDatatype.asArray方法代码示例

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


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

示例1: glVertexAttribPointer

# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import asArray [as 别名]
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,代码行数:34,代码来源:GL_2_0.py

示例2: __setitem__

# 需要导入模块: from OpenGL.arrays.arraydatatype import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.arraydatatype.ArrayDatatype import asArray [as 别名]
        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,代码行数:53,代码来源:vbo.py


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