diff --git a/src/Main/main.cxx b/src/Main/main.cxx index f15de3610..67e4aa02c 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -199,6 +199,7 @@ ssgSimpleState *menus; void fgBuildRenderStates( void ) { default_state = new ssgSimpleState; + default_state->ref(); default_state->disable( GL_TEXTURE_2D ); default_state->enable( GL_CULL_FACE ); default_state->enable( GL_COLOR_MATERIAL ); @@ -210,12 +211,14 @@ void fgBuildRenderStates( void ) { default_state->disable( GL_LIGHTING ); hud_and_panel = new ssgSimpleState; + hud_and_panel->ref(); hud_and_panel->disable( GL_CULL_FACE ); hud_and_panel->disable( GL_TEXTURE_2D ); hud_and_panel->disable( GL_LIGHTING ); hud_and_panel->enable( GL_BLEND ); menus = new ssgSimpleState; + menus->ref(); menus->disable( GL_CULL_FACE ); menus->disable( GL_TEXTURE_2D ); menus->enable( GL_BLEND ); diff --git a/src/Objects/newmat.cxx b/src/Objects/newmat.cxx index d9e753986..f6d3ec53a 100644 --- a/src/Objects/newmat.cxx +++ b/src/Objects/newmat.cxx @@ -75,8 +75,12 @@ void FGNewMat::build_ssg_state( const string& path, tex_file.append( texture_name ); state = new ssgStateSelector(2); + textured = new ssgSimpleState(); + textured->ref(); + nontextured = new ssgSimpleState(); + nontextured->ref(); // Set up the textured state textured->setShadeModel( shade_model ); @@ -130,7 +134,9 @@ void FGNewMat::build_ssg_state( const string& path, void FGNewMat::set_ssg_state( ssgSimpleState *s ) { state = new ssgStateSelector(2); textured = s; + nontextured = new ssgSimpleState(); + nontextured->ref(); // Set up the coloured state nontextured->enable( GL_LIGHTING );