Jump to content
  • Advertisement
Sign in to follow this  

2D graphics API for flight sim avionics displays?

This topic is 4396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings all. I'm struggling to find a suitable 2D/vector graphics API to enable me to avoid having to rely on the slow GDI/GDI+ engine in Windows for my real-time rendering needs. I'm a big fan of Microsoft Flight Simulator 2004 (FS2004 from here on for finger-saving purposes). FS2004 has an SDK kit available at http://www.microsoft.com/games/flightsimulator/fs2004_downloads_sdk.asp, which allows third-parties to develeop all manner of add-ons such as aircraft, scenery and panels. Panels are the graphical represenation of an aircraft's internal cockpit showing discreet avionics instruments such as airspeed indicators, altimeters, engine temperature gauges etc. FS2004 has a specific panel SDK that I'm currently learning to use but it's one weakness is that the entire panel-drawing system is based on GDI/GDI+. Hence I cannot make use of hardware accelerated alternatives. I'm at the stage now where I wish to create aircraft instruments that mimic some of today's latest 'glass cockpit' avionics systems such as moving map displays and navigation systems such as those from Garmin ( http://www.garmin.com/products/g1000/ ) and Cirrus Design http://www.cirrusdesign.com/aircraft/avionics/pfd/. It's at this point that GDI/GDI+ breaks down and is simply not fast enough to do the job. My current understanding of the FS2004 panel SDK is that I'm restricted to drawing to a GDI/GDI+ surface. So, I'm looking for an API with the following main features: *** High performance, real-time software rendering to a surface *** I'm guessing that due to FS2004's panel SDK reliance on GDI/GDI+ I may be forced to work with GDI/GDI+ bitmap surfaces. Is there a way to draw directly to an instance of a GDI/GDI+ surface without having to use GDI/GDI+ calls? If not I guess I would have to draw to a non-GDI surface first, then blit/copy from that surface to another GDI surface before displaying it? *** A library of drawing functions *** As well as drawing primitive vector-type elements such as lines, polygons (solid and gradient filled), circles, arcs and other basic shapes, the ability to handle raster bitmaps would be useful for rendering terrain maps in a display. Sub-pixel anti-aliasing would also be a big plus. In my lengthy searching for a suitable API, I did encounter Antigrain at http://www.antigrain.com. It's a damned impressive piece of work but from what I can tell it's largely a low-level foundation on which to build a more complete vector drawing API (beyond my abilities at this time). The many examples shown also only appear to be suitable for applications of a 'document based' nature, rather than a real-time, high speed rendering environment. I am looking further into it though to see if my assumptions are incorrect :) So, if any of you gurus out there have come across an API that would 'fit the bill' so-to-speak, I'll be eternally grateful for a heads up on where to point my browser. Grassy arse amigos :)

Share this post


Link to post
Share on other sites
Advertisement
I'm not an GDI nor a DX expert, but I assume you can draw your instruments using DirectX/D3D and then copy the DX surface to a GDI surface.

You can probably get a good answer about such things in the DirectX forum.

Using DirectX would give you vector drawing with textures and antialiasing and all such nice things.

I have myself done glass cockpit and HUD-type instruments in opengl (though not for MSFS) with excellent results. But I think DX is better for integrating with GDI.

Share this post


Link to post
Share on other sites
I thought about doing that but there seems no way to use DirectX from within an instrument written in C/C++ using the panel system of FS2004. All the instrument (or gauges as they say in the FS2004 SDK world) are actually DLL files that you write which expose a number of callback functions for FS2004's panel system to call. FS2004 already uses Direct3D for it's main window on the world you fly in. The panel system appears to be drawn using GDI/GDI+ calls to create the flight simulator menu system as well as these aircraft panels and instruments.

That said I'll have to see if it's possible to create and use another Direcct3D device from within a gauge DLL. Or is that inherently a problem because FS2004 is using the one video card already and you can only have one Direct3D device instanced at a time?

Drawing on the FS2004 Direct3D screen environment appears out of bounds except through GDI/GDI+ calls and surfaces set up within your gauge DLLs using specific routines that the flight simulator panel drawing system allows.

I think the solution for higher performnance vector drawing lies in my finding a good 2D/vector drawing API that renders in software to a surface. I can then bypass the need to use the overly complex and bloated GDI/GDI+ code because I do not need all of its device independant drawing abilitiess. Once I've written to a surface using a third-party API I guess I then need to find out the best and fastest way to get the surface drawn by the API onto GDI/GDI+ bitmaps that FS2004 usesp to display gauges.

I'm still somewhat confused about GDI/GDI+ surface types such as DDB (Device Dependant Bitmaps) and DIBs (Device Independant Bitmaps). Ideally I would be able to use an API to write directly to a GDI/GDI+ surface without then having to use slow blit copy processes to get it onto a GDI/GDI+ surface. I believe surface copying from bitmap to bitmap using GDI involves relatively slow conversions? I'd also need to double buffer the drawing to avoid flickering on the gauge thereby adding to the blitting time.

Unfortunately, all my searches for 2D/vector drawing APIs return APIs that are designed to simply provide GUI widgets and windows and not designed for use in a fast, real-time rendering loop to draw lines, polygons (solid-filled and gradient), circles, arcs etc. I did find Antigrain ( www.antigrain.com ) but this is a basic framework from which to build your own API (beyond my abilities at the moment). I really need something language specific (geared to Win32 C/C++) that has drawing functions already implemented.

Other API's I get in search results are predominently 3D. It seems everyone is mad-happy on 3D hardware acceleration at the moment so interest in producing a 2D/vector drawing API has waned considerably :)

I guess I could use a 3D engine to draw to 2D screen coordinates but with no need, or ability within a flight simulator gauge, to use hardware acceleration I fear such an API would be inefficient and 'memory bulky'.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!