1
0
Fork 0
flightgear/src/Main/fg_os.hxx

74 lines
2.1 KiB
C++
Raw Normal View History

#ifndef _FG_OS_HXX
#define _FG_OS_HXX
// Plib pui needs to know at compile time what toolkit is in use.
// Change this when we move to something other than glut.
#define PU_USE_GLUT
enum { MOUSE_BUTTON_LEFT,
MOUSE_BUTTON_MIDDLE,
MOUSE_BUTTON_RIGHT };
enum { MOUSE_BUTTON_DOWN,
MOUSE_BUTTON_UP };
enum { MOUSE_CURSOR_NONE,
MOUSE_CURSOR_POINTER,
MOUSE_CURSOR_WAIT,
MOUSE_CURSOR_CROSSHAIR,
MOUSE_CURSOR_LEFTRIGHT };
enum { KEYMOD_NONE = 0,
KEYMOD_RELEASED = 1, // Not a mod key, indicates "up" action
KEYMOD_SHIFT = 2,
KEYMOD_CTRL = 4,
KEYMOD_ALT = 8,
KEYMOD_MAX = 16 };
// A note on key codes: none are defined here. FlightGear has no
// hard-coded interpretations of codes other than modifier keys, so we
// can get away with that. The only firm requirement is that the
// codes passed to the fgKeyHandler function be correctly interpreted
// by the PUI library. Users who need to hard-code key codes
// (probably not a good idea in any case) can use the pu.hxx header
// for definitions.
//
// OS integration functions
//
void fgOSInit(int* argc, char** argv);
Frederic Bouvier: FG_ENABLE_MULTIPASS_CLOUDS must be defined to enable the algorithm. I made this because the stencil buffer must be initialized at the beginning of the program and OpenGL can fallback to software rendering if it can't find a visual with stencil buffer. I didn't touch the configure script, so CXXFLAGS=-DFG_ENABLE_MULTIPASS_CLOUDS must be set before running ./configure. If FG_ENABLE_MULTIPASS_CLOUDS is defined, the main render loop begins by reading the /sim/rendering/multi-pass-clouds property. It is a boolean property so there are only two quality levels. false means no multi pass and no use of the stencil buffer, true means an additionnal pass for both upper and lower cloud layers. The algorithms are as follow : /sim/rendering/multi-pass-clouds=false 1. draw sky dome 2. draw terrain only 3. draw clouds above the viewer 4. draw models except the aircraft 5. draw clouds below the viewer 6. draw the aircraft. The cloud rendering doesn't update the depth buffer. This means that models overwrite clouds above the viewer. This is only noticeable for tall buildings and when flying very low. Also, drawing low clouds after models means that they are not blended with models' translucent surfaces. Large transparent area require alpha test enabled and AI aircraft canopy are making holes. The pilot's aircraft being rendered at the end, there is no problem with canopy or prop disc. /sim/rendering/multi-pass-clouds=true 1. draw the sky dome 2. draw the terrain only 3. draw all clouds 4. draw models except the aircraft 5. redraw the clouds where the models where drawn ( stencil test on ) 6. draw the aircraft The assumptions made by this algoritm are that the terrain is not transparent ( should be true in all cases and that there are no clouds between the aircraft and the viewer. Assuming these facts, there should be no blending bugs. The screenshot rendering is not updated yet.
2004-04-02 14:40:54 +00:00
void fgOSOpenWindow(int w, int h, int bpp, bool alpha, bool stencil);
void fgOSFullScreen();
void fgOSMainLoop();
void fgSetMouseCursor(int cursor);
int fgGetMouseCursor();
void fgWarpMouse(int x, int y);
int fgGetKeyModifiers();
void fgRequestRedraw();
//
// Callbacks and registration API
//
typedef void (*fgIdleHandler)();
typedef void (*fgDrawHandler)();
typedef void (*fgWindowResizeHandler)(int w, int h);
typedef void (*fgKeyHandler)(int key, int keymod, int mousex, int mousey);
typedef void (*fgMouseClickHandler)(int button, int updown, int x, int y);
typedef void (*fgMouseMotionHandler)(int x, int y);
void fgRegisterIdleHandler(fgIdleHandler func);
void fgRegisterDrawHandler(fgDrawHandler func);
void fgRegisterWindowResizeHandler(fgWindowResizeHandler func);
void fgRegisterKeyHandler(fgKeyHandler func);
void fgRegisterMouseClickHandler(fgMouseClickHandler func);
void fgRegisterMouseMotionHandler(fgMouseMotionHandler func);
#endif // _FG_OS_HXX