• 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++] no graphics shown in the 2D cockpit

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hello again,

once again I made an attempt to understand programming c gauges. Once again I am stuck.

First, I tried to compile the SDK samples. Didn't work. Then I tried to compile the samples provided with Dais programming tutorial. Didn't work. Then I tried to set up an easy gauge with a static graphic, using parts of both, SDK and Dais tutorial. Finally Visual Studio was able to compile it! But after integrating it into the 2D panel, it just don't show up.

Here is what I did.
main.cpp:
Code:
[...]
#define GAUGE_NAME "annunciator"
#define GAUGEHDR_VAR_NAME gaugehdr_annunciator
#define GAUGE_W 100
#include "subgauges/annunciator.cpp"

GAUGE_TABLE_BEGIN()
	GAUGE_TABLE_ENTRY(&gaugehdr_annunciator)
GAUGE_TABLE_END()

annunciator.cpp:
Code:
//Gauge header
char annunciator_gauge_name[] = GAUGE_NAME;
extern PELEMENT_HEADER			annunciator_list;
extern MOUSERECT				annunciator_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, annunciator_gauge_name, &annunciator_list,annunciator_mouse_rect,0,0,0,0 );

/////////////////////////////////////////////////////////////////////////////
MAKE_ICON(		test_icon,
				BMP_TEST,
				NULL,
				NULL,
				IMAGE_USE_ERASE || IMAGE_USE_TRANSPARENCY,
				0,
				10,10,
				MODULE_VAR_NONE, 
				NULL,
				ICON_SWITCH_TYPE_SET_CUR_ICON,
				1,
				0,
				0 )

PELEMENT_HEADER		pTstLst[] =
{
	&test_icon.header,
	NULL
};

MAKE_STATIC(	
	annunciator_bg,
	BMP_TEST,
	pTstLst,
	NULL,
	IMAGE_USE_TRANSPARENCY,
	0,
	0, 0 )

PELEMENT_HEADER annunciator_list = &annunciator_bg.header;

MOUSE_BEGIN(annunciator_mouse_rect,0,0,0)
MOUSE_END

#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W

All graphics are correctly integrated in the resource file, filename and ID are correctly set.
main.h:
Code:
[...]
#define BMP_ANNUNCIATOR_BG				0x1000
#define BMP_ANNUNCIATOR_L_OIL			0x1100
#define BMP_TEST						0x1200
[...]

After several attempts I integrated a second graphic (MAKE_ICON) and linked it to a graphic copied from the MS SDK. One assumption was, that my graphics are stored in a wrong bmp format. Bad shot.

Any ideas what I made wrong?
Regards from Downunder
Vitus
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Your link to the MAKE_ICON callback is incorrect. It should be a pointer to the next item on the list:
Code:
MAKE_STATIC(	
	annunciator_bg,
	BMP_TEST,
	[COLOR="Red"][B]&[/B][/COLOR]pTstLst,
	NULL,
	IMAGE_USE_TRANSPARENCY,
	0,
	0, 0 )
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hi Bill,

To be honest, I don't understand the logic. The pTstLst has the type PELEMENT_HEADER - not ELEMENT_HEADER. So it should already be a pointer?! If I use &pTstLst that will be a pointer to a pointer to a element header!?

Anyway, I changed the code as you said, no change. Not even the background image is visible. :(

Any further ideas?
Best regards
Vitus
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Yes, it is a pointer to a pointer... I don't ask why, all I know is that it works... ;)

BTW, if you write to me at n4gix@comcast.net I'll send you the SDK Sample gauge set up as a VS solution, ready to compile.

Here is a similar example (Master Warning) gauge from one of my projects...

Code:
FLOAT64 FSAPI MW_callback3( PELEMENT_ICON pelement)
{
	FLOAT64 rtn=pelement->source_var.var_value.n;
	PUINT32 rotartest = (PUINT32)rotartestREAD1.var_ptr;
	PUINT32 dim = (PUINT32)dimREAD51.var_ptr;
	PUINT32 cabwarnr = (PUINT32)cabwarnrREAD64.var_ptr;
	LIGHT_IMAGE(pelement) ; 
	rtn= (float)diml ; 
	if ( power == 1  
			&&  ( fmod(MWtick,16) ) < 8  
			&&  ( MWwarn == 1  ||  testred == 1 ) ) 
		{ SHOW_IMAGE(pelement) ; } 
	else { HIDE_IMAGE(pelement) ; } 
	return rtn;
}

MAKE_ICON(
           MW_Icon3,
           MW_Rec4,
           NULL,
           NULL,
           IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,
           0,4,8,
	   MODULE_VAR_NONE,
           MW_callback3,
           ICON_SWITCH_TYPE_STEP_TO,2,0,0
          )

PELEMENT_HEADER 
           MW_ElementList2[] = 
           {
             &MW_Icon3.header,
             NULL
           };

MAKE_STATIC(
            MW_Static1,
            MW_Rec0,
            &MW_ElementList2,
            NULL,
            IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,
            0,0,0
           )

PELEMENT_HEADER escj1masterwarn_list = &MW_Static1.header;
 
Last edited:

ddawson

Resource contributor
Messages
862
Country
canada
Hello again,
main.cpp:
Code:
[...]
annunciator.cpp:
[CODE]//Gauge header
char annunciator_gauge_name[] = GAUGE_NAME;
extern PELEMENT_HEADER			annunciator_list;
extern MOUSERECT				annunciator_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, annunciator_gauge_name, &annunciator_list,annunciator_mouse_rect,0,0,0,0 );

/////////////////////////////////////////////////////////////////////////////
MAKE_ICON(		test_icon,
				BMP_TEST,
				NULL,
				NULL,
				IMAGE_USE_ERASE || IMAGE_USE_TRANSPARENCY,
				0,
				10,10,
				MODULE_VAR_NONE, 
				NULL,
				ICON_SWITCH_TYPE_SET_CUR_ICON,
				1,
				0,
				0 )

PELEMENT_HEADER		pTstLst[] =
{
	&test_icon.header,
	NULL
};

MAKE_STATIC(	
	annunciator_bg,
	BMP_TEST,
	pTstLst,
	NULL,
	IMAGE_USE_TRANSPARENCY,
	0,
	0, 0 )

PELEMENT_HEADER annunciator_list = &annunciator_bg.header;

MOUSE_BEGIN(annunciator_mouse_rect,0,0,0)
MOUSE_END

#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W

All graphics are correctly integrated in the resource file, filename and ID are correctly set.
main.h:
Code:
[...]
#define BMP_ANNUNCIATOR_BG				0x1000
#define BMP_ANNUNCIATOR_L_OIL			0x1100
#define BMP_TEST						0x1200
[...]

You're using the same bitmap for both the icon and the static (BMP_TEST)
Also, you have not assigned a variable or a callback to determine a value to drive the icon - MODULE_VAR_NONE will always return zero.

Doug
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hi Doug,

yipyip! You are right. But as long as I cannot even see a background image, I don't worry about callback and functionality ;)
Also with BMP_TEST you are right. As I stated before, after noticing that my own graphics doesn't show up I implemented some original graphics from the SDK for testing. Not even these images want to get visible...

In the meanwhile, Bill sent me his VS solution and I will check this evening whether or not its working on my computer.

regards
Vitus
 
Messages
516
Bill,
I think you're wrong about that pointer. I never have to use the & in that place in my gauges.

I've compiled and tested the original poster's code and it works fine as is. I can see the static and icon on my panel, (though I had to change the BMP name obviously to one in my project.)

Vitus,
I notice that in your exert from main.c, you're not including main.h. (But then it wouldn't compile so I'm assuming you've just not pasted it here.)

If you PM me, I will send you a working copy of your gauge as a VisualStudio 2008 project.

Si
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hi there,

I received Simons solution, compiled it, embedded it, tested it and finally, it works. So thanks very much Bill and Simon for your help!

Now I will have to find out what I made wrong. As Simons code seems to be exactly the same, I think I will have to check the resources. Is there something I have to pay attention about? I am a little bit confused...

Regards from Downunder
Vitus
 
Messages
516
Make sure you add the bitmaps to the .rc file as well as the project's main.h. Since the rc file is not editable in VC2008 Express (and I can't remember if I even included it in your solution's file list) this can easily be forgotten about, and then nothing will work.

The only change I made to your code (I think) was to remove the double || from the bitmap display options. It would have worked, but is syntactically wrong, as it's the bitwise OR you want, not the logical OR. So your code was effectively saying
IMAGE_USE_ERASE | 0 | IMAGE_USE_TRANSPARENCY, which works but is unnecessary. Just combine bit flags with a single |.

Don't worry. It wook me long enough to get through the stage you're at. Once it's working progress is a lot smoother. So I'm more than happy to help somebody else over that first hurdle!!

Si
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Make sure you add the bitmaps to the .rc file as well as the project's main.h. Since the rc file is not editable in VC2008 Express (and I can't remember if I even included it in your solution's file list) this can easily be forgotten about, and then nothing will work.

I don't use VC2008, but in my MSVC++ .NET 2003 version, if I rightclick on the .rc file in the list I can manually select how the RC file opens. I choose "Source Code (Text) Editor"

The only change I made to your code (I think) was to remove the double || from the bitmap display options. It would have worked, but is syntactically wrong, as it's the bitwise OR you want, not the logical OR. So your code was effectively saying
IMAGE_USE_ERASE | 0 | IMAGE_USE_TRANSPARENCY, which works but is unnecessary. Just combine bit flags with a single |.

Actually, they won't work correctly with "||"...

I spent several days trying to discover why a few gauges in my latest multi-gauge cluster wouldn't "erase" during the callback, only to discover that during a search/replace operation I used to correct another problem, I had accidentally replaced the single, bit-wise or operator with the logical or operator in all the image flags! :eek:

After fixing up the boo-boo's, the problem gauges resumed normal operations... :D
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hello again,

I played around with the code yesterday and it works fine. But there is something thats really annoying (and maybe the reason for my trouble) - when I add a new resource to the project I do the following:
- double click on the resource.rc file to open it. The resource view appears.
- Right click in the resource view -> add resource. The "add resource" dialog appears.
- Click on Bitmap, then "import". The Import Dialog appears for selecting the file.
- choose the file, then OK.

After this, I find a new entry named "IDB_BITMAP1" in the section "BITMAP". I change the name to something that makes sense, click on "save all" and close the resource view.
Now its getting weird. A new entry is made in the "Solution Explorer" under the section "resource files", thats fine for three, four bitmaps, but if your project grows, its getting more and more confusing.
The second thing is, that VS adds a new file called resourc.h under the "header files" section in which the resources are listed. I don't want all this stuff...

There must be a different approach to add resource files, right? Please share your wisdom with me! :rolleyes:

Regards
Vitus
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Truthfully? As I said, I use the built-in TEXT resource editor...

Alternatively, you can simply use notepad.exe to create/edit your xxx.rc file. After all is said and done, that's all it is!

The header information for every xxx.rc file is pretty much a boilerplate template that you can load from a template.rc file and edit as needed (highlighted in red)...

For each new bitmap listed, add a corresponding entry in your xxx.h file as well, making sure that the resource names match, and that the resource id number is both valid and licit.

For example:

Code:
[COLOR="Red"]#include"escj1_hobbs.h"[/COLOR]
VS_VERSION_INFO VERSIONINFO
 FILEVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
 PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
 FILEFLAGSMASK 0x3fL
 FILEFLAGS 0x0L
 FILEOS 0x10004L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "CompanyName", "[COLOR="red"]Eaglesoft Development Group[/COLOR]\0"
            VALUE "FileDescription", "[COLOR="red"]FS9/FSX Gauge[/COLOR]\0"
            VALUE "FileVersion", VERSION_STRING
            VALUE "LegalCopyright", "[COLOR="red"]2004-2008 EaglesoftDG & Bill Leaming.[/COLOR]\0"
            VALUE "ProductName", "[COLOR="red"]Citation CJ1[/COLOR]\0"
            VALUE "ProductVersion", VERSION_STRING
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

// Hobbs Bitmaps
Hobbs_bgnd                 BITMAP  DISCARDABLE     "res\\CJ1_Hobbs_background.BMP"
Hobbs_txt                  BITMAP  DISCARDABLE     "res\\CJ1_Hobbs_text.BMP"
Hobbs_bgnd_night	   BITMAP  DISCARDABLE     "res\\CJ1_Hobbs_background_night.BMP"

xxx.h file
Code:
#define         VERSION_MAJOR           3
#define         VERSION_MINOR           1
#define         VERSION_BUILD           1


#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  Hobbs_bgnd                    0x1000
#define  Hobbs_txt                     0x1005
#define  Hobbs_bgnd_night              0xac40
 
Last edited:

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hi fellows,

I just want to let you know, that (almost) everything works fine now. My workspace is not a mess anymore (thanks to Bill), my bitmaps are shown correctly (thanks to Simon, Bill and Dai), and the panel looks nice (thanks to my photoshop wisdom :D).

I still have a minor issue with testing and debugging - after I build the gau file, I can't copy it in the panel directory as long as the FS is running. Everytime I try it, I get the message that the file is used by another program. As workaround, I rename the file, and change all the entries in the panel.cfg. That works fine, but gets really annoying the more subgauges are included in the file. One option maybe could be to load a different aircraft, copy the file, and load the not-yet-finished-one again. But even that is annoying, because it takes a huge amount of time to switch the aircraft (due to the heaps of planes installed on my machine :rolleyes:).

How do you solve the problem?

best regards
Vitus
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
You will have to do like everyone else does; unload the a/c. One "trick" I use is to set up a dummy panel.dummy in my a/c folder, with a pretty much empty panel.cfg file.

This allows me to simply change to the dummy panel instead of having to load another a/c entirely... ;)
 
Top