• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python gl.glVertex2f函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: draw_circle

def draw_circle(cx, cy, r, num_segments=None, mode=gl.GL_POLYGON, color=(1, 1, 1, 1)):
	if not num_segments:
		num_segments = get_num_circle_segments(r)

	theta = 2 * math.pi / float(num_segments)
	tangetial_factor = math.tan(theta)
	radial_factor = math.cos(theta)

	x = float(r)
	y = 0.0

	gl.glColor4f(color[0], color[1], color[2], color[3])
	gl.glBegin(mode)
	for i in xrange(num_segments):
		gl.glVertex2f(x + cx, y + cy)

		tx = y * -1
		ty = x

		x += tx * tangetial_factor
		y += ty * tangetial_factor

		x *= radial_factor
		y *= radial_factor
	gl.glEnd()
开发者ID:PermianLizard,项目名称:Pyweek-17,代码行数:25,代码来源:render.py


示例2: nakresli_caru

def nakresli_caru(x1, y1, x2, y2):
   
    gl.glBegin(gl.GL_LINES)
    #  gl.glBegin(gl.GL_TRIANGLE_FAN)
    gl.glVertex2f(x1, y1)
    gl.glVertex2f(x2, y2)   
    gl.glEnd()
开发者ID:zzuzzy,项目名称:PyLadies,代码行数:7,代码来源:myPong.py


示例3: draw_points

    def draw_points(self):
        self.points_lock.acquire()
        
        try:
            from pyglet.gl import glBegin, glEnd, GL_POINTS, glColor4f, glVertex2f
                   
            glBegin(GL_POINTS)
               
            for i in xrange(0, len(self.points)):
                p = self.points[i]
                parameter_index = self.parameter_indices[0]
                state_index = self.state_indices[0]

                glColor4f(1, 1, 1, p.age / (self.age_max*2.0))
                glVertex2f(p.parameters[parameter_index], p.state[state_index])
                
                p.state = self.system.iterate(p.state, p.parameters)
                p.age += 1
                
                #if p.age >= self.age_max:
                #    self.points[i] = OrbitPoint(tool=self, varying_parameter=p.parameters[parameter_index])
            
            glEnd()
        except Exception, detail:
            print 'draw_points()', type(detail), detail
开发者ID:cmorgan,项目名称:dypy,代码行数:25,代码来源:OrbitTool.py


示例4: draw_block

def draw_block(block):
    transformed = [world_to_screen(block.GetWorldPoint(p)) for p in POINTS]
    gl.glColor3f(1.0, 0.1, 0)
    gl.glBegin(gl.GL_LINE_LOOP)
    for p in transformed:
        gl.glVertex2f(*p)
    gl.glEnd()
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:7,代码来源:demo1.py


示例5: draw_points

    def draw_points(self):
        self.points_lock.acquire()

        try:
            from pyglet.gl import glCallList, glBegin, GL_LINE_STRIP, glColor4f, glVertex2f, glEnd

            # line from previous iterate to next iterate of function
            glBegin(GL_LINE_STRIP)
            glColor4f(1, 1, 1, 0.3)

            state_index = self.state_indices[0]

            for i in [1, 2]:
                state_previous = self.point.state[state_index]
                self.point.state = self.system.iterate(self.point.state, self.point.parameters)

                glVertex2f(state_previous, state_previous)
                glVertex2f(state_previous, self.point.state[state_index])

            glEnd()

            # call display lists, doesn't work in init_points()
            if self.server.iteration <= 1:
                glCallList(self.iterate_list)
                glCallList(self.reflection_list)
        except Exception, detail:
            print "draw_points()", type(detail), detail
开发者ID:cmorgan,项目名称:dypy,代码行数:27,代码来源:CobwebTool.py


示例6: draw

 def draw(self, colour=(0., 0., 1.)):
   s = self.size # just a shorthand
   gl.glColor3f(*colour)
   gl.glBegin(gl.GL_LINE_LOOP)
   for vertex in self.verticies:
     gl.glVertex2f(*vertex)
   gl.glEnd()
开发者ID:DomNomNom,项目名称:Jumpy2D,代码行数:7,代码来源:Trigger.py


示例7: draw

 def draw(self):
   r = self.size.x
   gl.glColor3f(1.0, .7, 0.0)
   with shiftView(self.body.position):
     gl.glBegin(gl.GL_LINE_LOOP)
     for angle in xrange(0, 360, 360/12):
       gl.glVertex2f(*self.size.rotated_degrees(angle))
     gl.glEnd()
开发者ID:DomNomNom,项目名称:Jumpy2D,代码行数:8,代码来源:Explosion.py


示例8: display_pointer

def display_pointer(angle, color, radius):
    x_value = math.cos(angle)
    y_value = math.sin(angle)
    glBegin(GL_LINES)
    glColor3ub(*color)
    glVertex2f(0.0, 0.0)
    glVertex2f(x_value * radius, y_value * radius)
    glEnd()
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:8,代码来源:kcclock.py


示例9: draw_line

def draw_line(a, b, color):
    gl.glPushMatrix()
    gl.glColor3f(color[0], color[1], color[2])
    gl.glLineWidth(2)
    gl.glBegin(gl.GL_LINES)
    gl.glVertex2f(a[0], a[1])
    gl.glVertex2f(b[0], b[1])
    gl.glEnd()
    gl.glPopMatrix()
开发者ID:mraxilus,项目名称:color-blind,代码行数:9,代码来源:graphics.py


示例10: line

def line(x, y, size, angle, color=(1, 0, 0, 1), thickness=1):
    x1, y1 = x, y
    x2, y2 = x1 + cos(angle) * size, y1 + sin(angle) * size
    glColor4f(*color)
    glLineWidth(thickness)
    glBegin(GL_LINES)
    glVertex2f(x1, y1)
    glVertex2f(x2, y2)
    glEnd()
开发者ID:evuez,项目名称:raycaster,代码行数:9,代码来源:geometry.py


示例11: draw_fan

def draw_fan(center, vertices, color):
    gl.glPushMatrix()
    gl.glColor4f(*color)
    gl.glBegin(gl.GL_TRIANGLE_FAN)
    gl.glVertex2f(center[0], center[1])
    for vertex in vertices:
        gl.glVertex2f(vertex[0], vertex[1])
    gl.glEnd()
    gl.glPopMatrix()
开发者ID:mraxilus,项目名称:color-blind,代码行数:9,代码来源:graphics.py


示例12: draw

    def draw(self):
        gl.glColor3f(1, 1, 1)
        gl.glBegin(gl.GL_LINES)
        gl.glVertex2f(0, 50)
        gl.glVertex2f(self.window.width, 50)
        gl.glEnd()

        for label in self.labels:
            label.draw()
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:9,代码来源:VALIGN.py


示例13: draw_bone

    def draw_bone(self, bone):
        p1 = bone.get_start()
        p2 = bone.get_end()

        gl.glColor4ub(*self.color)
        gl.glLineWidth(5)
        gl.glBegin(gl.GL_LINES)
        gl.glVertex2f(*p1)
        gl.glVertex2f(*p2)
        gl.glEnd()
开发者ID:fpietka,项目名称:cocos,代码行数:10,代码来源:skeleton.py


示例14: draw

 def draw(self):
     if not self.visible:
         return
     gl.glLineWidth(2)  # deprecated
     gl.glColor3ub(*self.color3)
     gl.glBegin(gl.GL_LINE_STRIP)
     for v in self.vertexes:
         gl.glVertex2f(*v)
     gl.glVertex2f(*self.vertexes[0])
     gl.glEnd()
开发者ID:1414648814,项目名称:cocos,代码行数:10,代码来源:mouse_elastic_box_selection.py


示例15: circle

def circle(x, y, radius):
    iterations = int(tau * radius) * 2
    s = sin(tau / iterations)
    c = cos(tau / iterations)
    gl.glBegin(gl.GL_TRIANGLE_FAN)
    gl.glVertex2f(x, y)
    dx, dy = radius, 0
    for i in range(iterations + 1):
        gl.glVertex2f(x + dx, y + dy)
        dx, dy = (dx * c - dy * s), (dy * c + dx * s)
    gl.glEnd()
开发者ID:encukou,项目名称:slides,代码行数:11,代码来源:gitvisualizer.py


示例16: render_change_vectors

    def render_change_vectors(self):
        glBegin(GL_LINES)

        color = [0.0, 0.0, 0.0]
        for i, (factor, vec) in enumerate(self.change_vectors):
            color[i % 3] = 1.0
            glColor3f(*color)
            glVertex2f(0.0, 0.0)
            glVertex2f(*[i * factor * _CHANGE_VECTOR_LENGTH for i in vec])
            color[i % 3] = 0.0
        glEnd()
开发者ID:mdodsworth,项目名称:pyglet-boids,代码行数:11,代码来源:boid.py


示例17: blit

 def blit(self, x, y, w, h, z=0, s=(0,1), **kwargs):
     ''' Draw texture to active framebuffer. '''
     gl.glEnable (gl.GL_TEXTURE_2D)
     gl.glDisable (gl.GL_TEXTURE_1D)
     gl.glBindTexture(self.target, self._id)
     gl.glBegin(gl.GL_QUADS)
     gl.glTexCoord2f(s[0], 1), gl.glVertex2f(x,   y)
     gl.glTexCoord2f(s[0], 0), gl.glVertex2f(x,   y+h)
     gl.glTexCoord2f(s[1], 0), gl.glVertex2f(x+w, y+h)
     gl.glTexCoord2f(s[1], 1), gl.glVertex2f(x+w, y)
     gl.glEnd()
开发者ID:matthew-brett,项目名称:miniglumpy,代码行数:11,代码来源:textures.py


示例18: on_draw

def on_draw():
    global vertices
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)

    gl.glColor3f(0, 0, 0)

    gl.glBegin(gl.GL_TRIANGLES)
    for vertex in vertices:
        gl.glVertex2f(*vertex)

    gl.glEnd()
开发者ID:ben-albrecht,项目名称:eg,代码行数:11,代码来源:opengl.py


示例19: render_view

    def render_view(self):
        glColor3f(0.6, 0.1, 0.1)
        glBegin(GL_LINE_LOOP)

        step = 10
        # render a circle for the boid's view
        for i in range(-_BOID_VIEW_ANGLE, _BOID_VIEW_ANGLE + step, step):
            glVertex2f(_BOID_RANGE * math.sin(math.radians(i)),
                       (_BOID_RANGE * math.cos(math.radians(i))))
        glVertex2f(0.0, 0.0)
        glEnd()
开发者ID:mdodsworth,项目名称:pyglet-boids,代码行数:11,代码来源:boid.py


示例20: on_draw

def on_draw():
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glLoadIdentity()

    transformed = [world_to_screen(block.GetWorldPoint(p)) for p in POINTS]
    gl.glColor3f(1.0, 0.1, 0)
    gl.glBegin(gl.GL_QUADS)
    for p in transformed:
        gl.glVertex2f(*p)
    gl.glEnd()
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:11,代码来源:demo2.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glVertex3f函数代码示例发布时间:2022-05-25
下一篇:
Python gl.glUseProgram函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap