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


Python GL.glDrawArrays方法代码示例

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


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

示例1: render

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def render(self, context):
        self.shader.bind()

        flipY = -1
        projection = utils.createPerspectiveOrtho(-1.0, 1.0, 1.0 * flipY, -1.0 * flipY, -1.0, 1.0)
        self.shader.uniformMatrix4f(shader.PROJECTION, projection)
        self.shader.uniformf("imageSize", *self.getSize())

        self.setUniforms(self.shader, context.uniforms)

        self.textureMap.bindTextures(self.shader)

        gl.glClearColor(*self.clearColor)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        self.bindAttributeArray(self.shader, "inVertex", self.verts, 4)
        gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, len(self.verts) // 4);
        self.unbindAttributeArray(self.shader, "inVertex")

        self.textureMap.unbindTextures()

        self.shader.unbind() 
开发者ID:bitsawer,项目名称:renpy-shader,代码行数:24,代码来源:rendering.py

示例2: drawFaceVertices

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def drawFaceVertices(self, buf):
        if 0 == len(buf):
            return
        stride = elementByteLength

        GL.glVertexPointer(3, GL.GL_FLOAT, stride, (buf.ravel()))
        GL.glTexCoordPointer(2, GL.GL_FLOAT, stride, (buf.ravel()[3:]))
        GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, stride, (buf.view(dtype=numpy.uint8).ravel()[20:]))

        GL.glDepthMask(False)

        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)

        GL.glLineWidth(2.0)
        GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)

        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)

        GL.glPolygonOffset(DepthOffset.TerrainWire, DepthOffset.TerrainWire)
        with gl.glEnable(GL.GL_POLYGON_OFFSET_FILL, GL.GL_DEPTH_TEST):
            GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
        GL.glDepthMask(True) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:24,代码来源:renderer.py

示例3: _drawCeiling

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def _drawCeiling():
        lines = []
        minz = minx = -256
        maxz = maxx = 256
        for x in range(minx, maxx + 1, 16):
            lines.append((x, 0, minz))
            lines.append((x, 0, maxz))
        for z in range(minz, maxz + 1, 16):
            lines.append((minx, 0, z))
            lines.append((maxx, 0, z))

        GL.glColor(0.3, 0.7, 0.9)
        GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array(lines, dtype='float32'))

        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(False)
        GL.glDrawArrays(GL.GL_LINES, 0, len(lines))
        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(True) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:21,代码来源:camera.py

示例4: gl_draw

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def gl_draw(self):
        if self.schematic.chunkCount > len(self.renderer.chunkRenderers):
            self.gl_draw_thumb()
        else:
            if self.fbo is None:
                w, h = self.fboSize
                self.fbo = FramebufferTexture(w, h, self.gl_draw_tex)
            GL.glMatrixMode(GL.GL_PROJECTION)
            GL.glLoadIdentity()
            GL.glMatrixMode(GL.GL_MODELVIEW)
            GL.glLoadIdentity()
            GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
            GL.glColor(1.0, 1.0, 1.0, 1.0)
            GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
                                                         - 1, 1,
                                                         1, 1,
                                                         1, -1, ], dtype='float32'))
            GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([0, 0, 0, 256, 256, 256, 256, 0], dtype='float32'))
            e = (GL.GL_TEXTURE_2D,)
            if not self.drawBackground:
                e += (GL.GL_ALPHA_TEST,)
            with gl.glEnable(*e):
                self.fbo.bind()
                GL.glDrawArrays(GL.GL_QUADS, 0, 4)
            GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:27,代码来源:thumbview.py

示例5: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def paintGL(self):
        self.makeCurrent()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        self.program.bind()

        self.program.enableAttributeArray("position")
        self.vbo.bind()
        gl.glVertexAttribPointer(self.program.attributeLocation("position"), 2, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo)


        self.program.enableAttributeArray("normal")
        self.vbo_cols.bind()
        gl.glVertexAttribPointer(self.program.attributeLocation("normal"), 3, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo_cols)


        gl.glDrawArrays(gl.GL_TRIANGLES, 0, len(self.data))



        print(self.context().format().majorVersion())
        print(self.context().format().minorVersion())


        print(gl.glGetString(gl.GL_VERSION)); 
开发者ID:maweigert,项目名称:spimagine,代码行数:27,代码来源:test_opengl.py

示例6: render

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def render(self, pixmap, viewport_shape):
    """Renders the pixmap on a fullscreen quad.

    Args:
      pixmap: A 3D numpy array of bytes (np.uint8), with dimensions
        (width, height, 3).
      viewport_shape: A tuple of two elements, (width, height).
    """
    GL.glClear(GL.GL_COLOR_BUFFER_BIT)
    GL.glViewport(0, 0, *viewport_shape)
    GL.glUseProgram(self._shader)
    GL.glActiveTexture(GL.GL_TEXTURE0)
    GL.glBindTexture(GL.GL_TEXTURE_2D, self._texture)
    GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, pixmap.shape[1],
                    pixmap.shape[0], 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE,
                    pixmap)
    GL.glUniform1i(self._var_texture_sampler, 0)
    GL.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4) 
开发者ID:deepmind,项目名称:dm_control,代码行数:21,代码来源:fullscreen_quad.py

示例7: drawFaceVertices

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def drawFaceVertices(self, buf):
        if not len(buf):
            return
        stride = elementByteLength

        GL.glVertexPointer(3, GL.GL_FLOAT, stride, (buf.ravel()))
        GL.glTexCoordPointer(2, GL.GL_FLOAT, stride, (buf.ravel()[3:]))
        GL.glColorPointer(4, GL.GL_UNSIGNED_BYTE, stride, (buf.view(dtype=numpy.uint8).ravel()[20:]))

        GL.glDepthMask(False)

        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE)

        GL.glLineWidth(2.0)
        GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)

        GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL)

        GL.glPolygonOffset(DepthOffset.TerrainWire, DepthOffset.TerrainWire)
        with gl.glEnable(GL.GL_POLYGON_OFFSET_FILL, GL.GL_DEPTH_TEST):
            GL.glDrawArrays(GL.GL_QUADS, 0, len(buf) * 4)
        GL.glDepthMask(True) 
开发者ID:Podshot,项目名称:MCEdit-Unified,代码行数:24,代码来源:renderer.py

示例8: _drawCeiling

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def _drawCeiling():
        lines = []
        minz = minx = -256
        maxz = maxx = 256
        append = lines.append
        for x in xrange(minx, maxx + 1, 16):
            append((x, 0, minz))
            append((x, 0, maxz))
        for z in xrange(minz, maxz + 1, 16):
            append((minx, 0, z))
            append((maxx, 0, z))

        GL.glColor(0.3, 0.7, 0.9)
        GL.glVertexPointer(3, GL.GL_FLOAT, 0, numpy.array(lines, dtype='float32'))

        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(False)
        GL.glDrawArrays(GL.GL_LINES, 0, len(lines))
        GL.glDisable(GL.GL_DEPTH_TEST)
        GL.glDepthMask(True) 
开发者ID:Podshot,项目名称:MCEdit-Unified,代码行数:22,代码来源:camera.py

示例9: drawSelf

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def drawSelf(self):
        if self._tex is None:
            filename = os.path.join("toolicons", "compass.png")

            self._tex = loadPNGTexture(filename)
            
        self._tex.bind()
        size = 0.001 * config.settings.compassSize.get()

        with gl.glPushMatrix(GL.GL_MODELVIEW):
            GL.glLoadIdentity()

            yaw, pitch = self.yawPitch
            if config.settings.viewMode.get() == "Chunk":
                yaw = -180
            GL.glTranslatef(1. - (size + self.x), size + self.y, 0.0)  # position on upper right corner
            GL.glRotatef(180 - yaw, 0., 0., 1.)  # adjust to north
            GL.glColor3f(1., 1., 1.)

            with gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY):
                GL.glVertexPointer(2, GL.GL_FLOAT, 0, makeQuad(-size, -size, 2 * size, 2 * size))
                GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, makeQuad(0, 0, 256, 256))

                with gl.glEnable(GL.GL_BLEND, GL.GL_TEXTURE_2D):
                    GL.glDrawArrays(GL.GL_QUADS, 0, 4) 
开发者ID:Podshot,项目名称:MCEdit-Unified,代码行数:27,代码来源:compass.py

示例10: drawStars

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def drawStars(self):
        pos = self.mainViewport.cameraPosition
        self.mainViewport.cameraPosition = map(lambda x: x / 128.0, pos)
        self.mainViewport.setModelview()

        GL.glColor(.5, .5, .5, 1.)

        GL.glVertexPointer(3, GL.GL_FLOAT, 0, self.starVertices)
        GL.glDrawArrays(GL.GL_QUADS, 0, len(self.starVertices) / 3)

        self.mainViewport.cameraPosition = pos
        self.mainViewport.setModelview() 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:14,代码来源:leveleditor.py

示例11: _drawFloorQuad

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def _drawFloorQuad(self):
        GL.glDepthMask(True)
        GL.glPolygonOffset(DepthOffset.ChunkMarkers + 2, DepthOffset.ChunkMarkers + 2)
        GL.glVertexPointer(3, GL.GL_FLOAT, 0, self.floorQuad)
        GL.glColor(*self.floorColor)
        with gl.glEnable(GL.GL_BLEND, GL.GL_DEPTH_TEST, GL.GL_POLYGON_OFFSET_FILL):
            GL.glDrawArrays(GL.GL_QUADS, 0, 4) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:9,代码来源:camera.py

示例12: _gl_draw

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def _gl_draw(self):
        blockInfo = self.blockInfo
        if blockInfo.ID is 0:
            return

        GL.glColor(1.0, 1.0, 1.0, 1.0)
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glEnable(GL.GL_ALPHA_TEST)
        self.materials.terrainTexture.bind()
        pixelScale = 0.5 if self.materials.name in ("Pocket", "Alpha") else 1.0
        texSize = 16 * pixelScale

        GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glVertexPointer(2, GL.GL_FLOAT, 0, array([-1, -1,
                                                     - 1, 1,
                                                     1, 1,
                                                     1, -1, ], dtype='float32'))
        # hack to get end rod to render properly
        # we really should use json models?
        if blockInfo.ID == 198:
            texOrigin = array([17*16, 20*16])
        else:
            texOrigin = array(self.materials.blockTextures[blockInfo.ID, blockInfo.blockData, 0])
        texOrigin = texOrigin.astype(float) * pixelScale

        GL.glTexCoordPointer(2, GL.GL_FLOAT, 0, array([texOrigin[0], texOrigin[1] + texSize,
                                                       texOrigin[0], texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1],
                                                       texOrigin[0] + texSize, texOrigin[1] + texSize],
                                                      dtype='float32'))

        GL.glDrawArrays(GL.GL_QUADS, 0, 4)

        GL.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY)
        GL.glDisable(GL.GL_ALPHA_TEST)
        GL.glDisable(GL.GL_TEXTURE_2D) 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:38,代码来源:blockview.py

示例13: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def paintGL(self):
        #GL.glClear(GL.GL_COLOR_BUFFER_BIT)
        self.program.bind()

        self.program.enableAttributeArray("position")
        self.program.enableAttributeArray("texcoord")
        self.program.setAttributeArray("position", self.quadCoord)
        self.program.setAttributeArray("texcoord", self.quadCoordTex)

        GL.glActiveTexture(GL.GL_TEXTURE0)
        GL.glBindTexture(GL.GL_TEXTURE_2D, self.texture)
        self.program.setUniformValue("texture", 0)

        GL.glDrawArrays(GL.GL_TRIANGLES, 0, len(self.quadCoord)) 
开发者ID:maweigert,项目名称:spimagine,代码行数:16,代码来源:test_opengl.py

示例14: paintGL

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def paintGL(self):
        self.makeCurrent()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        self.program.bind()

        self.program.enableAttributeArray("position")
        self.vbo.bind()
        gl.glVertexAttribPointer(self.program.attributeLocation("position"), 2, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo)


        self.program.enableAttributeArray("color")
        self.vbo_cols.bind()
        gl.glVertexAttribPointer(self.program.attributeLocation("color"), 3, gl.GL_FLOAT, gl.GL_FALSE, 0, self.vbo_cols)

        self.vbo_index.bind()

        #gl.glDrawArrays(gl.GL_TRIANGLES, 0, len(self.data))

        gl.glDrawElements(gl.GL_TRIANGLES, len(self.index), gl.GL_UNSIGNED_INT, None)

        print(self.context().format().majorVersion())
        print(self.context().format().minorVersion())


        print(gl.glGetString(gl.GL_VERSION)); 
开发者ID:maweigert,项目名称:spimagine,代码行数:28,代码来源:test_opengl2.py

示例15: draw

# 需要导入模块: from OpenGL import GL [as 别名]
# 或者: from OpenGL.GL import glDrawArrays [as 别名]
def draw(self, primitive_type=None, first_vertex=None, vertex_count=None, n_instances=None):
        if primitive_type is None:
            primitive_type = self.primitive_type

        if first_vertex is None:
            first_vertex = self.first_vertex

        if vertex_count is None:
            vertex_count = self.vertex_count

        if n_instances is None:
            n_instances = self.n_instances

        if vertex_count == 0:
            return

        self.bind()

        if self.single_colour is not None:
            normcolor = [c / 255 for c in self.single_colour]
            gl.glVertexAttrib4f(self.attrib_color, *normcolor)

        if n_instances > 0:
            gl.glDrawArraysInstanced(primitive_type, first_vertex, vertex_count, n_instances * self.max_instance_divisor)
        else:
            gl.glDrawArrays(primitive_type, first_vertex, vertex_count) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:28,代码来源:glhelpers.py


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