本文整理汇总了Python中pyglet.gl.glBindTexture函数的典型用法代码示例。如果您正苦于以下问题:Python glBindTexture函数的具体用法?Python glBindTexture怎么用?Python glBindTexture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glBindTexture函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, width, height, background=[255,255,255]):
self.width = width
self.height = height
self.triangles = []
self.batch = Batch()
self.bg_colour = background
has_fbo = gl.gl_info.have_extension('GL_EXT_framebuffer_object')
#setup a framebuffer
self.fb = gl.GLuint()
gl.glGenFramebuffersEXT(1, ctypes.byref(self.fb))
gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, self.fb)
#allocate a texture for the fb to render to
tex = image.Texture.create_for_size(gl.GL_TEXTURE_2D, width, height, gl.GL_RGBA)
gl.glBindTexture(gl.GL_TEXTURE_2D, tex.id)
gl.glFramebufferTexture2DEXT(gl.GL_FRAMEBUFFER_EXT, gl.GL_COLOR_ATTACHMENT0_EXT, gl.GL_TEXTURE_2D, tex.id, 0)
status = gl.glCheckFramebufferStatusEXT(gl.GL_FRAMEBUFFER_EXT)
assert status == gl.GL_FRAMEBUFFER_COMPLETE_EXT
gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, 0)
self.bg = self.batch.add( 6,
gl.GL_TRIANGLES,None,
("v2i/static", (0,0,0,height,width,height,width,height,width,0,0,0)),
("c3B/static",background*6)
)
开发者ID:msarch,项目名称:py,代码行数:28,代码来源:pyglet-bsoup.py
示例2: create_texture
def create_texture(self, cls, rectangle=False, force_rectangle=False):
'''Create a texture containing this image.
If the image's dimensions are not powers of 2, a TextureRegion of
a larger Texture will be returned that matches the dimensions of this
image.
:Parameters:
`cls` : class (subclass of Texture)
Class to construct.
`rectangle` : bool
``True`` if a rectangle can be created; see
`AbstractImage.get_texture`.
:rtype: cls or cls.region_class
'''
_is_pow2 = lambda v: (v & (v - 1)) == 0
target = gl.GL_TEXTURE_2D
if rectangle and not (_is_pow2(self.width) and _is_pow2(self.height)):
if gl.gl_info.have_extension('GL_ARB_texture_rectangle'):
target = gl.GL_TEXTURE_RECTANGLE_ARB
elif gl.gl_info.have_extension('GL_NV_texture_rectangle'):
target = gl.GL_TEXTURE_RECTANGLE_NV
texture = cls.create_for_size(target, self.width, self.height)
subimage = False
if texture.width != self.width or texture.height != self.height:
texture = texture.get_region(0, 0, self.width, self.height)
subimage = True
internalformat = self._get_internalformat(self.format)
gl.glBindTexture(texture.target, texture.id)
gl.glTexParameteri(texture.target, gl.GL_TEXTURE_WRAP_S,
gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(texture.target, gl.GL_TEXTURE_WRAP_T,
gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(texture.target, gl.GL_TEXTURE_MAG_FILTER,
gl.GL_LINEAR)
gl.glTexParameteri(texture.target, gl.GL_TEXTURE_MIN_FILTER,
gl.GL_LINEAR)
if subimage:
width = texture.owner.width
height = texture.owner.height
blank = (ctypes.c_ubyte * (width * height * 4))()
gl.glTexImage2D(texture.target, texture.level,
internalformat,
width, height,
1,
gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
blank)
internalformat = None
self.blit_to_texture(texture.target, texture.level,
0, 0, 0, internalformat)
return texture
开发者ID:burnpanck,项目名称:enable,代码行数:60,代码来源:gl.py
示例3: buffer_texture
def buffer_texture(width, height):
id_ = gl.GLuint()
gl.glGenTextures(1, byref(id_))
gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_TEXTURE_BIT)
gl.glActiveTexture(gl.GL_TEXTURE0)
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glBindTexture(gl.GL_TEXTURE_2D, id_)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MIN_FILTER,
gl.GL_LINEAR)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER,
gl.GL_LINEAR)
gl.glTexImage2D(
gl.GL_TEXTURE_2D, 0, gl.GL_RGBA,
width, height,
0,
gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
(gl.GLubyte * (width*height * 4))(),
)
gl.glFlush()
gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
gl.glPopAttrib()
return id_
开发者ID:edne,项目名称:pineal,代码行数:29,代码来源:framebuffer.py
示例4: draw
def draw(self):
if self._dirty:
self._context = Context()
self._parts = []
self.free()
self.render()
self.build_vbo()
self._dirty = False
# set
gl.glEnable(self._texture.target)
gl.glBindTexture(self._texture.target, self._texture.id)
gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glPushMatrix()
self.transform()
# cuadric.begin()
self._vertex_list.draw(gl.GL_TRIANGLES)
# cuadric.end()
# unset
gl.glPopMatrix()
gl.glPopAttrib()
gl.glDisable(self._texture.target)
开发者ID:1414648814,项目名称:cocos,代码行数:27,代码来源:draw.py
示例5: set_state
def set_state(self):
gl.glBindTexture( gl.GL_TEXTURE_CUBE_MAP, self.tex_object )
gl.glTexGeni( gl.GL_S, gl.GL_TEXTURE_GEN_MODE, gl.GL_REFLECTION_MAP )
gl.glTexGeni( gl.GL_T, gl.GL_TEXTURE_GEN_MODE, gl.GL_REFLECTION_MAP )
gl.glTexGeni( gl.GL_R, gl.GL_TEXTURE_GEN_MODE, gl.GL_REFLECTION_MAP )
gl.glEnable( gl.GL_TEXTURE_CUBE_MAP )
gl.glTexEnvi( gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_DECAL )
开发者ID:Knio,项目名称:miru,代码行数:7,代码来源:graphics.py
示例6: upload
def upload(self):
'''
Upload atlas data into video memory.
'''
glEnable( GL_TEXTURE_2D )
if self.texid is None:
self.texid = GLuint(0)
glGenTextures(1,ctypes.byref(self.texid))
glBindTexture( GL_TEXTURE_2D, self.texid )
glTexParameteri( GL_TEXTURE_2D,
GL_TEXTURE_WRAP_S, GL_CLAMP )
glTexParameteri( GL_TEXTURE_2D,
GL_TEXTURE_WRAP_T, GL_CLAMP )
glTexParameteri( GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER, GL_LINEAR )
glTexParameteri( GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER, GL_LINEAR )
if self.depth == 1:
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA,
self.width, self.height, 0,
GL_ALPHA, GL_UNSIGNED_BYTE, self.data.ctypes )
elif self.depth == 3:
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB,
self.width, self.height, 0,
GL_RGB, GL_UNSIGNED_BYTE, self.data.ctypes )
else:
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
self.width, self.height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, self.data.ctypes )
glBindTexture( GL_TEXTURE_2D, 0 )
开发者ID:9173860,项目名称:psychopy,代码行数:30,代码来源:textureatlas.py
示例7: set_state
def set_state(self):
gl.glPushMatrix()
gl.glMultMatrixf(rendering.matrix_to_gl(self.transform))
if self.texture:
gl.glEnable(self.texture.target)
gl.glBindTexture(self.texture.target, self.texture.id)
开发者ID:mikedh,项目名称:trimesh,代码行数:7,代码来源:widget.py
示例8: texture_from_data
def texture_from_data(internalformat, size, data_format, data_type, data):
'''Create texture from a data buffer (whatever can be passed as pointer to ctypes)
internalformat - GL_RGBA8 or GL_RGB8 recommended
size - a 1-, 2- or 3-tuple describing the image sizes
data_format - see 'format' parameter of glDrawPixels
data_type - see 'type' parameter of glDrawPixels
data - pointer to memory'''
size = list(size)
dimensions = len(size)
binding = getattr(gl, 'GL_TEXTURE_BINDING_{0:d}D'.format(dimensions))
target = getattr(gl,'GL_TEXTURE_{0:d}D'.format(dimensions))
texImage = getattr(gl,'glTexImage{0:d}D'.format(dimensions))
oldbind = ctypes.c_uint(0)
gl.glGetIntegerv(binding, ctypes.cast(ctypes.byref(oldbind), ctypes.POINTER(ctypes.c_int)))
texid = ctypes.c_uint(0)
gl.glEnable(target)
gl.glGenTextures(1, ctypes.byref(texid))
gl.glBindTexture(target, texid)
gl.glTexParameteri(target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
gl.glTexParameteri(target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
args = [target, 0, internalformat] + size + [0, data_format, data_type, data]
texImage(*args)
gl.glBindTexture(target, oldbind)
return texid
开发者ID:moshev,项目名称:project-viking,代码行数:27,代码来源:sprite.py
示例9: get_blocky_image
def get_blocky_image(name):
import pyglet.gl as gl
image = pyglet.resource.image(name)
gl.glBindTexture(image.target, image.id)
gl.glTexParameteri(image.target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glTexParameteri(image.target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
return image
开发者ID:wkevina,项目名称:logic-game,代码行数:7,代码来源:entity.py
示例10: from_atlas
def from_atlas(cls, name, firstgid, file, tile_width, tile_height):
image = pyglet.image.load(file)
rows = image.height // tile_height
columns = image.width // tile_width
image_grid = pyglet.image.ImageGrid(image, rows, columns)
atlas = pyglet.image.TextureGrid(image_grid)
id = firstgid
ts = cls(name, {})
ts.firstgid = firstgid
for j in range(rows-1, -1, -1):
for i in range(columns):
tile_image = image.get_region(atlas[j, i].x,
atlas[j, i].y,
atlas[j, i].width,
atlas[j, i].height)
# Set texture clamping to avoid mis-rendering subpixel edges
gl.glBindTexture(tile_image.texture.target, id)
gl.glTexParameteri(tile_image.texture.target,
gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(tile_image.texture.target,
gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
ts[id] = Tile(id, {}, tile_image)
id += 1
return ts
开发者ID:WizardWizardSomething,项目名称:wizardwar,代码行数:26,代码来源:tiles.py
示例11: set_data
def set_data(self, arr):
arr = np.asarray(arr)
self.src_format, self.dst_format = fmts_from_shape(arr.shape,
self._texture_dim)
# Float is default type
if arr.dtype == np.uint8:
arr = np.ascontiguousarray(arr)
self.src_type = gl.GL_UNSIGNED_BYTE
elif arr.dtype == np.float32:
arr = np.ascontiguousarray(arr)
self.src_type = gl.GL_FLOAT
else:
arr = np.astype(np.float32)
self.src_type = gl.GL_FLOAT
self._arr = arr
if self._id:
gl.glDeleteTextures(1, gl.byref(self._id))
id = gl.GLuint()
gl.glGenTextures(1, gl.byref(id))
self._id = id
gl.glPixelStorei (gl.GL_UNPACK_ALIGNMENT, 1)
gl.glPixelStorei (gl.GL_PACK_ALIGNMENT, 1)
gl.glBindTexture (self.target, self._id)
gl.glTexParameterf (self.target,
gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
gl.glTexParameterf (self.target,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glTexParameterf (self.target, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP)
gl.glTexParameterf (self.target, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP)
self._setup_tex()
self.update()
开发者ID:matthew-brett,项目名称:miniglumpy,代码行数:31,代码来源:textures.py
示例12: poll
def poll(dt):
out = next(itr, False)
if out is False:
if args.pause:
label.text = "Done. ('q' to quit)"
else:
pyglet.app.exit()
elif out is not None:
name, buf = out
real_dt = time.time() - last_time[0]
last_time[0] = time.time()
if buf.dtype == np.uint8:
fmt = gl.GL_UNSIGNED_BYTE
elif buf.dtype == np.uint16:
fmt = gl.GL_UNSIGNED_SHORT
else:
label.text = 'Unsupported format: ' + buf.dtype
return
h, w, ch = buf.shape
gl.glEnable(tex.target)
gl.glBindTexture(tex.target, tex.id)
gl.glTexImage2D(tex.target, 0, gl.GL_RGB8, w, h, 0, gl.GL_RGBA,
fmt, buf.tostring())
gl.glDisable(tex.target)
label.text = '%s (%g fps)' % (name, 1./real_dt)
else:
label.text += '.'
开发者ID:gijzelaerr,项目名称:cuburn,代码行数:28,代码来源:main.py
示例13: __init__
def __init__(self, width, height, scale=2):
"""
width, height:
size of the window in pixels.
scale:
the size of the texture is (width//scale) x (height//scale).
"""
pyglet.window.Window.__init__(self, width, height, caption='GrayScott Simulation',
visible=False, vsync=False)
self.reaction_shader = Shader('./glsl/default.vert', './glsl/reaction.frag')
self.render_shader = Shader('./glsl/default.vert', './glsl/render.frag')
self.pattern = DEFAULT_PATTERN
self.palette = DEFAULT_PALETTE
self.tex_width = width // scale
self.tex_height = height // scale
self.uv_texture = create_uv_texture(width//scale, height//scale)
gl.glActiveTexture(gl.GL_TEXTURE0)
gl.glBindTexture(self.uv_texture.target, self.uv_texture.id)
# use an invisible buffer to do the computation.
with FrameBuffer() as self.fbo:
self.fbo.attach_texture(self.uv_texture)
# why do we need this? the reason is in the 'on_mouse_drag' function.
self.mouse_down = False
# put all patterns in a list for iterating over them.
self._species = list(SPECIES.keys())
# set the uniforms and attributes in the two shaders.
self.init_reaction_shader()
self.init_render_shader()
开发者ID:biddy,项目名称:pywonderland,代码行数:32,代码来源:main.py
示例14: _drawLUTtoScreen
def _drawLUTtoScreen(self):
"""(private) Used to set the LUT in Bits++ mode.
Should not be needed by user if attached to a ``psychopy.visual.Window()``
since this will automatically draw the LUT as part of the screen refresh.
"""
#push the projection matrix and set to orthorgaphic
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glOrtho( 0, self.win.size[0],self.win.size[1], 0, 0, 1 ) #this also sets the 0,0 to be top-left
#but return to modelview for rendering
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
#draw the pixels
GL.glActiveTextureARB(GL.GL_TEXTURE0_ARB)
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
GL.glActiveTextureARB(GL.GL_TEXTURE1_ARB)
GL.glEnable(GL.GL_TEXTURE_2D)
GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
GL.glRasterPos2i(0,1)
GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
GL.glDrawPixels(len(self._HEADandLUT),1,
GL.GL_RGB,GL.GL_UNSIGNED_BYTE,
self._HEADandLUTstr)
#GL.glDrawPixels(524,1, GL.GL_RGB,GL.GL_UNSIGNED_BYTE, self._HEADandLUTstr)
#return to 3D mode (go and pop the projection matrix)
GL.glMatrixMode( GL.GL_PROJECTION )
GL.glPopMatrix()
GL.glMatrixMode( GL.GL_MODELVIEW )
开发者ID:alexholcombe,项目名称:psychopy,代码行数:32,代码来源:bits.py
示例15: draw
def draw(self):
'''
Draw the windows.
'''
self.program.use()
data = list(self.root.get_data(0, 0))
data = (gl.GLfloat * len(data))(*data)
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
gl.glBufferData(gl.GL_ARRAY_BUFFER, sizeof(data), data, gl.GL_DYNAMIC_DRAW)
gl.glActiveTexture(gl.GL_TEXTURE0)
gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture)
if self.textmanager.dirty:
# only upload the texture to the GPU if it has actually changed
gl.glTexImage2D(gl.GL_TEXTURE_2D,
0, # level
gl.GL_R8,
self.textmanager.width,
self.textmanager.height,
0,
gl.GL_RED,
gl.GL_UNSIGNED_BYTE,
ctypes.create_string_buffer(self.textmanager.img.tobytes()))
self.textmanager.dirty = False
self.program.uniform1i(b"tex", 0) # set to 0 because the texture is bound to GL_TEXTURE0
self.program.vertex_attrib_pointer(self.buffer, b"position", 4)
# self.program.vertex_attrib_pointer(self.buffer, b"texcoord", 2, stride=4 * sizeof(gl.GLfloat), offset=2 * sizeof(gl.GLfloat))
gl.glDrawArrays(gl.GL_QUADS, 0, len(data) // 4)
开发者ID:leovt,项目名称:openpark,代码行数:31,代码来源:windowmanager.py
示例16: blit_buffer
def blit_buffer(self, framebuffer, parent_width, parent_height, **kwargs):
"""Draw the texture into the parent scene
.. warning:
This method's arguments are not part of the API yet and may change
at any time.
"""
gl.glViewport(0, 0, parent_width, parent_height)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glBindTexture(gl.GL_TEXTURE_2D, framebuffer.texture_id)
gl.glEnable(gl.GL_TEXTURE_2D)
gl.glColor4fv((gl.GLfloat * 4)(*self.color + (self.opacity, )))
gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA) # premultipl.
gl.glBegin(gl.GL_TRIANGLE_STRIP)
gl.glTexCoord2f(0, 0)
gl.glVertex2i(0, 0)
gl.glTexCoord2f(0, parent_height)
gl.glVertex2i(0, parent_height)
gl.glTexCoord2f(parent_width, 0)
gl.glVertex2i(parent_width, 0)
gl.glTexCoord2f(parent_width, parent_height)
gl.glVertex2i(parent_width, parent_height)
gl.glEnd()
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
gl.glDisable(gl.GL_TEXTURE_2D)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glViewport(0, 0, parent_width, parent_height)
开发者ID:encukou,项目名称:gillcup_graphics,代码行数:35,代码来源:effectlayer.py
示例17: after_draw
def after_draw(self, camera):
"""Called by CocosNode when the texture is already grabbed.
The FrameBuffer will be unbound and the texture will be drawn
:Parameters:
`camera` : `Camera`
The target's camera object.
"""
# capture after drawing
self.grabber.after_render(self.texture)
# after unbinding
# set a 3d projection
self._set_3d_projection()
# and center the camera
camera.locate(force=True)
# blit
gl.glEnable(self.texture.target)
gl.glBindTexture(self.texture.target, self.texture.id)
gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
self._blit()
gl.glPopAttrib()
gl.glDisable(self.texture.target)
开发者ID:los-cocos,项目名称:cocos,代码行数:29,代码来源:grid.py
示例18: on_draw
def on_draw():
gl.glClearColor(1.0,1.0,1.0,1.0)
window.clear()
# Compute
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, 1, 0, 1, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glActiveTexture( gl.GL_TEXTURE1 )
gl.glBindTexture(texture_s.target, texture_s.id)
gl.glActiveTexture( gl.GL_TEXTURE0 )
gl.glBindTexture(texture_uv.target, texture_uv.id)
gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, framebuffer)
reaction_shader.bind()
texture_uv.blit(x=0.0, y=0.0, width=1.0, height=1.0)
reaction_shader.unbind()
gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, 0)
# Render
gl.glViewport(0, 0, window.width, window.height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, 1, 0, 1, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
color_shader.bind()
texture_uv.blit(x=0.0, y=0.0, width=1.0, height=1.0)
color_shader.bind()
开发者ID:rougier,项目名称:grayscott,代码行数:33,代码来源:grayscott.py
示例19: on_draw
def on_draw(self):
self.window.clear()
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
self.camera()
gl.glEnable(self.grass.target)
gl.glEnable(gl.GL_BLEND)
gl.glBindTexture(self.grass.target, self.grass.id)
W = 10000.
graphics.draw(4, gl.GL_QUADS,
('v2f', (-W, -W, W, -W, W, W, -W, W)),
('t2f', (0., 0., W*5., 0., W*5., W*5., 0., W*5.))
)
gl.glDisable(self.grass.target)
for lane in self.lanes:
self.draw_lane_surface(lane)
for lane in self.lanes:
self.draw_lane_lines(lane)
for obj in self.objects:
self.draw_object(obj)
for car in self.cars:
if car!=self.main_car and car not in self.visible_cars:
self.draw_car(self.anim_x[car], car.color)
if self.heat is not None:
self.draw_heatmap()
for car in self.cars:
if car==self.main_car or car in self.visible_cars:
self.draw_car(self.anim_x[car], car.color)
gl.glPopMatrix()
if isinstance(self.main_car, Car):
self.label.text = 'Speed: %.2f'%self.anim_x[self.main_car][3]
self.label.draw()
if self.output is not None:
pyglet.image.get_buffer_manager().get_color_buffer().save(self.output.format(self.frame))
开发者ID:dsadigh,项目名称:Autonomous_Driving,代码行数:35,代码来源:visualize.py
示例20: data
def data(self, buffer_type, data, offset):
if buffer_type != "texture":
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffers[buffer_type])
if buffer_type == "color":
offset *= 16
else:
offset *= 12
gl_data = to_gl_float(data)
length = len(data) * 4
gl.glBufferSubData(gl.GL_ARRAY_BUFFER, offset, length, gl_data)
if buffer_type == "vertex":
self.vertex_count += int(len(data) / 3)
else:
self.buffers["texture"] = gl.GLuint(0)
gl.glGenTextures(1, self.buffers["texture"])
gl.glBindTexture(data.target, data.id)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, texture.width, texture.height, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE,
texture_data)
开发者ID:anden3,项目名称:Python,代码行数:26,代码来源:Craftmine.py
注:本文中的pyglet.gl.glBindTexture函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论