SGD_RADIANS_TO_DEGREES);
// BusyCursor(0);
fgReInitSubsystems();
+ double visibility_meters =
+ fgGetDouble("/environment/visibility-m");
global_tile_mgr.update( longitude->getDoubleValue(),
- latitude->getDoubleValue() );
+ latitude->getDoubleValue(),visibility_meters );
// BusyCursor(1);
} else {
AptId += " not in database.";
fgReInitSubsystems();
// reduntant(fgReInitSubsystems) ?
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg") );
+ fgGetDouble("/position/latitude-deg"),visibility_meters );
cur_light_params.Update();
// BusyCursor(0);
if ( global_tile_mgr.init() ) {
// Load the local scenery data
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg"));
+ fgGetDouble("/position/latitude-deg"),
+ visibility_meters);
} else {
SG_LOG( SG_GENERAL, SG_ALERT,
"Error in Tile Manager initialization!" );
if ( global_tile_mgr.init() ) {
// Load the local scenery data
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
+
global_tile_mgr.update( longitude->getDoubleValue(),
- latitude->getDoubleValue() );
+ latitude->getDoubleValue(),
+ visibility_meters );
} else {
SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
// Update the default (kludged) properties.
fgUpdateProps();
+ FGViewer *current__view = globals->get_current_view();
+
fgLIGHT *l = &cur_light_params;
static double last_visibility = -9999;
// ssg does to set up the model view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
+ ssgSetCamera( (sgVec4 *)current__view->get_VIEW() );
// set the opengl state to known default values
default_state->force();
// update fog params if visibility has changed
- thesky->set_visibility(fgGetDouble("/environment/visibility-m"));
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
+ thesky->set_visibility(visibility_meters);
thesky->modify_vis( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER,
( global_multi_loop * fgGetInt("/sim/speed-up") )
<< " moon ra = " << globals->get_ephem()->getMoonRightAscension()
<< " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */
- thesky->reposition( globals->get_current_view()->get_view_pos(),
- globals->get_current_view()->get_zero_elev(),
- globals->get_current_view()->get_world_up(),
+ thesky->reposition( current__view->get_view_pos(),
+ current__view->get_zero_elev(),
+ current__view->get_world_up(),
longitude->getDoubleValue()
* SGD_DEGREES_TO_RADIANS,
latitude->getDoubleValue()
// glMatrixMode( GL_PROJECTION );
// glLoadIdentity();
- ssgSetFOV( globals->get_current_view()->get_h_fov(),
- globals->get_current_view()->get_v_fov() );
+ ssgSetFOV( current__view->get_h_fov(),
+ current__view->get_v_fov() );
double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
- scenery.get_cur_elev();
current_model.update(dt_ms);
// $$$ begin - added VS Renganthan 17 Oct 2K
- fgUpdateDCS();
+ if(objc)
+ fgUpdateDCS();
// $$$ end - added VS Renganthan 17 Oct 2K
# ifdef FG_NETWORK_OLK
# endif
// position tile nodes and update range selectors
- global_tile_mgr.prep_ssg_nodes();
+ global_tile_mgr.prep_ssg_nodes(visibility_meters);
if ( fgGetBool("/sim/rendering/skyblend") ) {
// draw the sky backdrop
}
// if in cockpit view adjust nearfar...
- if (globals->get_current_view()->getType() == 0 ) {
+ if (current__view->getType() == 0 ) {
glClearDepth(1);
glClear(GL_DEPTH_BUFFER_BIT);
ssgSetNearFar( cockpit_nearplane, cockpit_farplane );
#endif
// see if we need to load any new scenery tiles
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
global_tile_mgr.update( longitude->getDoubleValue(),
- latitude->getDoubleValue() );
+ latitude->getDoubleValue(), visibility_meters );
// see if we need to load any deferred-load textures
material_lib.load_next_deferred();
// We've finished all our initialization steps, from now on we
// run the main loop.
- fgMainLoop();
+ glutIdleFunc(fgMainLoop);
} else {
if ( fgGetBool("/sim/startup/splash-screen") ) {
fgSplashUpdate(0.0);
}
// for all views
- for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
- globals->get_viewmgr()->get_view(i)->
- set_aspect_ratio((float)view_h / (float)width);
+ FGViewMgr *viewmgr = globals->get_viewmgr();
+ for ( int i = 0; i < viewmgr->size(); ++i ) {
+ viewmgr->get_view(i)->
+ set_aspect_ratio((float)view_h / (float)width);
}
glViewport( 0, (GLint)(height - view_h), (GLint)(width), (GLint)(view_h) );
fgSetInt("/sim/startup/ysize", height);
guiInitMouse(width, height);
- ssgSetFOV( globals->get_current_view()->get_h_fov(),
- globals->get_current_view()->get_v_fov() );
+ ssgSetFOV( viewmgr->get_current_view()->get_h_fov(),
+ viewmgr->get_current_view()->get_v_fov() );
fgHUDReshape();
}
-
// Initialize GLUT and define a main window
int fgGlutInit( int *argc, char **argv ) {
} else {
// Open the cool new 'game mode' window
char game_mode_str[256];
+//#define SYNC_OPENGL_WITH_DESKTOP_SETTINGS
+#if defined(WIN32) && defined(SYNC_OPENGL_WITH_DESKTOP_SETTINGS)
+#ifndef ENUM_CURRENT_SETTINGS
+#define ENUM_CURRENT_SETTINGS ((DWORD)-1)
+#define ENUM_REGISTRY_SETTINGS ((DWORD)-2)
+#endif
+
+ DEVMODE dm;
+ dm.dmSize = sizeof(DEVMODE);
+ EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
+ fgSetInt("/sim/startup/xsize", dm.dmPelsWidth);
+ fgSetInt("/sim/startup/ysize", dm.dmPelsHeight);
+ glutInitWindowSize( fgGetInt("/sim/startup/xsize"),
+ fgGetInt("/sim/startup/ysize") );
+ sprintf( game_mode_str, "%dx%d:%d@%d",
+ dm.dmPelsWidth,
+ dm.dmPelsHeight,
+ dm.dmBitsPerPel,
+ dm.dmDisplayFrequency );
+#else
+ // Open the cool new 'game mode' window
sprintf( game_mode_str, "width=%d height=%d bpp=%d",
fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize"),
fgGetInt("/sim/rendering/bits-per-pixel"));
+#endif // HAVE_WINDOWS_H
SG_LOG( SG_GENERAL, SG_INFO,
"game mode params = " << game_mode_str );
glutGameModeString( game_mode_str );
glutEnterGameMode();
-#endif
+#endif // GLUT_WRONG_VERSION
}
// This seems to be the absolute earliest in the init sequence
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h> //snprintf
-#if defined( _MSC_VER )
+#if defined( _MSC_VER ) || defined(__MINGW32__)
# include <io.h> //lseek, read, write
#endif
SG_USING_STD(string);
-#if defined( _MSC_VER )
+#if defined( _MSC_VER ) || defined(__MINGW32__)
# define snprintf _snprintf
#endif
# error This library requires C++
#endif
+#include <time.h> // time_t
+
const int FG_NET_FDM_VERSION = 5;
// Define a structure containing the top level flight dynamics model
// Update the ssg transform node for this tile so it can be
// properly drawn relative to our (0,0,0) point
-void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
+void FGTileEntry::prep_ssg_node( const Point3D& p, sgVec3 up, float vis) {
if ( !loaded ) return;
SetOffset( p );
#ifdef USE_UP_AND_COMING_PLIB_FEATURE
terra_range->setRange( 0, SG_ZERO );
terra_range->setRange( 1, vis + bounding_radius );
+ if ( gnd_lights_range ) {
gnd_lights_range->setRange( 0, SG_ZERO );
gnd_lights_range->setRange( 1, vis * 1.5 + bounding_radius );
- rwy_lights_range->setRange( 0, SG_ZERO );
- rwy_lights_range->setRange( 1, vis * 1.5 + bounding_radius );
+ }
+ if ( rwy_lights_range ) {
+ rwy_lights_range->setRange( 0, SG_ZERO );
+ rwy_lights_range->setRange( 1, vis * 1.5 + bounding_radius );
+ }
#else
float ranges[2];
ranges[0] = SG_ZERO;
// z-buffer fighting. We do this based on our altitude and
// the distance this tile is away from scenery center.
- sgVec3 up;
- sgCopyVec3( up, globals->get_current_view()->get_world_up() );
+// sgVec3 up;
+// sgCopyVec3( up, globals->get_current_view()->get_world_up() );
double agl;
if ( current_aircraft.fdm_state ) {
// Update the ssg transform node for this tile so it can be
// properly drawn relative to our (0,0,0) point
- void prep_ssg_node( const Point3D& p, float vis);
+ void prep_ssg_node( const Point3D& p, sgVec3 up, float vis);
/**
* Load tile data from a file.
// schedule a needed buckets for loading
-void FGTileMgr::schedule_needed() {
+void FGTileMgr::schedule_needed( double vis) {
// sanity check (unfortunately needed!)
if ( longitude < -180.0 || longitude > 180.0
|| latitude < -90.0 || latitude > 90.0 )
SG_LOG( SG_TERRAIN, SG_INFO,
"scheduling needed tiles for " << longitude << " " << latitude );
- vis = fgGetDouble("/environment/visibility-m");
+// vis = fgGetDouble("/environment/visibility-m");
double tile_width = current_bucket.get_width_m();
double tile_height = current_bucket.get_height_m();
// start with the center tile and work out in concentric
// "rings"
- schedule_needed();
+ double visibility_meters = fgGetDouble("/environment/visibility-m");
+ schedule_needed(visibility_meters);
// do we really want to lose this? CLO
#if 0
// given the current lon/lat (in degrees), fill in the array of local
// chunks. If the chunk isn't already in the cache, then read it from
// disk.
-int FGTileMgr::update( double lon, double lat ) {
+int FGTileMgr::update( double lon, double lat, double visibility_meters ) {
// SG_LOG( SG_TERRAIN, SG_DEBUG, "FGTileMgr::update() for "
// << lon << " " << lat );
if ( !(current_bucket == previous_bucket) ) {
// We've moved to a new bucket, we need to schedule any
// needed tiles for loading.
- schedule_needed();
+ schedule_needed(visibility_meters);
}
} else if ( state == Start || state == Inited ) {
SG_LOG( SG_TERRAIN, SG_INFO, "State == Start || Inited" );
sgdSetVec3( tmp_abs_view_pos, tmp.x(), tmp.y(), tmp.z() );
// cout << "abs_view_pos = " << tmp_abs_view_pos << endl;
- prep_ssg_nodes();
+ prep_ssg_nodes(visibility_meters);
double tmp_elev;
if ( fgCurrentElev(tmp_abs_view_pos, sc, &hit_list,
}
-void FGTileMgr::prep_ssg_nodes() {
- float vis = 0.0;
+void FGTileMgr::prep_ssg_nodes(float vis) {
+// float vis = 0.0;
- vis = fgGetDouble("/environment/visibility-m");
+// vis = fgGetDouble("/environment/visibility-m");
// traverse the potentially viewable tile list and update range
// selector and transform
FGTileEntry *e;
tile_cache.reset_traversal();
+ sgVec3 up;
+ sgCopyVec3( up, globals->get_current_view()->get_world_up() );
+
while ( ! tile_cache.at_end() ) {
// cout << "processing a tile" << endl;
if ( (e = tile_cache.get_current()) ) {
- e->prep_ssg_node( scenery.get_center(), vis);
+ e->prep_ssg_node( scenery.get_center(), up, vis);
} else {
SG_LOG(SG_INPUT, SG_ALERT, "warning ... empty tile in cache");
}
void sched_tile( const SGBucket& b );
// schedule a needed buckets for loading
- void schedule_needed();
+ void schedule_needed(double visibility_meters);
// see comment at prep_ssg_nodes()
void prep_ssg_node( int idx );
// given the current lon/lat (in degrees), fill in the array of
// local chunks. If the chunk isn't already in the cache, then
// read it from disk.
- int update( double lon, double lat );
+ int update( double lon, double lat, double visibility_meters );
// Determine scenery altitude. Normally this just happens when we
// render the scene, but we'd also like to be able to do this
// Prepare the ssg nodes ... for each tile, set it's proper
// transform and update it's range selector based on current
// visibilty
- void prep_ssg_nodes();
+ void prep_ssg_nodes(float visibility_meters);
};