本文整理汇总了Python中PyQt4.QtOpenGL.QGLWidget.convertToGLFormat方法的典型用法代码示例。如果您正苦于以下问题:Python QGLWidget.convertToGLFormat方法的具体用法?Python QGLWidget.convertToGLFormat怎么用?Python QGLWidget.convertToGLFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtOpenGL.QGLWidget
的用法示例。
在下文中一共展示了QGLWidget.convertToGLFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadFromFile
# 需要导入模块: from PyQt4.QtOpenGL import QGLWidget [as 别名]
# 或者: from PyQt4.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def loadFromFile(cls, path, internalFormat=GL_RGBA):
image = QImage(path)
image = QGLWidget.convertToGLFormat(image)
dataFormat = { QImage.Format_ARGB32: GL_RGBA }.get(image.format(), None)
dataType = GL_UNSIGNED_BYTE
data = [0] * image.numBytes()
bits = image.constBits()
bits.setsize(image.numBytes())
for i in range(image.numBytes()):
data[i] = bits[i][0]
return Texture2D(image.width(), image.height(), internalFormat, dataFormat, dataType, data)
示例2: generate_textures
# 需要导入模块: from PyQt4.QtOpenGL import QGLWidget [as 别名]
# 或者: from PyQt4.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def generate_textures(self):
num_text = len(self.ply["material"])
self.textures = glGenTextures(num_text)
if num_text == 1:
self.textures = [self.textures]
else:
self.textures = list(self.textures)
for i in xrange(num_text):
text_id = self.textures[i]
text_path = self.ply["material"][i]["texture_map"].strip()
if not len(text_path):
self.textures[i] = None
continue
glBindTexture(GL_TEXTURE_2D, text_id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
img = QImage(text_path)
img = QGLWidget.convertToGLFormat(img)
glTexImage2D(
GL_TEXTURE_2D,
0,
3,
img.width(),
img.height(),
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
img.bits().asstring(img.numBytes()),
)
glBindTexture(GL_TEXTURE_2D, 0)
if not any(self.textures):
self.textures = None
示例3: setup_skybox
# 需要导入模块: from PyQt4.QtOpenGL import QGLWidget [as 别名]
# 或者: from PyQt4.QtOpenGL.QGLWidget import convertToGLFormat [as 别名]
def setup_skybox(self, image_path):
self.skybox_textures = glGenTextures(6)
sides = ('front','left','back','right','top','bottom')
for (tex_id, side) in zip(self.skybox_textures, sides):
glBindTexture(GL_TEXTURE_2D, tex_id)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
img = QImage(image_path+'-'+side+'.png')
img = QGLWidget.convertToGLFormat(img)
glTexImage2D(GL_TEXTURE_2D, 0, 3, img.width(), img.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits().asstring(img.numBytes()))
glBindTexture(GL_TEXTURE_2D, 0)
self.sky_angles = [uniform(-180.,180.) for i in xrange(3)]
self.sky_angles_vel = [uniform(-0.5,0.5) for i in xrange(3)]