This will allow solvespace to run on pre-OpenGL 3.0 implementations,
such as VirtualBox (and possibly others).
However, VirtualBox's handling of framebuffer objects is buggy;
it tries to draw over our X window and fails to do either.
I hate OpenGL.
Apparently pbuffers are also a deprecated and unportable
way of offscreen rendering. They're not supported by
Chromium OpenGL implementation, which is what 3D-accelerated
VirtualBox uses.
This would also help a future OS X port.
Apparently GLX pixmaps are an antiquated and unsupported method
for offscreen rendering in OpenGL. Specifically this broke
software and VirtualBox accelerated rendering in Ubuntu trusty
and who knows which other systems.
This commit switches the rendering to use pbuffers instead,
while retaining all other logic. The pbuffers are fixed-size,
because reallocating pbuffers during a resize sometimes results
in segfaults in glXMakeCurrent despite apparently correct
API usage.
In principle, GTK3 is the way forward, and GTK2 is officially
deprecated, though still maintained. In practice however, GTK3
is often unbearably buggy; e.g. on my system, combo boxes
don't ever roll up in GTK3 windows. So I have added support
for both.
This required a few minor changes to the core, namely:
* GTK wants to know beforehand whether a menu item is a check
menu item or a regular one.
* GTK doesn't give us an easy way to execute something after
any event is processed, so an explicit idle timer is added.
This is a no-op on Win32.
* A few function signatures were const'ed, since GTK expects
immutable strings when converting to Glib::ustring.
fltkutil.cpp should be independent of FLTK so that it can be linked
into libslvs while neither requiring every user of the library to
reimplement these support routines nor requiring linking in FLTK.
However, don't use ssglLineWidth for UI drawing operations.
These only draw horizontal or vertical lines that don't need to
be antialiased, and thus don't require the workaround. In fact
the workaround would make them thicker than needed.
fltkmain accidentally used optind instead of optndx. optind is
defined as an extern int in glibc but not on BSD systems.
This also broke passing a filename on command line.
Writing to NULL is undefined behavior and it is legal for the
compiler to simply remove it; clang will do so. abort()
or __builtin_trap() would produce the desirable result.
abort() is used as it is more portable.
Since SolveSpace's config.h is not exported, we cannot depend
on HAVE_C99_INTEGER_TYPES or similar variables. It's simplest
to just define it from scratch in the same way as MSVC does.
The GUI application and library share some object files but don't
enable object renaming resulting in the second compilation overwriting
the results of the first compilation. This can be fixed by setting
explicit preprocessor flags for one compilation. The actual problem,
however, is that recursive make is used in an inappropriate way; two
Makefiles shouldn't refer to the same source files. In this case,
libslvs should be under src/ and handled by the same Makefile, in
which case the issue would have been obvious when the Makefile was
written in the first place.
Requested by yugami:
> might I suggest explicitly including libGL as well as libpng.
> One of the previous builders errors needed that explicitly added in
As Peter Stuge pointed out, it works anyway if fltk is built with png
support because solvespace uses the flags returned by fltk-config.
If fltk was built with png support enabled, these include -lpng.