From 72a211674cdf88b80ba31115b9a7ff621ec48e29 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Tue, 8 Sep 2009 21:54:32 +0000 Subject: [PATCH] on the way to Togl2.0 --- ng/Makefile.am | 1 - ng/drawing.tcl | 10 +++-- ng/ng.tcl | 2 +- ng/ngpkg.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 109 insertions(+), 8 deletions(-) diff --git a/ng/Makefile.am b/ng/Makefile.am index 86b13a68..2e5e4f6d 100644 --- a/ng/Makefile.am +++ b/ng/Makefile.am @@ -18,7 +18,6 @@ netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \ $(top_builddir)/libsrc/general/libgeneral.la \ $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS) - # # add for static linkage of ngsolve: # /opt/netgen/lib/libngsolve.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngfemng.a /opt/netgen/lib/libngmg.a /opt/netgen/lib/libngla.a /opt/netgen/lib/libngbla.a /opt/netgen/lib/libngstd.a -llapack diff --git a/ng/drawing.tcl b/ng/drawing.tcl index 575dba87..7cf75076 100644 --- a/ng/drawing.tcl +++ b/ng/drawing.tcl @@ -7,12 +7,14 @@ set oldmousey 0 # if { 1 } { -# if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true -create create_cb -display display_cb -reshape reshape_cb }] } { -# puts "no OpenGL20" -# } { + + + +# if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true -create init -display draw -reshape reshape }] } { + if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true }] } { - puts "no OpenGL" + puts "no OpenGL" } { # pack .ndraw -expand true -fill both -padx 10 -pady 10 diff --git a/ng/ng.tcl b/ng/ng.tcl index 6739687f..00e718ee 100644 --- a/ng/ng.tcl +++ b/ng/ng.tcl @@ -6,7 +6,7 @@ if {[catch {package require Tix } result ]} { } # if {[catch {package require Togl 2.0 } result ]} { -# puts "cannot find package Togl 2.0" +# puts "cannot find package Togl 2.0" # puts "error : $result" # } diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index f94821d6..53a4c666 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -34,7 +34,7 @@ The interface between the GUI and the netgen library // to be sure to include the 'right' togl-version #include "togl_1_7.h" - +// #include "Togl2/togl.h" extern bool nodisplay; @@ -3212,6 +3212,89 @@ namespace netgen // Sorry, Togl 2.0 not supported + Tcl_Obj * togl_font; + + void MyOpenGLText (const char * text) + { + cout << "togl - text" << endl; + } + + + + static int + init(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) + { + Togl * togl; + if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) + return TCL_ERROR; + + cout << "call Togl - load font (crash on my Linux64)" << endl; + // togl_font = Togl_LoadBitmapFont( togl, "Times"); // TOGL_BITMAP_8_BY_13 ); + togl_font = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 ); + cout << "success" << endl; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + + SetVisualScene (Togl_Interp(togl)); + vs->DrawScene(); + return TCL_OK; + } + + static int + zap(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) + { + return TCL_OK; + } + + + static int + draw(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) + { + Togl * togl; + if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) + return TCL_ERROR; + + + SetVisualScene (interp); + + glPushMatrix(); + glLoadIdentity(); + // gluLookAt (0, 0, 6, 0, 0, 0, 0, 1, 0); + vs->DrawScene(); + + Togl_SwapBuffers(togl); + glPopMatrix(); + + return TCL_OK; + } + + static int + reshape(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) + { + Togl * togl; + if (Togl_GetToglFromObj(interp, objv[1], &togl) != TCL_OK) + return TCL_ERROR; + + int w = Togl_Width (togl); + int h = Togl_Height (togl); + + glViewport(0, 0, w, h); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(20.0f, double(w) / h, pnear, pfar); + glMatrixMode(GL_MODELVIEW); + + // draw (togl); + + return TCL_OK; + } + + + + #endif @@ -5137,7 +5220,24 @@ namespace netgen // Togl_CreateCommand("position",position); } #else - cout << "togl 2.0 setup missing" << endl; + if(!nodisplay) + { + Tcl_CreateObjCommand(interp, "init", init, NULL, NULL); + Tcl_CreateObjCommand(interp, "zap", zap, NULL, NULL); + Tcl_CreateObjCommand(interp, "draw", draw, NULL, NULL); + Tcl_CreateObjCommand(interp, "reshape", reshape, NULL, NULL); + /* + Togl_CreateFunc( init ); + Togl_DestroyFunc( zap ); + Togl_DisplayFunc( draw ); + Togl_ReshapeFunc( reshape ); + */ + // Togl_TimerFunc( idle ); + // Togl_CreateCommand( (char*)"Ng_SnapShot", Ng_SnapShot); + // Togl_CreateCommand( (char*)"Ng_VideoClip", Ng_VideoClip); + // Togl_CreateCommand("position",position); + } + #endif