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

C++ Bitmaps

Messages
57
Country
unitedstates
Hey guys,

I have written a gauge for FSX (in this case, the base of an altitude gauge), and I followed the same procedure I have for gauges in the past (that worked). Now, I am having an inexplicable access violation error loading the gauge from within FSX. I have tried using GAUGE_HEADER_FS700 and GAUGE_HEADER_FS1000 (using NULL in place of callbacks and serialization data in the latter), and both times, what happens is this:

When using FsPanelStudio to place the gauge, it recognizes that it is an FSX gauge, and reads the gauge table to identify that !altitude points to the altitude guage. As soon as I click on it, FsPanelStudio freezes, and if I select it from withing FSX, FSX crashed with an unhandled exception either in user32.dll or ntdll.dll. There are no compiler errors, except for an Intellisense "Expected a declaration" warning in the .rc file (which was not present in VS2010/VC++ 2010, but is in VS11). I have tried using a different bitmap, and I have tried compiling it with VS2010 as well (to no avail).

If anyone else has had this issue before, please let me know how you fixed it. I have read the FSX SDK samples several times, and read the Dragonfly Gauge Tutorial as a guide, and I have checked my code several times. I will publish that actual code later if neccesary, just wondering if there is something obvious I overlooked.

Thanks ahead of time,
 

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
I have found VS2008 to be a bit more stable for FSX stuff than the newer versions....
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
I will publish that actual code later if neccesary, just wondering if there is something obvious I overlooked.

Thanks ahead of time,

Would be great that you post all (or part if it is too big) of the code in the .rc file, the main .cpp (and) the one where macros FS700etc and MAKE_STATIC, etc are located.

Tom
 
Messages
57
Country
unitedstates
I have edited out certain sections, as the project is secret.


---------ers_FILE.rc-----------------------------
ALTITUDE_BACKGROUND BITMAP DISCARDABLE "res\\ALTITUDE_BACKGROUND.BMP"
------------------------------------------------


----------altitude.cpp----------------------------
char altitude_gauge_name[] = GAUGE_NAME;
extern PELEMENT_HEADER altitude_list;
extern MOUSERECT altitude_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W,altitude_gauge_name,&altitude_list,altitude_mouse_rect,0,0,0,0);

MAKE_STATIC(alt_back,ALTITUDE_BACKGROUND,NULL,NULL,IMAGE_USE_TRANSPARENCY | IMAGE_USE_ERASE,0,0,0)

PELEMENT_HEADER altitude_list = &alt_back.header;

MOUSE_BEGIN(altitude_mouse_rect,NULL,0,0)
MOUSE_END

#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W
--------------------------------------------------------------


-------------ers_FILE.cpp---------------------------------
#include "inc\\gauges.h"
#include "ers_FILE.h"

//Altitude Gauge
#define GAUGE_NAME "altitude"
#define GAUGEHDR_VAR_NAME gaugehdr_altitude
#define GAUGE_W 100

#include "gauges\altitude.cpp"




GAUGE_TABLE_BEGIN()
GAUGE_TABLE_ENTRY(&gaugehdr_altitude)
GAUGE_TABLE_END()
--------------------------------------------------------


--------------------------ers_FILE.h----------------------

#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_BUILD 0

// magic to get the preprocessor to do what we want
#define lita(arg) #arg
#define xlita(arg) lita(arg)
#define cat3(w,x,z) w##.##x##.##z##\000
#define xcat3(w,x,z) cat3(w,x,z)
#define VERSION_STRING xlita(xcat3(VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD))

#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 0x0001
#endif

#define ALTITUDE_BACKGROUND 0x1000
-------------------------------------------------------------
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
I have edited out certain sections, as the project is secret.


---------ers_FILE.rc-----------------------------
ALTITUDE_BACKGROUND BITMAP DISCARDABLE "res\\ALTITUDE_BACKGROUND.BMP"
------------------------------------------------

Did you include

#include "ers_FILE.h"

in the .rc file? Otherwise ALTITUDE_BACKGROUND bitmap's physical location wouldn't be associated with 0x1000 address.

Appart from that, I can't find anything wrong with your code.


Tom
 
Messages
57
Country
unitedstates
Yes, I did include the header. You just confirmed my fears my friend. Either VS11 is compiling wrong, or my FSX is screwed up.
 

mgh

Messages
1,413
Country
unitedkingdom
A very remote possibility, but has your new bitmap the same nunber of bits/pixel as previous ones that were OK?
 
Messages
57
Country
unitedstates
Here's the weird part - it worked on one of my other dev's computers. Just not mine; I am unsure of the reason, but it is definitively something on my side (the other dev did indeed see the bitmap).
 

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
overall though GDI+ is a better way to go when it comes to C++ gauges....
 
Messages
240
Country
switzerland
Not always.

Always.

If you know how to use it *properly*, which means avoiding the functions that looks easy to use (which are usually slower) and use the more low-level functions that are harder and looks on paper more "complex", but are usually faster, and also if you skip GDI+ for some things that can be done with regular GDI and are way faster with it (like clearing the screen).

There's nothing that can't be done with GDI+, including analog gauges with a custom bitmap background and vector needles drawn with GDI+ on top of them.
 
Messages
2,077
Country
us-ohio
Oh, I agree you can do it "all" with GDI+... I disagree that it's always the best choice.
 
Messages
240
Country
switzerland
Oh, I agree you can do it "all" with GDI+... I disagree that it's always the best choice.

It's always the best choice, provided you know exactly how GDI+ works (have you profiled all of the API, including the low-level functions ? ) and what functions should be used in any situation and what functions should never be used.

So yes, I agree that, for someone without all the above information, it might not always be the best choice...
 
Top