m3g/m3gcore11/src/m3g_fog.c
changeset 36 01a6848ebfd7
parent 0 5d03bc08d59c
equal deleted inserted replaced
0:5d03bc08d59c 36:01a6848ebfd7
   195 		glDisable(GL_FOG);
   195 		glDisable(GL_FOG);
   196 	}
   196 	}
   197     M3G_ASSERT_GL;
   197     M3G_ASSERT_GL;
   198 }
   198 }
   199 
   199 
   200 /*!
   200 #ifdef M3G_USE_NGL_API
   201  * \internal
   201 /*!
   202  * \brief Applies fog to OpenGL. This is used for
   202  * \internal
       
   203  * \brief Applies fog to NGL. This is used for
   203  * Sprite3D objects only.
   204  * Sprite3D objects only.
   204  *
   205  *
   205  * \param self          Fog object
   206  * \param self          Fog object
   206  * \param eyeZ          Eye space Z (e.g. after modelview)
   207  * \param eyeZ          Eye space Z (e.g. after modelview)
   207  * \param finalZ        Final Z (e.g. after modelview and projection)
   208  * \param finalZ        Final Z (e.g. after modelview and projection)
   230 
   231 
   231         m3gGLColor(self->color, temp);
   232         m3gGLColor(self->color, temp);
   232 
   233 
   233 		glEnable(GL_FOG);
   234 		glEnable(GL_FOG);
   234 		glFogf(GL_FOG_MODE, GL_LINEAR);
   235 		glFogf(GL_FOG_MODE, GL_LINEAR);
   235 #ifdef M3G_USE_NGL_API
   236 
   236         /* NGL works differently in fog calculation */
   237         /* NGL works differently in fog calculation */
   237 		glFogf(GL_FOG_START, -m3gDiv(finalZ, fogValue));
   238 		glFogf(GL_FOG_START, -m3gDiv(finalZ, fogValue));
   238 #else
       
   239 		glFogf(GL_FOG_START, m3gAbs(m3gDiv(finalZ, fogValue)));
       
   240 #endif
       
   241 		glFogf(GL_FOG_END, 0.f);
   239 		glFogf(GL_FOG_END, 0.f);
   242 		glFogxv(GL_FOG_COLOR, temp);
   240 		glFogxv(GL_FOG_COLOR, temp);
   243     }
   241     }
   244     else {
   242     else {
   245 		glDisable(GL_FOG);
   243 		glDisable(GL_FOG);
   246     }
   244     }
   247 }
   245 }
   248 
   246 #endif
   249 /*----------------------------------------------------------------------
   247 /*----------------------------------------------------------------------
   250  * Virtual function table
   248  * Virtual function table
   251  *--------------------------------------------------------------------*/
   249  *--------------------------------------------------------------------*/
   252 
   250 
   253 static const ObjectVFTable m3gvf_Fog = {
   251 static const ObjectVFTable m3gvf_Fog = {