コード例 #1
0
ファイル: shapes.cs プロジェクト: GNOME/gtkglext-sharp
        public static int Main(string[] args)
        {
            Gtk.Application.Init (ref args);
            GtkGL.Application.Init (ref args);

            /*
            * Query OpenGL extension version.
            */
            int major, minor;
            Query.Version (out major, out minor);
            Console.WriteLine ("\nOpenGL extension version - {0}.{1}", major, minor);

            // * Configure OpenGL-capable visual.
            // Try double-buffered visual
            GdkGL.Config glconfig = new GdkGL.Config (GdkGL.ConfigMode.Rgb | GdkGL.ConfigMode.Double);
            if (glconfig == null) {
              		Console.WriteLine ("*** Cannot find the double-buffered visual.\n*** Trying single-buffered visual.");
                glconfig = new GdkGL.Config (GdkGL.ConfigMode.Rgb);
                if (glconfig == null) {
                      Console.WriteLine ("*** Cannot find any OpenGL-capable visual.");
                      return 1;
                }
            }

            GlUtilities.WriteOutConfig (glconfig);

            // Top-level window.
            Window window = new Window (WindowType.Toplevel);
            window.Title = "shapes";

            // Get automatically redrawn if any of their children changed allocation.
            window.ReallocateRedraws = true;
            window.DeleteEvent += new DeleteEventHandler (OnDelete);

            // VBox.
            VBox vbox = new VBox (false, 0);
            window.Add (vbox);
            vbox.Show ();

            // Drawing area for drawing OpenGL scene.
            ShapesArea drawing_area = new ShapesArea (glconfig);
            drawing_area.SetSizeRequest (300, 300);

            vbox.PackStart (drawing_area, true, true, 0);
            drawing_area.Show ();

            // Simple quit button.
            Button button = new Button ("Quit");
            button.Clicked += new EventHandler (OnQuit);
            vbox.PackStart (button, false, false, 0);
            button.Show ();

            // Show window.
            window.Show ();

            //
            Gtk.Application.Run ();
            return 0;
        }
コード例 #2
0
ファイル: WidgetGL.cs プロジェクト: codyn-net/plot-sharp
        public WidgetGL() : base()
        {
            GdkGL.Config config = new GdkGL.Config(Screen,
                                                   GdkGL.ConfigMode.Rgb |
                                                   GdkGL.ConfigMode.Depth |
                                                   GdkGL.ConfigMode.Double);

            d_isrealized = false;

            d_gl = new GlWidget(this,
                                config,
                                null,
                                true,
                                RenderType.RgbaType);

            Realized += delegate {
                d_isrealized = true;
                Reconfigure();
            };
        }