Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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

  • 2 weeks later...

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

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

  • Moderator

>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

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

  • Moderator

>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

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

  • Moderator

>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

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

  • Moderator

>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

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

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

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.