Yes, Fl_Window::make_current() seems to work for me too.

Anyway, I have written much faster fl_read_image() for windows based on
GetDIBits() function (original one is bloody slow as it reads data on
per-pixel basis)  so I will submit that as an STR - but it should be
revised by somebody more familiar with win32 GDI (works for me thought)...

Thank you,
R.



imacarthur wrote:
> 
> On 25 Jun 2010, at 18:01, Roman Kantor wrote:
> 
>> Hi, I have encountered problem that fl_create_offscreen() fails on
>> certain platforms (win 7) under certain circumstances, eg when called
>> from menu. This problem appears only on some platforms - like win 7 (on
>> win XP it seems to work fine).
>>
>> Under further investigation it looks like it is caused by the fact that
>> fl_gc is NULL (probably fl_gc is reset to 0 after menu window is closed
>> - maybe the callback is called AFTER the menu window destructuion?) at
>> that stage and CreateCompatibleBitmap() function (within
>> fl_create_offscreen()) does not have a valid DC reference. This means
>> that it is safe to call fl_create_ofscreen() only within draw() methods
>> when fl_gc is valid.
>>
>> I have resolved (made work-around) the problem by postponing  the calls
>> to offscreen functions during redraw but in general I believe that it
>> should be possible to create/manipulate offscreens at any time.
>>
>> Any thoughts from Win32 API gurus?
> 
> I'm not a win32 API guru by any stretch, but I have observed the same
> (or very similar) effect on WinVista in the past, with code that works
> OK on Linux and OSX (and I *think* WinXP).
> 
> What I did was add a make_current() call, based on the apps main window,
> just before creating the offscreen for the first time. (I think I did
> this for all platforms, not just #ifdef WIN32, and it seemed to be safe
> enough...)
> 
> That seemed to be god enough to get things working robustly.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to