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


Python vbo.VBO属性代码示例

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


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

示例1: paintGL

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def paintGL(self):
        """Paint the scene.
        """            
        self.update_buffer()   
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        if (np.mod(self.enctime,4)==0 or ENC==0 or 1):

            if (1):
                
                gl.glBindTexture(gl.GL_TEXTURE_2D, self.idtexgl)
                gl.glEnable(gl.GL_TEXTURE_2D)
                gl.glBegin(gl.GL_QUADS)
                gl.glTexCoord2f(0.0, 0.0)
                gl.glVertex2f(0, 0); 
                gl.glTexCoord2f(1.0, 0.0)
                gl.glVertex2f( 1.0, 0); 
                gl.glTexCoord2f(1.0, 1.0)
                gl.glVertex2f( 1.0, 1.0); 
                gl.glTexCoord2f(0.0, 1.0)
                gl.glVertex2f(0, 1.0);
                gl.glEnd()
                
            else:
                gl.glColor4d(0.5,0.7,0.8,0.04)
                gl.glEnable(gl.GL_BLEND)
                gl.glBlendEquationSeparate( gl.GL_FUNC_ADD,  gl.GL_FUNC_ADD);
                gl.glBlendFuncSeparate(gl.GL_SRC_ALPHA,gl.GL_ONE_MINUS_SRC_ALPHA, gl.GL_ONE,    gl.GL_ONE, gl.GL_ZERO);
                # bind the VBO
                self.glbuf.bind()
                # tell OpenGL that the VBO contains an array of vertices
                gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
                # these vertices contain 2 simple precision coordinates
                gl.glVertexPointer(2, gl.GL_FLOAT, 0, self.glbuf)
                # draw "count" points from the VBO
                gl.glDrawArrays(gl.GL_POINTS, 0, self.count)
        
        self.update() 
开发者ID:appleminis,项目名称:gravity,代码行数:40,代码来源:galaxy.py

示例2: __init__

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def __init__(self, vertex, fragment, total_vertex, texture=None):
        """Funcion constructora"""
        if isinstance(vertex, vbo.VBO) and isinstance(fragment, vbo.VBO):
            if isinstance(total_vertex, types.IntType):
                self.vertex = vertex
                self.fragment = fragment
                self.totalVertex = total_vertex
                self.texture = texture
                if self.texture is None:
                    self.texlen = 0
                else:
                    self.texlen = len(self.texture)
            else:
                raise Exception("total_vertex debe ser del tipo int")
        else:
            raise Exception(
                "vertex y fragment deben ser del tipo VBO (OpenGL.arrays.vbo)") 
开发者ID:ppizarror,项目名称:CC3501-2017-1,代码行数:19,代码来源:figures.py

示例3: updateColorChoiceBuffers

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def updateColorChoiceBuffers(self):
        #Remake color and vertex buffers
        if self.colorPosVBO:
            self.colorPosVBO.delete()
        if self.colorColorVBO:
            self.colorColorVBO.delete()
        N = len(self.colorChoices)
        Pos = np.zeros((N, 3))
        Colors = np.zeros((N, 3))
        i = 0
        for idx in self.colorChoices:
            Pos[i, :] = self.mesh.VPos[idx, :]
            Colors[i, :] = self.colorChoices[idx]/255.0
            i += 1
        self.colorPosVBO = vbo.VBO(np.array(Pos, dtype=np.float32))
        self.colorColorVBO = vbo.VBO(np.array(Colors, dtype=np.float32)) 
开发者ID:bmershon,项目名称:laplacian-meshes,代码行数:18,代码来源:LapGUI.py

示例4: _draw_pixels

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def _draw_pixels(self, frame_buffer=0):
        """ Draw stars as pixels.

        frame_buffer: int
            OpenGL frame buffer id.
        """

        glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer)
        self._bind_star_vbo()

        # Choose appropriate shader program
        if self.use_adaptative_opacity:
            glUseProgram(self._ao_shader_program)
            glUniform1f(glGetUniformLocation(self._ao_shader_program, 'opacity_factor'),
                        self._calc_opacity_factor())
        else:
            glUseProgram(0)

        # Draw "count" points from the VBO
        glDrawArrays(GL_POINTS, 0, self._star_count) 
开发者ID:gouarin,项目名称:formation_python2017,代码行数:22,代码来源:animation.py

示例5: add_array_buffer

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def add_array_buffer(self, format, vbo):
        """
        Register a vbo in the VAO. This can be called multiple times.
        This can be one or multiple buffers (interleaved or not)

        :param format: The format of the buffer
        :param vbo: The vbo object
        """
        if not isinstance(vbo, VBO):
            raise VAOError("vbo parameter must be an OpenGL.arrays.vbo.VBO instance")

        # Check that the buffer target is sane
        if vbo.target not in ["GL_ARRAY_BUFFER", "GL_TRANSFORM_FEEDBACK_BUFFER"]:
            raise VAOError("VBO must have target GL_ARRAY_BUFFER or GL_TRANSFORM_FEEDBACK_BUFFER, "
                           "not {}".format(vbo.target))

        self.array_buffer_map[id(vbo)] = ArrayBuffer(format, vbo) 
开发者ID:Contraz,项目名称:demosys-py,代码行数:19,代码来源:vao.py

示例6: set_element_buffer

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def set_element_buffer(self, format, vbo):
        """
        Set the index buffer for this VAO

        :param format: The format of the element buffer
        :param vbo: the vbo object
        """
        if not isinstance(vbo, VBO):
            raise VAOError("vbo parameter must be an OpenGL.arrays.vbo.VBO instance")

        if vbo.target not in ["GL_ELEMENT_ARRAY_BUFFER"]:
            raise VAOError("Element buffers must have target=GL_ELEMENT_ARRAY_BUFFER")

        if format not in [GL.GL_UNSIGNED_INT]:
            raise VAOError("Format can currently only be GL_UNSIGNED_INT")

        self.element_buffer = ArrayBuffer(format, vbo) 
开发者ID:Contraz,项目名称:demosys-py,代码行数:19,代码来源:vao.py

示例7: map_buffer

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def map_buffer(self, vbo, attrib_name, components):
        """
        Map parts of the vbos to an attribute name.
        This can be called multiple times to describe hos the buffers map to attribute names.
        If the same vbo is passed more than once it must be an interleaved buffer.

        :param vbo: The vbo
        :param attrib_name: Name of the attribute in the shader
        :param components: Number of components (for example 3 for a x, y, x position)
        """
        if not isinstance(vbo, VBO):
            raise VAOError("vbo parameter must be an OpenGL.arrays.vbo.VBO instance")

        ab = self.array_buffer_map.get(id(vbo))
        if not ab:
            raise VAOError("VBO {} not previously added as an array map. "
                           "Forgot to call add_arrray_buffer(..)?".format(id(vbo)))

        # FIXME: Determine byte size based on data type in VBO
        offset = ab.stride
        ab.stride += components * type_size(ab.format)
        am = ArrayMapping(ab, attrib_name, components, offset)

        self.array_mapping.append(am)
        self.array_mapping_map[attrib_name] = am 
开发者ID:Contraz,项目名称:demosys-py,代码行数:27,代码来源:vao.py

示例8: points_random_3d

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def points_random_3d(count, range_x=(-10.0, 10.0), range_y=(-10.0, 10.0), range_z=(-10.0, 10.0), seed=None):
    """
    Generates random positions

    :param count: Number of points
    :param range_x: min-max range for x axis
    :param range_y: min-max range for y axis
    :param range_z: min-max range for z axis
    :param seed: The random seed to be used
    """
    random.seed(seed)

    def gen():
        for i in range(count):
            yield random.uniform(*range_x)
            yield random.uniform(*range_y)
            yield random.uniform(*range_z)

    data = numpy.fromiter(gen(), count=count * 3, dtype=numpy.float32)
    pos = VBO(data)
    vao = VAO("geometry:points_random_3d", mode=GL.GL_POINTS)
    vao.add_array_buffer(GL.GL_FLOAT, pos)
    vao.map_buffer(pos, "in_position", 3)
    vao.build()
    return vao 
开发者ID:Contraz,项目名称:demosys-py,代码行数:27,代码来源:points.py

示例9: initializeGL

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def initializeGL(self):
        super().initializeGL('sb05a.shaders')

        v = np.array([
             0.25, -0.25,  0.50, 1.0, 0.0, 0.0,
            -0.25, -0.25,  0.50, 0.0, 1.0, 0.0,
             0.00,  0.25,  0.50, 0.0, 0.0, 1.0], dtype=np.float32)

        vertex_b = vbo.VBO(v)
        vertex_b.bind()

        glVertexAttribPointer(self.program.A['position_vs'], 3, GL_FLOAT, GL_FALSE, 24, None)
        glEnableVertexAttribArray(0)

        glVertexAttribPointer(self.program.A['color_vs'], 3, GL_FLOAT, GL_FALSE, 24, ctypes.c_void_p(12))
        glEnableVertexAttribArray(1)

        print('initialization done') 
开发者ID:wakita,项目名称:glvis,代码行数:20,代码来源:sb05a3.py

示例10: __enter__

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def __enter__(self):
        # Create the VBO
        vertices = np.array([
            [1, 1, 0, 1, 1],
            [1, -1, 0, 1, -1],
            [-1, -1, 0, -1, -1],
            [-1, 1, 0, -1, 1]], dtype='f')
        self.vertexPositions = vbo.VBO(vertices)

        # Create the index buffer object
        indices = np.array([[0, 1, 2], [0, 2, 3]], dtype=np.int32)
        self.index_positions = vbo.VBO(indices,
                                       target=GL.GL_ELEMENT_ARRAY_BUFFER)
        self.shader = shaders.compileProgram(self.vertex_shader,
                                             self.fragment_shader)
        self.create_texture()

        uConnectedLoc = GL.glGetUniformLocation(self.shader, 'connected')
        GL.glUniform1i(uConnectedLoc, 1 if self.connected else 0)
        return self 
开发者ID:MateusZitelli,项目名称:convert360,代码行数:22,代码来源:projector.py

示例11: __get_position_index

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def __get_position_index(self, point):
        """
        Get the index in the point VBO for a given Point2 coordinate
        :type point: pcbre.matrix.Point2
        :param point:
        :return:
        """
        norm_pos = point.intTuple()

        try:
            return self.__position_lookup[norm_pos]
        except KeyError:
            self.__position_lookup[norm_pos] = len(self.__position_list)
            self.__position_list.append(norm_pos)
            self.__vert_vbo_current = False

        return self.__position_lookup[norm_pos] 
开发者ID:pcbre,项目名称:pcbre,代码行数:19,代码来源:cachedpolygonrenderer.py

示例12: __build_trace

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def __build_trace(self):
        # Update trace VBO
        self.working_array["vertex"][0] = (0,0)
        self.working_array["ptid"][0] = 0
        self.working_array["vertex"][1] = (0,0)
        self.working_array["ptid"][1] = 1

        end = Vec2(1,0)
        for i in range(0, NUM_ENDCAP_SEGMENTS):
            theta = math.pi * i/(NUM_ENDCAP_SEGMENTS - 1) + math.pi/2
            m = rotate(theta).dot(end.homol())
            self.working_array["vertex"][2 + i] = m[:2]
            self.working_array["ptid"][2 + i] = 0
            self.working_array["vertex"][2 + i + NUM_ENDCAP_SEGMENTS] = -m[:2]
            self.working_array["ptid"][2 + i + NUM_ENDCAP_SEGMENTS] = 1

        # Force data copy
        self.trace_vbo.copied = False
        self.trace_vbo.bind() 
开发者ID:pcbre,项目名称:pcbre,代码行数:21,代码来源:traceview.py

示例13: __init__

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def __init__(self, **kwds):
        GLGraphicsItem.__init__(self)
        glopts = kwds.pop('glOptions', 'additive')
        self.setGLOptions(glopts)
        self.pos = []
        self.size = 10
        self.color = [1.0,1.0,1.0,0.5]
        self.pxMode = True
        #self.vbo = {}      ## VBO does not appear to improve performance very much.
        self.setData(**kwds) 
开发者ID:neoanalysis,项目名称:NeoAnalysis,代码行数:12,代码来源:GLScatterPlotItem.py

示例14: initializeGL

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def initializeGL(self):
        
        ## Generate texture for rendering points
        w = 64
        def fn(x,y):
            r = ((x-w/2.)**2 + (y-w/2.)**2) ** 0.5
            return 255 * (w/2. - np.clip(r, w/2.-1.0, w/2.))
        pData = np.empty((w, w, 4))
        pData[:] = 255
        pData[:,:,3] = np.fromfunction(fn, pData.shape[:2])
        #print pData.shape, pData.min(), pData.max()
        pData = pData.astype(np.ubyte)
        
        if getattr(self, "pointTexture", None) is None:
            self.pointTexture = glGenTextures(1)
        glActiveTexture(GL_TEXTURE0)
        glEnable(GL_TEXTURE_2D)
        glBindTexture(GL_TEXTURE_2D, self.pointTexture)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pData.shape[0], pData.shape[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, pData)
        
        self.shader = shaders.getShaderProgram('pointSprite')
        
    #def getVBO(self, name):
        #if name not in self.vbo:
            #self.vbo[name] = vbo.VBO(getattr(self, name).astype('f'))
        #return self.vbo[name]
        
    #def setupGLState(self):
        #"""Prepare OpenGL state for drawing. This function is called immediately before painting."""
        ##glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)  ## requires z-sorting to render properly.
        #glBlendFunc(GL_SRC_ALPHA, GL_ONE)
        #glEnable( GL_BLEND )
        #glEnable( GL_ALPHA_TEST )
        #glDisable( GL_DEPTH_TEST )
        
        ##glEnable( GL_POINT_SMOOTH )

        ##glHint(GL_POINT_SMOOTH_HINT, GL_NICEST)
        ##glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, (0, 0, -1e-3))
        ##glPointParameterfv(GL_POINT_SIZE_MAX, (65500,))
        ##glPointParameterfv(GL_POINT_SIZE_MIN, (0,)) 
开发者ID:neoanalysis,项目名称:NeoAnalysis,代码行数:43,代码来源:GLScatterPlotItem.py

示例15: initializeGL

# 需要导入模块: from OpenGL.arrays import vbo [as 别名]
# 或者: from OpenGL.arrays.vbo import VBO [as 别名]
def initializeGL(self):
        """Initialize OpenGL, VBOs, upload data on the GPU, etc.
        """
        # background color
        gl.glClearColor(0,0,0,0)
        # create a Vertex Buffer Object with the specified data
        self.vbo = glvbo.VBO(self.data) 
开发者ID:kmolLin,项目名称:Pyquino,代码行数:9,代码来源:opgl_class.py


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