[Gmsh] Antialiasing gmsh2

Kubicek Bernhard Bernhard.Kubicek at arsenal.ac.at
Wed Jan 17 20:42:49 CET 2007


Hello!

While playing around with the gmsh-2.0.0-nightly-20070117 source, I
found that at least on my system (Ubuntu-x86 dapper, nvidia) enabling
antialiasing leads to nicer/smoother look in the gmsh-OpenGL window. A
drawback might be slower rendering time. Attached are two PNGs showing
the difference. 

To do so, one needs to change the sourcecode and recompile.

In the file Fltk/GUI.cpp, after line 1445, change the code to (basically
just inserting FL_MULTISAMPLE): 
----
  // opengl window

  g_opengl_window = new Opengl_Window(0, 0, width, glheight);
	g_opengl_window->mode(FL_RGB | FL_DEPTH | FL_MULTISAMPLE |
FL_DOUBLE ); //enable antialiasing
  if(!opt_general_double_buffer(0, GMSH_GET, 0)) {
    Msg(INFO, "Setting OpenGL visual to single buffered");
    g_opengl_window->mode(FL_RGB | FL_DEPTH | FL_MULTISAMPLE | FL_SINGLE
); //enable antialiasing
  }
----

However for being able to switch between single and double buffered
display without loosing the antialiasing, also Common/Options.cpp needs
to changed similarly:
----
double opt_general_double_buffer(OPT_ARGS_NUM)
{
  if(action & GMSH_SET) {
    CTX.db = (int)val;
#if defined(HAVE_FLTK)
    if(WID) {
      if(CTX.db) {
        Msg(INFO, "Setting OpenGL visual to double buffered");
        WID->g_opengl_window->mode(FL_RGB | FL_DEPTH | FL_MULTISAMPLE |
FL_DOUBLE); //enable antialiasing
      }
      else {
        Msg(INFO, "Setting OpenGL visual to single buffered");
        WID->g_opengl_window->mode(FL_RGB | FL_DEPTH | FL_MULTISAMPLE |
FL_SINGLE);//enable antialiasing
      }
    }
#endif
  }
#if defined(HAVE_FLTK)
  if(WID && (action & GMSH_GUI))
    WID->gen_butt[3]->value(CTX.db);
#endif
  return CTX.db;
}
----
For productive usage, one probably could include a preprocessor switch
or a GUI element similar to the double-buffering switch.

Nice greetings,
 Bernhard


/------
| freelancer at Arsenal Research, Vienna, Austria http://arsenal.ac.at/ 
| PhD at Vienna University of Technology, Austria 
| http://www.phdcomics.com/comics/archive.php?comicid=180
\------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: antialiased.png
Type: image/png
Size: 74185 bytes
Desc: antialiased.png
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20070117/8d8d31f6/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: antialiased_not.png
Type: image/png
Size: 85223 bytes
Desc: antialiased_not.png
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20070117/8d8d31f6/attachment-0001.png>