From 7d961851fb3427c70f3fd70557644bb48bf65234 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 7 Sep 2009 15:15:22 +0000 Subject: [PATCH] prepare for togl2.0 --- libsrc/include/incvis.hpp | 7 ------ libsrc/visualization/mvdraw.cpp | 39 +++++++++++++++++++++++---------- libsrc/visualization/mvdraw.hpp | 8 +++++-- libsrc/visualization/vsmesh.cpp | 15 ++++++++----- ng/drawing.tcl | 7 +++++- ng/ng.tcl | 6 ++--- ng/ngpkg.cpp | 12 +++++++++- 7 files changed, 63 insertions(+), 31 deletions(-) diff --git a/libsrc/include/incvis.hpp b/libsrc/include/incvis.hpp index 19a5aae8..cec32d9f 100644 --- a/libsrc/include/incvis.hpp +++ b/libsrc/include/incvis.hpp @@ -31,13 +31,6 @@ #endif -#ifndef NOTCL -// #include -// #include "../../togl/togl.h" -#endif - - - // part of OpenGL 1.2, but not in Microsoft's OpenGL 1.1 header: // GL version sould be checked at runtime diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 58b4173e..a2651ee7 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -29,7 +29,15 @@ namespace netgen Point3d VisualScene :: center; double VisualScene :: rad; GLdouble VisualScene :: backcolor; + + /* +#if TOGL_MAJOR_VERSION!=2 GLuint VisualScene :: fontbase = 0; +#else + Tcl_Obj * VisualScene :: fontbase = NULL; + Togl * VisualScene :: globtogl; +#endif + */ // texture for color decoding // GLubyte * VisualScene :: colortexture = NULL; @@ -740,7 +748,7 @@ namespace netgen glColor3fv (textcol); glPushAttrib (GL_LIST_BIT); - glListBase (fontbase); + // glListBase (fontbase); char buf[20]; for (int i = 0; i <= 4; i++) @@ -755,7 +763,8 @@ namespace netgen val = minval + i * (maxval-minval) / 4; sprintf (buf, "%8.3e", val); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); } glPopAttrib (); @@ -808,19 +817,22 @@ namespace netgen glEnd (); glPushAttrib (GL_LIST_BIT); - glListBase (fontbase); + // glListBase (fontbase); char buf[20]; glRasterPos3d (len, 0.0f, 0.0f); sprintf (buf, "x"); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); glRasterPos3d (0.0f, len, 0.0f); sprintf (buf, "y"); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); glRasterPos3d (0.0f, 0.0f, len); sprintf (buf, "z"); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); glPopAttrib (); @@ -865,12 +877,13 @@ namespace netgen glLineWidth (1.0f); glPushAttrib (GL_LIST_BIT); - glListBase (fontbase); + // glListBase (fontbase); char buf[] = "Netgen " PACKAGE_VERSION; glRasterPos3d (0.0f, 0.0f, 0.0f); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); glPopAttrib (); @@ -1310,7 +1323,7 @@ namespace netgen glColor3fv (textcol); glNormal3d (0, 0, 1); glPushAttrib (GL_LIST_BIT); - glListBase (fontbase); + // glListBase (fontbase); char buf[20]; for (int i = 1; i <= mesh->GetNSeg(); i++) @@ -1323,7 +1336,8 @@ namespace netgen glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", seg.edgenr); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); } glPopAttrib (); @@ -1380,7 +1394,7 @@ namespace netgen glColor3fv (textcol); glNormal3d (0, 0, 1); glPushAttrib (GL_LIST_BIT); - glListBase (fontbase); + // glListBase (fontbase); char buf[20]; for (int i = 1; i <= mesh->GetNP(); i++) @@ -1389,7 +1403,8 @@ namespace netgen glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); - glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + // glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); } glPopAttrib (); diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index e7f0380e..2d844f66 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -15,6 +15,8 @@ namespace netgen extern void Render (); + + class VisualScene { protected: @@ -42,8 +44,6 @@ namespace netgen static int selecttimestamp; public: - static GLuint fontbase; - // static Tcl_Obj* fontbase; // Togl 2.0 // static GLubyte * colortexture; static GLuint coltexname; @@ -93,6 +93,10 @@ namespace netgen }; + extern void MyOpenGLText (const char * text); + + + class VisualSceneGeometry : public VisualScene { Array trilists; diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index 2f3ab3eb..d7b13338 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -419,7 +419,7 @@ namespace netgen glColor3fv (textcol); glNormal3d (0, 0, 1); glPushAttrib (GL_LIST_BIT); - glListBase (fontbase); + // glListBase (fontbase); char buf[30]; @@ -431,7 +431,8 @@ namespace netgen sprintf (buf, "%d", i); - glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); } if (vispar.drawedgenumbers) @@ -462,7 +463,9 @@ namespace netgen glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); - glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); + } } @@ -493,7 +496,8 @@ namespace netgen glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); - glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); } } @@ -577,7 +581,8 @@ namespace netgen glRasterPos3d (p.X(), p.Y(), p.Z()); sprintf (buf, "%d", i); - glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + // glCallLists (strlen (buf), GL_UNSIGNED_BYTE, buf); + MyOpenGLText (buf); } } diff --git a/ng/drawing.tcl b/ng/drawing.tcl index af3cf630..575dba87 100644 --- a/ng/drawing.tcl +++ b/ng/drawing.tcl @@ -6,8 +6,13 @@ 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 }] } { - 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 c18554d3..74cbf370 100644 --- a/ng/ng.tcl +++ b/ng/ng.tcl @@ -5,9 +5,9 @@ if {[catch {package require Tix } result ]} { puts "error : $result" } -# if {[catch {package require Togl 2.0 }]} { -# puts "cannot find package Togl 2.0" -# } +# if {[catch {package require Togl } result ]} { +# puts "cannot find package Togl 2.0" +# puts "error : $result" diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index b250cf3b..7f09c9b3 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -3116,10 +3116,20 @@ namespace netgen // Togl + + static int fontbase = 0; + + void MyOpenGLText (const char * text) + { + glListBase (fontbase); + glCallLists (GLsizei(strlen(text)), GL_UNSIGNED_BYTE, text); + } + + static void init( struct Togl *togl ) { - VisualScene::fontbase = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 ); + fontbase = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 ); glMatrixMode(GL_PROJECTION); glLoadIdentity();