diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index 4ccceb468..165a00c1f 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -696,7 +696,7 @@ void guiInit() // Install our fast fonts fntpath.append( "typewriter.txf" ); guiFntHandle = new fntTexFont ; - guiFntHandle -> load ( fntpath.c_str() ) ; + guiFntHandle -> load ( (char *)fntpath.c_str() ) ; puFont GuiFont ( guiFntHandle, 15 ) ; puSetDefaultFonts( GuiFont, GuiFont ) ; guiFnt = puGetDefaultLabelFont(); diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index 604871337..a6492a22b 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -4,7 +4,7 @@ else SERIAL_LIBS = endif -CPPFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\" +CPPFLAGS += -DUSE_SSG -DPKGLIBDIR=\"$(pkglibdir)\" EXTRA_DIST = 3dfx.sh runfgfs.in runfgfs.bat.in diff --git a/src/Main/main.cxx b/src/Main/main.cxx index c26b29d76..0f8b6a544 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -182,8 +182,6 @@ static void fgInitVisuals( void ) { // xglFogi (GL_FOG_MODE, GL_LINEAR); xglFogi (GL_FOG_MODE, GL_EXP2); - // Fog density is now set when the weather system is initialized - // xglFogf (GL_FOG_DENSITY, w->fog_density); if ( (current_options.get_fog() == 1) || (current_options.get_shading() == 0) ) { // if fastest fog requested, or if flat shading force fastest @@ -354,11 +352,12 @@ static void fgRenderFrame( void ) { xglEnable( GL_DEPTH_TEST ); if ( current_options.get_fog() > 0 ) { xglEnable( GL_FOG ); - xglFogfv (GL_FOG_COLOR, l->adj_fog_color); + xglFogi( GL_FOG_MODE, GL_EXP2 ); + xglFogfv( GL_FOG_COLOR, l->adj_fog_color ); } // set lighting parameters - xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); - xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); + xglLightfv( GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); + xglLightfv( GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); // xglLightfv(GL_LIGHT0, GL_SPECULAR, white ); if ( current_options.get_textures() ) { @@ -383,12 +382,25 @@ static void fgRenderFrame( void ) { // ssg test - xglMatrixMode(GL_PROJECTION); + xglMatrixMode( GL_PROJECTION ); xglLoadIdentity(); - ssgSetFOV(60.0f, 0.0f); - ssgSetNearFar(10.0f, 14000.0f); - sgMat4 sgTRANS; + ssgSetFOV( current_options.get_fov(), 0.0f ); + double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER + - scenery.cur_elev; + + FG_LOG( FG_ALL, FG_INFO, "visibility is " + << current_weather.get_visibility() ); + + if ( agl > 10.0 ) { + // ssgSetNearFar( 10.0f, current_weather.get_visibility() ); + ssgSetNearFar( 10.0f, 100000.0f ); + } else { + // ssgSetNearFar( 0.5f, current_weather.get_visibility() ); + ssgSetNearFar( 0.5f, 100000.0f ); + } + + sgMat4 sgTRANS; sgMakeTransMat4( sgTRANS, current_view.view_pos.x() + current_view.view_forward[0] * 20, diff --git a/src/Main/views.cxx b/src/Main/views.cxx index b8cd9ce60..c6f6eba4f 100644 --- a/src/Main/views.cxx +++ b/src/Main/views.cxx @@ -239,10 +239,10 @@ void FGView::UpdateViewParams( void ) { xglMatrixMode(GL_PROJECTION); xglLoadIdentity(); if ( f->get_Altitude() * FEET_TO_METER - scenery.cur_elev > 10.0 ) { - ssgSetNearFar( 10.0, 100000.0 ); + // ssgSetNearFar( 10.0, 100000.0 ); gluPerspective(current_options.get_fov(), win_ratio, 10.0, 100000.0); } else { - ssgSetNearFar( 0.5, 100000.0 ); + // ssgSetNearFar( 0.5, 100000.0 ); gluPerspective(current_options.get_fov(), win_ratio, 0.5, 100000.0); // printf("Near ground, minimizing near clip plane\n"); } @@ -378,7 +378,6 @@ void FGView::UpdateViewParams( void ) { xglLoadMatrixf( m ); } #endif // FG_VIEW_INLINE_OPTIMIZATIONS - panel_hist = current_options.get_panel_status(); } diff --git a/src/Scenery/tilecache.cxx b/src/Scenery/tilecache.cxx index 234abf1dd..188aa3e8d 100644 --- a/src/Scenery/tilecache.cxx +++ b/src/Scenery/tilecache.cxx @@ -161,7 +161,7 @@ FGTileCache::fill_in( int index, const FGBucket& p ) void FGTileCache::entry_free( int index ) { - tile_cache[index].release_fragments(); + tile_cache[index].free_tile(); } diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index d90f465f2..3c66667d5 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -55,17 +55,57 @@ FGTileEntry::~FGTileEntry ( void ) { } -// Step through the fragment list, deleting the display list, then -// the fragment, until the list is empty. +// Step through the fragment list, deleting the display list, then the +// fragment, until the list is empty. Also delete the arrays used by +// ssg as well as the whole ssg branch void -FGTileEntry::release_fragments() +FGTileEntry::free_tile() { FG_LOG( FG_TERRAIN, FG_DEBUG, "FREEING TILE = (" << tile_bucket << ")" ); + + // mark tile unused + mark_unused(); + + // delete fragment list for_each( begin(), end(), mem_fun_ref( &fgFRAGMENT::deleteDisplayList )); fragment_list.erase( begin(), end() ); - mark_unused(); + + // delete the ssg used structures + delete vtlist; + delete vnlist; + delete tclist; + + // delete the ssg branch + + // make sure we have a sane number of parents + int pcount = branch_ptr->getNumParents(); + if ( pcount > 0 ) { + // find the first parent (should only be one) + ssgBranch *parent = branch_ptr->getParent( 0 ) ; + // find the number of kids this parent has + int kcount = parent->getNumKids(); + // find the kid that matches our original branch_ptr + bool found_kid = false; + for ( int i = 0; i < kcount; ++i ) { + ssgEntity *kid = parent->getKid( i ); + if ( kid == branch_ptr ) { + FG_LOG( FG_TERRAIN, FG_INFO, + "Found a kid to delete " << kid); + found_kid = true; + } + } + if ( ! found_kid ) { + FG_LOG( FG_TERRAIN, FG_ALERT, + "Couldn't find the kid to delete! Dying" ); + exit(-1); + } + } else { + FG_LOG( FG_TERRAIN, FG_ALERT, + "Parent count is zero for an ssg tile! Dying" ); + exit(-1); + } } diff --git a/src/Scenery/tileentry.hxx b/src/Scenery/tileentry.hxx index 719536110..1a80f53c7 100644 --- a/src/Scenery/tileentry.hxx +++ b/src/Scenery/tileentry.hxx @@ -136,8 +136,9 @@ public: } // Step through the fragment list, deleting the display list, then - // the fragment, until the list is empty. - void release_fragments(); + // the fragment, until the list is empty. Also delete the arrays + // used by ssg as well as the whole ssg branch + void free_tile(); // Calculate this tile's offset void SetOffset( const Point3D& off) diff --git a/src/Weather/weather.hxx b/src/Weather/weather.hxx index 228967936..355a1a20d 100644 --- a/src/Weather/weather.hxx +++ b/src/Weather/weather.hxx @@ -45,6 +45,7 @@ public: inline double get_visibility() const { return visibility; } inline void set_visibility( double v ) { + xglMatrixMode(GL_MODELVIEW); // in meters visibility = v; @@ -56,8 +57,11 @@ public: // Set correct opengl fog density xglFogf (GL_FOG_DENSITY, fog_exp2_density); + xglFogi( GL_FOG_MODE, GL_EXP2 ); - // FG_LOG( FG_INPUT, FG_DEBUG, "Fog density = " << w->fog_density ); + // FG_LOG( FG_INPUT, FG_DEBUG, "Fog density = " << fog_density ); + FG_LOG( FG_INPUT, FG_INFO, + "Fog exp2 density = " << fog_exp2_density ); } };