just like the threads name says, i don
t understand why , but after i enable fog , my scene isn`t visible anymore , the only thing i see is dense grey fog …
i use fog in my recently started opengl app , so far i`ve got some models , which i made in 3ds max , and i imported, using the GLM library into my opengl app. my models are a terrain , a skydome and a castle , which are also textured.
ive managed to rotate , scale and translate the objects so that every one is at they
re correct place in the scene .
i also can move “the camera” through the scene with W A S D keys and look around with the mouse.
i also defined a simple directional light.
my light code:
GLfloat ambientLight[]={0.1, 0.1,0.1,1.0};
GLfloat diffuseLight[]={0.8,0.8,0.8,1.0};
GLfloat specularLight[]={0.2,0.2,0.2,1.0};
GLfloat lightPos[]={1.0 , 1.0 , 1.0 , 0.0};
GLfloat specularReflection[]={1.0,1.0,1.0,1.0};
glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_SPECULAR,specularLight);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glMaterialfv(GL_FRONT, GL_SPECULAR, specularReflection);
glMateriali(GL_FRONT,GL_SHININESS,128);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight); glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
glShadeModel(GL_SMOOTH);
my fog code :
GLfloat fogColor[4]= {0.5f, 0.5f, 0.5f, 1.0f};
GLfloat density = 0.3;
glEnable (GL_FOG);
glFogi (GL_FOG_MODE, GL_EXP2);
glFogfv (GL_FOG_COLOR, fogColor);
glFogf (GL_FOG_DENSITY, density);
glHint (GL_FOG_HINT, GL_NICEST);
if anyone has an ideea , please help
i also added pictures