def setSubImage(self, filename, level, xoffset, yoffset): self.subimage = ZOpenGLImage(filename) w = self.subimage.width h = self.subimage.height glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, w, h, GL_RGBA, GL_UNSIGNED_BYTE, self.subimage.bytes)
def createTexture(self, filename): self.id = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, self.id) glPixelStorei(GL_UNPACK_ALIGNMENT, 1) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) #glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) #glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) #glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); #glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP) glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP) glEnable(GL_TEXTURE_GEN_S) glEnable(GL_TEXTURE_GEN_T) self.image = ZOpenGLImage(filename) w = self.image.width h = self.image.height glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes) self.torus = ZOpenGLSolidTorus(None, 0.6, 1.2, 50, 40) # 0.8, 2.0, 20, 50)
def mipmapFromFile(self, filename): if filename == None: raise ValueError("Invalid argument") self.image = ZOpenGLImage(filename) w = self.image.width h = self.image.height self.mipmap(GL_RGBA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes)
def imageFromFile(self, filename, level=0, border=0, flip=True): if filename == None: raise ValueError("Invalid argument") self.image = ZOpenGLImage(filename, flip) w = self.image.width h = self.image.height glTexImage2D(self.getTarget(), 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes)
def subImageFromFile(self, filename, level, xoffset, yoffset): if filename == None: raise ValueError("Invalid argument") self.image = ZOpenGLImage(filename) w = self.image.width h = self.image.height glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes) glTexSubImage2D(self.getTarget(), level, xoffset, yoffset, w, h, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes)
def createTexture(self, filename): self.id = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, self.id) glPixelStorei(GL_UNPACK_ALIGNMENT, 1) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) self.image = ZOpenGLImage(filename) w = self.image.width h = self.image.height glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes)
def createTexture(self, filename): self.id = glGenTextures(1); glBindTexture(GL_TEXTURE_2D, self.id) glPixelStorei(GL_UNPACK_ALIGNMENT, 4) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) #glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); #glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); self.image = ZOpenGLImage(filename, flip=False) w = self.image.width h = self.image.height glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, self.image.bytes) self.sphere = ZOpenGLSolidSphere(None, 1.5, 30, 30)