本文整理汇总了Python中PySide.QtOpenGL.QGLWidget.convertToGLFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QGLWidget.convertToGLFormat方法的具体用法?Python QGLWidget.convertToGLFormat怎么用?Python QGLWidget.convertToGLFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtOpenGL.QGLWidget
的用法示例。
在下文中一共展示了QGLWidget.convertToGLFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reload
# 需要导入模块: from PySide.QtOpenGL import QGLWidget [as 别名]
# 或者: from PySide.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def reload(self, gl, full_reload):
imgs = self.images
reload_buffers = False
reload_images = False
if full_reload:
reload_buffers =True
reload_images = True
# If this is a full reload, all the textures were automatically deleted,
# so just create new arrays so we won't try to delete the old ones again.
self.textures = [None] * len(imgs)
self.red_textures = [None] * len(imgs)
else:
# Process any queued updates.
reset = self.update_type.Reset in self.updates
reload_buffers = reload_buffers or reset or self.update_type.UpdatePositions in self.updates
reload_images = reload_images or reset or self.update_type.UpdateImages in self.updates
self.updates = set()
if reload_buffers:
self.vertex_buffer.reload()
self.text_coord_buffer.reload()
if reload_images:
for i in range(0, len(self.textures)):
#If the image is already allocated, delete it.
if self.textures[i] != None:
self.textures[i].delete(gl)
self.red_textures[i].delete(gl)
bmp = self.images[i].pixmap
self.textures[i] = TextureManager().create_texture(gl)
self.textures[i].bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
'''
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
The image has to be mirrored for some reason
'''
q_img = QImage(bmp.toImage()).mirrored()
img = QGLWidget.convertToGLFormat(q_img)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA,
gl.GL_UNSIGNED_BYTE, str(img.bits()))
self.red_textures[i] = TextureManager().create_texture(gl)
self.red_textures[i].bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
red_pixels = self.create_red_image(q_img)
red_pixels = QGLWidget.convertToGLFormat(red_pixels)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, red_pixels.width(), red_pixels.height(),
0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, str(red_pixels.bits()))
示例2: loadPNGImage
# 需要导入模块: from PySide.QtOpenGL import QGLWidget [as 别名]
# 或者: from PySide.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def loadPNGImage(img):
glImg = QGLWidget.convertToGLFormat(img)
if glImg is None:
raise ValueError, "Loading png file %s: Conversion to GL format failed." % img
ndata = numpy.fromstring(glImg.bits(), dtype='uint8')
w = glImg.width()
h = glImg.height()
b = glImg.depth() / 8
assert len(ndata) == w * h * b
return w, h, ndata.reshape((h, w, b))
示例3: end_adding
# 需要导入模块: from PySide.QtOpenGL import QGLWidget [as 别名]
# 或者: from PySide.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def end_adding(self, gl):
self.texture.bind(gl)
'''
IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
The image has to be mirrored for some reason
'''
img = QImage(self.bitmap.toImage()).mirrored()
img = QGLWidget.convertToGLFormat(img)
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA,
gl.GL_UNSIGNED_BYTE, str(img.bits()))
# This particular bitmap is no longer needed
self.bitmap = None
示例4: create_texture_from_resource
# 需要导入模块: from PySide.QtOpenGL import QGLWidget [as 别名]
# 或者: from PySide.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def create_texture_from_resource(self, gl, resource_id):
'''
Unlike the original java source, convertToGLFormat is used
'''
text = self.create_texture_internal(gl)
img = QImage("assets/drawable/" + self.images[resource_id] + ".png")
img = QGLWidget.convertToGLFormat(img)
text.bind(gl)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE);
gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA,
gl.GL_UNSIGNED_BYTE, str(img.bits()))
return text
示例5: fname_to_tex
# 需要导入模块: from PySide.QtOpenGL import QGLWidget [as 别名]
# 或者: from PySide.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def fname_to_tex(file_name):
img = QImage()
img.load(file_name)
img2 = QGLWidget.convertToGLFormat(img)
img3 = str(img2.bits())
return img3