Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7557 in orxonox.OLD for branches/atmospheric_engine/src/lib


Ignore:
Timestamp:
May 9, 2006, 7:18:24 PM (19 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: volfog cleanup, still not working

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc

    r7546 r7557  
    3333    this->loadParams(root);
    3434
     35  // Initialize Effect
    3536  this->init();
    3637
    37   //if (! this->init())                        // Check And Enable Fog Extension If Available
    38     //return false;                         // Return False If Extension Not Supported
    39 
    40   // Set Up Fog
    41   //glEnable(GL_FOG);                         // Enable Fog
    42   //glFogi(GL_FOG_MODE, GL_LINEAR);                   // Fog Fade Is Linear
    43   //glFogfv(GL_FOG_COLOR, fogColor);                  // Set The Fog Color
    44   //glFogf(GL_FOG_START,  1.0f);                    // Set The Fog Start
    45   //glFogf(GL_FOG_END,    0.0f);                    // Set The Fog End
    46   //glHint(GL_FOG_HINT, GL_NICEST);                   // Per-Pixel Fog Calculation
    47   //glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);    // Set Fog Based On Vertice Coordinates
    48 
     38  // Activate Effect
    4939  this->activate();
    5040}
     
    6555  PRINTF(0)("Initalize VolFogEffect\n");
    6656
    67   fogColor[0] = 0.6f;
    68   fogColor[1] = 0.3f;
    69   fogColor[2] = 0.0f;
    70   fogColor[3] = 1.0f;
     57  // Set fog color
     58  float fogColor[4] = {0.4, 0.4, 0.4, 1.0};
    7159
    72   //glDepthFunc (GL_LEQUAL);                            // The Type Of Depth Testing
    73   //glEnable (GL_DEPTH_TEST);                           // Enable Depth Testing
    74   //glShadeModel (GL_SMOOTH);                           // Select Smooth Shading
    75   //glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most AccurateAbility
     60  // glClearColor(0.0, 0.0, 0.0, 1.0);  //sets bg color?!
     61
     62  /* set up fog params */       
     63  glEnable(GL_FOG);                                             // Enable Fog
     64  glFogi(GL_FOG_MODE, GL_LINEAR);                               // Fog Fade Is Linear
     65  glFogfv(GL_FOG_COLOR, fogColor);                              // Set The Fog Color
     66  glFogf(GL_FOG_START, 0.0f);                                   // Set The Fog Start
     67  glFogf(GL_FOG_END, 1.0f);                                     // Set The Fog End
     68  glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);  // Set Perspective Calculations To Most Accurate
     69  // glHint(GL_FOG_HINT, GL_NICEST);                            // Per-Pixel Fog Calculation
     70
     71  /* enable texturing & set texturing function */
     72  glEnable(GL_TEXTURE_2D);
     73  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
     74
     75  // *********************************************
    7676
    7777  char extensions[ 16384 ];
     
    9292
    9393  PRINTF(0)( "%s\n", (char *)glGetString( GL_EXTENSIONS ) );
    94   PRINTF(0)( "%s not found, dammit.\n", Extension_Name );
     94  PRINTF(0)( "%s not found.\n", Extension_Name );
    9595  return false;
    9696}
     
    113113void VolFogEffect::draw() const
    114114{
    115     glPushAttrib(GL_ENABLE_BIT);
     115        //glPushAttrib(GL_ENABLE_BIT);
     116       
     117        /* clear all pixels in colour buffer */
     118        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    116119
    117 glClearDepth (1.0f);
    118   glDepthFunc (GL_LEQUAL);                            // The Type Of Depth Testing
    119   glEnable (GL_DEPTH_TEST);                           // Enable Depth Testing
    120   glShadeModel (GL_SMOOTH);                           // Select Smooth Shading
    121   glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most AccurateAbili
     120        //glLoadIdentity ();    // Reset The Modelview Matrix
    122121
    123122
    124   // Set Up Fog
    125   glEnable(GL_FOG);                         // Enable Fog
    126   glFogi(GL_FOG_MODE, GL_LINEAR);                   // Fog Fade Is Linear
    127   glFogfv(GL_FOG_COLOR, fogColor);                  // Set The Fog Color
    128   glFogf(GL_FOG_START,  1.0f);                    // Set The Fog Start
    129   glFogf(GL_FOG_END,    0.0f);                    // Set The Fog End
    130   glHint(GL_FOG_HINT, GL_NICEST);                   // Per-Pixel Fog Calculation
    131   glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);    // Set Fog Based On Vertice Coordinates
     123        // glBindTexture(GL_TEXTURE_2D, 0);
     124        /* draw the panels */
     125        glBegin(GL_QUADS); // Floor
     126                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,0.0f);
     127                glFogCoordfEXT(0.0f);   glVertex3f(100.0f,0.0f,0.0f);
     128                glFogCoordfEXT(0.0f);   glVertex3f(100.0f,0.0f, 100.0f);
     129                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f, 100.0f);
     130        glEnd();
    132131
     132        glBegin(GL_QUADS); // Roof
     133                glFogCoordfEXT(5.0f);glVertex3f(0.0f, 100.0f,0.0f);
     134                glFogCoordfEXT(5.0f);glVertex3f( 100.0f, 100.0f,0.0f);
     135                glFogCoordfEXT(5.0f);glVertex3f( 100.0f, 100.0f, 100.0f);
     136                glFogCoordfEXT(5.0f);glVertex3f(0.0f, 100.0f, 100.0f);
     137        glEnd();
    133138
     139        glBegin(GL_QUADS); // Back Wall
     140                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,0.0f);
     141                glFogCoordfEXT(0.0f);   glVertex3f( 100.0f,0.0f,0.0f);
     142                glFogCoordfEXT(5.0f);glVertex3f( 100.0f, 100.0f,0.0f);
     143                glFogCoordfEXT(5.0f);glVertex3f(0.0f, 100.0f,0.0f);
     144        glEnd();
    134145
    135   //glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);        // Clear Screen And Depth Buffer
    136   //glLoadIdentity ();                          // Reset The Modelview Matrix
     146        glBegin(GL_QUADS); // Front Wall
     147                glFogCoordfEXT(0.0f);           glVertex3f(0.0f,0.0f,100.0f);
     148                glFogCoordfEXT(0.0f);   glVertex3f( 100.0f,0.0f,100.0f);
     149                glFogCoordfEXT(5.0f);glVertex3f( 100.0f, 100.0f,100.0f);
     150                glFogCoordfEXT(5.0f);glVertex3f(0.0f, 100.0f,100.0f);
     151        glEnd();
    137152
    138   //glTranslatef(camx, 0.0f, camz);             // Move To Our Camera Z/X Position
     153        glBegin(GL_QUADS); // Right Wall
     154                glFogCoordfEXT(0.0f);   glVertex3f( 100.0f,0.0f, 100.0f);
     155                glFogCoordfEXT(5.0f);glVertex3f( 100.0f, 100.0f, 100.0f);
     156                glFogCoordfEXT(5.0f);glVertex3f( 100.0f, 100.0f,0.0f);
     157                glFogCoordfEXT(0.0f);   glVertex3f( 100.0f,0.0f,0.0f);
     158        glEnd();
    139159
    140   // glFogCoordEXT is very similar to glVertex3f. If you understand
    141   // the way vertexs are applied in OpenGL, you will not have any dificulty
    142   // understanding glFogCoordEXT.
     160        glBegin(GL_QUADS); // Left Wall
     161                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f, 100.0f);
     162                glFogCoordfEXT(5.0f);   glVertex3f(0.0f, 100.0f, 100.0f);
     163                glFogCoordfEXT(5.0f);   glVertex3f(0.0f, 100.0f,0.0f);
     164                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,0.0f);
     165        glEnd();
     166       
     167        /* process all buffered OpenGL commands */
     168        glFlush();
    143169
    144   // In this tutorial we are applyng the fog in a corridor, so the fog
    145   // goes from the less density (the minor z) to a bigger density (the biggest z).
    146   // If you check the fog_start and fog_eng, it's 0 and 1.
     170        // glPopAttrib();
     171}
    147172
    148   // So, we will pass to the function glFogCoordEXT, the fog value corresponding
    149   // with the glVertex3f value.If we are drawing a quad from z minus to z major,
    150   // we do exactly the same with glFogCoord.
    151 
    152   // For example, in the first quad, is vertex coordinates in the Z field are all
    153   // -15.0f. So we want the fog to completely fill this quad, so we assign 0 to all
    154   // the glFogCoordExt.
    155  
    156   glBegin(GL_QUADS);                          // Back Wall
    157     glFogCoordfEXT( 0.0f); glVertex3f(-2.5f,-2.5f,-15.0f);
    158     glFogCoordfEXT( 0.0f); glVertex3f( 2.5f,-2.5f,-15.0f);
    159     glFogCoordfEXT( 0.0f); glVertex3f( 2.5f, 2.5f,-15.0f);
    160     glFogCoordfEXT( 0.0f); glVertex3f(-2.5f, 2.5f,-15.0f);
    161   glEnd();
    162 
    163   glBegin(GL_QUADS);                          // Floor
    164     glFogCoordfEXT( 0.0f); glVertex3f(-2.5f,-2.5f,-15.0f);
    165     glFogCoordfEXT( 0.0f); glVertex3f( 2.5f,-2.5f,-15.0f);
    166     glFogCoordfEXT( 1.0f); glVertex3f( 2.5f,-2.5f, 15.0f);
    167     glFogCoordfEXT( 1.0f); glVertex3f(-2.5f,-2.5f, 15.0f);
    168   glEnd();
    169 
    170   glBegin(GL_QUADS);                          // Roof
    171     glFogCoordfEXT( 0.0f); glVertex3f(-2.5f, 2.5f,-15.0f);
    172     glFogCoordfEXT( 0.0f); glVertex3f( 2.5f, 2.5f,-15.0f);
    173     glFogCoordfEXT( 1.0f); glVertex3f( 2.5f, 2.5f, 15.0f);
    174     glFogCoordfEXT( 1.0f); glVertex3f(-2.5f, 2.5f, 15.0f);
    175   glEnd();
    176 
    177   glBegin(GL_QUADS);                          // Right Wall
    178     glFogCoordfEXT( 1.0f); glVertex3f( 2.5f,-2.5f, 15.0f);
    179     glFogCoordfEXT( 1.0f); glVertex3f( 2.5f, 2.5f, 15.0f);
    180     glFogCoordfEXT( 0.0f); glVertex3f( 2.5f, 2.5f,-15.0f);
    181     glFogCoordfEXT( 0.0f); glVertex3f( 2.5f,-2.5f,-15.0f);
    182   glEnd();
    183 
    184   glBegin(GL_QUADS);                          // Left Wall
    185     glFogCoordfEXT( 1.0f); glVertex3f(-2.5f,-2.5f, 15.0f);
    186     glFogCoordfEXT( 1.0f); glVertex3f(-2.5f, 2.5f, 15.0f);
    187     glFogCoordfEXT( 0.0f); glVertex3f(-2.5f, 2.5f,-15.0f);
    188     glFogCoordfEXT( 0.0f); glVertex3f(-2.5f,-2.5f,-15.0f);
    189   glEnd();
    190  
    191   //glFlush ();                             // Flush The GL Rendering Pipeline
    192   glPopAttrib();
    193 }
    194173
    195174
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.h

    r7546 r7557  
    3131
    3232  private:
    33 
    3433    GLfloat fogColor[4];
    3534
Note: See TracChangeset for help on using the changeset viewer.