Slow alpha blending with VSTGUI 3.6
-
- KVRist
- Topic Starter
- 54 posts since 13 Feb, 2014
Hello,
I have published my freeware VSTi few weeks ago and I have a problem with PNG knobs using alpha blending (I'm using VSTGUI 3.6). The knob drawing is very slow, and moving knobs continuously is cpu demanding. I've replaced the PNG by BMP, the problem has gone but there is no alpha blending. I have the same problem on Note Expression Synth sample from the SDK. Does anyone have met the same problem and managed to solve it?
Thanks,
I have published my freeware VSTi few weeks ago and I have a problem with PNG knobs using alpha blending (I'm using VSTGUI 3.6). The knob drawing is very slow, and moving knobs continuously is cpu demanding. I've replaced the PNG by BMP, the problem has gone but there is no alpha blending. I have the same problem on Note Expression Synth sample from the SDK. Does anyone have met the same problem and managed to solve it?
Thanks,
-
- KVRAF
- 6656 posts since 14 Nov, 2006 from Ankara, Turkey
If there is no scaling of images involved when drawing, please use GDI not GDI+. That will fix the performance issues
Bülent
Bülent
Works at KV331 Audio
SynthMaster voted #1 in MusicRadar's "Best Synth of 2019" poll
SynthMaster One voted #4 in MusicRadar's "Best Synth of 2019" poll
SynthMaster voted #1 in MusicRadar's "Best Synth of 2019" poll
SynthMaster One voted #4 in MusicRadar's "Best Synth of 2019" poll
-
- KVRist
- Topic Starter
- 54 posts since 13 Feb, 2014
Thanks for the tip I've tried to replace GDI+ by GDI by doing the following steps:
- start from the last VSTSDK revision and work on the again sample project
- set GDIPLUS=0
- set VSTGUI_USES_UTF8=0 to get rid of wchar / char issues since it sets UNICODE=0
- in vstcontrols.cpp, cast from void* to HBITMAP the CBitmap handle for the MENUITEMINFO hbmpItem (line 3168)
Now it compiles fine but it looks like the PNG/BMP are not displayed. Am I doing something wrong ?
I see you suggested another way to do this in that topic : http://www.kvraudio.com/forum/viewtopic ... w=previous . Should I do that way ?
Thanks,
Olivier.
- start from the last VSTSDK revision and work on the again sample project
- set GDIPLUS=0
- set VSTGUI_USES_UTF8=0 to get rid of wchar / char issues since it sets UNICODE=0
- in vstcontrols.cpp, cast from void* to HBITMAP the CBitmap handle for the MENUITEMINFO hbmpItem (line 3168)
Now it compiles fine but it looks like the PNG/BMP are not displayed. Am I doing something wrong ?
I see you suggested another way to do this in that topic : http://www.kvraudio.com/forum/viewtopic ... w=previous . Should I do that way ?
Thanks,
Olivier.
-
- KVRAF
- 6656 posts since 14 Nov, 2006 from Ankara, Turkey
Not that's not what I meant.
Just replace the code that draws images (so they draw with GDI when there is NO scaling involved)
Just replace the code that draws images (so they draw with GDI when there is NO scaling involved)
Works at KV331 Audio
SynthMaster voted #1 in MusicRadar's "Best Synth of 2019" poll
SynthMaster One voted #4 in MusicRadar's "Best Synth of 2019" poll
SynthMaster voted #1 in MusicRadar's "Best Synth of 2019" poll
SynthMaster One voted #4 in MusicRadar's "Best Synth of 2019" poll
-
- KVRist
- Topic Starter
- 54 posts since 13 Feb, 2014
Thanks! Works really good now
-
- KVRist
- Topic Starter
- 54 posts since 13 Feb, 2014
I just tested that change on Win XP and I can't manage to display a picture. It works perfectly on Win 7. Is there something tricky with HBITMAP / GDI drawing on Win XP ?
Thanks,
Thanks,
- KVRAF
- 7953 posts since 12 Feb, 2006 from Helsinki, Finland
No.. not really, unless you use GDI AlphaBlend(), which if I recall is basically just broken (as in MSDN example code doesn't work) on x64 Windows (at least XP and Vista, can't remember if I ever tested on Win7) at least for 32-bit software. On 32-bit XP everything should work though.roazhondsp wrote:I just tested that change on Win XP and I can't manage to display a picture. It works perfectly on Win 7. Is there something tricky with HBITMAP / GDI drawing on Win XP ?
-
- KVRist
- Topic Starter
- 54 posts since 13 Feb, 2014
Thanks for the info, I then found that something was wrong in my changes. I've tested my synth on XP, Vista, 7, 8 and it works fine for 32 and 64 bits OS versions On XP 64 the knobs are sometimes flickering while moving, but I was trying on a VM with SP2.
- KVRAF
- 7953 posts since 12 Feb, 2006 from Helsinki, Finland
Normally Windows will clear the window are to be repainted. Since there's no double buffering, this can lead to flickering. To avoid the automatic clears, either set the window class hbrBackground to NULL, or intercept WM_ERASEBKGND message and return non-zero (by default it goes to DefWindowProc that does the clear). This might or might not already be the case with VSTGUI, but it's easy to double check.roazhondsp wrote:Thanks for the info, I then found that something was wrong in my changes. I've tested my synth on XP, Vista, 7, 8 and it works fine for 32 and 64 bits OS versions On XP 64 the knobs are sometimes flickering while moving, but I was trying on a VM with SP2.
Then you might want to do the painting into a DIBSection (or something) and copy the whole repaint area to screen with a single BitBLT [obviously only an issue if you do multipass drawing, say copy the knob image on top of a separate background, or something], so you never have to clear the visible window. Otherwise the system could end up drawing the partially completed redraw and you would again get flickering.
-
- KVRist
- Topic Starter
- 54 posts since 13 Feb, 2014
Interesting inputs VSTGUI seems to have the settings to avoid automatic clears. But indeed having double buffering, drawing to back buffer and updating front buffer partially seems to be the best path.