• 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?

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
Can anyone tell me how to get around this draw flag and create my own "Device Independent Bitmap" within the FSX panel system? Or better yet does someone know how to draw directly to textures in FSX? The reason i ask is i am finding the above draw flag to be really frame intensive....
 
It's the only way... and it is not frame intensive (create a simple gauge that does zero GDI/GDI+ rendering with that flag active and you'll see). If it is impacting your performance... review how you're doing things.
 
I did....having just one takes at least 10 frames away. Removed the dibsection flag and frames sky rocketed. But then nothing could be drawn. And I know there is another way.....but it requires some DirectX hacking. I have a basic knowledge of DX now but not the hacking part. Thats why i asked here.
 
Ok... I don't lose 10 frames for having a simple blank DIBSECTION gauge. Something's not making sense.

Hacking is not a good idea... simple reason: You've now stepped outside the 'sandbox' and the rules no longer apply. Which means the protection the rules offer no longer apply either.

If I can get 50+ FPS running multiple GDI+ gauges (10+) in a VC... then I have to say you've got something else impacting your performance... not the DIBSECTION.
 
Well i am running them at rather high resolution due to the bitmaps involved....1024x1024. But the GDI+ part is NOT affecting it and i know that for a fact because the DrawImage functions are only executing when they receive the correct key events. I put them inside a initialization routine which runs only once and gets reset only per click.
 
Even if your callback is not called at every frame, that doesn't mean FSX itself is copying the DIBSECTION at each frame on its own.

How many 1024x1024 bitmaps you have ? I might just need to lower your resolution, perhaps not *all* gauges need to be at the same resolution.

If you are making a VC-only airplane (or a gauge that is used only in VC) it might be faster to draw everything as a single gauge, and assign different parts to their correct instruments locations, by playing with UV coordinates in the model for the $ textures.
 
I have 10 maps that im working with. The reason being is I can only work with the UVs that have already been done in the model. Not being a modeller, i cant change them and the modellers have made it clear that they will not be changed as will be a couple months of work to redo and we dont have that kind of time.

As far as i understand the MAKE_STATIC macros are being called at 18Hz though? Just to rule out the number of gauges as the cause of the loss of frames, i took out 9 of them out of both the dll and the panel cfg with no change in frames. It sat steady at 20 or 15 depending on the area i was flying in. Took all the gauges out and it shot up to over 30.

I would reduce the resolution but then the appearance comes out looking really horrible.

All in all....I narrowed it down to the dibsection flag because when i removed it i got my frames back. So i need an alternate solution to that flag.
 
Last edited:
the modellers have made it clear that they will not be changed as will be a couple months of work to redo and we dont have that kind of time.

I question the ability of a "modeler" that would need 2 months of work to change UV coordinates for a dozen or so of polygons...

Using ten 1024x1024 bitmaps is probably overkill, and I don't think *every* gauge needs that resolution and if they all do, a redesign of the panel is in order.

The issue is, modeling a VC, and adding the gauges when the modeling is considered to be final, as they were an afterthought, it's a sure recipe for disaster. The design of a panel should START by planning how you are going to code the gauges, and the VC modeling should be *driven* by that, not the opposite.
 
Its not so much a gauge as it is a lighting system. It covers the whole pit and it is rheostat controlled. And its not a dozen polys.....its around 150 000 thousand. Its a steam pit....but in order to get the lighting to work properly for each control requires some blending of several bitmaps (i actually have 3 per gauge. 3 rheostats. So im blending several bitmaps together to make the final image on the make_static bitmap). If i was doing some glass gauges i would make things around 512 or even 256 if i had to. But in order to light up the pit properly and to have those nice clear textures worthy of this payware project, i need 1024 minimum.

Now once again, i have traced the performance drop to the dibsection flag. I would like to dump the FS panel system entirely and draw directly to surface with directX but it seems that pretty much no one here knows how to do that and those that i have met who do know how are not willing to tell me and i cant exactly blame them cuz they work for other companies as well :) . So i just need at minimum, a more efficient way than the default dibsection flag. Even if there is some way i can execute the make_static macro per click instead of per tick I will be happy. However with GDI/GDI+ no longer being hardware accelerated i would like some guidance in working with these undocumented things to get better performance along with awesome visuals :) .
 
Last edited:
Just for fun, a pic of what im working on.

file.php
 
Its not so much a gauge as it is a lighting system. It covers the whole pit and it is rheostat controlled. And its not a dozen polys.....its around 150 000 thousand.

How many polygons the whole model has is not an issue, you don't need to modify UV coordinates on all polygons, ONLY the few that have the $ texture, my suggestion was to use a single (or two) gauges, and map various sections of it using UV maps over the polygons with a $ texture that creates the canvas that gauges uses.

In order to get the lighting to work properly for each control requires some blending of several bitmaps (i actually have 3 per gauge. 3 rheostats. So im blending several bitmaps together to make the final image on the make_static bitmap).

As I thought, you are probably locked yourself into a design, that might have been better done if you worked on programming before the 3d modeling started.

You might used a different approach entirely, for example using visibility-triggered 3d sections of the gauges and FSX shaders to control blending, perhaps using a separate 3d object with a couple of generic "light" and a shader materials that creates the final result, triggered by L: vars controlled by C++ code. That's just an rough idea, but of course this would required some heavy remodeling.

Don't assume the DirectX approach woud be automatically faster: at some point there WILL be a copy operation from RAM to VRAM at each frame, and this is what is expensive, so you might basically end up replicating yourself in code what the CREATE_DIBSECTION flag does.
 
Well all i really need in this case is to be able to copy from RAM to VRAM ONCE when i click and have that bitmap remain in VRAM. Since its not animated but static i only need it to render once instead of every frame. Thats what im really needing.
 
But as far as the DirectX approach goes....isnt it possible using DX to work inside the video card directly instead of in the system memory and that way make things more efficient?
 
Maybe I'm pissing up a rope here Jon, but how about limiting this final function call to only occur when you've "mouse clicked" on the lighting knob (i.e., changed it's value):

Code:
SET_OFF_SCREEN (pelement);

Alternatively, only allow the rendering loop in the case PANEL_SERVICE_PRE_DRAW: section to execute after a mouse event?

In other words, run it once on panel load, then only re-draw when something has changed?

Or is too simple? :cool:
 
lol theres an idea. Although....It would mean i have to split my lighting gauge from the current systems that im dealing with since im working in the GAUGE_HEADER_FS1000 system so everything is under a single function....But worth a try. Ill come back on that. But in the mean time, anyone else who has any ideas....please post here. That way we can all learn something....
 
In general, it's very difficult giving ideas without looking at your entire source code.

Years ago, I made gauges that handled updated the background bitmaps only once per second, instead of every frame, with the needles on top of them updating every frame. The only side effect, is that you had a lag of up 1 second in response time when turning off lights.
 
Thats why i dont update on a time or per so many frames basis but rather on a event basis. As far as other drawing goes, like HUDs/other glass gauges, there i just leave things to run at 18Hz and i keep anything that is not needed out of the way. Although...being able to change the rate would be nice. Any chance you can share how you did it and also how to combine legacy GDI with GDI+ in something like the ESP GDI+ example? Im a tad leary of trying to combine 2 systems since im not that good with classes yet....
 
Last edited:
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
 
Last edited:
Maybe I'm pissing up a rope here Jon, but how about limiting this final function call to only occur when you've "mouse clicked" on the lighting knob (i.e., changed it's value):

Code:
SET_OFF_SCREEN (pelement);

Alternatively, only allow the rendering loop in the case PANEL_SERVICE_PRE_DRAW: section to execute after a mouse event?

In other words, run it once on panel load, then only re-draw when something has changed?

Or is too simple? :cool:

Ok Bill you did it :D. I can now light the pit in a way that would bring the sim to its knees if i let the sim render it.....back to 30fps LOCKED. Naturally if i scroll through the knobs too quickly the sim freezes for a second but thats no biggie....after all users are not supposed to play with the lighting knobs all the time on the fly.
 
I'm happy to hear that my KISS suggestion works out well...

This only goes to show that sometimes even a blind squirrel can find an acorn! :rotfl:
 
Back
Top