import pygame, sys,os from pygame.locals import * from Image import * from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * class Imagen: def __init__(self): self.image = pygame.image.load("folder_home.png") self.textura = glGenTextures(1) self.tint = (1.0,1.0,1.0) self.alpha = 0.01 self.origen = [0.0,0.0] self.escala = 1.0 glBindTexture(GL_TEXTURE_2D, self.textura) # 2d texture (x and y size) self.imageData = pygame.image.tostring(self.image,"RGBA") glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, self.image.get_width(), self.image.get_height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, self.imageData) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) def dibujarImagen(self): glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() glBindTexture(GL_TEXTURE_2D, self.textura) glTranslatef(self.origen[0],self.origen[1],0.0) #rota 45 grados en eje Z (X,Y,Z) glRotatef(45,0,0,1) glColor4f(self.tint[0],self.tint[1],self.tint[2],self.alpha) glBegin(GL_QUADS) glTexCoord2f(0.0,0.0) glVertex3f(-1.0*self.escala, 1.0*self.escala, -2.0) glTexCoord2f(1.0,0.0) glVertex3f(1.0*self.escala, 1.0*self.escala, -2.0) glTexCoord2f(1.0,1.0) glVertex3f(1.0*self.escala, -1.0*self.escala, -2.0) glTexCoord2f(0.0,1.0) glVertex3f(-1.0*self.escala, -1.0*self.escala, -2.0) glEnd() glPopMatrix() def dibujar(self,x,y,escala): self.origen[0] = x self.origen[1] = y self.escala = escala self.dibujarImagen()