From 7aa4f0ccdbbf0851916891b3402eaa2fde6b45b4 Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 2 Apr 2004 14:39:42 +0000 Subject: [PATCH] Frederic Bouvier: Move the rendering stage for upper clouds from preDraw to drawUpperClouds. Rename postDraw to drawLowerClouds. --- simgear/scene/sky/sky.cxx | 21 +++++++++++---------- simgear/scene/sky/sky.hxx | 38 +++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index fe6bb0ed..e95a7302 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -168,15 +168,9 @@ bool SGSky::reposition( SGSkyState &st, double dt ) // draw background portions of the sky ... do this before you draw the // rest of your scene. -void SGSky::preDraw( float alt, float fog_exp2_density ) { +void SGSky::preDraw( float alt ) { ssgCullAndDraw( pre_root ); - // FIXME: This should not be needed, but at this time (08/15/2003) - // certain NVidia drivers don't seem to implement - // glPushAttrib(FG_FOG_BIT) properly. The result is that - // there is not fog when looking at the sun. - glFogf ( GL_FOG_DENSITY, fog_exp2_density ); - // if we are closer than this to a cloud layer, don't draw clouds static const float slop = 5.0; int i; @@ -206,9 +200,17 @@ void SGSky::preDraw( float alt, float fog_exp2_density ) { { ++cur_layer_pos; } +} + +void SGSky::drawUpperClouds( float fog_exp2_density ) { + // FIXME: This should not be needed, but at this time (08/15/2003) + // certain NVidia drivers don't seem to implement + // glPushAttrib(FG_FOG_BIT) properly. The result is that + // there is not fog when looking at the sun. + glFogf ( GL_FOG_DENSITY, fog_exp2_density ); // draw the cloud layers that are above us, top to bottom - for ( i = (int)cloud_layers.size() - 1; i >= cur_layer_pos; --i ) { + for ( int i = (int)cloud_layers.size() - 1; i >= cur_layer_pos; --i ) { if ( i != in_cloud ) { cloud_layers[i]->draw(); } @@ -218,10 +220,9 @@ void SGSky::preDraw( float alt, float fog_exp2_density ) { // draw translucent clouds ... do this after you've drawn all the // oapaque elements of your scene. -void SGSky::postDraw( float alt ) { +void SGSky::drawLowerClouds() { // draw the cloud layers that are below us, bottom to top - for ( int i = 0; i < cur_layer_pos; ++i ) { if ( i != in_cloud ) { cloud_layers[i]->draw(); diff --git a/simgear/scene/sky/sky.hxx b/simgear/scene/sky/sky.hxx index 099357bd..2bee33da 100644 --- a/simgear/scene/sky/sky.hxx +++ b/simgear/scene/sky/sky.hxx @@ -143,22 +143,27 @@ typedef struct { * Rendering the Sky - * The sky is designed to be rendered in two stages. The first stage + * The sky is designed to be rendered in three stages. The first stage * renders the parts that form your back drop - the sky dome, the * stars and planets, the sun, and the moon. These should be rendered * before the rest of your scene by calling the preDraw() method. The - * second stage renders the clouds which are likely to be translucent - * (depending on type) and should be drawn after your scene has been - * rendered. Use the postDraw() method to draw the second stage of - * the sky. + * second stage renders the clouds that are above the viewer. This stage + * is done before translucent objects in the main scene are drawn. It + * is seperated from the preDraw routine to enable to implement a + * multi passes technique and is located in the drawUpperClouds() method. + * The third stage renders the clouds that are below the viewer an which + * are likely to be translucent (depending on type) and should be drawn + * after your scene has been rendered. Use the drawLowerClouds() method + * to draw the second stage of the sky. * A typical application might do the following: - *
  • thesky->preDraw(); + *
  • thesky->preDraw( my_altitude ); + *
  • thesky->drawUpperClouds(); *
  • ssgCullAndDraw ( myscene ) ; - *
  • thesky->postDraw( my_altitude ); + *
  • thesky->drawLowerClouds(); - * The current altitude in meters is passed to the postDraw() method + * The current altitude in meters is passed to the preDraw() method * so the clouds layers can be rendered correction from most distant * to closest. @@ -329,15 +334,22 @@ public: * class description. * @param alt current altitude */ - void preDraw( float alt, float fog_exp2_density ); + void preDraw( float alt ); /** - * Draw translucent clouds ... do this after you've drawn all the - * oapaque elements of your scene. See discussion in detailed + * Draw upper translucent clouds ... do this before you've drawn + * all the translucent elements of your scene. See discussion in + * detailed class description. + * @param fog_exp2_density fog density of the current cloud layer + */ + void drawUpperClouds( float fog_exp2_density ); + + /** + * Draw lower translucent clouds ... do this after you've drawn + * all the opaque elements of your scene. See discussion in detailed * class description. - * @param alt current altitude */ - void postDraw( float alt ); + void drawLowerClouds(); /** * Specify the texture path (optional, defaults to current directory) -- 2.39.5