1
0
Fork 0

Patches from Norm Vine to improve framerate and add a new

#ifdef'ed-out mode for syncing fullscreen with user settings in
Windows.
This commit is contained in:
david 2002-04-07 15:24:32 +00:00
parent 50c13f7972
commit 6e5d22789b
11 changed files with 89 additions and 44 deletions

View file

@ -100,8 +100,10 @@ void AptDialog_OK (puObject *)
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.";

View file

@ -88,8 +88,9 @@ void reInit(puObject *cb)
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();

View file

@ -307,8 +307,10 @@ do_tile_cache_reload (const SGPropertyNode * arg, SGCommandState ** state)
// 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!" );

View file

@ -712,8 +712,11 @@ bool fgInitSubsystems( void ) {
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);

View file

@ -419,6 +419,8 @@ void fgRenderFrame( void ) {
// Update the default (kludged) properties.
fgUpdateProps();
FGViewer *current__view = globals->get_current_view();
fgLIGHT *l = &cur_light_params;
static double last_visibility = -9999;
@ -492,13 +494,14 @@ void fgRenderFrame( void ) {
// 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") )
@ -544,9 +547,9 @@ void fgRenderFrame( void ) {
<< " 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()
@ -591,8 +594,8 @@ void fgRenderFrame( void ) {
// 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();
@ -614,7 +617,8 @@ void fgRenderFrame( void ) {
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
@ -639,7 +643,7 @@ void fgRenderFrame( void ) {
# 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
@ -724,7 +728,7 @@ void fgRenderFrame( void ) {
}
// 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 );
@ -1088,8 +1092,9 @@ static void fgMainLoop( void ) {
#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();
@ -1216,7 +1221,7 @@ static void fgIdleFunction ( void ) {
// 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);
@ -1238,9 +1243,10 @@ void fgReshape( int width, int height ) {
}
// 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) );
@ -1249,13 +1255,12 @@ void fgReshape( int width, int height ) {
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 ) {
@ -1284,16 +1289,38 @@ 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

View file

@ -32,7 +32,7 @@
#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
@ -52,7 +52,7 @@
SG_USING_STD(string);
#if defined( _MSC_VER )
#if defined( _MSC_VER ) || defined(__MINGW32__)
# define snprintf _snprintf
#endif

View file

@ -30,6 +30,8 @@
# 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

View file

@ -750,7 +750,7 @@ void FGTileEntry::free_tile() {
// 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 );
@ -759,10 +759,14 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
#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;
@ -786,8 +790,8 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
// 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 ) {

View file

@ -224,7 +224,7 @@ public:
// 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.

View file

@ -150,7 +150,7 @@ void FGTileMgr::sched_tile( const SGBucket& b ) {
// 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 )
@ -165,7 +165,7 @@ void FGTileMgr::schedule_needed() {
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();
@ -227,7 +227,8 @@ void FGTileMgr::initialize_queue()
// 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
@ -251,7 +252,7 @@ void FGTileMgr::initialize_queue()
// 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 );
@ -276,7 +277,7 @@ int FGTileMgr::update( double lon, double 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" );
@ -360,7 +361,7 @@ int FGTileMgr::update( double lon, double lat ) {
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,
@ -431,10 +432,10 @@ int FGTileMgr::update( double lon, double lat ) {
}
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
@ -442,10 +443,13 @@ void FGTileMgr::prep_ssg_nodes() {
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");
}

View file

@ -78,7 +78,7 @@ private:
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 );
@ -162,7 +162,7 @@ public:
// 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
@ -178,7 +178,7 @@ public:
// 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);
};