本文整理汇总了Python中bgl.glBlendFunc方法的典型用法代码示例。如果您正苦于以下问题:Python bgl.glBlendFunc方法的具体用法?Python bgl.glBlendFunc怎么用?Python bgl.glBlendFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bgl
的用法示例。
在下文中一共展示了bgl.glBlendFunc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_custom_3d_elements
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBlendFunc [as 别名]
def draw_custom_3d_elements(mode):
"""Draws custom 3D elements filled in buffers (if local view is active, then buffers are refilled also).
:param mode: drawing mode for custom 3D elements (can be: 'Normal' or 'X-ray')
:type mode: str
"""
# if empties are disabled in this viewport ... our locators and connections should be too
if not bpy.context.space_data.show_object_viewport_empty:
return
if mode == "Normal":
bgl.glEnable(bgl.GL_DEPTH_TEST)
bgl.glEnable(bgl.GL_BLEND)
bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
# draw buffers
_primitive.draw_buffers(bpy.context.space_data)
if mode == "Normal":
bgl.glDisable(bgl.GL_DEPTH_TEST)
bgl.glDisable(bgl.GL_BLEND)
示例2: draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBlendFunc [as 别名]
def draw(self, engine, context, scene):
if self._transparent:
bgl.glEnable(bgl.GL_BLEND)
bgl.glBlendFunc(bgl.GL_ONE, bgl.GL_ONE_MINUS_SRC_ALPHA)
engine.bind_display_space_shader(scene)
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
bgl.glBindVertexArray(self.vertex_array[0])
bgl.glDrawArrays(bgl.GL_TRIANGLE_FAN, 0, 4)
bgl.glBindVertexArray(NULL)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, NULL)
engine.unbind_display_space_shader()
err = bgl.glGetError()
if err != bgl.GL_NO_ERROR:
print("GL Error:", err)
if self._transparent:
bgl.glDisable(bgl.GL_BLEND)
示例3: display_islands
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBlendFunc [as 别名]
def display_islands(self, context):
# TODO: save the vertex positions and don't recalculate them always?
ob = context.active_object
if not ob or ob.type != 'MESH':
return
mesh = ob.data
if not mesh.paper_island_list or mesh.paper_island_index == -1:
return
bgl.glMatrixMode(bgl.GL_PROJECTION)
perspMatrix = context.space_data.region_3d.perspective_matrix
perspBuff = bgl.Buffer(bgl.GL_FLOAT, (4, 4), perspMatrix.transposed())
bgl.glLoadMatrixf(perspBuff)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
objectBuff = bgl.Buffer(bgl.GL_FLOAT, (4, 4), ob.matrix_world.transposed())
bgl.glLoadMatrixf(objectBuff)
bgl.glEnable(bgl.GL_BLEND)
bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
bgl.glEnable(bgl.GL_POLYGON_OFFSET_FILL)
bgl.glPolygonOffset(0, -10) # offset in Zbuffer to remove flicker
bgl.glPolygonMode(bgl.GL_FRONT_AND_BACK, bgl.GL_FILL)
bgl.glColor4f(1.0, 0.4, 0.0, self.islands_alpha)
island = mesh.paper_island_list[mesh.paper_island_index]
for lface in island.faces:
face = mesh.polygons[lface.id]
bgl.glBegin(bgl.GL_POLYGON)
for vertex_id in face.vertices:
vertex = mesh.vertices[vertex_id]
bgl.glVertex4f(*vertex.co.to_4d())
bgl.glEnd()
bgl.glPolygonOffset(0.0, 0.0)
bgl.glDisable(bgl.GL_POLYGON_OFFSET_FILL)
bgl.glLoadIdentity()
示例4: draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBlendFunc [as 别名]
def draw(self, context, render=False):
if self.image is None:
return
bgl.glPushAttrib(bgl.GL_ENABLE_BIT)
p0 = self.pts[0]
p1 = self.pts[1]
bgl.glEnable(bgl.GL_BLEND)
bgl.glColor4f(*self.colour)
bgl.glRectf(p0.x, p0.y, p1.x, p1.y)
self.image.gl_load()
bgl.glEnable(bgl.GL_BLEND)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.image.bindcode[0])
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST)
bgl.glEnable(bgl.GL_TEXTURE_2D)
bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
# bgl.glColor4f(1, 1, 1, 1)
bgl.glBegin(bgl.GL_QUADS)
bgl.glTexCoord2d(0, 0)
bgl.glVertex2d(p0.x, p0.y)
bgl.glTexCoord2d(0, 1)
bgl.glVertex2d(p0.x, p1.y)
bgl.glTexCoord2d(1, 1)
bgl.glVertex2d(p1.x, p1.y)
bgl.glTexCoord2d(1, 0)
bgl.glVertex2d(p1.x, p0.y)
bgl.glEnd()
self.image.gl_free()
bgl.glDisable(bgl.GL_TEXTURE_2D)