def randtri(self): glPushMatrix() glRotatef(self.angle7, 0.0, 1.0, 0.0) # Surface material properties. if 0: mat_ambient = [0.629412, 0.223529, 0.027451, 1.0] mat_diffuse = [0.980392, 0.568627, 0.113725, 1.0] mat_specular = [0.392157, 0.341176, 0.07843, 1.0] mat_shininess = 0.11794872 * 128.0 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient) glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse) glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular) glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess) glEnable(GL_COLOR_MATERIAL) glBegin(GL_TRIANGLES) #glColor3f (frand(1), frand(1), frand(1)) for aa in range(2000): glColor3f(rand.frand(1), rand.frand(1), rand.frand(1)) #glColor3f(self.xrand.rand(), self.xrand.rand(), self.xrand.rand()) xx = rand.frand2(2) yy = rand.frand2(2) zz = rand.frand2(2) #xx = self.xrand.s2(2) #yy = self.xrand.s2(2) #zz = self.xrand.s2(2) glVertex3f(xx, yy, zz) #glVertex3f(self.xrand.s3(xx, .1), self.xrand.s3(yy, .1), self.xrand.s3(zz, .1)) #glVertex3f(self.xrand.s3(xx, .2), self.xrand.s3(yy, .2), self.xrand.s3(zz, .2)) glVertex3f(rand.frand3(xx, .2), rand.frand3(yy, .1), rand.frand3(zz, .2)) glVertex3f(rand.frand3(xx, .2), rand.frand3(yy, .2), rand.frand3(zz, .2)) glEnd() glDisable(GL_COLOR_MATERIAL) glPopMatrix()
def __init__(self): self.display_mode = display_mode self.initvars() '''self.__sdepth = -15 self.__sphi = self.__stheta = self.__sgamma = 0.0 self.__sside = 0; self.__supdown = 0''' self.twinkle = 0.0 self.showstars = True self.showgrid = True self.showtri = not False self.showdonut = False self.showcubes = False self.showrand = False self.showtext = False self.enable = False self.anicount = 0 self.starcol = 0.3 self.cnt = 0 self.full = False self.zoffset = -50 self.arr = [] self.selarr = [] #ttt = time.time() self.xrand = rand.XRand() #print "Random gen time", time.time() - ttt self.stars = [] for jj in range(300): self.stars.append( (rand.frand2(10.0), rand.frand2(10.0), \ rand.frand4(-3, -12), rand.frand(1))) self.bigstars = [] for jj in range(200): self.bigstars.append((rand.frand2(8.0), rand.frand2(8.0), \ rand.frand4(-3, -12), rand.frand(1) )) self.initfonts() self.BLACK = gtk.gdk.Color(0x0, 0x0, 0x0) self.RED = gtk.gdk.Color(0xffff, 0x0, 0x0) self.GREEN = gtk.gdk.Color(0x0, 0xffff, 0x0) self.BLUE = gtk.gdk.Color(0x0, 0x0, 0xffff) # Try to create a double buffered framebuffer, if not successful then # attempt to create a single buffered one. try: self.glconfig = gtk.gdkgl.Config(mode=self.display_mode) except gtk.gdkgl.NoMatches: print "Switching to non double mode" self.display_mode &= ~gtk.gdkgl.MODE_DOUBLE self.glconfig = gtk.gdkgl.Config(mode=self.display_mode) # Create the window for the app. self.win = gtk.Window() self.win.set_title('Python 3D File Manager') if sys.platform != 'win32': self.win.set_resize_mode(gtk.RESIZE_IMMEDIATE) self.win.set_reallocate_redraws(True) #self.win.set_border_width(10) self.win.connect('destroy', lambda quit: gtk.main_quit()) # DrawingArea for OpenGL rendering. self.glarea = gtk.gtkgl.DrawingArea(self.glconfig) #self.glarea.set_size_request(600, 600) www = gtk.gdk.screen_width() hhh = gtk.gdk.screen_height() self.glarea.set_size_request(3 * www / 4, 3 * hhh / 4) self.win.set_position(gtk.WIN_POS_CENTER) self.win.fullscreen() self.full = True self.win.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK | gtk.gdk.FOCUS_CHANGE_MASK) self.win.connect("motion-notify-event", self.area_motion) self.win.connect("key-press-event", self.area_key) self.win.connect("key-release-event", self.area_key) self.win.connect("button-press-event", self.area_button) self.win.connect("button-release-event", self.area_button) # connect to the relevant signals. self.glarea.connect_after('realize', self.__realize) self.glarea.connect('configure_event', self.__configure_event) self.glarea.connect('expose_event', self.__expose_event) self.glarea.connect('map_event', self.__map_event) self.glarea.connect('unmap_event', self.__unmap_event) self.glarea.connect('visibility_notify_event', self.__visibility_notify_event) self.glarea.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) self.glarea.show() self.win.add(self.glarea) self.angle = 0.0 self.angle2 = 0.0 self.angle3 = 0.0 self.angle5 = 0.0 self.angle7 = 0.0 self.pos_y = 0.0 self.pos_y2 = 0.0 self.pos_x = 0.0 self.pos_x2 = 0.0 #self.__enable_timeout = False self.__enable_timeout = True self.__timeout_interval = 30 self.__timeout_id = 0
def __init__(self): self.display_mode = gtk.gdkgl.MODE_RGB | \ gtk.gdkgl.MODE_DEPTH | \ gtk.gdkgl.MODE_DOUBLE self.__sdepth = -15 self.__sphi = 0.0 self.__stheta = 0.0 self.__sgamma = 0.0 self.twinkle = 0.0 self.donut = False self.starcol = 0.3 self.cnt = 0 #ttt = time.time() self.xrand = rand.XRand() #print "Random gen time", time.time() - ttt self.stars = [] for jj in range(300): self.stars.append( (rand.frand2(8.0), rand.frand2(8.0), \ rand.frand4(-3, -12), rand.frand(1))) self.bigstars = [] for jj in range(200): self.bigstars.append((rand.frand2(8.0), rand.frand2(8.0), \ rand.frand4(-3, -12), rand.frand(1) )) self.fontListBase = glGenLists(128) self.fontString = 'courier 36' fontDesc = pango.FontDescription(self.fontString) font = gtk.gdkgl.font_use_pango_font(fontDesc, 0, 128, self.fontListBase) if not font: print "Can't load the font %s" % (self.fontString) raise SystemExit fontMetrics = font.get_metrics() self.fontHeight = fontMetrics.get_ascent() + fontMetrics.get_descent() self.fontHeight = pango.PIXELS(self.fontHeight) #print "self.fontHeight", self.fontHeight #colormap = self.glconfig.get_colormap() #self.BLACK = colormap.alloc_color(0x0, 0x0, 0x0, False, False) #self.RED = colormap.alloc_color(0xffff, 0x0, 0x0, False, False) #self.GREEN = colormap.alloc_color(0x0, 0xffff, 0x0, False, False) #self.BLUE = colormap.alloc_color(0x0, 0x0, 0xffff, False, False) self.BLACK = gtk.gdk.Color(0x0, 0x0, 0x0) self.RED = gtk.gdk.Color(0xffff, 0x0, 0x0) self.GREEN = gtk.gdk.Color(0x0, 0xffff, 0x0) self.BLUE = gtk.gdk.Color(0x0, 0x0, 0xffff) #self.render_type = gtk.gdkgl.RGBA_TYPE # Try to create a double buffered framebuffer, if not successful then # attempt to create a single buffered one. try: self.glconfig = gtk.gdkgl.Config(mode=self.display_mode) except gtk.gdkgl.NoMatches: print "Switching to non double mode" self.display_mode &= ~gtk.gdkgl.MODE_DOUBLE self.glconfig = gtk.gdkgl.Config(mode=self.display_mode) # Create the window for the app. self.win = gtk.Window() self.win.set_title('Python 3D File Manager') if sys.platform != 'win32': self.win.set_resize_mode(gtk.RESIZE_IMMEDIATE) self.win.set_reallocate_redraws(True) #self.win.set_border_width(10) self.win.connect('destroy', lambda quit: gtk.main_quit()) # DrawingArea for OpenGL rendering. self.glarea = gtk.gtkgl.DrawingArea(self.glconfig) #self.glarea.set_size_request(600, 600) www = gtk.gdk.screen_width() hhh = gtk.gdk.screen_height() self.glarea.set_size_request(3 * www / 4, 3 * hhh / 4) self.win.set_position(gtk.WIN_POS_CENTER) self.win.fullscreen() self.win.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK | gtk.gdk.FOCUS_CHANGE_MASK) self.win.connect("motion-notify-event", self.area_motion) self.win.connect("key-press-event", self.area_key) self.win.connect("key-release-event", self.area_key) # connect to the relevant signals. self.glarea.connect_after('realize', self.__realize) self.glarea.connect('configure_event', self.__configure_event) self.glarea.connect('expose_event', self.__expose_event) self.glarea.connect('map_event', self.__map_event) self.glarea.connect('unmap_event', self.__unmap_event) self.glarea.connect('visibility_notify_event', self.__visibility_notify_event) self.glarea.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) self.glarea.show() self.win.add(self.glarea) self.angle = 0.0 self.angle2 = 0.0 self.angle3 = 0.0 self.angle5 = 0.0 self.angle7 = 0.0 self.pos_y = 0.0 self.pos_y2 = 0.0 self.pos_x = 0.0 self.pos_x2 = 0.0 self.__enable_timeout = True self.__timeout_interval = 30 self.__timeout_id = 0