Hello everyone,

This is a patch (plus examples of use) I've created to solve the problem
we had at work. Short explanation - the aim was to have a separate HUD
code (as opposed to included in the FlightGear code).

Long explanation - the easiest solution I saw was to develop a plugin
system for the HUD code. I've done it under Linux (using dlfcn.h), and I
don't know how this can be adapted to other systems.

- new code in FlightGear (see files in mymods/source, the modifications
I made were all in src/Cockpit/)

I created a new class src/Cockpit/hud.hxx, hud_ext, which inherits from
instr_item. This class has members which help determine where on the
current HUD will the external code be displayed (see the file
mymods/doc/hud_coords.png). The constructor loads a dynamic library
defined by a path, and looks for a function in that library. The draw()
method is called by the functions in hud.cxx, and calls the function
found in the dynamic library.

- config files (see files in mymods/data)

It should be pretty straightforward. Just adapt the HUD on one of your
aircraft. I added the new <ext></ext> tags in the external.xml example.
Don't forget to mention the exact path to the library you want to use,
as well as the function name.

- library example (see files in mymods/myhud)

it works for me with just "make" in the directory containing the
Makefile, main.c and myhud.c. You should get a shared library (.so)
(libmyhud.so in this case), that you have to move to the correct path
(the one in the config file). There is a "prog" test program as well. In
the dynamic library, you can use plain OpenGL code, maybe GLU...

TODO:

- make sure that the coords are correctly taken into account. Currently,
I can only use efficiently a plugin that draws in a [-1,1] x [-1,1]
space. Maybe some computations are in order...

- clean up the code ? exit() calls, use of the HUD "options", OpenGL
transformations...

- other operating systems ?

- autoconf / automake requirements ?

- lots more, probably... at work, we still have to implement the
communication inside the library (inside the called function) to get the
info used for drawing the HUD.

Questions for you: what do you think ? can it be committed to CVS ?
other ideas ?

-- 
Jorge Van Hemelryck

Attachment: mymods.tar.gz
Description: Binary data

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to