Example #1
0
    def __init__(self):
        display_mode = gdkgl.MODE_RGB | gdkgl.MODE_DOUBLE
        try:
            self.glconfig = gdkgl.Config(mode=display_mode)
        except gdkgl.NoMatches:
            display_mode &= ~gdkgl.MODE_DOUBLE
            self.glconfig = gdkgl.Config(mode=display_mode)

        win = gtk.Window()
        win.set_title('OpenGL Color Gradient')
        win.connect('destroy', gtk.main_quit)
        self.win = win

        vbox = gtk.VBox()
        self.win.add(vbox)

        self.bpc = 16
        self.label = gtk.Label(" ")
        self.label.modify_font(pango.FontDescription("sans 24"))
        self.populate_label()
        vbox.add(self.label)

        glarea = gtkgl.DrawingArea(glconfig=self.glconfig, render_type=gdkgl.RGBA_TYPE)
        glarea.set_size_request(*SIZE)
        glarea.connect_after('realize', self.on_realize)
        glarea.connect('configure_event', self.on_configure_event)
        glarea.connect('expose_event', self.on_expose_event)
        win.connect("key_press_event", self.on_key_press)
        self.glarea = glarea
        vbox.add(glarea)
        win.show_all()
        add_close_accel(win, gtk.main_quit)
Example #2
0
	def __init__(self, config = None, share_group = None, **kwds):
		pf = GLConfig._from_args(config, kwds)
		GLContext.__init__(self, share_group, pf, kwds)
		gtk_share = self._gtk_get_share()
		area = gtkgl.DrawingArea(glconfig = self._gl_config, share_list = gtk_share,
			render_type = gdkgl.RGBA_TYPE)
		area.show()
		self._gtk_connect_after(area, "realize", self._gtk_realize_signal)
		self._gtk_connect(area, "expose-event", self._gtk_expose_event_signal)
		GGLView.__init__(self, _gtk_outer = area, _gtk_input = area,
			_gtk_focus = area)
		self.set(**kwds)