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


Python ArrayDatatype.arrayByteCount方法代码示例

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


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

示例1: createVertexAndTextureBuffers

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def createVertexAndTextureBuffers(self, vertices, tcoords, opacity = None):
        ''' Allocate hardware buffers for vertices, texture coordinates, and optionally opacity. '''
        if self.flipHorizontal:
            vertices[:,0] = -vertices[:,0]
        if self.flipVertical:
            vertices[:,1] = -vertices[:,1]

        GL.glEnableClientState (GL.GL_VERTEX_ARRAY)

        #vertex buffer in hardware
        self.gl_vb = GL.GLuint()
        GL.glGenBuffers(1 , self.gl_vb)
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.gl_vb)
        GL.glBufferData(GL.GL_ARRAY_BUFFER, ADT.arrayByteCount(vertices), ADT.voidDataPointer(vertices), GL.GL_STATIC_DRAW)

        #vertex buffer tdata in hardware
        self.gl_tb = GL.GLuint()
        GL.glGenBuffers(1 , self.gl_tb)
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.gl_tb)
        GL.glBufferData(GL.GL_ARRAY_BUFFER, ADT.arrayByteCount(tcoords), ADT.voidDataPointer(tcoords), GL.GL_STATIC_DRAW)

        # opacity buffer in hardware (only for warp files)
        if opacity is not None:
            self.gl_color = GL.GLuint()
            GL.glGenBuffers(1 , self.gl_color)
            GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.gl_color)
            #convert opacity to RGBA, one point for each corner of the quad
            GL.glBufferData(GL.GL_ARRAY_BUFFER, ADT.arrayByteCount(opacity), ADT.voidDataPointer(opacity), GL.GL_STATIC_DRAW)
        else:
            self.gl_color = None

        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, 0)
        GL.glDisableClientState(GL.GL_VERTEX_ARRAY)
开发者ID:papr,项目名称:psychopy,代码行数:35,代码来源:windowwarp.py

示例2: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def __init__(self, v, i):
        self.__T = mat4()
        v_buff = numpy.array(v, dtype=numpy.float32)
        i_buff = numpy.array(i, dtype=numpy.int16)
        self.__v_hdl = glGenBuffers(1)
        self.__i_hdl = glGenBuffers(1)
        self.__i_size = adt.arrayByteCount(i_buff) * 2

        glBindBuffer(GL_ARRAY_BUFFER, self.__v_hdl)
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.__i_hdl)
        glBufferData(GL_ARRAY_BUFFER, adt.arrayByteCount(v_buff), adt.voidDataPointer(v_buff), GL_STATIC_DRAW)
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, adt.arrayByteCount(i_buff), adt.voidDataPointer(i_buff), GL_STATIC_DRAW)
        if glGetError() != GL_NO_ERROR:
            raise RuntimeError('mesh create error!')
        Engine.get().add_object(Engine.get(), self)
开发者ID:donkaban,项目名称:3d-i-free,代码行数:17,代码来源:mesh.py

示例3: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
 def __init__(self, vertbuffer, indexbuffer):
     self.buffer = glGenBuffers(1)
     self.indexbuffer = indexbuffer
     glBindBuffer(GL_ARRAY_BUFFER, self.buffer)
     self.numverts = len(vertbuffer)
     vertbuffer = convertbuffer(vertbuffer)
     glBufferData(GL_ARRAY_BUFFER, ADT.arrayByteCount(vertbuffer), ADT.voidDataPointer(vertbuffer), GL_STATIC_DRAW)
开发者ID:ikarth,项目名称:Justify-Thyself,代码行数:9,代码来源:world.py

示例4: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
	def __init__(self, data, usage):
		self.buffer = GLuint(0)
		glGenBuffers(1, self.buffer)
		self.buffer = self.buffer.value
		glBindBuffer(GL_ARRAY_BUFFER, self.buffer)
		glBufferData(GL_ARRAY_BUFFER, ADT.arrayByteCount(data),
		ADT.voidDataPointer(data), usage)
开发者ID:keksnicoh,项目名称:numeric_gravity_experimental_2,代码行数:9,代码来源:transform.py

示例5: fillBuffers

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def fillBuffers(self, image = None):
        '''
        ALSO FILL IN LATER...PLOX
        '''
        size = 0
        vertByteCount = ADT.arrayByteCount(numpy.zeros((8, 2), 'f'))

        for layer in self.layers:
            size += len(self.images[layer])

        glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.VBO)

        if self.VBOBuffer <= size or image == None:
            self.VBOBuffer = nextPowerOfTwo(size+1)

            glBufferDataARB(GL_ARRAY_BUFFER_ARB, self.VBOBuffer*vertByteCount, None, GL_STATIC_DRAW_ARB)

            self.offset = 0

            for layer in self.layers:
                for img in self.images[layer]:
                    img.offset = int(float(self.offset)/vertByteCount*4)
                    VBOData = img.getVBOData()

                    glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, self.offset, vertByteCount, VBOData)
                    self.offset += vertByteCount

        else:
            image.offset = int(float(self.offset)/vertByteCount*4)
            VBOData = image.getVBOData()

            glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, self.offset, vertByteCount, VBOData)
            self.offset += vertByteCount
开发者ID:phire,项目名称:OpenAnt,代码行数:35,代码来源:GLWidget.py

示例6: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def __init__(self, parent):
        QGLWidget.__init__(self, parent)

        self.setMinimumSize(320, 240)
        self.w = 640
        self.h = 480
        self.images = dict()
        self.lastMousePos = [0, 0]
        self.camera = [0, 0]
        self.layers = []
        self.zoom = 1
        self.VBO = None
        self.vbos = False
        self.VBOBuffer = 0
        self.offset = 0
        self.ctrl = False
        self.shift = False
        self.qimages = {}
        self.texext = GL_TEXTURE_2D
        self.error = False
        self.texts = []
        self.textid = 0
        self.vertByteCount = ADT.arrayByteCount(numpy.zeros((8, 2), 'f'))
        self.movecam = False

        #default settings, though overriden in initializeGL by fieldtemp
        self.npot = 3
        self.anifilt = 0
        self.compress = False
        self.magfilter = GL_NEAREST
        self.mipminfilter = GL_NEAREST_MIPMAP_NEAREST
        self.minfilter = GL_NEAREST

        self.setFocusPolicy(Qt.StrongFocus)
        self.setMouseTracking(True) #this may be the fix for a weird problem with leaveevents
开发者ID:celx,项目名称:OpenAnt,代码行数:37,代码来源:GLWidget.py

示例7: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
 def __init__(self, parent):
     QGLWidget.__init__(self, parent)
     self.setMinimumSize(640, 480)
     self.w = 640
     self.h = 480
     self.images = dict()
     self.lastMousePos = [0, 0]
     self.camera = [0, 0]
     self.layers = []
     self.zoom = 1
     self.VBO = None
     self.vbos = False
     self.VBOBuffer = 0
     self.offset = 0
     self.ctrl = False
     self.shift = False
     self.qimages = {}
     self.texext = GL_TEXTURE_2D
     self.npot = 3
     self.lines = dict()
     self.error = False
     self.texts = []
     self.textid = 0
     self.vertByteCount = ADT.arrayByteCount(numpy.zeros((8, 2), 'f'))
     self.leftMouse = False
     
     self.setFocusPolicy(Qt.StrongFocus)
     self.setMouseTracking(True) #this may be the fix for a weird problem with leaveevents
开发者ID:Oipo,项目名称:Fantasia-Majestical,代码行数:30,代码来源:glwidget.py

示例8: glBufferSubData

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
def glBufferSubData( baseOperation, target, offset, size=None, data=None ):
    """Copy subset of data into the currently bound vertex-buffer-data object

    target -- the symbolic constant indicating which buffer type is intended
    offset -- offset from beginning of buffer at which to copy bytes
    size -- the count-in-bytes of the array (if an int/long), if None,
        calculate size from data, if an array and data is None, use as
        data (i.e. the parameter can be omitted and calculated)
    data -- data-pointer to be used, may be None to initialize without
        copying over a data-set

    Note that if size is not an int/long it is considered to be data
    *iff* data is None
    """
    if size is None:
        if data is None:
            raise TypeError( "Need data or size" )
    elif (not isinstance( size, integer_types)) and (data is None):
        data = size 
        size = None
    try:
        if size is not None:
            size = int( size )
    except TypeError:
        if data is not None:
            raise TypeError(
                """Expect an integer size *or* a data-array, not both"""
            )
        data = size
        size = None
    data = ArrayDatatype.asArray( data )
    if size is None:
        size = ArrayDatatype.arrayByteCount( data )
    return baseOperation( target, offset, size, data )
开发者ID:CaptainAL,项目名称:Spyder,代码行数:36,代码来源:GL_1_5.py

示例9: calculateVBOList

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def calculateVBOList(self, image = None):
        '''
        Create the VBO list to be passed on to the module for drawing
        vbolist could possibly be a multi-layered tuple, one tuple per layer.
        So that it doesn't have to be recalculated every time one single image is changed.
        '''
        if len(self.layers) > 0 and len(self.vbolist) > 2 and image != None:
            if image.layer == self.layers[0]:
                self.vbolist.insert(2, image.offset) #note the reversed order here
                self.vbolist.insert(2, image.textureId)
                glmod.setVBO(tuple(self.vbolist))
                return
            elif image.layer == self.layers[-1]:
                self.vbolist.append(image.textureId)
                self.vbolist.append(image.offset)
                glmod.setVBO(tuple(self.vbolist))
                return

        self.vbolist = [self.VBO, ADT.arrayByteCount(numpy.zeros((2, 2), 'f'))]
        for layer in self.layers:
            for img in self.images[layer]:
                if img.hidden:
                    continue
                self.vbolist.append(img.textureId)
                self.vbolist.append(img.offset)

        if len(self.vbolist) > 2:
            glmod.setVBO(tuple(self.vbolist))
开发者ID:Tuxman,项目名称:OpenAnt,代码行数:30,代码来源:GLWidget.py

示例10: reserveVBOSize

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def reserveVBOSize(self, size):
        '''
        Does not work yet. If this function is called, it makes glGenTextures fail
        '''
        return

        if Globals.vbos and size > self.VBOBuffer:
            self.VBOBuffer = size
            vertByteCount = ADT.arrayByteCount(numpy.zeros((8, 2), 'f'))

            glBufferDataARB(GL_ARRAY_BUFFER_ARB, self.VBOBuffer*vertByteCount, None, GL_STATIC_DRAW_ARB)

            self.offset = 0

            for layer in self.layers:
                for img in self.images[layer]:
                    img.offset = int(float(self.offset)/vertByteCount*4)
                    VBOData = img.getVBOData()

                    glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, self.offset, vertByteCount, VBOData)
                    self.offset += vertByteCount

            glBindBuffer(GL_ARRAY_BUFFER_ARB, 0)

            self.calculateVBOList()
开发者ID:Tuxman,项目名称:OpenAnt,代码行数:27,代码来源:GLWidget.py

示例11: vao_update

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def vao_update(self,data):
        if data.size:
           self.vao_data=data
        # Bind a buffer before we can use it
        glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)

        # Now go ahead and fill this bound buffer with some data
        glBufferSubData(GL_ARRAY_BUFFER,0, ArrayDatatype.arrayByteCount(self.vao_data), self.vao_data)
开发者ID:fboers,项目名称:jumeg,代码行数:10,代码来源:jumeg_tsv_glvob.py

示例12: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
 def __init__(self, v, i):
     self.__T = mat4()
     self.__verts = numpy.array(v, dtype=numpy.float32)
     self.__ndx = numpy.array(i, dtype=numpy.int16)
     self.__id = glGenBuffers(2)
     glBindBuffer(GL_ARRAY_BUFFER, self.__id[0])
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.__id[1])
     glBufferData(GL_ARRAY_BUFFER,
                  ARR.arrayByteCount(self.__verts),
                  ARR.voidDataPointer(self.__verts),
                  GL_STATIC_DRAW)
     glBufferData(GL_ELEMENT_ARRAY_BUFFER,
                  ARR.arrayByteCount(self.__ndx),
                  ARR.voidDataPointer(self.__ndx),
                  GL_STATIC_DRAW)
     if glGetError() != GL_NO_ERROR:
         raise RuntimeError('mesh vbo error!')
开发者ID:Afey,项目名称:3d-i-free,代码行数:19,代码来源:miniengine.py

示例13: setDrawRect

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
    def setDrawRect(self, drawRect):
        self.drawRect = drawRect

        if Globals.vbos:
            VBOData = self.getVBOData()
            vertByteCount = ADT.arrayByteCount(VBOData)

            glBindBuffer(GL_ARRAY_BUFFER_ARB, self.VBO)
            glBufferSubData(GL_ARRAY_BUFFER_ARB, int(self.offset*vertByteCount/4), vertByteCount, VBOData)
开发者ID:phire,项目名称:OpenAnt,代码行数:11,代码来源:Image.py

示例14: initBuffers

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
 def initBuffers(self):
     self.num= len(self.result)
     self.vertices = numpy.ndarray((self.num/4, 4), dtype=numpy.float32)
     for i in range(self.num):
         self.vertices[i/4,i%4] = self.result[i] 
     from OpenGL.arrays import ArrayDatatype as ADT
 
     self.bufferVertices = GLuint(0)
     self.bufferVertices = glGenBuffers(1)
     glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
     glBufferData(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(self.vertices), 
         ADT.voidDataPointer(self.vertices), GL_STATIC_DRAW_ARB)
开发者ID:fean9r,项目名称:FeaCL,代码行数:14,代码来源:OpenClOperations.py

示例15: draw

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import arrayByteCount [as 别名]
  def draw(self):
    """Render the textbox"""
    # Reload the texture coordinate buffer if anything changed
    if self._dirty:
      # Bind and load the buffer
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.__texCoordBuffer)
      glBufferDataARB(GL_ARRAY_BUFFER_ARB,
        ArrayDatatype.arrayByteCount(self._texCoordArray),
        ArrayDatatype.voidDataPointer(self._texCoordArray), GL_DYNAMIC_DRAW)

      glBindBufferARB(GL_ARRAY_BUFFER, 0)

      self._dirty = False

    # Set up transformations
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslatef(self._pos[0], self._pos[1], 0)
    glScalef(0.25, 0.25, 1)

    # Set up the foreground color
    glColor4f(*self._color)

    # Set up the texture
    glEnable(GL_TEXTURE_2D)
    self._charset.bind()
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)

    # Enable vertex and texture arrays
    glEnableClientState(GL_VERTEX_ARRAY)
    glEnableClientState(GL_TEXTURE_COORD_ARRAY)

    # Set the vertex buffer for rendering
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.__vertexBuffer)
    glVertexPointer(3, GL_FLOAT, 0, None)

    # Set the texture coordinate buffer for rendering
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.__texCoordBuffer)
    glTexCoordPointer(2, GL_FLOAT, 0, None)

    # Unbind the active buffer--pointers are already specified
    glBindBufferARB(GL_ARRAY_BUFFER, 0)

    # Render over everything else
    glDisable(GL_DEPTH_TEST)

    # Render
    glDrawArrays(GL_QUADS, 0, self._cols * self._rows * 4)

    # Disable vertex and texture arrays
    glDisableClientState(GL_VERTEX_ARRAY)
    glDisableClientState(GL_TEXTURE_COORD_ARRAY)
开发者ID:aarmea,项目名称:mumei,代码行数:55,代码来源:textbox.py


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