本文整理汇总了Python中bgl.glBindTexture方法的典型用法代码示例。如果您正苦于以下问题:Python bgl.glBindTexture方法的具体用法?Python bgl.glBindTexture怎么用?Python bgl.glBindTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bgl
的用法示例。
在下文中一共展示了bgl.glBindTexture方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def _draw(self):
self.buffer_image()
if not self.buffered: return
cx,cy = (self.pos.x + self.size.x / 2, self.pos.y - self.size.y / 2)
iw,ih = self.get_image_width(),self.get_image_height()
il,it = cx-iw/2, cy+ih/2
bgl.glColor4f(1,1,1,1)
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_TEXTURE_2D)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
bgl.glBegin(bgl.GL_QUADS)
bgl.glTexCoord2f(0,0); bgl.glVertex2f(il,it)
bgl.glTexCoord2f(0,1); bgl.glVertex2f(il,it-ih)
bgl.glTexCoord2f(1,1); bgl.glVertex2f(il+iw,it-ih)
bgl.glTexCoord2f(1,0); bgl.glVertex2f(il+iw,it)
bgl.glEnd()
bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)
示例2: draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [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: _update_texture
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def _update_texture(self, scene):
if self._transparent:
gl_format = bgl.GL_RGBA
internal_format = bgl.GL_RGBA32F
else:
gl_format = bgl.GL_RGB
internal_format = bgl.GL_RGB32F
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
bgl.glTexImage2D(bgl.GL_TEXTURE_2D, 0, internal_format, self._width, self._height,
0, gl_format, bgl.GL_FLOAT, self.buffer)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_WRAP_S, bgl.GL_CLAMP_TO_EDGE)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_WRAP_T, bgl.GL_CLAMP_TO_EDGE)
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
mag_filter = bgl.GL_NEAREST if scene.luxcore.viewport.mag_filter == "NEAREST" else bgl.GL_LINEAR
bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, mag_filter)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, NULL)
示例4: draw_texture
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def draw_texture(self, context):
sc = context.scene
# no textures are selected
if sc.muv_texproj_tex_image == "None":
return
# setup rendering region
rect = get_canvas(context, sc.muv_texproj_tex_magnitude)
positions = [
[rect.x0, rect.y0],
[rect.x0, rect.y1],
[rect.x1, rect.y1],
[rect.x1, rect.y0]
]
tex_coords = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0]]
# get texture to be renderred
img = bpy.data.images[sc.muv_texproj_tex_image]
# OpenGL configuration
bgl.glEnable(bgl.GL_BLEND)
bgl.glEnable(bgl.GL_TEXTURE_2D)
if img.bindcode:
bind = img.bindcode
bgl.glBindTexture(bgl.GL_TEXTURE_2D, bind)
bgl.glTexParameteri(
bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_LINEAR)
bgl.glTexParameteri(
bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_LINEAR)
bgl.glTexEnvi(
bgl.GL_TEXTURE_ENV, bgl.GL_TEXTURE_ENV_MODE, bgl.GL_MODULATE)
# render texture
bgl.glBegin(bgl.GL_QUADS)
bgl.glColor4f(1.0, 1.0, 1.0, sc.muv_texproj_tex_transparency)
for (v1, v2), (u, v) in zip(positions, tex_coords):
bgl.glTexCoord2f(u, v)
bgl.glVertex2f(v1, v2)
bgl.glEnd()
示例5: buffer_image
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def buffer_image(self):
if not self.loaded: return
if self.buffered: return
if self.deleted: return
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id)
bgl.glTexEnvf(bgl.GL_TEXTURE_ENV, bgl.GL_TEXTURE_ENV_MODE, bgl.GL_MODULATE)
bgl.glTexParameterf(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MAG_FILTER, bgl.GL_NEAREST)
bgl.glTexParameterf(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_LINEAR)
# texbuffer = bgl.Buffer(bgl.GL_BYTE, [self.width,self.height,self.depth], image_data)
image_size = self.image_width*self.image_height*self.image_depth
texbuffer = bgl.Buffer(bgl.GL_BYTE, [image_size], self.image_flat)
bgl.glTexImage2D(bgl.GL_TEXTURE_2D, 0, bgl.GL_RGBA, self.image_width, self.image_height, 0, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, texbuffer)
del texbuffer
bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)
self.buffered = True
示例6: draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [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)
示例7: __del__
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def __del__(self):
bgl.glDeleteBuffers(2, self.vertex_buffer)
bgl.glDeleteVertexArrays(1, self.vertex_array)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)
bgl.glDeleteTextures(1, self.texture)
示例8: draw_image
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def draw_image(x, y, width, height, image, transparency, crop=(0, 0, 1, 1)):
# draw_rect(x,y, width, height, (.5,0,0,.5))
coords = [
(x, y), (x + width, y),
(x, y + height), (x + width, y + height)]
uvs = [(crop[0], crop[1]),
(crop[2], crop[1]),
(crop[0], crop[3]),
(crop[2], crop[3]),
]
indices = [(0, 1, 2), (2, 1, 3)]
shader = gpu.shader.from_builtin('2D_IMAGE')
batch = batch_for_shader(shader, 'TRIS',
{"pos": coords,
"texCoord": uvs},
indices=indices)
# send image to gpu if it isn't there already
if image.gl_load():
raise Exception()
# texture identifier on gpu
texture_id = image.bindcode
# in case someone disabled it before
bgl.glEnable(bgl.GL_BLEND)
# bind texture to image unit 0
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture_id)
shader.bind()
# tell shader to use the image that is bound to image unit 0
shader.uniform_int("image", 0)
batch.draw(shader)
bgl.glDisable(bgl.GL_TEXTURE_2D)
示例9: draw
# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glBindTexture [as 别名]
def draw(self, context):
width = self.region.width
height = self.region.height
x = self.view_padding_left
y = height - self.view_padding_top
# Gem map
# -----------------------------
if not self.use_navigate:
bgl.glEnable(bgl.GL_BLEND)
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.offscreen.color_texture)
shader_img.bind()
shader_img.uniform_int("image", 0)
args = {
"pos": self.rect_coords(0, 0, width, height),
"texCoord": self.rect_coords(0, 0, 1, 1),
}
batch = batch_for_shader(shader_img, "TRI_FAN", args)
batch.draw(shader_img)
# Onscreen text
# -----------------------------
y = self.onscreen_gem_table(x, y)
y -= self.view_margin
if self.show_warn:
y = self.onscreen_warning(x, y)
y -= self.view_margin
self.onscreen_options(x, y)
# Restore OpenGL defaults
# ----------------------------
bgl.glDisable(bgl.GL_BLEND)