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


Python bgl.glBegin方法代码示例

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


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

示例1: draw_line

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_line(p1, p2, color, shadow=False, shadow_color=None):
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glEnable(bgl.GL_LINE_SMOOTH)

    # Draw shadow.
    if shadow:
        bgl.glLineWidth(3.0)
        bgl.glColor4f(*shadow_color, 1.0)
        bgl.glBegin(bgl.GL_LINES)
        bgl.glVertex2f(*p1)
        bgl.glVertex2f(*p2)
        bgl.glEnd()

    # Draw line.
    bgl.glLineWidth(1.5 if shadow else 1.0)
    bgl.glColor3f(*color)
    bgl.glBegin(bgl.GL_LINES)
    bgl.glVertex2f(*p1)
    bgl.glVertex2f(*p2)
    bgl.glEnd()

    bgl.glLineWidth(1.0)
    bgl.glDisable(bgl.GL_LINE_SMOOTH) 
开发者ID:nutti,项目名称:Screencast-Keys,代码行数:25,代码来源:ops.py

示例2: draw_callback_px

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_callback_px(self, context):
    print("mouse points", len(self.mouse_path))

    font_id = 0  # XXX, need to find out how best to get this.

    # draw some text
    blf.position(font_id, 15, 30, 0)
    blf.size(font_id, 20, 72)
    blf.draw(font_id, "Hello Word " + str(len(self.mouse_path)))

    # 50% alpha, 2 pixel width line
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 0.5)
    bgl.glLineWidth(2)

    bgl.glBegin(bgl.GL_LINE_STRIP)
    for x, y in self.mouse_path:
        bgl.glVertex2i(x, y)

    bgl.glEnd()

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:operator_modal_draw.py

示例3: draw_arc12

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_arc12(x, y, radius, start_angle, end_angle, subdivide):  # いずれ削除
    # 十二時から時計回りに描画
    v = Vector([0, 1, 0])
    e = Euler((0, 0, -start_angle))
    m = e.to_matrix()
    v = v * m
    if end_angle >= start_angle:
        a = (end_angle - start_angle) / (subdivide + 1)
    else:
        a = (end_angle + math.pi * 2 - start_angle) / (subdivide + 1)
    e = Euler((0, 0, -a))
    m = e.to_matrix()

    bgl.glBegin(bgl.GL_LINE_STRIP)
    for i in range(subdivide + 2):
        v1 = v * radius
        bgl.glVertex2f(x + v1[0], y + v1[1])
        v = v * m
    bgl.glEnd() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:gl.py

示例4: draw_quad_fan

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_quad_fan(x, y, inner_radius, outer_radius,
                  start_angle, end_angle, edgenum=16):
    # 三時から反時計回りに描画
    start = normalize_angle(start_angle)
    end = normalize_angle(end_angle)
    if end < start:
        end += math.pi * 2
    d = (end - start) / edgenum
    a = start
    bgl.glBegin(bgl.GL_QUAD_STRIP)
    for i in range(edgenum + 1):
        bgl.glVertex2f(x + inner_radius * math.cos(a),
                       y + inner_radius * math.sin(a))
        bgl.glVertex2f(x + outer_radius * math.cos(a),
                       y + outer_radius * math.sin(a))
        a += d
    bgl.glEnd() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:gl.py

示例5: draw_offset

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_offset(self, context):
        bgl.glShadeModel(bgl.GL_SMOOTH)

        tfm_operator = CursorDynamicSettings.active_transform_operator

        bgl.glBegin(bgl.GL_LINE_STRIP)

        if tfm_operator:
            p = tfm_operator.particles[0]. \
                get_initial_matrix().to_translation()
        else:
            p = self.get_pos(self.last_id)
        bgl.glColor4f(1.0, 0.75, 0.5, 1.0)
        bgl.glVertex3f(p[0], p[1], p[2])

        p = get_cursor_location(v3d=context.space_data)
        bgl.glColor4f(1.0, 1.0, 0.25, 1.0)
        bgl.glVertex3f(p[0], p[1], p[2])

        bgl.glEnd()

# ===== BOOKMARK ===== # 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:space_view3d_enhanced_3d_cursor.py

示例6: draw_rect

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_rect(x, y, w, h, margin=0, outline=False):
    if w < 0:
        x += w
        w = abs(w)

    if h < 0:
        y += h
        h = abs(h)

    x = int(x)
    y = int(y)
    w = int(w)
    h = int(h)
    margin = int(margin)

    if outline:
        bgl.glBegin(bgl.GL_LINE_LOOP)
    else:
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
    bgl.glVertex2i(x - margin, y - margin)
    bgl.glVertex2i(x + w + margin, y - margin)
    bgl.glVertex2i(x + w + margin, y + h + margin)
    bgl.glVertex2i(x - margin, y + h + margin)
    bgl.glEnd() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:space_view3d_enhanced_3d_cursor.py

示例7: draw_arrow

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_arrow(p0, x, y, z, n_scl=0.2, ort_scl=0.035):
    p1 = p0 + z

    bgl.glBegin(bgl.GL_LINE_STRIP)
    bgl.glVertex3f(p0[0], p0[1], p0[2])
    bgl.glVertex3f(p1[0], p1[1], p1[2])
    bgl.glEnd()

    p2 = p1 - z * n_scl
    bgl.glBegin(bgl.GL_TRIANGLE_FAN)
    bgl.glVertex3f(p1[0], p1[1], p1[2])
    p3 = p2 + (x + y) * ort_scl
    bgl.glVertex3f(p3[0], p3[1], p3[2])
    p3 = p2 + (-x + y) * ort_scl
    bgl.glVertex3f(p3[0], p3[1], p3[2])
    p3 = p2 + (-x - y) * ort_scl
    bgl.glVertex3f(p3[0], p3[1], p3[2])
    p3 = p2 + (x - y) * ort_scl
    bgl.glVertex3f(p3[0], p3[1], p3[2])
    p3 = p2 + (x + y) * ort_scl
    bgl.glVertex3f(p3[0], p3[1], p3[2])
    bgl.glEnd() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:space_view3d_enhanced_3d_cursor.py

示例8: draw_arrow_2d

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_arrow_2d(p0, n, L, arrow_len, arrow_width):
    p1 = p0 + n * L
    t = Vector((-n[1], n[0]))
    pA = p1 - n * arrow_len + t * arrow_width
    pB = p1 - n * arrow_len - t * arrow_width

    bgl.glBegin(bgl.GL_LINES)

    bgl.glVertex2f(p0[0], p0[1])
    bgl.glVertex2f(p1[0], p1[1])

    bgl.glVertex2f(p1[0], p1[1])
    bgl.glVertex2f(pA[0], pA[1])

    bgl.glVertex2f(p1[0], p1[1])
    bgl.glVertex2f(pB[0], pB[1])

    bgl.glEnd()

# Store/restore OpenGL settings and working with
# projection matrices -- inspired by space_view3d_panel_measure
# of Buerbaum Martin (Pontiac).

# OpenGl helper functions/data 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:space_view3d_enhanced_3d_cursor.py

示例9: __draw_ctrl_point

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def __draw_ctrl_point(self, context, pos):
        """
        Draw control point
        """
        cp_size = context.scene.muv_uvbb_cp_size
        offset = cp_size / 2
        verts = [
            [pos.x - offset, pos.y - offset],
            [pos.x - offset, pos.y + offset],
            [pos.x + offset, pos.y + offset],
            [pos.x + offset, pos.y - offset]
            ]
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBegin(bgl.GL_QUADS)
        bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
        for (x, y) in verts:
            bgl.glVertex2f(x, y)
        bgl.glEnd() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:muv_uvbb_ops.py

示例10: draw_outline_or_region

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_outline_or_region(mode, points, color):
    '''  
    draws and outline or region
    mode: either bgl.GL_POLYGON or bgl.GL_LINE_LOOP
    color: will need to be set beforehand using theme colors. eg
    bgl.glColor4f(self.ri, self.gi, self.bi, self.ai)
    return: None
    '''
    
    bgl.glColor4f(color[0],color[1],color[2],color[3])
    if mode == 'GL_LINE_LOOP':
        bgl.glBegin(bgl.GL_LINE_LOOP)
    else:
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBegin(bgl.GL_POLYGON)
    
    # start with corner right-bottom
    for i in range(0,len(points)):
        bgl.glVertex2f(points[i][0],points[i][1])
    
    bgl.glEnd() 
开发者ID:CreativeDesigner3D,项目名称:BlenderPro,代码行数:23,代码来源:opengl.py

示例11: draw_callback_px

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_callback_px(self, context):
    """From blender's operator_modal_draw.py modal operator template"""
    if self.do_draw:
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glEnable(bgl.GL_LINE_STIPPLE)
        bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
        bgl.glLineWidth(1)

        bgl.glBegin(bgl.GL_LINE_STRIP)
        bgl.glVertex2i(int(self.draw_start.x), int(self.draw_start.y))
        bgl.glVertex2i(int(self.draw_end.x), int(self.draw_end.y))

        bgl.glEnd()

        # restore opengl defaults
        bgl.glLineWidth(1)
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glDisable(bgl.GL_LINE_STIPPLE)
        bgl.glColor4f(0.0, 0.0, 0.0, 1.0) 
开发者ID:LesFeesSpeciales,项目名称:image-background-transform,代码行数:21,代码来源:image_background_transform.py

示例12: _draw

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def _draw(self):
        l,t = self.pos
        w,h = self.size

        if debug_draw:
            bgl.glEnable(bgl.GL_BLEND)
            bgl.glBegin(bgl.GL_QUADS)
            bgl.glColor4f(0,1,1,0.5)
            bgl.glVertex2f(l, t)
            bgl.glVertex2f(l, t - h)
            bgl.glVertex2f(l + w, t - h)
            bgl.glVertex2f(l + w, t)
            bgl.glEnd()

        if self.background:
            bgl.glEnable(bgl.GL_BLEND)
            bgl.glColor4f(*self.background)
            bgl.glBegin(bgl.GL_QUADS)
            bgl.glVertex2f(l, t)
            bgl.glVertex2f(l+w, t)
            bgl.glVertex2f(l+w, t-h)
            bgl.glVertex2f(l, t-h)
            bgl.glEnd() 
开发者ID:CGCookie,项目名称:addon_common,代码行数:25,代码来源:ui.py

示例13: draw_darken

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def draw_darken(self):
        bgl.glPushAttrib(bgl.GL_ALL_ATTRIB_BITS)
        bgl.glMatrixMode(bgl.GL_PROJECTION)
        bgl.glPushMatrix()
        bgl.glLoadIdentity()
        bgl.glColor4f(0,0,0,0.25)    # TODO: use window background color??
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glDisable(bgl.GL_DEPTH_TEST)
        bgl.glBegin(bgl.GL_QUADS)   # TODO: not use immediate mode
        bgl.glVertex2f(-1, -1)
        bgl.glVertex2f( 1, -1)
        bgl.glVertex2f( 1,  1)
        bgl.glVertex2f(-1,  1)
        bgl.glEnd()
        bgl.glPopMatrix()
        bgl.glPopAttrib() 
开发者ID:CGCookie,项目名称:addon_common,代码行数:18,代码来源:ui.py

示例14: mi_draw_2d_point

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def mi_draw_2d_point(point_x, point_y, p_size=4, p_col=(1.0,1.0,1.0,1.0)):
    bgl.glEnable(bgl.GL_BLEND)
    #bgl.glColor4f(1.0, 1.0, 1.0, 0.5)
    #bgl.glLineWidth(2)

    bgl.glPointSize(p_size)
#    bgl.glBegin(bgl.GL_LINE_LOOP)
    bgl.glBegin(bgl.GL_POINTS)
 #   bgl.glBegin(bgl.GL_POLYGON)
    bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3])
    bgl.glVertex2f(point_x, point_y)
    bgl.glEnd()

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)


# TODO MOVE TO UTILITIES 
开发者ID:mifth,项目名称:mifthtools,代码行数:22,代码来源:mi_curve_test.py

示例15: mi_curve_draw_3d_polyline

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBegin [as 别名]
def mi_curve_draw_3d_polyline(points, p_size, p_col, x_ray):
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glLineWidth(1)

    if x_ray is True:
        bgl.glDisable(bgl.GL_DEPTH_TEST)

    bgl.glPointSize(p_size)
#    bgl.glBegin(bgl.GL_LINE_LOOP)
    bgl.glBegin(bgl.GL_LINE_STRIP)
    bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3])
 #   bgl.glBegin(bgl.GL_POLYGON)

    for point in points:
        bgl.glVertex3f(point[0], point[1], point[2])

    if x_ray is True:
        bgl.glEnable(bgl.GL_DEPTH_TEST)

    bgl.glEnd()

    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0) 
开发者ID:mifth,项目名称:mifthtools,代码行数:27,代码来源:mi_curve_test.py


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