1
0
Fork 0

Rendering tweaks.

This commit is contained in:
curt 2000-03-17 06:16:15 +00:00
parent 314a1dd9dd
commit a9f48c0dac
6 changed files with 80 additions and 65 deletions

View file

@ -528,7 +528,10 @@ FGPanel::Update () const
// Draw the background // Draw the background
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glColor3f(1.0, 1.0, 1.0); glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glEnable(GL_COLOR_MATERIAL);
glColor4f(1.0, 1.0, 1.0, 1.0);
glBindTexture(GL_TEXTURE_2D, _bg->getHandle()); glBindTexture(GL_TEXTURE_2D, _bg->getHandle());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@ -813,6 +816,7 @@ FGCharInstrumentLayer::FGCharInstrumentLayer (text_func func,
_renderer.setFont(guiFntHandle); _renderer.setFont(guiFntHandle);
_renderer.setPointSize(14); _renderer.setPointSize(14);
_color[0] = _color[1] = _color[2] = 0.0; _color[0] = _color[1] = _color[2] = 0.0;
_color[3] = 1.0;
} }
FGCharInstrumentLayer::~FGCharInstrumentLayer () FGCharInstrumentLayer::~FGCharInstrumentLayer ()
@ -823,13 +827,13 @@ void
FGCharInstrumentLayer::draw () const FGCharInstrumentLayer::draw () const
{ {
glPushMatrix(); glPushMatrix();
glColor3fv(_color); glColor4fv(_color);
transform(); transform();
_renderer.begin(); _renderer.begin();
_renderer.start3f(0, 0, 0); _renderer.start3f(0, 0, 0);
_renderer.puts((*_func)(_buf)); _renderer.puts((*_func)(_buf));
_renderer.end(); _renderer.end();
glColor3f(1.0, 1.0, 1.0); // FIXME glColor4f(1.0, 1.0, 1.0, 1.0); // FIXME
glPopMatrix(); glPopMatrix();
} }
@ -839,6 +843,7 @@ FGCharInstrumentLayer::setColor (float r, float g, float b)
_color[0] = r; _color[0] = r;
_color[1] = g; _color[1] = g;
_color[2] = b; _color[2] = b;
_color[3] = 1.0;
} }
void void

View file

@ -246,7 +246,7 @@ public:
private: private:
text_func _func; text_func _func;
float _color[3]; float _color[4];
// FIXME: need only one globally // FIXME: need only one globally
mutable fntRenderer _renderer; mutable fntRenderer _renderer;
mutable char _buf[1024]; mutable char _buf[1024];

View file

@ -228,37 +228,37 @@ void fgInitVisuals( void ) {
// If enabled, normal vectors specified with glNormal are scaled // If enabled, normal vectors specified with glNormal are scaled
// to unit length after transformation. See glNormal. // to unit length after transformation. See glNormal.
// xglEnable( GL_NORMALIZE ); // glEnable( GL_NORMALIZE );
xglEnable( GL_LIGHTING ); glEnable( GL_LIGHTING );
xglEnable( GL_LIGHT0 ); glEnable( GL_LIGHT0 );
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
sgVec3 sunpos; sgVec3 sunpos;
sgSetVec3( sunpos, l->sun_vec[0], l->sun_vec[1], l->sun_vec[2] ); sgSetVec3( sunpos, l->sun_vec[0], l->sun_vec[1], l->sun_vec[2] );
ssgGetLight( 0 ) -> setPosition( sunpos ); ssgGetLight( 0 ) -> setPosition( sunpos );
// xglFogi (GL_FOG_MODE, GL_LINEAR); // glFogi (GL_FOG_MODE, GL_LINEAR);
xglFogi (GL_FOG_MODE, GL_EXP2); glFogi (GL_FOG_MODE, GL_EXP2);
if ( (current_options.get_fog() == 1) || if ( (current_options.get_fog() == 1) ||
(current_options.get_shading() == 0) ) { (current_options.get_shading() == 0) ) {
// if fastest fog requested, or if flat shading force fastest // if fastest fog requested, or if flat shading force fastest
xglHint ( GL_FOG_HINT, GL_FASTEST ); glHint ( GL_FOG_HINT, GL_FASTEST );
} else if ( current_options.get_fog() == 2 ) { } else if ( current_options.get_fog() == 2 ) {
xglHint ( GL_FOG_HINT, GL_NICEST ); glHint ( GL_FOG_HINT, GL_NICEST );
} }
if ( current_options.get_wireframe() ) { if ( current_options.get_wireframe() ) {
// draw wire frame // draw wire frame
xglPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
} }
// This is the default anyways, but it can't hurt // This is the default anyways, but it can't hurt
xglFrontFace ( GL_CCW ); glFrontFace ( GL_CCW );
// Just testing ... // Just testing ...
// xglEnable(GL_POINT_SMOOTH); // glEnable(GL_POINT_SMOOTH);
// xglEnable(GL_LINE_SMOOTH); // glEnable(GL_LINE_SMOOTH);
// xglEnable(GL_POLYGON_SMOOTH); // glEnable(GL_POLYGON_SMOOTH);
} }
@ -305,7 +305,7 @@ void fgRenderFrame( void ) {
current_view.UpdateViewParams(cur_view_fdm); current_view.UpdateViewParams(cur_view_fdm);
// set the sun position // set the sun position
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
clear_mask = GL_DEPTH_BUFFER_BIT; clear_mask = GL_DEPTH_BUFFER_BIT;
if ( current_options.get_wireframe() ) { if ( current_options.get_wireframe() ) {
@ -325,7 +325,7 @@ void fgRenderFrame( void ) {
l->sky_color[2], l->sky_color[3]); l->sky_color[2], l->sky_color[3]);
clear_mask |= GL_COLOR_BUFFER_BIT; clear_mask |= GL_COLOR_BUFFER_BIT;
} }
xglClear( clear_mask ); glClear( clear_mask );
// Tell GL we are switching to model view parameters // Tell GL we are switching to model view parameters
@ -333,8 +333,8 @@ void fgRenderFrame( void ) {
// back or something so that I can draw the sky within the // back or something so that I can draw the sky within the
// ssgCullandDraw() function, but for now I just mimic what // ssgCullandDraw() function, but for now I just mimic what
// ssg does to set up the model view matrix // ssg does to set up the model view matrix
xglMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
xglLoadIdentity(); glLoadIdentity();
ssgSetCamera( current_view.VIEW ); ssgSetCamera( current_view.VIEW );
/* /*
@ -342,7 +342,7 @@ void fgRenderFrame( void ) {
sgTransposeNegateMat4 ( vm_tmp, current_view.VIEW ) ; sgTransposeNegateMat4 ( vm_tmp, current_view.VIEW ) ;
sgCopyMat4( view_mat, copy_of_ssgOpenGLAxisSwapMatrix ) ; sgCopyMat4( view_mat, copy_of_ssgOpenGLAxisSwapMatrix ) ;
sgPreMultMat4( view_mat, vm_tmp ) ; sgPreMultMat4( view_mat, vm_tmp ) ;
xglLoadMatrixf( (float *)view_mat ); glLoadMatrixf( (float *)view_mat );
*/ */
// set the opengl state to known default values // set the opengl state to known default values
@ -376,7 +376,7 @@ void fgRenderFrame( void ) {
<< " moon_angle = " << cur_light_params.moon_angle << " moon_angle = " << cur_light_params.moon_angle
<< endl; */ << endl; */
thesky->repaint( cur_light_params.sky_color, thesky->repaint( cur_light_params.sky_color,
cur_light_params.fog_color, cur_light_params.adj_fog_color,
cur_light_params.sun_angle, cur_light_params.sun_angle,
cur_light_params.moon_angle, cur_light_params.moon_angle,
ephem->getNumPlanets(), ephem->getPlanets(), ephem->getNumPlanets(), ephem->getPlanets(),
@ -406,11 +406,11 @@ void fgRenderFrame( void ) {
ephem->getMoonDeclination(), 50000.0 ); ephem->getMoonDeclination(), 50000.0 );
} }
xglEnable( GL_DEPTH_TEST ); glEnable( GL_DEPTH_TEST );
if ( current_options.get_fog() > 0 ) { if ( current_options.get_fog() > 0 ) {
xglEnable( GL_FOG ); glEnable( GL_FOG );
xglFogi( GL_FOG_MODE, GL_EXP2 ); glFogi( GL_FOG_MODE, GL_EXP2 );
xglFogfv( GL_FOG_COLOR, l->adj_fog_color ); glFogfv( GL_FOG_COLOR, l->adj_fog_color );
} }
// update fog params if visibility has changed // update fog params if visibility has changed
@ -502,30 +502,30 @@ void fgRenderFrame( void ) {
fog_exp2_density = sqrt( -log(0.01) ) / actual_visibility; fog_exp2_density = sqrt( -log(0.01) ) / actual_visibility;
// Set correct opengl fog density // Set correct opengl fog density
xglFogf (GL_FOG_DENSITY, fog_exp2_density); glFogf (GL_FOG_DENSITY, fog_exp2_density);
} }
// set lighting parameters // set lighting parameters
xglLightfv( GL_LIGHT0, GL_AMBIENT, l->scene_ambient ); glLightfv( GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
xglLightfv( GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse ); glLightfv( GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
// xglLightfv(GL_LIGHT0, GL_SPECULAR, white ); // glLightfv(GL_LIGHT0, GL_SPECULAR, white );
// texture parameters // texture parameters
// xglEnable( GL_TEXTURE_2D ); // glEnable( GL_TEXTURE_2D );
xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ; glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
xglHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ; glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ) ;
// set base color (I don't think this is doing anything here) // set base color (I don't think this is doing anything here)
// xglMaterialfv (GL_FRONT, GL_AMBIENT, white); // glMaterialfv (GL_FRONT, GL_AMBIENT, white);
// (GL_FRONT, GL_DIFFUSE, white); // (GL_FRONT, GL_DIFFUSE, white);
// xglMaterialfv (GL_FRONT, GL_SPECULAR, white); // glMaterialfv (GL_FRONT, GL_SPECULAR, white);
// xglMaterialfv (GL_FRONT, GL_SHININESS, mat_shininess); // glMaterialfv (GL_FRONT, GL_SHININESS, mat_shininess);
sgVec3 sunpos; sgVec3 sunpos;
sgSetVec3( sunpos, l->sun_vec[0], l->sun_vec[1], l->sun_vec[2] ); sgSetVec3( sunpos, l->sun_vec[0], l->sun_vec[1], l->sun_vec[2] );
ssgGetLight( 0 ) -> setPosition( sunpos ); ssgGetLight( 0 ) -> setPosition( sunpos );
// xglMatrixMode( GL_PROJECTION ); // glMatrixMode( GL_PROJECTION );
// xglLoadIdentity(); // glLoadIdentity();
float fov = current_options.get_fov(); float fov = current_options.get_fov();
ssgSetFOV(fov * current_view.get_win_ratio(), fov); ssgSetFOV(fov * current_view.get_win_ratio(), fov);
@ -617,24 +617,24 @@ void fgRenderFrame( void ) {
// display HUD && Panel // display HUD && Panel
xglDisable( GL_FOG ); glDisable( GL_FOG );
xglDisable( GL_DEPTH_TEST ); glDisable( GL_DEPTH_TEST );
// xglDisable( GL_CULL_FACE ); // glDisable( GL_CULL_FACE );
// xglDisable( GL_TEXTURE_2D ); // glDisable( GL_TEXTURE_2D );
hud_and_panel->apply(); hud_and_panel->apply();
fgCockpitUpdate(); fgCockpitUpdate();
// We can do translucent menus, so why not. :-) // We can do translucent menus, so why not. :-)
// xglEnable ( GL_BLEND ) ; // glEnable ( GL_BLEND ) ;
menus->apply(); menus->apply();
xglBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
puDisplay(); puDisplay();
// xglDisable ( GL_BLEND ) ; // glDisable ( GL_BLEND ) ;
// xglEnable( GL_FOG ); // glEnable( GL_FOG );
} }
xglutSwapBuffers(); glutSwapBuffers();
} }
@ -1123,11 +1123,11 @@ static void fgIdleFunction ( void ) {
void fgReshape( int width, int height ) { void fgReshape( int width, int height ) {
if ( ! current_options.get_panel_status() ) { if ( ! current_options.get_panel_status() ) {
current_view.set_win_ratio( (GLfloat) width / (GLfloat) height ); current_view.set_win_ratio( (GLfloat) width / (GLfloat) height );
xglViewport(0, 0 , (GLint)(width), (GLint)(height) ); glViewport(0, 0 , (GLint)(width), (GLint)(height) );
} else { } else {
current_view.set_win_ratio( (GLfloat) width / current_view.set_win_ratio( (GLfloat) width /
((GLfloat) (height)*0.4232) ); ((GLfloat) (height)*0.4232) );
xglViewport(0, (GLint)((height)*0.5768), (GLint)(width), glViewport(0, (GLint)((height)*0.5768), (GLint)(width),
(GLint)((height)*0.4232) ); (GLint)((height)*0.4232) );
} }
@ -1162,23 +1162,23 @@ int fgGlutInit( int *argc, char **argv ) {
#if !defined( MACOS ) #if !defined( MACOS )
// GLUT will extract all glut specific options so later on we only // GLUT will extract all glut specific options so later on we only
// need wory about our own. // need wory about our own.
xglutInit(argc, argv); glutInit(argc, argv);
#endif #endif
// Define Display Parameters // Define Display Parameters
xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
FG_LOG( FG_GENERAL, FG_INFO, "Opening a window: " << FG_LOG( FG_GENERAL, FG_INFO, "Opening a window: " <<
current_options.get_xsize() << "x" << current_options.get_ysize() ); current_options.get_xsize() << "x" << current_options.get_ysize() );
// Define initial window size // Define initial window size
xglutInitWindowSize( current_options.get_xsize(), glutInitWindowSize( current_options.get_xsize(),
current_options.get_ysize() ); current_options.get_ysize() );
// Initialize windows // Initialize windows
if ( current_options.get_game_mode() == 0 ) { if ( current_options.get_game_mode() == 0 ) {
// Open the regular window // Open the regular window
xglutCreateWindow("Flight Gear"); glutCreateWindow("Flight Gear");
#ifndef GLUT_WRONG_VERSION #ifndef GLUT_WRONG_VERSION
} else { } else {
// Open the cool new 'game mode' window // Open the cool new 'game mode' window
@ -1246,10 +1246,10 @@ int fgGlutInit( int *argc, char **argv ) {
// Initialize GLUT event handlers // Initialize GLUT event handlers
int fgGlutInitEvents( void ) { int fgGlutInitEvents( void ) {
// call fgReshape() on window resizes // call fgReshape() on window resizes
xglutReshapeFunc( fgReshape ); glutReshapeFunc( fgReshape );
// call GLUTkey() on keyboard event // call GLUTkey() on keyboard event
xglutKeyboardFunc( GLUTkey ); glutKeyboardFunc( GLUTkey );
glutSpecialFunc( GLUTspecialkey ); glutSpecialFunc( GLUTspecialkey );
// call guiMouseFunc() whenever our little rodent is used // call guiMouseFunc() whenever our little rodent is used
@ -1259,10 +1259,10 @@ int fgGlutInitEvents( void ) {
// call fgMainLoop() whenever there is // call fgMainLoop() whenever there is
// nothing else to do // nothing else to do
xglutIdleFunc( fgIdleFunction ); glutIdleFunc( fgIdleFunction );
// draw the scene // draw the scene
xglutDisplayFunc( fgRenderFrame ); glutDisplayFunc( fgRenderFrame );
return(1); return(1);
} }

View file

@ -202,9 +202,9 @@ fgMATERIAL_MGR::load_lib ( void )
textured->disable( GL_BLEND ); textured->disable( GL_BLEND );
textured->disable( GL_ALPHA_TEST ); textured->disable( GL_ALPHA_TEST );
textured->setTexture( (char *)tex_file.c_str() ); textured->setTexture( (char *)tex_file.c_str() );
textured->setMaterial ( GL_AMBIENT_AND_DIFFUSE, 1, 1, 1, 1 ) ; textured->enable( GL_COLOR_MATERIAL );
textured->setMaterial ( GL_SPECULAR, 0, 0, 0, 0 ) ; textured->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
textured->setMaterial ( GL_EMISSION, 0, 0, 0, 0 ) ; textured->setMaterial( GL_SPECULAR, 0.0, 0.0, 0.0, 1.0 );
// Set up the coloured state // Set up the coloured state
nontextured->enable( GL_LIGHTING ); nontextured->enable( GL_LIGHTING );

View file

@ -229,6 +229,11 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
ssgVertexArray *vl = new ssgVertexArray( 4 ); ssgVertexArray *vl = new ssgVertexArray( 4 );
ssgNormalArray *nl = new ssgNormalArray( 4 ); ssgNormalArray *nl = new ssgNormalArray( 4 );
ssgTexCoordArray *tl = new ssgTexCoordArray( 4 ); ssgTexCoordArray *tl = new ssgTexCoordArray( 4 );
ssgColourArray *cl = new ssgColourArray( 1 );
sgVec4 color;
sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
cl->add( color );
// sgVec3 *vtlist = new sgVec3 [ 4 ]; // sgVec3 *vtlist = new sgVec3 [ 4 ];
// t->vec3_ptrs.push_back( vtlist ); // t->vec3_ptrs.push_back( vtlist );
@ -253,7 +258,7 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
} }
ssgLeaf *leaf = ssgLeaf *leaf =
new ssgVtxTable ( GL_TRIANGLE_FAN, vl, nl, tl, NULL ); new ssgVtxTable ( GL_TRIANGLE_FAN, vl, nl, tl, cl );
leaf->setState( state ); leaf->setState( state );
@ -756,6 +761,11 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) {
ssgVertexArray *vl = new ssgVertexArray( size ); ssgVertexArray *vl = new ssgVertexArray( size );
ssgNormalArray *nl = new ssgNormalArray( size ); ssgNormalArray *nl = new ssgNormalArray( size );
ssgTexCoordArray *tl = new ssgTexCoordArray( size ); ssgTexCoordArray *tl = new ssgTexCoordArray( size );
ssgColourArray *cl = new ssgColourArray( 1 );
sgVec4 color;
sgSetVec4( color, 1.0, 1.0, 1.0, 1.0 );
cl->add( color );
sgVec2 tmp2; sgVec2 tmp2;
sgVec3 tmp3; sgVec3 tmp3;
@ -774,11 +784,11 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) {
if ( token == "tf" ) { if ( token == "tf" ) {
// triangle fan // triangle fan
leaf = leaf =
new ssgVtxTable ( GL_TRIANGLE_FAN, vl, nl, tl, NULL ); new ssgVtxTable ( GL_TRIANGLE_FAN, vl, nl, tl, cl );
} else { } else {
// triangle strip // triangle strip
leaf = leaf =
new ssgVtxTable ( GL_TRIANGLE_STRIP, vl, nl, tl, NULL ); new ssgVtxTable ( GL_TRIANGLE_STRIP, vl, nl, tl, cl );
} }
// leaf->makeDList(); // leaf->makeDList();
leaf->setState( state ); leaf->setState( state );

View file

@ -117,7 +117,7 @@ void fgLIGHT::Update( void ) {
// calculate lighting parameters based on sun's relative angle to // calculate lighting parameters based on sun's relative angle to
// local up // local up
deg = sun_angle * 180.0 / FG_PI; deg = sun_angle * RAD_TO_DEG;
FG_LOG( FG_EVENT, FG_INFO, " Sun angle = " << deg ); FG_LOG( FG_EVENT, FG_INFO, " Sun angle = " << deg );
ambient = ambient_tbl->interpolate( deg ); ambient = ambient_tbl->interpolate( deg );