예제 #1
0
    def __init__(self):
        pts = generate_cyl_points().T

        colors = np.zeros_like(pts)
        colors[:,1]=1.0 # all green

        n_pts = len(pts)
        pts = map(float,pts.flat) # convert to flat list of floats
        colors = map(float, colors.flat)

        # Create ctypes arrays of the lists
        vertices = (gl.GLfloat * (n_pts*3))(*pts)
        colors = (gl.GLfloat * (n_pts*3))(*colors)

        # Create a list of triangle indices.
        indices = range(n_pts)
        indices = (gl.GLuint * n_pts)(*indices)

        # Compile a display list
        self.list = gl.glGenLists(1)
        gl.glNewList(self.list, gl.GL_COMPILE)

        gl.glPushClientAttrib(gl.GL_CLIENT_VERTEX_ARRAY_BIT)
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertices)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        gl.glColorPointer(3, gl.GL_FLOAT, 0, colors)
        gl.glDrawElements(gl.GL_LINES, len(indices), gl.GL_UNSIGNED_INT, indices)
        gl.glPopClientAttrib()

        gl.glEndList()
예제 #2
0
    def __init__(self):
        pts = generate_cyl_points().T

        colors = np.zeros_like(pts)
        colors[:,1]=1.0 # all green

        n_pts = len(pts)
        pts = map(float,pts.flat) # convert to flat list of floats
        colors = map(float, colors.flat)

        # Create ctypes arrays of the lists
        vertices = (gl.GLfloat * (n_pts*3))(*pts)
        colors = (gl.GLfloat * (n_pts*3))(*colors)

        # Create a list of triangle indices.
        indices = range(n_pts)
        indices = (gl.GLuint * n_pts)(*indices)

        # Compile a display list
        self.list = gl.glGenLists(1)
        gl.glNewList(self.list, gl.GL_COMPILE)

        gl.glPushClientAttrib(gl.GL_CLIENT_VERTEX_ARRAY_BIT)
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertices)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        gl.glColorPointer(3, gl.GL_FLOAT, 0, colors)
        gl.glDrawElements(gl.GL_POINTS, len(indices), gl.GL_UNSIGNED_INT, indices)
        gl.glPopClientAttrib()

        gl.glEndList()
예제 #3
0
    def on_draw(self):
        """
        Render the screen.
        """
        start = time.time()

        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glDisable(GL.GL_BLEND)

        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.vertex_vbo_id)
        GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
        GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)

        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.color_vbo_id)
        GL.glEnableClientState(GL.GL_COLOR_ARRAY)
        GL.glColorPointer(3, GL.GL_FLOAT, 0, 0)

        offset = 0
        for shape in self.shape_list:
            render_rect_filled(shape, offset)
            offset += 4

        elapsed = time.time() - start
        print(elapsed)
예제 #4
0
    def drawnvc( self, normals, points, colors, idxs  ):
        '''draw tri mesh using glDrawElements
        using input normals points colors and indexes'''
        n = 1
        for dim in idxs.shape:
            n *= dim

        iptr = vecutil.numpy2pointer(idxs)
        nptr = vecutil.numpy2pointer(normals)
        vptr = vecutil.numpy2pointer(points)
        cptr = vecutil.numpy2pointer(colors)

        mode = self.ui.fillmodes[self.ui.fillmode]

        gl.glPolygonMode( gl.GL_FRONT, mode )
        
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_NORMAL_ARRAY)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        gl.glVertexPointer(3, gl.GL_FLOAT, 0, vptr)
        gl.glNormalPointer( gl.GL_FLOAT, 0, nptr)
        gl.glColorPointer(3, gl.GL_FLOAT, 0, cptr)
        gl.glDrawElements(gl.gl.GL_TRIANGLES, n, gl.GL_UNSIGNED_INT, iptr)

        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
        gl.glDisableClientState(gl.GL_NORMAL_ARRAY)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)

        gl.glPolygonMode( gl.GL_FRONT, gl.GL_FILL )
예제 #5
0
    def draw(self):
        """Draw the text to the back buffer"""
        # Border width
        self.box.setLineWidth(
            self.palette['lineWidth'])  # Use 1 as base if border width is none
        #self.borderWidth = self.box.lineWidth
        # Border colour
        self.box.setLineColor(self.palette['lineColor'], colorSpace='rgb')
        #self.borderColor = self.box.lineColor
        # Background
        self.box.setFillColor(self.palette['fillColor'], colorSpace='rgb')
        #self.fillColor = self.box.fillColor

        if self._needVertexUpdate:
            #print("Updating vertices...")
            self._updateVertices()
        if self.fillColor is not None or self.borderColor is not None:
            self.box.draw()

        # self.boundingBox.draw()  # could draw for debug purposes
        gl.glPushMatrix()
        self.win.setScale('pix')

        gl.glActiveTexture(gl.GL_TEXTURE0)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self.glFont.textureID)
        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glDisable(gl.GL_DEPTH_TEST)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)

        gl.glVertexPointer(2, gl.GL_DOUBLE, 0, self.verticesPix.ctypes)
        gl.glColorPointer(4, gl.GL_DOUBLE, 0, self._colors.ctypes)
        gl.glTexCoordPointer(2, gl.GL_DOUBLE, 0, self._texcoords.ctypes)

        self.shader.bind()
        self.shader.setInt('texture', 0)
        self.shader.setFloat('pixel', [1.0 / 512, 1.0 / 512])
        nVerts = len(self._text) * 4

        gl.glDrawArrays(gl.GL_QUADS, 0, nVerts)
        self.shader.unbind()

        # removed the colors and font texture
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)
        gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        gl.glDisableVertexAttribArray(1)
        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)

        gl.glActiveTexture(gl.GL_TEXTURE0)
        gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
        gl.glDisable(gl.GL_TEXTURE_2D)

        if self.hasFocus:  # draw caret line
            self.caret.draw()

        gl.glPopMatrix()
예제 #6
0
def render(shape):
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glLoadIdentity()
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_COLOR_ARRAY)
    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, shape.vbo_id)
    gl.glVertexPointer(2, gl.GL_FLOAT, 0, None)
    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, shape.vbo_color_id)
    gl.glColorPointer(4, gl.GL_FLOAT, 0, None)
    gl.glDrawArrays(shape.draw_mode, 0, shape.size)
def stripped_render_with_colors(shape: VertexBuffer):
    """
    Render an shape previously created with a ``create`` function.
    Used by ``ShapeElementList.draw()`` for drawing several shapes in a batch.
    This version also assumes there is a color list as part of the VBO.
    """

    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, shape.vbo_vertex_id)
    gl.glVertexPointer(2, gl.GL_FLOAT, 0, None)
    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, shape.vbo_color_id)
    gl.glColorPointer(4, gl.GL_FLOAT, 0, None)
    gl.glDrawArrays(shape.draw_mode, 0, shape.size)
예제 #8
0
    def draw(self):
        gl.glClearColor(0.2, 0.4, 0.5, 1.0)
        gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)                             
        gl.glEnable (gl.GL_BLEND)                                                            
        gl.glEnable (gl.GL_LINE_SMOOTH);                                                     
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)

        #TODO verts._buffer.ctypes.data is awkward
        gl.glVertexPointer(2, self.vert_dtype.gl, 0, self.verts._buffer.ctypes.data)
        gl.glColorPointer(3,  self.color_dtype.gl, 0, self.colors._buffer.ctypes.data)
        gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, len(self.verts._buffer)//2)
예제 #9
0
    def draw_fallback(self):
        """Called instead of :meth:`draw` when quads are used instead of
        Point Sprite.
        """
        self.make_delta_pos_to_vertex()
        self.update_vertexs_from_pos()
        self.update_per_vertex_colors()

        gl.glPushMatrix()
        self.transform()

        # color preserve - at least intel 945G needs that
        gl.glPushAttrib(gl.GL_CURRENT_BIT)

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture.id)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        vertexs_ptr = PointerToNumpy(self.vertexs)
        gl.glVertexPointer(2, gl.GL_FLOAT, 0, vertexs_ptr)

        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        color_ptr = PointerToNumpy(self.per_vertex_colors)
        # gl.glColorPointer(4, gl.GL_UNSIGNED_BYTE, 0, color_ptr)
        gl.glColorPointer(4, gl.GL_FLOAT, 0, color_ptr)

        gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        tex_coord_ptr = PointerToNumpy(self.tex_coords)
        gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, tex_coord_ptr)

        gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
        gl.glEnable(gl.GL_BLEND)
        if self.blend_additive:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        else:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        gl.glDrawArrays(gl.GL_QUADS, 0, len(self.vertexs) * 4)

        # un -blend
        gl.glPopAttrib()

        # color restore
        gl.glPopAttrib()

        # disable states
        gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)
        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
        gl.glDisable(gl.GL_TEXTURE_2D)

        gl.glPopMatrix()
예제 #10
0
파일: particle.py 프로젝트: fpietka/cocos
    def draw_fallback(self):
        """Called instead of :meth:`draw` when quads are used instead of
        Point Sprite.
        """
        self.make_delta_pos_to_vertex()
        self.update_vertexs_from_pos()
        self.update_per_vertex_colors()

        gl.glPushMatrix()
        self.transform()

        # color preserve - at least intel 945G needs that
        gl.glPushAttrib(gl.GL_CURRENT_BIT)

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture.id)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        vertexs_ptr = PointerToNumpy(self.vertexs)
        gl.glVertexPointer(2, gl.GL_FLOAT, 0, vertexs_ptr)

        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        color_ptr = PointerToNumpy(self.per_vertex_colors)
        # gl.glColorPointer(4, gl.GL_UNSIGNED_BYTE, 0, color_ptr)
        gl.glColorPointer(4, gl.GL_FLOAT, 0, color_ptr)

        gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        tex_coord_ptr = PointerToNumpy(self.tex_coords)
        gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, tex_coord_ptr)

        gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
        gl.glEnable(gl.GL_BLEND)
        if self.blend_additive:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        else:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        gl.glDrawArrays(gl.GL_QUADS, 0, len(self.vertexs) * 4)

        # un -blend
        gl.glPopAttrib()

        # color restore
        gl.glPopAttrib()

        # disable states
        gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)
        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
        gl.glDisable(gl.GL_TEXTURE_2D)

        gl.glPopMatrix()
def update_display(render_verts, colors):
    gl.glClearColor(0.2, 0.4, 0.5, 1.0)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_COLOR_ARRAY)

    n = len(render_verts[:])
    # TODO verts._buffer.ctypes.data is awkward
    gl.glVertexPointer(3, vert_dtype.gl, 0, render_verts[:].ctypes.data)
    gl.glColorPointer(3, color_dtype.gl, 0, colors[:].ctypes.data)
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, n)
def update_display(render_verts, colors):
    gl.glClearColor(0.2, 0.4, 0.5, 1.0)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_COLOR_ARRAY)

    n = len(render_verts[:])
    #TODO verts._buffer.ctypes.data is awkward
    gl.glVertexPointer(3, vert_dtype.gl, 0, render_verts[:].ctypes.data)
    gl.glColorPointer(3, color_dtype.gl, 0, colors[:].ctypes.data)
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, n)
예제 #13
0
def draw(verts, colors):
    '''draw the numpy arrays `verts` and `colors`.'''

    gl.glClearColor(0.2, 0.4, 0.5, 1.0)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_COLOR_ARRAY)

    gl.glVertexPointer(2, vert_dtype.gl_type, 0, verts.ctypes.data)
    gl.glColorPointer(3, color_dtype.gl_type, 0, colors.ctypes.data)
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, len(verts) // 2)
    fps_display.draw()
예제 #14
0
def draw(verts,colors):
    '''draw the numpy arrays `verts` and `colors`.'''

    gl.glClearColor(0.2, 0.4, 0.5, 1.0)
    gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)                             
    gl.glEnable (gl.GL_BLEND)                                                            
    gl.glEnable (gl.GL_LINE_SMOOTH);                                                     
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_COLOR_ARRAY)

    gl.glVertexPointer(2, vert_dtype.gl_type, 0, verts.ctypes.data)
    gl.glColorPointer(3,  color_dtype.gl_type, 0, colors.ctypes.data)
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, len(verts)//2)
    fps_display.draw()
예제 #15
0
    def drawlines( self, verts, colors, idxs ):
        'helper to draw lines from numpy arrays of verts/colors/indexes'
        vptr = vecutil.numpy2pointer(verts)
        iptr = vecutil.numpy2pointer(idxs)

        if colors is not None:
            cptr = vecutil.numpy2pointer(colors)
            gl.glEnableClientState(gl.GL_COLOR_ARRAY)
            gl.glColorPointer(3, gl.GL_FLOAT, 0, cptr)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        gl.glVertexPointer(3, gl.GL_FLOAT, 0, vptr)
        gl.glDrawElements(gl.GL_LINES, len(idxs), gl.GL_UNSIGNED_INT, iptr)
        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)
예제 #16
0
    def render_road(self):
        if self.initialized < 3:
            vertices = []
            colors = []

            def vert(a, b, c):
                for v in (a, b, c):
                    vertices.append(v)
                for c in color:
                    colors.append(c)

            color = (0.4, 0.8, 0.4, 1.0)
            vert(-PLAYFIELD, +PLAYFIELD, 0)
            vert(+PLAYFIELD, +PLAYFIELD, 0)
            vert(+PLAYFIELD, -PLAYFIELD, 0)
            vert(-PLAYFIELD, -PLAYFIELD, 0)
            color = (0.4, 0.9, 0.4, 1.0)
            k = PLAYFIELD / 20.0
            for x in range(-20, 20, 2):
                for y in range(-20, 20, 2):
                    vert(k * x + k, k * y + 0, 0)
                    vert(k * x + 0, k * y + 0, 0)
                    vert(k * x + 0, k * y + k, 0)
                    vert(k * x + k, k * y + k, 0)
            for poly, col in self.road_poly:
                color = (col[0], col[1], col[2], 1)
                for p in poly:
                    vert(p[0], p[1], 0)
            self.initialized += 1
            gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
            gl_vertices = (gl.GLfloat * len(vertices))(*vertices)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER_ARB, self.vertex_vbo_id)
            gl.glBufferData(gl.GL_ARRAY_BUFFER_ARB,
                            len(vertices) * 4, gl_vertices, gl.GL_STATIC_DRAW)

            gl_colors = (gl.GLfloat * len(colors))(*colors)
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER_ARB, self.color_vbo_id)
            gl.glBufferData(gl.GL_ARRAY_BUFFER_ARB,
                            len(colors) * 4, gl_colors, gl.GL_STATIC_DRAW)
            self.numdraw = len(vertices) // 3
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER_ARB, self.vertex_vbo_id)
        gl.glVertexPointer(3, gl.GL_FLOAT, 0, 0)

        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER_ARB, self.color_vbo_id)
        gl.glColorPointer(4, gl.GL_FLOAT, 0, 0)

        gl.glDrawArrays(gl.GL_QUADS, 0, self.numdraw)
예제 #17
0
    def paintGL(self):
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        gl.glLoadIdentity()

        #draw lines
        gl.glEnableClientState(gl.GL_COLOR_ARRAY)

        self.lineVerts = (self.spl.segments + self.centre).flatten()
        self.lineVerts_gl = (gl.GLfloat * len(self.lineVerts))(*self.lineVerts)
        self.lineColors = (self.spl.segColor).flatten()
        self.lineColors_gl = (gl.GLfloat *
                              len(self.lineColors))(*self.lineColors)

        gl.glVertexPointer(2, gl.GL_FLOAT, 0, self.lineVerts_gl)
        gl.glColorPointer(4, gl.GL_FLOAT, 0, self.lineColors_gl)
        gl.glDrawArrays(gl.GL_LINES, 0, len(self.lineVerts) // 2)

        gl.glDisableClientState(gl.GL_COLOR_ARRAY)

        #draw points
        gl.glColor3f(1.0, 1.0, 1.0)
        vertPoints = (self.spl.state[:, :2] + self.centre).flatten().astype(
            ctypes.c_float)
        vertices_gl = vertPoints.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
        gl.glVertexPointer(2, gl.GL_FLOAT, 0, vertices_gl)
        gl.glDrawArrays(gl.GL_POINTS, 0, len(vertPoints) // 2)

        #overdraw selected point
        if self.spl.clicked != -1:
            gl.glColor3f(1.0, 0.0, 0.0)
            point = (self.spl.clickedState[:2] + self.centre).astype(
                ctypes.c_float)
            point_gl = point.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
            gl.glVertexPointer(2, gl.GL_FLOAT, 0, point_gl)
            gl.glDrawArrays(gl.GL_POINTS, 0, 1)

        pyglet.text.Label("Epoch: %s" % self.secStruct.epochCount,
                          x=5,
                          y=10,
                          font_name='Times New Roman',
                          font_size=20).draw()
예제 #18
0
파일: zgl2.py 프로젝트: znah/yoxel-voxel
def draw_arrays(primitive, verts=None, colors=None, tc0=None, tc1=None, tc2=None, tc3=None):
    states = []
    if verts is not None:
        verts = ascont(verts)
        assert verts.ndim >= 2 and verts.shape[-1] <= 4
        gl.glVertexPointer( verts.shape[-1], arrayToGLType(verts), verts.strides[-2], verts.ctypes.data)
        states.append( gl.GL_VERTEX_ARRAY )
    if colors is not None:
        colors = ascont(colors)
        gl.glColorPointer( colors.shape[-1], arrayToGLType(colors), colors.strides[-2], colors.ctypes.data)
        states.append( gl.GL_COLOR_ARRAY )
    protect = []
    for i, tc in enumerate([tc0, tc1, tc2, tc3]):
        if tc is not None:
            tc = ascont(tc)
            protect.append(tc)
            gl.glClientActiveTexture(GL_TEXTURE0 + i) 
            gl.glTexCoordPointer(tc.shape[-1], arrayToGLType(tc), tc.strides[-2], tc.ctypes.data)
            states.append( (GL_TEXTURE_COORD_ARRAY, i) )
    with glstate(*states):
        gl.glDrawArrays( primitive, 0, np.prod(verts.shape[:-1]) )
예제 #19
0
파일: Scene.py 프로젝트: bm1362/atlas-py
    def draw_background(self):
        varray = []
        carray = []
        x = self.top_left['x']
        y = self.top_left['y']
        
        for _ in self.background:
            basePosition = _[0]
            depth = _[1]
            color = _[2]

            #parallax scrolling and wrapping
            realPosition = (basePosition[0] + x * depth, basePosition[1] + y * depth)
            wrappedPosition = ( realPosition[0] % self.background_width, realPosition[1] % self.background_height)
            varray += [wrappedPosition[0], wrappedPosition[1], 0]
            carray += color

        # # # needs to be commented and understood..
        # glEnable(GL_BLEND)
        # glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)
        # point_size = GLfloat(10.0)
        # glGetFloatv(GL_POINT_SIZE_MAX_ARB, point_size)
        # glPointSize(point_size)
        # glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, (GLfloat * 3)(0, 0, 5))
        # glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 5)
                
        varray = (GLfloat * len(varray))(*varray)
        carray = (GLfloat * len(carray))(*carray)

        glVertexPointer(3, GL_FLOAT, 0, varray)
        glColorPointer(4, GL_FLOAT, 0, carray)

        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_COLOR_ARRAY)
        
        glDrawArrays(GL_POINTS, 0, len(varray)//3)
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);
예제 #20
0
 def color(self):
     gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffers["color"])
     gl.glColorPointer(4, gl.GL_FLOAT, 0, 0)
예제 #21
0
파일: actors.py 프로젝트: pavlog/Printrun
    def _display_movements(self, has_vbo):
        self.vertex_buffer.bind()
        glVertexPointer(3, GL_FLOAT, 0, self.vertex_buffer.ptr)

        self.vertex_color_buffer.bind()
        glColorPointer(3, GL_FLOAT, 0, self.vertex_color_buffer.ptr)

        self.vertex_normal_buffer.bind()
        glNormalPointer(GL_FLOAT, 0, self.vertex_normal_buffer.ptr)

        self.index_buffer.bind()

        # Prevent race condition by using the number of currently loaded layers
        max_layers = self.layers_loaded

        start = 1
        layer_selected = self.num_layers_to_draw <= max_layers
        if layer_selected:
            end_prev_layer = self.layer_stops[self.num_layers_to_draw - 1]
        else:
            end_prev_layer = 0
        end = self.layer_stops[min(self.num_layers_to_draw, max_layers)]

        glDisableClientState(GL_COLOR_ARRAY)

        glColor3f(*self.color_printed[:-1])

        # Draw printed stuff until end or end_prev_layer
        cur_end = min(self.printed_until, end)
        if not self.only_current:
            if 1 <= end_prev_layer <= cur_end:
                self._draw_elements(1, end_prev_layer)
            elif cur_end >= 1:
                self._draw_elements(1, cur_end)

        glEnableClientState(GL_COLOR_ARRAY)

        # Draw nonprinted stuff until end_prev_layer
        start = max(cur_end, 1)
        if end_prev_layer >= start:
            if not self.only_current:
                self._draw_elements(start, end_prev_layer)
            cur_end = end_prev_layer

        # Draw current layer
        if layer_selected:
            glDisableClientState(GL_COLOR_ARRAY)

            glColor3f(*self.color_current_printed[:-1])

            if cur_end > end_prev_layer:
                self._draw_elements(end_prev_layer + 1, cur_end)

            glColor3f(*self.color_current[:-1])

            if end > cur_end:
                self._draw_elements(cur_end + 1, end)

            glEnableClientState(GL_COLOR_ARRAY)

        # Draw non printed stuff until end (if not ending at a given layer)
        start = max(self.printed_until, 1)
        if not layer_selected and end >= start:
            self._draw_elements(start, end)

        self.index_buffer.unbind()
        self.vertex_buffer.unbind()
        self.vertex_color_buffer.unbind()
        self.vertex_normal_buffer.unbind()
예제 #22
0
파일: actors.py 프로젝트: ptitleud/Printrun
    def _display_movements(self, mode_2d=False):
        self.vertex_buffer.bind()
        has_vbo = isinstance(self.vertex_buffer, VertexBufferObject)
        if has_vbo:
            glVertexPointer(3, GL_FLOAT, 0, None)
        else:
            glVertexPointer(3, GL_FLOAT, 0, self.vertex_buffer.ptr)

        self.vertex_color_buffer.bind()
        if has_vbo:
            glColorPointer(4, GL_FLOAT, 0, None)
        else:
            glColorPointer(4, GL_FLOAT, 0, self.vertex_color_buffer.ptr)

        start = 0
        if self.num_layers_to_draw <= self.max_layers:
            end_prev_layer = self.layer_stops[self.num_layers_to_draw - 1]
        else:
            end_prev_layer = -1
        end = self.layer_stops[min(self.num_layers_to_draw, self.max_layers)]

        glDisableClientState(GL_COLOR_ARRAY)

        glColor4f(*self.color_printed)

        # Draw printed stuff until end or end_prev_layer
        cur_end = min(self.printed_until, end)
        if not self.only_current:
            if 0 <= end_prev_layer <= cur_end:
                glDrawArrays(GL_LINES, start, end_prev_layer)
            elif cur_end >= 0:
                glDrawArrays(GL_LINES, start, cur_end)

        glEnableClientState(GL_COLOR_ARRAY)

        # Draw nonprinted stuff until end_prev_layer
        start = max(cur_end, 0)
        if end_prev_layer >= start:
            if not self.only_current:
                glDrawArrays(GL_LINES, start, end_prev_layer - start)
            cur_end = end_prev_layer

        # Draw current layer
        if end_prev_layer >= 0:
            glDisableClientState(GL_COLOR_ARRAY)

            # Backup & increase line width
            orig_linewidth = (GLfloat)()
            glGetFloatv(GL_LINE_WIDTH, orig_linewidth)
            glLineWidth(2.0)

            glColor4f(*self.color_current_printed)

            if cur_end > end_prev_layer:
                glDrawArrays(GL_LINES, end_prev_layer, cur_end - end_prev_layer)

            glColor4f(*self.color_current)

            if end > cur_end:
                glDrawArrays(GL_LINES, cur_end, end - cur_end)

            # Restore line width
            glLineWidth(orig_linewidth)

            glEnableClientState(GL_COLOR_ARRAY)

        # Draw non printed stuff until end (if not ending at a given layer)
        start = max(self.printed_until, 0)
        end = end - start
        if end_prev_layer < 0 and end > 0 and not self.only_current:
            glDrawArrays(GL_LINES, start, end)

        self.vertex_buffer.unbind()
        self.vertex_color_buffer.unbind()
예제 #23
0
def drawVertexbuffers(vertexBuffer, *args, mode=GL.GL_TRIANGLES, flush=True):
    """Draw a vertex buffer using glDrawArrays. This method does not require
    shaders.

    Parameters
    ----------
    vertexBuffer : :obj:`Vertexbuffer`
        Vertex buffer descriptor, must have 'bufferType' as GL_VERTEX_ARRAY.
        Optional vertex buffer descriptors can be passed as seperate arguments,
        they must have 'bufferTypes' as GL_TEXTURE_COORD_ARRAY, GL_NORMAL_ARRAY
        or GL_COLOR_ARRAY.
    mode : :obj:`int`
        Drawing mode to use (e.g. GL_TRIANGLES, GL_QUADS, GL_POINTS, etc.)
    flush : :obj:`bool`
        Flush queued drawing commands before returning.

    Returns
    -------
    None

    Examples
    --------
    # vertices of a triangle
    verts = [ 1.0,  1.0, 0.0,   # v0
              0.0, -1.0, 0.0,   # v1
             -1.0,  1.0, 0.0]   # v2

    # triangle vertex colors
    colors = [1.0, 0.0, 0.0,  # v0
              0.0, 1.0, 0.0,  # v1
              0.0, 0.0, 1.0]  # v2

    # load vertices to graphics device, return a descriptor
    vertexBuffer = createVertexbuffer(verts, 3)
    colorBuffer = createVertexbuffer(c, 3, GL.GL_COLOR_ARRAY)

    # draw the VBO
    drawVertexbuffer(vertexBuffer, colorBuffer, GL.GL_TRIANGLES)

    """
    # must have a vertex pointer
    assert vertexBuffer.bufferType == GL.GL_VERTEX_ARRAY

    # bind and set the vertex pointer
    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer.id)
    GL.glVertexPointer(vertexBuffer.vertexSize, vertexBuffer.dtype, 0, None)
    GL.glEnableClientState(vertexBuffer.bufferType)

    # handle additional buffers
    if args:
        for buffer in args:
            # check if the number of indicies are the same
            if vertexBuffer.indices != buffer.indices:
                raise RuntimeError("Vertex buffer indices do not match!")

            GL.glBindBuffer(GL.GL_ARRAY_BUFFER, buffer.id)
            if buffer.bufferType == GL.GL_TEXTURE_COORD_ARRAY:
                GL.glTexCoordPointer(buffer.dtype, 0, None)
            elif buffer.bufferType == GL.GL_NORMAL_ARRAY:
                GL.glNormalPointer(buffer.dtype, 0, None)
            elif buffer.bufferType == GL.GL_COLOR_ARRAY:
                GL.glColorPointer(buffer.vertexSize, buffer.dtype, 0, None)

            GL.glEnableClientState(buffer.bufferType)

    GL.glDrawArrays(mode, 0, vertexBuffer.indices)  # draw arrays

    # reset
    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, 0)
    GL.glDisableClientState(vertexBuffer.bufferType)
    if args:
        for vbo in args:
            GL.glDisableClientState(vbo.bufferType)

    if flush:
        GL.glFlush()
예제 #24
0
    def _display_movements(self, has_vbo):
        self.vertex_buffer.bind()
        glVertexPointer(3, GL_FLOAT, 0, self.vertex_buffer.ptr)

        self.vertex_color_buffer.bind()
        glColorPointer(3, GL_FLOAT, 0, self.vertex_color_buffer.ptr)

        self.vertex_normal_buffer.bind()
        glNormalPointer(GL_FLOAT, 0, self.vertex_normal_buffer.ptr)

        self.index_buffer.bind()

        # Prevent race condition by using the number of currently loaded layers
        max_layers = self.layers_loaded

        start = 1
        layer_selected = self.num_layers_to_draw <= max_layers
        if layer_selected:
            end_prev_layer = self.layer_stops[self.num_layers_to_draw - 1]
        else:
            end_prev_layer = 0
        end = self.layer_stops[min(self.num_layers_to_draw, max_layers)]

        glDisableClientState(GL_COLOR_ARRAY)

        glColor3f(*self.color_printed[:-1])

        # Draw printed stuff until end or end_prev_layer
        cur_end = min(self.printed_until, end)
        if not self.only_current:
            if 1 <= end_prev_layer <= cur_end:
                self._draw_elements(1, end_prev_layer)
            elif cur_end >= 1:
                self._draw_elements(1, cur_end)

        glEnableClientState(GL_COLOR_ARRAY)

        # Draw nonprinted stuff until end_prev_layer
        start = max(cur_end, 1)
        if end_prev_layer >= start:
            if not self.only_current:
                self._draw_elements(start, end_prev_layer)
            cur_end = end_prev_layer

        # Draw current layer
        if layer_selected:
            glDisableClientState(GL_COLOR_ARRAY)

            glColor3f(*self.color_current_printed[:-1])

            if cur_end > end_prev_layer:
                self._draw_elements(end_prev_layer + 1, cur_end)

            glColor3f(*self.color_current[:-1])

            if end > cur_end:
                self._draw_elements(cur_end + 1, end)

            glEnableClientState(GL_COLOR_ARRAY)

        # Draw non printed stuff until end (if not ending at a given layer)
        start = max(self.printed_until, 1)
        if not layer_selected and end >= start:
            self._draw_elements(start, end)

        self.index_buffer.unbind()
        self.vertex_buffer.unbind()
        self.vertex_color_buffer.unbind()
        self.vertex_normal_buffer.unbind()
예제 #25
0
파일: particle.py 프로젝트: fpietka/cocos
    def draw(self):
        """Draw the particles system"""
        gl.glPushMatrix()
        self.transform()

        # color preserve - at least nvidia 6150SE needs that
        gl.glPushAttrib(gl.GL_CURRENT_BIT)
        # glPointSize(self.get_scaled_particle_size())

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glEnable(gl.GL_PROGRAM_POINT_SIZE)
        # glBindTexture(GL_TEXTURE_2D, self.texture.id)


        gl.glEnable(gl.GL_POINT_SPRITE)
        gl.glTexEnvi(gl.GL_POINT_SPRITE, gl.GL_COORD_REPLACE, gl.GL_TRUE)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        vertex_ptr = PointerToNumpy(self.particle_pos)
        gl.glVertexPointer(2, gl.GL_FLOAT, 0, vertex_ptr)

        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        color_ptr = PointerToNumpy(self.particle_color)
        gl.glColorPointer(4, gl.GL_FLOAT, 0, color_ptr)

        gl.glEnableVertexAttribArray(self.particle_size_idx)

        size_ptr = PointerToNumpy(self.particle_size_scaled)
        gl.glVertexAttribPointer(self.particle_size_idx, 1, gl.GL_FLOAT,
                                 False, 0, size_ptr)

        gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
        gl.glEnable(gl.GL_BLEND)
        if self.blend_additive:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        else:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        # mode = GLint()
        # glTexEnviv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode )
        #
        # if self.color_modulate:
        #   glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE )
        # else:
        #   glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE )

        self.sprite_shader.install()
        self.sprite_shader.usetTex('sprite_texture', 0,
                                   gl.GL_TEXTURE_2D, self.texture.id)

        gl.glDrawArrays(gl.GL_POINTS, 0, self.total_particles)

        self.sprite_shader.uninstall()
        # un -blend
        gl.glPopAttrib()

        # color restore
        gl.glPopAttrib()

        # restore env mode
        # glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode)

        # disable states
        gl.glDisableVertexAttribArray(self.particle_size_idx)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)
        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)

        gl.glDisable(gl.GL_POINT_SPRITE)
        gl.glDisable(gl.GL_PROGRAM_POINT_SIZE)
        gl.glDisable(gl.GL_TEXTURE_2D)

        gl.glPopMatrix()
예제 #26
0
파일: actors.py 프로젝트: ptitleud/Printrun
    def _display_movements(self, has_vbo):
        self.vertex_buffer.bind()
        if has_vbo:
            glVertexPointer(3, GL_FLOAT, 0, None)
        else:
            glVertexPointer(3, GL_FLOAT, 0, self.vertex_buffer.ptr)

        self.vertex_color_buffer.bind()
        if has_vbo:
            glColorPointer(4, GL_FLOAT, 0, None)
        else:
            glColorPointer(4, GL_FLOAT, 0, self.vertex_color_buffer.ptr)

        self.index_buffer.bind()

        start = 1
        layer_selected = self.num_layers_to_draw <= self.max_layers
        if layer_selected:
            end_prev_layer = self.layer_stops[self.num_layers_to_draw - 1]
        else:
            end_prev_layer = 0
        end = self.layer_stops[min(self.num_layers_to_draw, self.max_layers)]

        glDisableClientState(GL_COLOR_ARRAY)

        glColor4f(*self.color_printed)

        # Draw printed stuff until end or end_prev_layer
        cur_end = min(self.printed_until, end)
        if not self.only_current:
            if 1 <= end_prev_layer <= cur_end:
                self._draw_elements(1, end_prev_layer)
            elif cur_end >= 1:
                self._draw_elements(1, cur_end)

        glEnableClientState(GL_COLOR_ARRAY)

        # Draw nonprinted stuff until end_prev_layer
        start = max(cur_end, 1)
        if end_prev_layer >= start:
            if not self.only_current:
                self._draw_elements(start, end_prev_layer)
            cur_end = end_prev_layer

        # Draw current layer
        if layer_selected:
            glDisableClientState(GL_COLOR_ARRAY)

            # Backup & increase line width
            orig_linewidth = (GLfloat)()
            glGetFloatv(GL_LINE_WIDTH, orig_linewidth)
            glLineWidth(2.0)

            glColor4f(*self.color_current_printed)

            if cur_end > end_prev_layer:
                self._draw_elements(end_prev_layer + 1, cur_end)

            glColor4f(*self.color_current)

            if end > cur_end:
                self._draw_elements(cur_end + 1, end)

            # Restore line width
            glLineWidth(orig_linewidth)

            glEnableClientState(GL_COLOR_ARRAY)

        # Draw non printed stuff until end (if not ending at a given layer)
        start = max(self.printed_until, 1)
        if not layer_selected and end >= start:
            self._draw_elements(start, end)

        self.vertex_buffer.unbind()
        self.vertex_color_buffer.unbind()
예제 #27
0
def createVAO(vertexBuffer,
              textureCoordBuffer=None,
              normalBuffer=None,
              colorBuffer=None):
    """Create a Vertex Array Object (VAO) with specified Vertex Buffer Objects.
    VAOs store buffer binding states, reducing binding overhead when drawing
    objects with vertext data stored in VBOs.

    Parameters
    ----------
    vertexBuffer : :obj:`VertexBufferObject`
        Vertex buffer descriptor, must have 'bufferType' as GL_VERTEX_ARRAY.
    textureCoordBuffer : :obj:`VertexBufferObject` or None, optional
        Vertex buffer descriptor of texture coordinates, must have 'bufferType'
        as GL_TEXTURE_COORD_ARRAY.
    normalBuffer : :obj:`VertexBufferObject` or None, optional
        Vertex buffer descriptor of normals, must have 'bufferType' as
        GL_NORMAL_ARRAY.
    colorBuffer :obj:`VertexBufferObject` or None, optional
        Vertex buffer descriptor of colors, must have 'bufferType' as
        GL_COLOR_ARRAY.

    Returns
    -------
    VertexArrayObject
        A descriptor with vertex buffer information.

    Examples
    --------
    # create a VAO
    vaoDesc = createVAO(vboVerts, vboTexCoords, vboNormals)

    # draw the VAO, renders the mesh
    drawVAO(vaoDesc, GL.GL_TRIANGLES)

    """
    # create a vertex buffer ID
    vaoId = GL.GLuint()
    GL.glGenVertexArrays(1, ctypes.byref(vaoId))
    GL.glBindVertexArray(vaoId)

    # must have a vertex pointer
    assert vertexBuffer.bufferType == GL.GL_VERTEX_ARRAY

    # bind and set the vertex pointer, this is must be bound
    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer.id)
    GL.glVertexPointer(vertexBuffer.vertexSize, vertexBuffer.dtype, 0, None)
    GL.glEnableClientState(vertexBuffer.bufferType)

    # texture coordinates
    if textureCoordBuffer is not None:
        if vertexBuffer.indices != textureCoordBuffer.indices:
            raise RuntimeError(
                "Texture and vertex buffer indices do not match!")
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, textureCoordBuffer.id)
        GL.glTexCoordPointer(textureCoordBuffer.vertexSize,
                             textureCoordBuffer.dtype, 0, None)
        GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)

    # normals
    if normalBuffer is not None:
        if vertexBuffer.indices != normalBuffer.indices:
            raise RuntimeError(
                "Normal and vertex buffer indices do not match!")
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, normalBuffer.id)
        GL.glNormalPointer(normalBuffer.dtype, 0, None)
        GL.glEnableClientState(GL.GL_NORMAL_ARRAY)

    # colors
    if colorBuffer is not None:
        if vertexBuffer.indices != colorBuffer.indices:
            raise RuntimeError("Color and vertex buffer indices do not match!")
        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, colorBuffer.id)
        GL.glColorPointer(colorBuffer.vertexSize, colorBuffer.dtype, 0, None)
        GL.glEnableClientState(GL.GL_COLOR_ARRAY)

    GL.glBindVertexArray(0)

    return VertexArrayObject(vaoId, vertexBuffer.indices, dict())
예제 #28
0
    def draw(self):
        gl.glPushMatrix()
        self.transform()

        # color preserve - at least nvidia 6150SE needs that
        gl.glPushAttrib(gl.GL_CURRENT_BIT)
        # glPointSize(self.get_scaled_particle_size())

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glEnable(gl.GL_PROGRAM_POINT_SIZE)
        # glBindTexture(GL_TEXTURE_2D, self.texture.id)


        gl.glEnable(gl.GL_POINT_SPRITE)
        gl.glTexEnvi(gl.GL_POINT_SPRITE, gl.GL_COORD_REPLACE, gl.GL_TRUE)

        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
        vertex_ptr = PointerToNumpy(self.particle_pos)
        gl.glVertexPointer(2, gl.GL_FLOAT, 0, vertex_ptr)

        gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        color_ptr = PointerToNumpy(self.particle_color)
        gl.glColorPointer(4, gl.GL_FLOAT, 0, color_ptr)

        gl.glEnableVertexAttribArray(self.particle_size_idx)

        size_ptr = PointerToNumpy(self.particle_size_scaled)
        gl.glVertexAttribPointer(self.particle_size_idx, 1, gl.GL_FLOAT,
            False, 0, size_ptr)

        gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
        gl.glEnable(gl.GL_BLEND)
        if self.blend_additive:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
        else:
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        # mode = GLint()
        # glTexEnviv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode )
        #
        # if self.color_modulate:
        #   glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE )
        # else:
        #   glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE )

        self.sprite_shader.install()
        self.sprite_shader.usetTex('sprite_texture', 0, 
            gl.GL_TEXTURE_2D, self.texture.id)

        gl.glDrawArrays(gl.GL_POINTS, 0, self.total_particles)

        self.sprite_shader.uninstall()
        # un -blend
        gl.glPopAttrib()

        # color restore
        gl.glPopAttrib()

        # restore env mode
        # glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, mode)

        # disable states
        gl.glDisableVertexAttribArray(self.particle_size_idx)
        gl.glDisableClientState(gl.GL_COLOR_ARRAY)
        gl.glDisableClientState(gl.GL_VERTEX_ARRAY)

        gl.glDisable(gl.GL_POINT_SPRITE)
        gl.glDisable(gl.GL_PROGRAM_POINT_SIZE)
        gl.glDisable(gl.GL_TEXTURE_2D)

        gl.glPopMatrix()
예제 #29
0
 def bind(self):
     gl.glEnableClientState(self.type)
     gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.id)
     gl.glColorPointer(4, gl.GL_FLOAT, 0, 0)