I invite fellow FLTK developers to, please, consider whether it would make
sense to have the Windows FLTK platform use GDI+ to perform all graphics,
instead of GDI that's currently used.
Sounds generally good to me, gonna go with your instinct on
this, as my only concern
is that FLTK still build on XP and up, which it sounds like it
does.
However there are some folks working on DOS support
somehow; will their
efforts be negatively affected?
Beyond that I have no opinion, other than it sounds like it's
more C++ "friendly" and offers
features the older GDI does not which may help us in the long
run. So I'm not sure I see a
downside other than backwards support before XP (which might
be an issue for some).
Just doing a casual google search for GDI vs GDI+:
https://stackoverflow.com/questions/4551224/what-is-the-difference-between-gdi-and-gdi
"""
GDI+ is object oriented, and it's main purpose is to provide C++ classes to simplify and extend in some ways GDI usage. GDI+ is an improvement on GDI. It contains features not readily available in GDI such as gradient brushes, alpha blending, and more image format support.
"""
"""
With the introduction of Windows XP, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem. GDI+ adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG, and support for composition of affine transformations in the 2D view pipeline.
"""
According to the Windows documentation,
https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-gdi-start
"GDI+ is a class-based API for C/C++ programmers. It enables applications to use graphics
and formatted text on both the video display and the printer."
"GDI+ can be used in all Windows-based applications. GDI+ was introduced in Windows XP and
Windows Server 2003."
Expected benefits of using GDI+ are :
All sounds good to me!
I could not try it with Visual C++ but expect no problem because only documented API's are used.
I don't know, though, if the extra argument "-lgdiplus" of the link command (see below)
takes a different form with Visual C++.
I can try your fork in VS 7 and VS Express 2017 later today
and report back
if that would help.
Let me know if there's any specific things you want me to
enable or look for/test.
I can also provide you with executables if need be to play
with.
I can try your fork in VS 7 and VS Express 2017 later today and report back if that would help.
Let me know if there's any specific things you want me to enable or look for/test.
I can also provide you with executables if need be to play with.
What's your (and other devs') idea/vision: keep the full code base for
both GDI and GDI+ in the future, or switch entirely to GDI+ once we know
it's working?
> With one exception, all changes to the FLTK code base are located in
> Windows-specific
> parts, which guarantees that the X11 and macOS platforms and the public
> FLTK API are
> totally unaffected. The exception is
Hmm, I don't understand this. IIRC it's well documented that ld() == 0
is a shortcut for ld() == w() * d(). So why does this need a special
treatment?
…
> That part of the FLTK doc
> https://fltk.gitlab.io/fltk/osissues.html#osissues_win32_gdi
> would become invalidated by the GDI+ change.
Is it possible to have an alternative for user code using GDI+ for
drawing in their own draw() methods?
I have decided to give a try with Visual Studio and installed VS 2019,
and arrived to the same conclusions as you [Albrecht]: added the include <objidl.h>,
a couple of #include <FL/math.h> and of the pragma directive.Its now pushed to the git granch. Please, pull it.
Looks like I'm a little late to the party; cloned/checked out your repo just now,
which is currently at:
commit 356e60c26f39d3391f0b54ecaa315bb69f6c8825 (HEAD -> GDI+, origin/GDI+)Then used cmake to configure for VS 2017:
Author: ManoloFLTK <41016272+...@users.noreply.github.com>
Date: Thu Feb 4 19:05:41 2021 +0100
Windows GDI+: add support of Visual Studio
cmake -G "Visual Studio 15 2017" -D CMAKE_BUILD_TYPE=Release ..
Loaded the fltk.sln up in VS 2017, changed Debug -> Release and built the whole project,
resulting in "94 succeeded" and no fails or skips, but lots of the usual warnings (attached as warnings.txt).
Test programs look OK so far, unit tests for drawing all seem to look consistent with linux.Should the lines be antialiased? If so, not for me:
Widgets look ok, e.g. test/tree
Next I'll try building an app that draws lots and lots of vectors quickly in animation, a good way to see if there's
any slowness for line drawing.
But before I do that, wanted to check if I've built this right, because I was expecting antialiased lines..?
On 2/4/21 11:22 AM, Albrecht Schlosser wrote:
On 2/4/21 7:51 PM Greg Ercolano wrote:
_*Should the lines be antialiased? If so, not for me:*_
First of all, I assume you checked out branch GDI+, right?
Ya. Copy pasted the clone + checkout commands from Manolo's earlier msg.
Second important point is to set OPTION_USE_GDIPLUS but your CMake command above doesn't include this.
In case you didn't you can just run cmake again with that option (-D OPTION_USE_GDIPLUS=ON) or edit the option with cmake-gui.
Thanks, that must be it -- will retry with that.
It would be good if the FLTK api provided a way to turn AA off
from within the app, as there are rare apps
that can benefit from turning AA on/off within the app. PCB
board CAD comes to mind.
OK, 94 succeeded, no errors, but there are some new warnings
about the /ldgiplus flag being ignored, which has already
been noted by Albrecht.
Can now confirm AA lines in the unittests, which do look great..
and text looks better (see "rendering text" unit test results,
compared to my previous screenshots).
I should my tests today with VS2017 are all on Windows 8.
Here's the above GDI+ screenshow shown with the non-GDI+ overlaid
in red boxes for comparison:
I'll follow up with results for my real world app that renders
lots of vectors in animation.
[..]
Widgets look good/the same, however oddly the text seems more aliased in the GDI+ build than the non-GDI build.
Perhaps AA is turned ON for lines, but turned OFF for text? Seems to be.
[..]
Widgets look good/the same, however oddly the text seems more aliased in the GDI+ build than the non-GDI build.
Perhaps AA is turned ON for lines, but turned OFF for text? Seems to be.
It's almost like the rendering of text has been reversed; in GDI+ the default font look worse/aliased,
but the larger fonts (under unittests "rendering text") looks better/anti-aliased.The large text in the non-GDI version was kinda ugly, had weird stair-stepping in the "a":
Oh, and I guess I didn't notice this before, but now zooming in, looks like GDI+ has a little trouble
with the 'missing pixel' problem; note the top/left corner of the green rectangle in the GDI+ screenshot above:
Now that I look closely at my unittest shots, seems they too have the missing pixel at the top/left, e.g. the "drawing lines":
Also, the "square" in the above has some tell-tale pixels showing at all 4 corners, and some aliasing where perhaps there shouldn't be? It's also more than one pixel wide and gray instead of black. I think the square is drawn with a series of fl_line() calls, whereas
the other segments that look OK are drawn with fl_xyline().. I think.
On 3 Feb 2021, at 13:29, Manolo wrote:Branch GDI+ now draws all but horizontal and vertical lines in antialiased form. That's an interesting improvement over GDI.Gave this a try with mingw on Win10, built (via cmake) for 32 and 64 bit. Both compiled fine and seem to run OK. Haven’t tried Vs yet though. (Note: This was checked out prior to Manolo’s commits to address the VS2019 issues, though that does not seem to affect mingw builds anyway.) Observations: - As Albrecht noted, the rotated text looks disappointing. It doesn’t seem to be well AA’d at all, and just looks a bit messy.
Can confirm on rotated text:
See my previous comments; I think AA text may be off for some cases and on for others. Not sure why or how.
Here's a different font and set to a larger size, making it easy to see the horiz text is AA, but the rotated is not:
In fact, *all* text rendering looks a bit fuzzy, so it must be being anti-aliased in a different fashion from the Windows default.
- The line AA looks (mostly) pretty good, I liked that.
Question: Can we do a compromise that uses our existing text rendering scheme (which I think looks consistent with other Windows apps and generally looks pretty decent) but uses the AA GDI+ stuff for other rendering?
Many thanks to Greg, Albrecht and Ian for all your testing.
Please pull from the git repository, to a01e74e or after. That should fix most of the issues reported.
@Albrecht: your patch is included, and VS now builds everything OK.
@Greg:
- The missing pixel at rectangle top-left should be fixed.
- As you have reported, antialiasing was missing for rotated text. That's now fixed.
- A more intensive text antialiasing option is now used. All font sizes should now
be antialiased. That's the same output I see when looking at system-generated text
under Windows 10. Under XP, system-generated text seems less antialiased.
I don't know the situation with Win8.
Hmm, I think it's better than it was; just rotating without
changing the font or size
looks much better now than it did (non-GDI left, GDI+ right):
..but I'm still seeing full aliasing on most of the rotated
text when I increase the size (with 09202a32b3c6f)..
Left: GDI+ with font 0/size 64/angle 34, Right:
linux with same settings:
![]()
Perhaps it's just how MS renders some fonts though.
For instance, after I took the above MS GDI+ screenshot, I changed to font 14, it's a bit better with the AA:
Anyway, certainly better than it was! In the old GDI, when I rotated the text, it was not only jaggy,
but it also jittered around, and letters would get too close or too far from one another. With GDI+
it rotated "smoothly"..
- Yes, it's possible to add an API to turn antialiasing off. Let's first agree on the defaultbehaviour.
Yep, OK
Perhaps it's just how MS renders some fonts though.
For instance, after I took the above MS GDI+ screenshot, I changed to font 14, it's a bit better with the AA: