From: Tim R. <ti...@us...> - 2004-07-18 15:03:44
|
Update of /cvsroot/csdopenglnet/tutorials/lesson01 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3812 Modified Files: Makefile Added Files: lesson01gtk.cs Log Message: Gtk base example --- NEW FILE: lesson01gtk.cs --- using csDragons.OpenGL; using GLib; using Gtk; using GtkSharp; using System; public class GtkTest : csdGL { GtkGLArea glarea; bool stop; float angle = 0.0f; public GtkTest() { Application.Init(); Gtk.Window window = new Gtk.Window( "Gtk Triangle" ); window.ReallocateRedraws = true; window.DeleteEvent += new DeleteEventHandler( OnDeleteEvent ); glarea = new GtkGLArea(); glarea.Realized += new EventHandler (OnRealized); glarea.ConfigureEvent += new ConfigureEventHandler (OnConfigure); glarea.ExposeEvent += new ExposeEventHandler (OnExpose); glarea.MapEvent += new MapEventHandler (OnMap); glarea.UnmapEvent += new UnmapEventHandler (OnUnmap); Table table = new Table( 10, 20, true ); table.Attach( glarea, 1, 19, 1, 9 ); window.Add( table ); glarea.Show (); window.ShowAll (); Application.Run (); } protected void OnDeleteEvent (object obj, DeleteEventArgs args) { Application.Quit (); } protected void OnMap (object obj, MapEventArgs args) { GLib.Idle.Add (new IdleHandler (Animate)); stop = false; } protected void OnUnmap (object obj, UnmapEventArgs args) { stop = true; } protected bool Animate () { angle += 0.2f; glarea.QueueDraw (); return !stop; } protected void OnExpose (object obj, ExposeEventArgs args) { if (glarea.MakeCurrent()) { glClearColor( 0, 0, 0, 0 ); glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPopMatrix(); glarea.SwapBuffers(); } } protected void OnConfigure (object obj, ConfigureEventArgs args) { if (glarea.MakeCurrent()) { glViewport(0, 0, glarea.Allocation.Width, glarea.Allocation.Height); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); float h = (float) glarea.Allocation.Height / (float) (glarea.Allocation.Width); glFrustum( -1.0f, 1.0f, -h, h, 5.0f, 5.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } } protected void OnRealized (object obj, EventArgs args) { glShadeModel( GL_SMOOTH ); glClearColor( 0.0f, 0.0f, 0.0f, 0.5f ); glClearDepth( 1.0f ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); } public static void Main( string[] args) { GtkTest gl = new GtkTest(); } } Index: Makefile =================================================================== RCS file: /cvsroot/csdopenglnet/tutorials/lesson01/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 13 Jul 2004 22:24:19 -0000 1.2 --- Makefile 18 Jul 2004 15:03:35 -0000 1.3 *************** *** 5,12 **** LIBS=csdGL.dll MCS=$(CC) $(OPTS) -lib:/usr/lib/mono/csDragons -lib:/usr/lib/mono/gtk-sharp ! FILES = lesson01glut.exe all: $(FILES) %.exe:%.cs $(MCS) -r:csdGL.dll $^ -o $@ --- 5,15 ---- LIBS=csdGL.dll MCS=$(CC) $(OPTS) -lib:/usr/lib/mono/csDragons -lib:/usr/lib/mono/gtk-sharp ! FILES = lesson01glut.exe lesson01gtk.exe all: $(FILES) + lesson01gtk.exe: lesson01gtk.cs + $(MCS) -r:csdGL_Gtk -r:glib-sharp.dll -r:gtk-sharp.dll $^ -o $@ + %.exe:%.cs $(MCS) -r:csdGL.dll $^ -o $@ |