• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

IMAGE_CREATE_DIBSECTION. Other options?

well there are some things i wont mess with without guidance....but thats what FSDeveloper is for right?
 
The ESP GDI+ example is taken almost entirely from the source code of the F/A-18 that I made for Microsoft, they changed it a bit, but the main concepts are there, and the comments are still mine...

Combining GDI and GDI+ is really easy, since you have an hDC anyway, you just use it with GDI.

Not that I use GDI much but, is very effective for a single purpose: clearing the screen. The GDI+ clear screen command is VERY slow, when I profiled the F-18 code for optimization (a profiler is probably the most important tool to a gauge developer that *cares* about performances), the most expensive operation was clearing the screen, it took more time than the whole gauge drawing! I fixed it by simply "clearing" the screen with GDI instead of GDI+, by BitBlitting a black square.

Of course, clearing the screen applies to glass gauges only, with analog gauges it's a bit more complex, because instead of clearing, you need to restore your background, see this post of mine in a previous discussion here:

http://www.fsdeveloper.com/forum/showthread.php?t=22024
Umberto,
I read your post with great interest as it appeared to be an easy way of gaining performance and FPS. I made a quick test and just removed all Clear invocations from my code. Of course, the displays look messy, but I didn't see any improvement in the FPS (measured by FS and by Fraps).
To be honest, I didn't make a serious profiling to determine the time spent for each function call, but my "basic" profiling on the FPS didn't show any improvement.
Did I do something wrong or should we say that the performance gain is not visible?

Thanks,
Eric
 
If you have just 1 Clear function i cant say there is a noticable loss of frames. Not on todays hardware anyway. But if you start clearing for every gauge.....I perfer just doing black rectangles for non transparent gauges and since i have only 1 HUD/Gunsight in my projects i can get away with it.
 
Did I do something wrong or should we say that the performance gain is not visible?

It's really all relative: it depends what the rest of your code is doing.

Please, don't take it in the wrong way but, if your code is already slow, removing a single slow call like GDI+ Clear() might not be visible enough on the fps counter.

But if your GDI+ code is very fast, chances are the Clear() instruction might be the slowest part of the whole gauge code, and that will show on the fps counter.

There are lot of things that looks easy and simple in GDI+, but are very slow, and other that looks cumbersome and complex, but are faster, you really need to profile to test this.

For example, if you need to draw a straight line, it's much faster drawing a very short rectangle instead.
 
If you have just 1 Clear function i cant say there is a noticable loss of frames.

That's understandable, it would be difficult to see any difference with just 1 gauge. And, it also depends how big the canvas area is.

My testing reference was the F-18 gauges, there were 4 in 440x440 in size, and 3 smaller ones, so there were 7 Clear() instructions at each frame, and the fps increase was noticeable, after replacing them with a GDI FillRect in black.
 
Back
Top