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


Python arrays.ArrayDatatype类代码示例

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


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

示例1: glBufferSubData

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,代码行数:34,代码来源:GL_1_5.py

示例2: initBuffers

 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,代码行数:12,代码来源:OpenClOperations.py

示例3: draw

  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,代码行数:53,代码来源:textbox.py

示例4: vao_update

    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,代码行数:8,代码来源:jumeg_tsv_glvob.py

示例5: __init__

  def __init__(self, ui, pos, rows, cols, color=COLOR_WHITE):
    """Initialize the vertex buffer, text array, and texture coordinate
    array"""
    self._pos = pos
    self._rows = rows
    self._cols = cols
    self._color = color
    self._charset = ui.characterSet

    # Set up the vertex buffer
    self.__vertexBuffer = glGenBuffersARB(1)
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.__vertexBuffer)

    # Generate the vertices
    vertices = []
    for row in xrange(rows):
      for col in xrange(cols):
        vertices.append((col * self.SCALEX, -row, 0))
        vertices.append(((col + 1) * self.SCALEX, -row, 0))
        vertices.append(((col + 1) * self.SCALEX, -row + 1, 0))
        vertices.append((col * self.SCALEX, -row + 1, 0))

    vertexArray = numpy.array(vertices, dtype=numpy.float32)

    # Load the vertices into the vertex buffer
    glBufferDataARB(GL_ARRAY_BUFFER_ARB,
      ArrayDatatype.arrayByteCount(vertexArray),
      ArrayDatatype.voidDataPointer(vertexArray), GL_STATIC_DRAW)

    # Initialize the text array
    self._textArray = numpy.zeros((rows, cols), dtype=numpy.uint8)

    # Set up the texture coordinate buffer
    self.__texCoordBuffer = glGenBuffersARB(1)
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.__texCoordBuffer)

    # Initialize all texture coordinates to zero
    self._texCoordArray = numpy.zeros((rows, cols, 4, 2),
      dtype=numpy.float32)

    # Force the buffer to be reloaded on the next draw
    self._dirty = True
开发者ID:aarmea,项目名称:mumei,代码行数:42,代码来源:textbox.py

示例6: glBufferDataARB

def glBufferDataARB( baseOperation, target, size, data=None, usage=None ):
    """Copy given data into the currently bound vertex-buffer-data object
    
    target -- the symbolic constant indicating which buffer type is intended
    size -- if provided, the count-in-bytes of the array
    data -- data-pointer to be used, may be None to initialize without 
        copying over a data-set 
    usage -- hint to the driver as to how to set up access to the buffer 
    
    Note: parameter "size" can be omitted, which makes the signature
        glBufferData( target, data, usage )
    instead of:
        glBufferData( target, size, data, usage )
    """
    if usage is None:
        usage = data 
        data = size 
        size = None 
    data = ArrayDatatype.asArray( data )
    if size is None:
        size = ArrayDatatype.arrayByteCount( data )
    return baseOperation( target, size, data, usage )
开发者ID:AJMartel,项目名称:3DPrinter,代码行数:22,代码来源:vertex_buffer_object.py

示例7: __init__

 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,代码行数:7,代码来源:world.py

示例8: __init__

	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,代码行数:7,代码来源:transform.py

示例9: __init__

 def __init__(self, data, usage):
   self.buffer = GLuint(0)
   self.buffer = glGenBuffers(1)
   self.usage = usage
   self.data = data
   
   # Add a little warning
   if data.dtype == np.float:
     Warning('This float array is 64 bit')
   
   glBindBuffer(GL_ARRAY_BUFFER, self.buffer)
   glBufferData(GL_ARRAY_BUFFER, ADT.arrayByteCount(data),
                ADT.voidDataPointer(data), usage)
   glBindBuffer(GL_ARRAY_BUFFER, 0)
开发者ID:moxon6,项目名称:chemlab,代码行数:14,代码来源:buffers.py

示例10: __init__

    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,代码行数:15,代码来源:mesh.py

示例11: calculateVBOList

    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,代码行数:28,代码来源:GLWidget.py

示例12: reserveVBOSize

    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,代码行数:25,代码来源:GLWidget.py

示例13: fillBuffers

    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,代码行数:33,代码来源:GLWidget.py

示例14: __init__

 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,代码行数:28,代码来源:glwidget.py

示例15: __init__

    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,代码行数:35,代码来源:GLWidget.py


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