Jump to content
Sign in to follow this  
Guest fturner

GDI+ Alternative - C++ Gauge

Recommended Posts

Guest JeanLuc_

Thank you for your kind words Tiberiu!Actually, to each his own. Ed requirements are different that my requirements that are different than your requirements etc...He clearly said it: "I'll stick to what provides the most capability with the least manhour/maintenance cost."This is the premise of C++ and libraries/reusable classes. You can use them, or do your own.I have two example about reusability as opposed to performance lately though.1) I was working on a database class and started to use standard C++ libraries, more particularly ifstream for reading the database text files, strings to store and partse each line of the text files and vectors of waypoint classes to store the database in memory. Neat result: more than 1 min to load the database.After many iterations, I then resorted to implementing a class that maps a text file in memory (memory map file) with methods similar to standard file access libraries (seek, getline, getchar etc...). Then I've almost eliminated all string reference and made my own multibyte/unicode to ASCII converter to ensure compatibility with the text file source, and I've used only vectors as containers in the end. Results? the database (similar in complexity to a Level D 767 database) loads in roughly 3 seconds.2) when designing FLN/FLT, I needed bitmap rotation code. I ended up doing my own of course, and it was impressively way faster than FS own code (which looks like being an MMX implementation of a generic rotation code). Of course it was fast already, thanks to nice optimizations in the algorithm. Nevertheless, I analyzed further the code, and discovered that one of the bottleneck was memory access (as usual). So I decided to invest even more time to optimize this, and I ended up with a solution: thanks to pre-processing the bitmaps in a certain way (kind of interleaving some of the pixel data in a certain way in the bitmap), I managed to divide by 2 (yes, that is 100% faster) the time needed to rotate a bitmap!So in the end, the good lesson about this for me is simple: with little extra work that I wanted to do (in particular this bitmap rotation thing took roughly 1 week full time for this function alone) instead of using default/standard libraries, I've managed to achieve better performance, and less CPU incentive products.Thanks to managing the low level bits of the pipeline, I've also managed to go further, like I've written above in making FS directly take the TDXP rendering backbuffer to the screen without any intermediate conversion/storage/blit (and with no-hack, it is in the gauge.h) :-)AntiGrain is a very good API, very fast and powerfull, at the expense of coding to a lower level than GDI+. A little bit like ASM vs C++ (well not that much but for a practical illustration).Hope this helps!

Share this post


Link to post
Share on other sites

Hello Jean-Luc,Thanks for your explanations, they are perfectly clear and any good developer can understand this as the trade off between an API ease of use and performance. A high level easy-to-use API is always slower than a low level one...These explanations also show your expertise in the FS gauge area, you keep amazing me.(I know I shouldn't say this to a "competitor", but it is true ;-))Eric

Share this post


Link to post
Share on other sites

>you keep amazing me.lol, could not have said it any better. :-hah Great in-depth knowledge. As a former casual gauge programmer I am not even close to that. *:-*Keep it up guys,Etienne :-wave

Share this post


Link to post
Share on other sites

>A high level easy-to-use API>is always slower than a low level one...I think DirectX vs AGG is most definitely closer to high-level and definitely easier to use. Yet it's quite fast. So, your statement is not always true. ;)Easy to use has a few requirements:1) Documentation.2) Standard libraries, offering encapsulating classes.3) Clear, concise examples.Using DirectX inside a gauge though wouldn't be fun at all. In that regard AGG is the most promising, however it's complete lack of documentation presents a learning curve of epic proportions.AGG is missing encapsulating classes, which is paramount for useability. A flat API is not the most 'friendly' of approaches these days. AggPlus is a promising start, but it falls far short of ready to use. I've been going through the code and there are a lot, and I do mean a LOT of Graphics class functions simply not implemented.I've not found any information on how to get AGG to clip to a polygon or a path. In complex PFD/MFD displays this is critical as there are many types of PFD/MFD systems that have complex interleaved information displays that overlay each other.To make AGG the replacement for everyone, AggPlus would need to be finished up. Otherwise it's a long, hard road to develop the more complex PFD/MFD gauges out there.As for Jean-Luc's statement regarding me... I work with entire aircraft packages which places more restrictions and time constraints. He works strictly with generic* gauges, allowing quite a bit more freedom because none of them are aircraft specific. Two completely different worlds, so to speak. ;)*generic: as in not aircraft model/installation specific.


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites
Guest fturner

Ed,If you want to stick to using GDI+ cause its "easy" and does the job for you, what with THOUSANDS of examples out there to do everything, and documentation through the yin yang, well heck, go for it :), cause frankly "NO ONE CARES WHAT YOU DO OR USE"......But if your going to come here and argue that agg cannot be used then get your facts in order, and do your research. I don't mind having healthy debates with people in the know. So far you have not mentioned one thing that agg cannot do.... and you do not even bat an eye and state something else you say it can't do, and again your told that in fact it can do. You have just proven time and time again you know nothing about agg, so frankly this "debate" or "arguement" is pointless. I know alot more about agg than you obviously, and yet I have only scratched the surface of it.... and I have one ability over you anyday..... and thats to admit I am wrong about something.I said aggplus was not complete, but thats all you stick with. Dump it already, you have made your point about Aggplus and your right..... it needs work, and get this right..... Aggplus is an api to overlay agg, so the folks that are familiar with GDI(+) can take advantage of the better features of Agg, one reason being if they can't be bothered to dig into agg itself.There are several folks that have indicated an exciting interest in exploring agg and dig further into what it can/cannot do. I've already proven it can be used, but of course to you with your 25+ years experience etc that doesn't matter... does it, and judging from your comments above, you don't even think that highly of anyone in the FS community and their skills..... except obviously your own.You want to talk about insulting.... In fact, I am the one that has been insulted all along because essentially you have called me nothing but a liar the entire time by trying to say Agg cannot do whatever and cannot be used in gauges etc..... because if your the truth by stating agg cannot do anything, then how is my example PFD being drawn, and all the "complex interleaved information displays" that are in "entire aircraft packages" non *generic gauges (BTW woop de do, I've seen 1 "generic" gauge that was far more complex than an entire aircraft package cause I've been there myself) being drawn.......... OH MY!!!!! THEY ARE USING AGG.If your so good and so experienced, then Agg should be a breeze for you, BECUASE IT IS NOT HARD TO USE, and in fact once I got on a roll with it, it was much easier to utilize than GDI+.Anyways... for those that like new challenges and like to think out of the box, come on over to CFStudios forums and we will keep improving FS, because obviously the "expert" around here will not leave Agg alone until its buried in oblivion.Ed, its not me that can't handle things as you stated above, its obviously you.best regardsFraser

Share this post


Link to post
Share on other sites

Well let's see... the only clipping routine available to AGG is in agg_clip_liang_barsky.h. It doesn't support path clipping. It only supports box and line. In fact, the only other "clipping" discussed is an alpha blend routine using polys. But that's not a path clip, nor is it actually a clip. In fact, I've scanned the AGG mailing list/newsgroup... Nope, no path clipping even discussed there. The only clipping in that list of posts is rectangular. Now, I know there's a 3rd party clipping library, but it's not available for commercial use without special permission... not to mention it's not actually part of AGG. So... feel free to name the clipping that I've missed... because I've scanned the entire AGG source code for 'clip' and found just the one class set. Using an alpha blend routine to mimic clipping with a polygon isn't the same as a path clip. Heck, not even close.I never once stated AGG can not be used. I have, however, stated that it is not complete and ready-to-go for everything. Using AGG standalone will require a rather significant learning curve hurtle. For projects with deadlines, that's not a positive step forward. Any API that lacks any documentation whatsoever is not 'easy'. Especially when the source is spread out over 142 files, not including text rendering. I never stated AGG can not be used for gauges, you're literally making things up at this point. I have no idea why you feel the need to. There are abilities GDI+ has that AGG can not duplicate at all. If you know GDI+ well, you would know what they are.I have a PFD that has on one side five tapes that interleave combined with 3 markers that slide based on autopilot settings and two rolling numbers. None of the tapes are full foreground or full background. This requires a rather complex set of clipping areas defined by paths. Without path clipping support, AGG couldn't possibly render this PFD. One tape shows through the rolling numbers window... the others do not... but the others have parts that render in front of the tape that shows through the rolling numbers window. It's truly more complex than what AGG can handle without path clipping. As for the generic statement... that was actually regarding what Jean-Luc does business wise versus what I do business wise. It didn't have anything specifically to do with whether AGG would render a PFD.You appear to have a problem allowing someone to point out limitations and suggesting caution... especially when it goes against your views. I'm not, nor have I ever come out and stated that no one should use AGG. Instead I've repeatedly pointed out that it is completely and totally undocumented, there are certain areas it is weak, there are areas it literally can't do things at all. It is best to let people know both good and bad... not just good and hope they ignore the bad.Regarding AggPlus, you offered it up as a GDI replacement for familiarity. It can't even draw an ellipse!! Yes, I know that AGG can... but AggPlus is missing quite a bit more than 30%. I went through it and compared it versus the actual GDI+ source. ImageAttributes... can't do it. Using containers... can't. All the quality control functions... dummy functions that do absolutely nothing. No DrawEllipse,FillEllipse,DrawPolygon,FillPolygon... I could go on and on... these are basic graphics functions that AggPlus doesn't have. Oh, and there's no clipping set up in AggPlus either. Well, there is... but it's not the correct function names and it's only rectangular. No path, no poly clip. Same clipping routines actually missing from the AGG source.For those that want to explore AGG further, at least they head that direction knowing more than just the 'rose colored' picture you paint. Working without documentation is perhaps one of the most frustrating aspects of using someone else's code. I think it's a good thing to ensure that everyone knows both the pros and the cons of AGG and AggPlus. People tend to make a better decision when they're completely informed... not just tossed a 'sales pitch'.Now... at this point... if you want to discuss me... you're on your own. I'll discuss AGG itself... but this isn't about me, nor is it about you. I'm tired of your incessant need to attempt to discredit me because I am saying things you don't like to hear about your favorite "toy". AGG has pros and cons. Leave the discussion to those.


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

Jean-Luc,thanks for the clarification about the "psycho-visual filtering". Impressive -- it wasn't clear to me indeed from the description on the website that you were actually simulating the display characteristics of a CRT. That's a point that might indeed be worth emphasizing on the website.Interesting stuff too about rendering to a backbuffer that FS can use directly... hmmm, seems I'll have to go rooting through gauges.h and see if I can figure out how it's done... ;-)Great thread -- I've learned a lot!Martin

Share this post


Link to post
Share on other sites

>Jean-Luc,>>thanks for the clarification about the "psycho-visual>filtering". Impressive -- it wasn't clear to me indeed from>the description on the website that you were actually>simulating the display characteristics of a CRT. That's a>point that might indeed be worth emphasizing on the website.>>Interesting stuff too about rendering to a backbuffer that FS>can use directly... hmmm, seems I'll have to go rooting>through gauges.h and see if I can figure out how it's done...>;-)>>Great thread -- I've learned a lot!>>MartinThere's a DirectX pointer that can be accessed... the question is, exactly what is it pointing to? If I knew, I'd tell you. However, don't expect Jean-Luc to speak publicly about it.


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

> There's a DirectX pointer that can be accessed... the question is,> exactly what is it pointing to? If I knew, I'd tell you.Makes sense, though... it's probably the surface that FS renders the gauge to. If one knew how to use it, one could do what Jean-Luc implies... well, thanks for that tidbit of information. Maybe I'll get round to investigating this myself one day...> However, don't expect Jean-Luc to speak publicly about it.Well, I wouldn't either if I were him... ;-)Martin

Share this post


Link to post
Share on other sites
Guest fturner

You win.......You are obviously the voice for the entire community which will make you the guru of all programming, what with your 25+ years of programming professionally and I humbly apologize for trying to step on your toes.I will withdraw the sample, and I will not discuss Agg here again as I know it is not welcomed as it is a very inferior option and in fact cannot be used for gauges, as it can't even draw polygons.I apologize to the rest of the community for my "sales" pitch. I have been proven that in fact I am wrong about Agg.Frit

Share this post


Link to post
Share on other sites

>You win.......No, "we" loose......but, only because you apparently cannot separate discussion of the pro's and con's of programming paradigms from the psycho-social aspects of communications.You treat all "dissent" as a personal affront and resort to ad hominem against anyone who dares to discuss the "con's" of your proposition.There is an old carney maxim, "If you can't dazzle 'em with brilliance, buffalo 'em with bulls**t..."Sadly, what could have been a fruitful discussion spiraled into a diatribe of poste-reposte, or - perhaps more a propos - thrust-block. You thrust; Ed blocks... back and forth...Does Ed speak for the entire community here? By no means! However, I respect his views immensely, because he never has resorted to ad hominem with his argumentation. He presents solid facts, backed by examples.Is Ed always right? Heck no! But, none of us ever are, are we? :)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest fturner

The whole reason for starting this thread was to give a viable option to GDI+, and to start working with other people to learn and work with agg. Instead, I get told that Agg can't draw polygons, and it can't do this and it can't do that and so on and so on, and in fact Agg is not ready for full use in FS, and this is stated even before the individual even knows anything about Agg.I guess it doesn't matter that I have already proven I can do full blown aircraft systems with all displays etc with just using Agg, but again I get told that it can't be done.So, am I just suppose to sit back and let this individual keep stating things like that when he is NOT right? I guess so, because I am suppose to accept the con's as well, even if they are wrong.So lets flip the coin here for a minute.... so you're telling me I have to accept the con's as well as the pro's, and Ed doesn't have to accept the pro's and he can just accept the con's.Interesting..... I came here all ready to work out the con's to take advantage of the pro's with everyone.........So, again I will say.... You win, and I will bow out graciously.Frit

Share this post


Link to post
Share on other sites

>The whole reason for starting this thread was to give a>viable option to GDI+, and to start working with other people>to learn and work with agg. Instead, I get told that Agg>can't draw polygons, and it can't do this and it can't do that>and so on and so on, and in fact Agg is not ready for full use>in FS, and this is stated even before the individual even>knows anything about Agg.>No, you were told AggPlus doesn't do polygons. I stated Agg won't polygon or path clip. It only does rectangular. Let's keep things straight ok?>I guess it doesn't matter that I have already proven I can do>full blown aircraft systems with all displays etc with just>using Agg, but again I get told that it can't be done.>The steps required to accomplish what you did are significantly greater than utilizing most APIs. APIs are designed for ease of use, not just power. AGG has no ease of use primarily because it's undocumented more than anything else.>So, am I just suppose to sit back and let this individual keep>stating things like that when he is NOT right? I guess so,>because I am suppose to accept the con's as well, even if they>are wrong.>You never did discuss polygon and path clipping. Please, all I see in the AGG source is rectangular clipping. Point to what I've missed.>So lets flip the coin here for a minute.... so you're telling>me I have to accept the con's as well as the pro's, and Ed>doesn't have to accept the pro's and he can just accept the>con's.>No, see... I never said anything about whether or not people should or shouldn't accept anything. I'm simply pointing out issues you're not mentioning.>Interesting..... I came here all ready to work out the con's>to take advantage of the pro's with everyone.........>Fine... where's the path clipping? Where's the documentation?


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites
Guest fturner

-Your right in that Agg does not have a full blown suite in clipping. However it does do path clipping, polygon clipping and it in fact does do rasterizer clipping as well... all rectangular. I have had no issues dealing with that as I have a VERY powerful suite of other tools in Agg to work with to go around that issue, again not complicated, and very easily done. Clipping is not the only way of layering and drawing several elements on a screen.-You did not define above that you where only stating aggplus does not do polygons, you generalized and serveral people, not just myself, took it as Agg/Aggplus does not do polygons, otherwise I would have agreed with you, IF you had clearly stated that Aggplus itself does not support polygons, but Agg does.-Everything has a learning curve, I found GDI+ to be a major pain to work with and did not perform well at all. I searched for an alternative, and I came across several, including directdraw/direct3d and even have samples of them all, fully working. I chose Agg because I like simplicity.-Pro's and con's... still, it appears I am the one that has to be open to both sides, which I am :). I have yet to see any kind of pro from you.... as I mentioned earlier, all I have read from you is agg can't do this and can't do that..... all cannot's... where's the can do.-Yes your right, Agg is a hurdle to get over to learn it, but isn't everything, including GDI+? Wasn't learning C/C++ and programming gauges in the first place a hurdle to get over?-Can Agg do everything in the world.. nope. Can Agg do FS gauges and replace GDI+... yup, if your willing to think out of the box and be willing to put some initial effort into setting up a base to start with. I had to do that just with gauges, even before I drew a bitmap on the screen. As for GDI+, I know for a fact you'd have to do the same thing. Since its a big deal to mention years as experience, I have been coding gauges and modules etc for FS since FS95 (darn, I just realized thats over 10 years WOW! LOL I'm beginning to feel old already) and I have had to set up base line code with everything to make things easier.... isn't that why they have functions, subroutines, and classes for programming with?-Text, as I said before, Agg has very weak support for text directly and if you follow the example, which I have said before is bad, its very slow. But if you take a minute and look through my example of how to do text in a gauge, you will see that I have an easy alternative that performs way better than GDI+ can ever hope to do, and if you look at my code that does that, you will see that it did not take much code at all... and I'm still trying to figure out how it is so complex and took me along time to develop.-You mentioned that my example took alot more lines of code to draw something. Do you honestly think that I would code that way to do a main line gauge?In my opinion, Agg is ready to be utilized to replace GDI+. The pro's far outweigh the con's just in alpha blending, gradient, sub-pixel accuracy, anti-aliasing and performance alone, and I've only scratched the surface of what Agg can do. All the con's I've come across I've easily worked around them by using other tools offered in Agg. Ed, you have pointed out con's (either right or wrong) and I have been forced to be the opposite.As I have said before Ed, you win, you have managed to put Agg down and convinced alot of people that it cannot be used. Frit

Share this post


Link to post
Share on other sites

>In my opinion, Agg is ready to be utilized to replace GDI+. >The pro's far outweigh the con's just in alpha blending,>gradient, sub-pixel accuracy, anti-aliasing and performance>alone, and I've only scratched the surface of what Agg can do.> All the con's I've come across I've easily worked around them>by using other tools offered in Agg. Ed, you have pointed out>con's (either right or wrong) and I have been forced to be the>opposite.I must commend you on the tone of this response.I'd also like to mention that I particularly like the way in which you provide copious comments in your example code, as well as leaving in the original GDI+ code to illustrate how the Agg code differs... Nice touch!I'd like to extend an invitation to begin a series of 'mini-tutorials' at http://flightsim.com in my Panel and Gauges forum. I began that forum almost a year ago simply because the forum here seems heavily weighted towards XML coding (which is perfectly fine!), and wanted to develop a forum that is primarly focused on "C gauges"... :)


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...