From aa27214f65bbb35055863d579fd303ec9ce5ff41 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 28 Jun 1999 05:47:02 +0000 Subject: [PATCH] Additional tweaks to fix the ssg texture (state) problems. Tweaked near and far clip planes. Adjusted rendering order so menus and hud get drawn last. --- src/Main/main.cxx | 30 +++++++++++++++--------------- src/Objects/material.hxx | 1 + src/Objects/materialmgr.cxx | 29 ++++++++++++++++------------- src/Objects/materialmgr.hxx | 6 +++--- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 830abc001..8e06130c8 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -381,26 +381,12 @@ static void fgRenderFrame( void ) { global_tile_mgr.render(); - xglDisable( GL_TEXTURE_2D ); - xglDisable( GL_FOG ); - - // display HUD && Panel - xglDisable( GL_CULL_FACE ); - fgCockpitUpdate(); - - // We can do translucent menus, so why not. :-) - xglEnable ( GL_BLEND ) ; - xglBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; - puDisplay(); - xglDisable ( GL_BLEND ) ; - xglEnable( GL_FOG ); - // ssg test xglMatrixMode(GL_PROJECTION); xglLoadIdentity(); ssgSetFOV(60.0f, 0.0f); - ssgSetNearFar(1.0f, 14000.0f); + ssgSetNearFar(10.0f, 14000.0f); sgMat4 sgTRANS; sgMakeTransMat4( sgTRANS, @@ -430,6 +416,20 @@ static void fgRenderFrame( void ) { // ssgSetCamera( current_view.sgVIEW ); ssgCullAndDraw( scene ); + xglDisable( GL_TEXTURE_2D ); + xglDisable( GL_FOG ); + + // display HUD && Panel + xglDisable( GL_CULL_FACE ); + fgCockpitUpdate(); + + // We can do translucent menus, so why not. :-) + xglEnable ( GL_BLEND ) ; + xglBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; + puDisplay(); + xglDisable ( GL_BLEND ) ; + xglEnable( GL_FOG ); + } xglutSwapBuffers(); diff --git a/src/Objects/material.hxx b/src/Objects/material.hxx index fff6695e1..ac103440f 100644 --- a/src/Objects/material.hxx +++ b/src/Objects/material.hxx @@ -88,6 +88,7 @@ public: inline bool is_loaded() const { return loaded; } inline GLuint get_texture_id() const { return texture_id; } + inline string get_texture_name() const { return texture_name; } inline double get_xsize() const { return xsize; } inline double get_ysize() const { return ysize; } inline GLfloat *get_ambient() { return ambient; } diff --git a/src/Objects/materialmgr.cxx b/src/Objects/materialmgr.cxx index 790b2b273..ece3f4d65 100644 --- a/src/Objects/materialmgr.cxx +++ b/src/Objects/materialmgr.cxx @@ -88,15 +88,6 @@ FGMaterialSlot::render_fragments() if ( !m.is_loaded() ) { m.load_texture( current_options.get_fg_root() ); - - // build the ssgSimpleState - GLuint tex_id = m.get_texture_id(); - state.setTexture( tex_id ); - state.enable( GL_TEXTURE_2D ); - state.enable( GL_LIGHTING ); - state.setShadeModel( GL_SMOOTH ); - state.enable ( GL_CULL_FACE ) ; - state.setMaterial ( GL_AMBIENT_AND_DIFFUSE, 1, 1, 1, 1 ) ; } #ifdef GL_VERSION_1_1 @@ -167,12 +158,24 @@ fgMATERIAL_MGR::load_lib ( void ) FGMaterial m; in >> m; - // if ( current_options.get_textures() ) { - // m.load_texture( current_options.get_fg_root() ); - // } - FGMaterialSlot m_slot; m_slot.set_m( m ); + + // build the ssgSimpleState + FGPath tex_file( current_options.get_fg_root() ); + tex_file.append( "Textures" ); + tex_file.append( m.get_texture_name() ); + tex_file.concat( ".rgb" ); + + ssgSimpleState *state = new ssgSimpleState; + state->setTexture( tex_file.c_str() ); + state->enable( GL_TEXTURE_2D ); + state->enable( GL_LIGHTING ); + state->setShadeModel( GL_SMOOTH ); + state->enable ( GL_CULL_FACE ) ; + state->setMaterial ( GL_AMBIENT_AND_DIFFUSE, 1, 1, 1, 1 ) ; + m_slot.set_state( state ); + material_mgr.material_map[material_name] = m_slot; } } diff --git a/src/Objects/materialmgr.hxx b/src/Objects/materialmgr.hxx index 299608dbf..34865eed2 100644 --- a/src/Objects/materialmgr.hxx +++ b/src/Objects/materialmgr.hxx @@ -83,7 +83,7 @@ private: // size_t list_size; // ssg stage structure - ssgSimpleState state; + ssgSimpleState *state; bool state_valid; public: @@ -115,8 +115,8 @@ public: inline void set_m( FGMaterial new_m ) { m = new_m; } // ssg state - inline ssgSimpleState *get_state() { return &state; } - inline void set_state( ssgSimpleState s ) { state = s; } + inline ssgSimpleState *get_state() { return state; } + inline void set_state( ssgSimpleState *s ) { state = s; } inline bool get_state_valid() const { return state_valid; } inline void set_state_valid( bool flag ) { state_valid = flag; } };