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

FSX C++ OOP examples

ddawson

Resource contributor
Messages
862
Country
canada
I thought I would extricate us from the other thread...

Well, there is a pretty straightforward example packaged with the SDK.
After that, I would start with this:
http://library.avsim.net/download.php?DLID=178435
A blunt force search of the Avsim library for the phrase "source code" produces five pages of hits, admittedly not all for FS gauge code.
Bill Leaming posted a bunch of stuff on the flightsim.com forum:
http://www.flightsim.com/vbfs/forumdisplay.php?24-Panel-amp-Gauge-Design

There is help out there.
The source code for my fuel dump gauges is on my website.

Doug
Eventually, I might figure out which examples from your references use OOP techniques and which are more like 'C using classic procedural programming', but I have to start some place.

I think you will find the best example available is the Cabin Comfort module in the SDK. This one is not a gauge, but a module loaded through dll.xml.
The FS gauge structure is so heavily based on macros that for simple gauges, an OOP approach will be of little benefit.
Where it starts to become your friend is when you want to create a gauge that is going to do more than just put bitmaps on the screen. It is certainly an excellent way to organize code you're going to use again. I've created classes to handle SimVars, LVars, sound, GPS interaction, game controllers, reading the FS config files, and SimConnect metar strings. I'm working on one for SimConnect itself.

Doug
 
The FS gauge structure is so heavily based on macros that for simple gauges, an OOP approach will be of little benefit.

Why not ? I'd say it could be made fit into an OOP structure very well. Have a look at this post of mine from 2010:

http://www.fsdeveloper.com/forum/threads/gdi-draw-on-element_static_image.20863/#post-138510

Which explains the concepts behind the ESP GDI+ sample. As I've said in that post, the idea behind that implementation, was to convert something that was thought as pure C (the original Gauges SDK) into object oriented code. Which is interesting because, if you *really* think about it, the whole concept of how SDK Gauges works, it's a way to simulate object orientation and templates, with a language that doesn't support any of it!

Where it starts to become your friend is when you want to create a gauge that is going to do more than just put bitmaps on the screen. It is certainly an excellent way to organize code you're going to use again.

Of course, that's what I'm trying to convey here, which has been discussed in the other thread of C++ against XML. There's some kind of common knowledge that C++ is only good to get you access to unreachable APIs like DirectX, GDI+ or doing file I/O operations, but in fact when C++ shines, is to put order to your *own* code!

I've created classes to handle SimVars, LVars, sound, GPS interaction, game controllers, reading the FS config files, and SimConnect metar strings. I'm working on one for SimConnect itself.

Of course, this is what any C++ developer should do: your own personal framework that interfaces with the sim and the various SDK/APIs, so your "real" code for the project would be very clean and easy to write, and won't contain any direct reference to the SDKs, so in any case they would ever change, you will only have to update your framework, and everything in your code (which is the most valuable part of any project and the most time consuming to maintain) would keep working correctly, even in a different sim.
 
FOR GOD'S SAKE MAN, GIVE IT A REST!

Now I really lost you...

I made a post to praise and in total agreement of your comments about how C++ is good to organize your code, and the fact you did the right thing writing classes ease development, which is how C++ is supposed to be used, and THIS is your reply ? I couldn't imagine a more clear case of *total* misunderstanding: I thought your post was in support of my views, and posted something in support of it!

Is there some kind of a language barrier at play here ? English is not my mother tongue, the intention behind my post was ENTIRELY in your favor, how's possible you took it the opposite way ? Did it sound any different to you ?
 
Umberto, the very beginning of the first post says "I thought I would extricate us from the other thread...".

He started this thread to get away from both you and Tom and the endless debate you two bring to threads.
 
Umberto, the very beginning of the first post says "I thought I would extricate us from the other thread...".

He started this thread to get away from both you and Tom and the endless debate you two bring to threads.

Which I understood as an invitation to move the discussion about C++ in general HERE, in order to return the *other* thread to its original topic!

But I didn't had ANY intention to continue arguing with Tom here, I just thought this was supposed to be a new thread dedicated to just C++ discussions, in general, and more specifically the issue of the lack of tutorials, which is why I also posted a link to an older thread BECAUSE there are too few C++ tutorials, and the few we have should be preserved, not anyone would go back 4 years to read all post.

Didn't realized I wasn't invited, and that anything I would post here, even my clear appreciations for Doug post (or, more precisely, what I THOUGHT to be received as an appreciation), would be so badly received.
 
Last edited:
Back
Top