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


Python ArrayDatatype.voidDataPointer方法代码示例

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


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

示例1: createVertexAndTextureBuffers

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [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 voidDataPointer [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 voidDataPointer [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

示例4: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [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

示例5: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [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

示例6: draw

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [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

示例7: initBuffers

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [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

示例8: __init__

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

示例9: __init__

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

示例10: update_data

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [as 别名]
 def update_data(self, data, usage):
   glBindBuffer(GL_ARRAY_BUFFER_ARB, self.buffer)
   glBufferData(GL_ARRAY_BUFFER_ARB,
                ADT.arrayByteCount(data),
                ADT.voidDataPointer(data),
                usage)
开发者ID:serpent-project,项目名称:serpent,代码行数:8,代码来源:buffers.py

示例11: set_data

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [as 别名]
 def set_data(self, data):
   self.bind()
   glBufferData(GL_ARRAY_BUFFER, ADT.arrayByteCount(data), ADT.voidDataPointer(data), self.usage)
   self.unbind()
开发者ID:moxon6,项目名称:chemlab,代码行数:6,代码来源:buffers.py

示例12: create_index_buffer

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [as 别名]
 def create_index_buffer(self, data, usage=GL_STATIC_DRAW):
     self.index_buffer = glGenBuffers(1)
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.index_buffer)
     glBufferData(GL_ELEMENT_ARRAY_BUFFER, ADT.arrayByteCount(data),
                  ADT.voidDataPointer(data), usage)
开发者ID:namenu,项目名称:ObjLoader,代码行数:7,代码来源:obj.py

示例13: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [as 别名]
	def __init__(self, data, usage):
		self.vbo_id = glGenBuffers(2)
		self.buffer = self.vbo_id[0]
		glBindBuffer(GL_ARRAY_BUFFER, self.buffer)
		glBufferData(GL_ARRAY_BUFFER, ADT.arrayByteCount(data), ADT.voidDataPointer(data), usage)
开发者ID:uoscompsci,项目名称:ASPECTA-Server,代码行数:7,代码来源:buffers.py

示例14: __init__

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [as 别名]
 def __init__(self, data, usage, type=GL_ARRAY_BUFFER_ARB):
     self.buffer = glGenBuffers(1)
     self.type = type
     glBindBuffer(self.type, self.buffer)
     glBufferData(self.type, ArrayDatatype.arrayByteCount(data), ArrayDatatype.voidDataPointer(data), usage)
     glBindBuffer(self.type, 0)
开发者ID:houshuo,项目名称:pyradiosity,代码行数:8,代码来源:gl_functions.py

示例15: makeBuffer

# 需要导入模块: from OpenGL.arrays import ArrayDatatype [as 别名]
# 或者: from OpenGL.arrays.ArrayDatatype import voidDataPointer [as 别名]
 def makeBuffer(target, data):
     temp = glGenBuffers(1)
     glBindBuffer(target, temp)
     glBufferData(target, ADT.arrayByteCount(data), ADT.voidDataPointer(data), GL_STATIC_DRAW)
     glBindBuffer(target, 0)
     return temp
开发者ID:dannyn,项目名称:Playing-With-PythonGL,代码行数:8,代码来源:mesh.py


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