diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 5a05d8872..7989cd0f7 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -102,7 +102,6 @@ extern void fgLatLonFormatToggle( puObject *); #if defined( TR_HIRES_SNAP) #include -extern void trRenderFrame( void ); extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start, GLfloat x_end, GLfloat y_end ); #endif @@ -376,8 +375,8 @@ void guiTogglePanel(puObject *cb) else fgSetBool("/sim/panel/visibility", true); - fgReshape(fgGetInt("/sim/startup/xsize"), - fgGetInt("/sim/startup/ysize")); + globals->get_renderer()->resize(fgGetInt("/sim/startup/xsize"), + fgGetInt("/sim/startup/ysize")); } void goodBye(puObject *) @@ -534,15 +533,16 @@ void fgHiResDump() puHideCursor(); } - fgInitVisuals(); - fgReshape( fgGetInt("/sim/startup/xsize"), - fgGetInt("/sim/startup/ysize") ); + FGRenderer *renderer = globals->get_renderer(); + renderer->init(); + renderer->resize( fgGetInt("/sim/startup/xsize"), + fgGetInt("/sim/startup/ysize") ); // we need two render frames here to clear the menu and cursor // ... not sure why but doing an extra fgRenderFrame() shouldn't // hurt anything - fgRenderFrame(); - fgRenderFrame(); + renderer->update(); + renderer->update(); // Make sure we have SSG projection primed for current view glMatrixMode(GL_MODELVIEW); @@ -633,7 +633,7 @@ void fgHiResDump() trBeginTile(tr); int curColumn = trGet(tr, TR_CURRENT_COLUMN); int curRow = trGet(tr, TR_CURRENT_ROW); - trRenderFrame(); + globals->get_renderer()->screendump(); if ( do_hud ) fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step, (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step ); @@ -670,7 +670,7 @@ void fgHiResDump() } - fgReshape( width, height ); + globals->get_renderer()->resize( width, height ); trDelete(tr); @@ -714,7 +714,7 @@ GLubyte *hiResScreenCapture( int multiplier ) float fov = oldfov / multiplier; FGViewer *v = globals->get_current_view(); fgSetDouble("/sim/current-view/field-of-view", fov); - fgInitVisuals(); + globals->get_renderer()->init(); int cur_width = fgGetInt("/sim/startup/xsize"); int cur_height = fgGetInt("/sim/startup/ysize"); if (b1) delete( b1 ); @@ -723,10 +723,10 @@ GLubyte *hiResScreenCapture( int multiplier ) int x,y; for ( y = 0; y < multiplier; y++ ) { for ( x = 0; x < multiplier; x++ ) { - fgReshape( cur_width, cur_height ); + globals->get_renderer()->resize( cur_width, cur_height ); // pan to tile rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) ); - fgRenderFrame(); + globals->get_renderer()->update(); // restore view GlBitmap b2; b1->copyBitmap( &b2, cur_width*x, cur_height*y ); @@ -794,15 +794,15 @@ void fgDumpSnapShot () { puHideCursor(); } - fgInitVisuals(); - fgReshape( fgGetInt("/sim/startup/xsize"), - fgGetInt("/sim/startup/ysize") ); + globals->get_renderer()->init(); + globals->get_renderer()->resize( fgGetInt("/sim/startup/xsize"), + fgGetInt("/sim/startup/ysize") ); // we need two render frames here to clear the menu and cursor // ... not sure why but doing an extra fgRenderFrame() shouldn't // hurt anything - fgRenderFrame(); - fgRenderFrame(); + globals->get_renderer()->update(); + globals->get_renderer()->update(); while (count < 1000) { FILE *fp; diff --git a/src/GUI/gui_local.cxx b/src/GUI/gui_local.cxx index e881cd2a7..adb75f656 100644 --- a/src/GUI/gui_local.cxx +++ b/src/GUI/gui_local.cxx @@ -81,7 +81,7 @@ void reInit(puObject *cb) globals->get_tile_mgr()->update( fgGetDouble("/environment/visibility-m") ); - fgReshape( xsize, ysize ); + globals->get_renderer()->resize( xsize, ysize ); // BusyCursor(1); diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index 9a3064fda..87fc984aa 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -37,6 +37,7 @@ noinst_LIBRARIES = libMain.a libMain_a_SOURCES = \ main.cxx main.hxx \ + renderer.cxx renderer.hxx \ fg_commands.cxx fg_commands.hxx \ fg_init.cxx fg_init.hxx \ fg_io.cxx fg_io.hxx \ diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 73adb93ea..d8b2997c8 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -42,6 +42,7 @@ FGGlobals *globals; // Constructor FGGlobals::FGGlobals() : + renderer( new FGRenderer ), subsystem_mgr( new SGSubsystemMgr ), event_mgr( new SGEventMgr ), sim_time_sec( 0.0 ), @@ -95,6 +96,7 @@ FGGlobals::~FGGlobals() delete props; delete commands; delete io; + delete renderer; // make sure only to delete the initial waypoints list if it acually // still exists. @@ -157,6 +159,12 @@ void FGGlobals::set_fg_scenery (const string &scenery) { } +FGRenderer * +FGGlobals::get_renderer () const +{ + return renderer; +} + SGSubsystemMgr * FGGlobals::get_subsystem_mgr () const { diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index 3077e750e..13215e6ee 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -42,6 +42,8 @@ SG_USING_STD( string ); typedef vector string_list; +#include "renderer.hxx" + // Forward declarations // This file is included, directly or indirectly, almost everywhere in @@ -97,6 +99,7 @@ class FGGlobals private: + FGRenderer *renderer; SGSubsystemMgr *subsystem_mgr; SGEventMgr *event_mgr; @@ -217,6 +220,8 @@ public: FGGlobals(); virtual ~FGGlobals(); + virtual FGRenderer *get_renderer () const; + virtual SGSubsystemMgr *get_subsystem_mgr () const; virtual SGSubsystem *get_subsystem (const char * name); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 0915f2d23..8f80effbb 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -41,31 +41,23 @@ # include #endif -#include #include -#include -#include #include -#include #include -#include -#include -#include #include -#include -#ifdef FG_USE_CLOUDS_3D -# include -# include -#endif +// Class refferences +#include +#include +#include +#include +#include +#include