Jump to content
Sign in to follow this  
Guest _ak

GDI+ gauges, FPS, Virtual Cockpit and 2D Panel

Recommended Posts

Guest coal

HelloI'm finding a problem with GDI+ gauges when changing from Virtual Cockpit to 2D Panel.I've made a PFD and MFD using GDI+ vectorial graphics and strings and they work fine. When I change from 2D panel to VC everything goes well but when I go back to 2D panel again, the Frames Per Second comes down a lot, between 30 - 50%, and recovers to normal FPS for this panel after a while (30 seconds or more). If you push ALT key twice, FPS recovers to normal figures immediately.These two gauge are part of a multigauge, and in the main gauge.c file I include:#include #include "fs9gauges.h"#include "B_737.h"#include #include #include using namespace Gdiplus;#pragma comment(lib, "gdiplus.lib")#define ULONG_PTR DWORDbool init = false;GdiplusStartupInput gdiplusStartupInput;ULONG_PTR gdiplusToken;Then, in the first subgauge that it's loaded (PFD) I include:void FSAPI gaugecall_ADI(PGAUGEHDR pgauge, int service_id, UINT32 extra_data){if(!init){ GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); init = true;}switch(service_id){case PANEL_SERVICE_PRE_KILL: if(init_b737) { GdiplusShutdown(gdiplusToken_b737); init_b737 = false; }break;etc...Is there anything wrong in what I'm doing ?Thanks for your helpDaniel

Share this post


Link to post
Share on other sites

This happens because as soon as the gauge is drawn in the VC, FS keeps drawing it even when you come back to the 2D panel. Consequently, your gauge is drawn once in the panel and once in the VC, which explains why it is so slow.The solution consists in stopping drawing the gauge in VC mode when the 2D panel is visible.Eric

Share this post


Link to post
Share on other sites
Guest coal

Thanks a lot Eric. I supposed something like that was the reason, because problem disappears if I remove the gauge from VC.Now, how can gauges be stopped in VC and keep them running in 2D panels, if they are the same gauges?Thanks again,Daniel

Share this post


Link to post
Share on other sites

>Thanks a lot Eric. I supposed something like that was the>reason, because problem disappears if I remove the gauge from>VC.>>Now, how can gauges be stopped in VC and keep them running in>2D panels, if they are the same gauges?Sure, just pass along a marker as the "fifth parameter" in your panel.cfg entry, and then check like this:char* VT_params; // put this in your variable declarations! case PANEL_SERVICE_PRE_DRAW: { PELEMENT_STATIC_IMAGE pelement = (PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]->next_element[0]); if (pelement) { HDC hdc = pelement->hdc; PIXPOINT dim = pelement->image_data.final->dim; VT_params = pgauge->parameters; if (hdc) { Graphics graphics(hdc); if((is_panel_window_visible_ident( 0 ) == 1 && memcmp(VT_params,"VT VC",5) == 0) || (is_panel_window_visible_ident( 0 ) == 0 && memcmp(VT_params,"VT MAIN",7) == 0 )) { Color Black(0,0,0); graphics.Clear(Black); } else { drawing code here! }The logic is: if (main panel visible & gauge is "VT VC", don't draw!-OR-if (main panel not visible & gauge is "VT MAIN", don't draw!:)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest coal

Thank you Bill, you've been as kind as you always are.Daniel

Share this post


Link to post
Share on other sites

>Thank you Bill, you've been as kind as you always are.>DanielNo problem... I'm sure you know that you can change VT_params to any name you like, as you can VT MAIN and VT VC. This code snip comes from my VisionTech from Vision Microsystems, hence the VT prefix on the variable names... ;)I should also mention that the number following each panel.cfg flag corresponds to the total number of characters in the parameter string...e.g., "VT VC",5


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest coal

Sure, it worked the first time I tried, without a problem.Thanks again,Daniel

Share this post


Link to post
Share on other sites

>Sure, it worked the first time I tried, without a problem.Great!Of course, it gets a bit more complicated if you have three instances to control:mainVCpopupbut, it's doable... ;)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest coal

Let me then to take advantage of your kindness. What should be done? Is there any special trick?:-)Daniel

Share this post


Link to post
Share on other sites

>Let me then to take advantage of your kindness. What should>be done? Is there any special trick?:-)Every gauge and panel combination needs to be accounted for in the logic tree.For simplicity, let's simply use some replacements for those long code entries to examine the logic needed. Currently we have:if (mainpanel visible && VC) { do not draw } else { draw }if (mainpanel not visible && MAIN { do not draw } else { draw }Now, let's add a third option: a zoom window!if (mainpanel visible && (VC || ZOOM) { do not draw } else { draw }This will shut down the VC and ZOOM instances of the gauges when the main panel is visible.if ((mainpanel not visible && zoompanel not visible) && (MAIN || ZOOM) { do not draw } else { draw }This will shut down the MAIN and ZOOM instances of the gauges when both the main panel and the zoom panel are not visible.if ((mainpanel not visible && zoompanel visible) && (MAIN || VC) { do not draw }else { draw }This should shut down the MAIN and VC instances of the gauges when the main panel is not visible and the zoom panel is visible... ;)I think the logic is sound... I'll find out later when I go to test it! ;)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest coal

Thanks again Bill, and thanks to Eric as well.Daniel

Share this post


Link to post
Share on other sites
Guest _ak

I think better check for popup first, it will make shorter if/else chain :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...