On 25.01.2018 17:18 Anthony Nemoff wrote:
>
> We experienced an OpenGL display bug when running FLTK applications that
> use Fl_Gl_Windows (our own app, but also FLTK examples like glpuzzle,
> gl_overlay, fractals, etc.) on a notebook that has both an Intel
> integrated GPU and an NVidia GPU:
> - correct display when running with the integrated GPU: everything looks
> fine (but obviously less performant);
> - incorrect display when running with the NVidia GPU (Right-click > Run
> with graphics processor > High-performance NVIDIA processor): the OpenGL
> viewport looks pale as if it had a gamma correction.
>
> We tried combining different modes when calling Fl_Gl_Window::mode, but
> it didn't fix the issue when running on NVIDIA.
> After digging into FLTK code and debugging we found out that the chosen
> pixel format is not the same, especially the color bit depth is smaller
> when running on the NVidia GPU (among other minor differences).
Can you post your exact findings? I'd be interested to know what's going
on. It'd be interesting to see the resultant pixel formats you get with
both GPU's.
Please see also below for a patch that is instrumented with debug output.
> We worked around this bug by forcing the pixel format to a hand crafted
> one in fl_create_gl_context instead of using the one chosen
> by Fl_Gl_Choice::find.
> But we're looking into a cleaner solution.
> We are using version 1.3.4 rev 11742.
Thanks for the report and the debugging. Selecting the "wrong" pixel
format seems to be a known issue (STR #3119), although this STR is a
slightly different case, i.e. it's a supposedly "wrong" pixel format but
with another background.
http://www.fltk.org/str.php?L3119
> Any ideas?
Please take a look at the above mentioned STR. I prepared a patch, but
this patch has not yet been integrated into the FLTK lib. But maybe it
can help you or you can provide additional insights to select a sensible
algorithm in FLTK. Please try the patch - it can be applied cleanly to
FLTK svn current and likely to the latest snapshot as well, but you may
need to tweak it if you want to apply it to FLTK 1.3.x.
http://www.fltk.org/strfiles/3119/support_composition_v2.diff
The patch contains some debug output statements that can be helpful. As
I said, it's related to another issue, but anyway, this is what I get on
my system when I run test/glpuzzle:
$ bin/examples/glpuzzle.exe
pfd #5 supports composition: yes
... & PFD_GENERIC_FORMAT: accelerated
... Overlay Planes : 0
... Color & Depth : 32, 24
pfd #7 supports composition: yes
... & PFD_GENERIC_FORMAT: accelerated
... Overlay Planes : 0
... Color & Depth : 32, 16
current pixelformat : 5
pfd #9 supports composition: yes
... & PFD_GENERIC_FORMAT: accelerated
... Overlay Planes : 0
... Color & Depth : 32, 16
current pixelformat : 5
pfd #10 supports composition: yes
... & PFD_GENERIC_FORMAT: accelerated
... Overlay Planes : 0
... Color & Depth : 32, 24
current pixelformat : 5
pfd #38 supports composition: yes
... & PFD_GENERIC_FORMAT: generic
... Overlay Planes : 0
... Color & Depth : 32, 32
current pixelformat : 10
pfd #39 supports composition: yes
... & PFD_GENERIC_FORMAT: generic
... Overlay Planes : 0
... Color & Depth : 32, 16
current pixelformat : 10
pfd #42 supports composition: yes
... & PFD_GENERIC_FORMAT: generic
... Overlay Planes : 0
... Color & Depth : 32, 32
current pixelformat : 10
pfd #43 supports composition: yes
... & PFD_GENERIC_FORMAT: generic
... Overlay Planes : 0
... Color & Depth : 32, 16
current pixelformat : 10
PFD_SUPPORT_COMPOSITION = 0x8000
Chosen pixel format is 10
Pixel format supports composition: yes
You may want to add other tests and output statements so you can see
what's different if you run it with different GPU's.
I can't test this since I don't have different GPU's and, BTW, I believe
the algorithm can fail on a particular GPU no matter if you have one or
two, so I guess it would always fail for you if you didn't have the
Intel GPU (or switched it off by hardware/BIOS setup), but this is only
a guess and may be wrong.
I'd appreciate if you post your results here. Maybe we can find a better
algorithm that selects the "right" pixel format for you. However, I
believe that the algorithm is very fragile because the order of pixel
formats in Windows' enumeration and the selection order based on
"assumed priority" both play a role in the final decision. It's hard or
even impossible to predict the outcome...
If this all doesn't work we can try to provide a function to let the
user set a pixel format or give a list of pixel format bits ordered by
user priority, but this would IMHO be a little too low level for most
users. But if it helps...
Currently I don't have another idea how to solve the issue in FLTK. Any
hints and suggestions are welcome.