Hi, I am a beginner in OpenGL. I am trying to integrate code for water caustics (available online) with water wave dynamics code which I have written.
The problem is the caustics code uses lighting in order to get the effect and I haven't used lighting, when i integrated the code it got compiled but everything appears dark as if light is switched off. So I made some changes with positioning but they aren't effective.
Following is my glutReshapeFunc
void reshape(int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float aspectRatio = (float)w / h;
gluPerspective(60.0f, (float)(w)/h, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
and my lightning positioning code inside display is
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
/* Reposition the light source. */
lightPosition[0] = 12cos(lightAngle);
lightPosition[1] = lightHeight;
lightPosition[2] = 12sin(lightAngle);
if (directionalLight) {
lightPosition[3] = 0.0;
} else {
lightPosition[3] = 1.0;
}
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
where lightangle is 0.0,
where lightHeight is 20.0,
My confusion is, in gluPerspective is the z near and far plane is 1.0 and 1000.0, where is my 3D water mesh drawn and then where do I position my light?
Many Thanks in advanceā¦