VST repaint issue when WIVI is loaded

Hi Jules,

There seem to be a strange interaction between JUCE based plugins and WIVI Trial ( http://www.wallanderinstruments.com/?mode=downloads&lang=en ), on windows. For some reason, if wivi and a juce plugin are loaded in a host (vsthost for example), the juce plugin will have repaint problems when opening its gui (especially the first time the gui is opened). It happens on juce 1.49, and also on the JuceDemoPlugin of the very latest git head. The repaint issue is very odd, some text labels are drawn with missing letters, some components are missing while others are drawn… I wonder what may be going on, do you have an idea ?

Here is the story… WIVI is changing the FPU precision flag (I assume it is a consequence of using direct3D , see http://blogs.msdn.com/tmiller/archive/2004/06/01/145596.aspx ). When my plugin gets instanciated, the x87 FPU precision has been set to 24 bits instead of the usual 53 bits, and that breaks badly all math functions of the visual c++ runtime ( log, exp etc… ) which return very wrong results. And my plugin starts to play out of tune. And the juce GUI starts do draw stuff very strangely with missing letters, non repainted areas etc.

#if JUCE_WIN32
_controlfp(_PC_53, _MCW_PC);

to the initialiseJuce_NonGUI() fixes that issue.

Wow… Why are they doing this ???

Still good to know. Thanks for the tip.

Ok that default’s Direct3D behavior in fact.
Quite annoying in the audio business

Sure !
I also recall having run into issues with the FPU rounding mode being messed up by some ASIO driver (I’m nore sure which soundcard it was – it was a customer issue that I could not reproduce myself). Changing the rounding mode from its default value (round to nearest) breaks some single precision functions of the c++ runtime (powf etc) , so adding a _controlfp(_RC_NEAR, _MCW_RC) might be useful also.

If you search for “fpreset”, you’ll see that I had to use that around the place to avoid similar problems - does fpreset() work for you instead of the _controlfp call? If so, I think the best place to put it would be in the VST code just before initialiseJuce_GUI, rather than in the juce core code.