FSDeveloper Community

Go Back   FSDeveloper Community > Microsoft Flight Simulator development > Aircraft Design > Gauges

Gauges Use this forum for all your gauges related discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 04 May 2012, 08:12
TurbofanDude TurbofanDude is offline
  unitedstates
Location: Florida
Join Date: Mar 2011
Posts: 48
Send a message via Skype™ to TurbofanDude
C++ Bitmaps

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,
__________________
Collin Biedenkapp,
Programmer and Manager,
TFDi Design,
http://tfdidesign.com
Reply With Quote
  #2  
Old 04 May 2012, 11:22
Naruto-kun's Avatar
Naruto-kun Naruto-kun is offline
  southafrica
Join Date: Jun 2010
Posts: 393
Send a message via MSN to Naruto-kun
I have found VS2008 to be a bit more stable for FSX stuff than the newer versions....
Reply With Quote
  #3  
Old 04 May 2012, 17:23
taguilo taguilo is offline
  argentina
Location: San Isidro-BsAs
Join Date: Oct 2006
Posts: 612
Quote:
Originally Posted by TurbofanDude View Post
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
Reply With Quote
  #4  
Old 04 May 2012, 21:25
TurbofanDude TurbofanDude is offline
  unitedstates
Location: Florida
Join Date: Mar 2011
Posts: 48
Send a message via Skype™ to TurbofanDude
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,&al titude_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_BU ILD))

#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 0x0001
#endif

#define ALTITUDE_BACKGROUND 0x1000
-------------------------------------------------------------
__________________
Collin Biedenkapp,
Programmer and Manager,
TFDi Design,
http://tfdidesign.com
Reply With Quote
  #5  
Old 05 May 2012, 10:22
taguilo taguilo is offline
  argentina
Location: San Isidro-BsAs
Join Date: Oct 2006
Posts: 612
Quote:
Originally Posted by TurbofanDude View Post
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
Reply With Quote
  #6  
Old 05 May 2012, 14:16
TurbofanDude TurbofanDude is offline
  unitedstates
Location: Florida
Join Date: Mar 2011
Posts: 48
Send a message via Skype™ to TurbofanDude
Yes, I did include the header. You just confirmed my fears my friend. Either VS11 is compiling wrong, or my FSX is screwed up.
__________________
Collin Biedenkapp,
Programmer and Manager,
TFDi Design,
http://tfdidesign.com
Reply With Quote
  #7  
Old 05 May 2012, 19:24
mgh mgh is offline
  unitedkingdom
Join Date: Jan 2010
Posts: 747
A very remote possibility, but has your new bitmap the same nunber of bits/pixel as previous ones that were OK?
Reply With Quote
  #8  
Old 06 May 2012, 12:08
TurbofanDude TurbofanDude is offline
  unitedstates
Location: Florida
Join Date: Mar 2011
Posts: 48
Send a message via Skype™ to TurbofanDude
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).
__________________
Collin Biedenkapp,
Programmer and Manager,
TFDi Design,
http://tfdidesign.com
Reply With Quote
  #9  
Old 06 May 2012, 15:09
Naruto-kun's Avatar
Naruto-kun Naruto-kun is offline
  southafrica
Join Date: Jun 2010
Posts: 393
Send a message via MSN to Naruto-kun
overall though GDI+ is a better way to go when it comes to C++ gauges....
Reply With Quote
  #10  
Old 06 May 2012, 23:38
WarpD WarpD is offline
  us-ohio
Join Date: Dec 2007
Posts: 300
Quote:
Originally Posted by Naruto-kun View Post
overall though GDI+ is a better way to go when it comes to C++ gauges....
Not always.
Reply With Quote
  #11  
Old 12 May 2012, 19:41
virtuali virtuali is offline
  italy
Join Date: Aug 2005
Posts: 120
Quote:
Originally Posted by WarpD View Post
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.
__________________
regards,

Umberto Colapicchioni
http://www.fsdreamteam.com
Reply With Quote
  #12  
Old 13 May 2012, 01:23
WarpD WarpD is offline
  us-ohio
Join Date: Dec 2007
Posts: 300
Oh, I agree you can do it "all" with GDI+... I disagree that it's always the best choice.
Reply With Quote
  #13  
Old 13 May 2012, 15:04
virtuali virtuali is offline
  italy
Join Date: Aug 2005
Posts: 120
Quote:
Originally Posted by WarpD View Post
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...
__________________
regards,

Umberto Colapicchioni
http://www.fsdreamteam.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Effects bitmaps itifonhom Special Effects General 3 03 Jun 2009 15:34
.gau file and bitmaps Capn_Geoff Gauges 8 10 Dec 2008 17:30
Gauge with Bitmaps PeterW Gauges 1 30 Jan 2008 09:05
2 bitmaps better than 1? Fern GMax and 3DS Max 9 05 Dec 2005 15:00
Repeating Bitmaps paul SCASM & ASM tweaking 2 31 Mar 2005 11:55


All times are GMT -4. The time now is 22:31.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.