okkk.thanks for your help…
well i have done the following:
define my initi() like this:
void initi() {
glutInitWindowPosition(50,50);
glutInitWindowSize(width,height);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutCreateWindow("pacman");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(-50,50,-50,50,-2000,2000);
gluPerspective(75,1,50,2000);
glMatrixMode(GL_MODELVIEW);
gluLookAt(-30,-30,90,0,0,0,0,1,0);
//Enabling the shading model
glEnable(GL_LIGHTING);
//Enabling normal vector normalization
glEnable(GL_NORMALIZE);
//Disabling global ambient light (In this example no ambient light will be present.)
GLfloat globalAmbient[]={0,0,0};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,globalAmbient);
//Defining the position of the point light source GL_LIGHT0 at (x,y,z)=(0,0,40)
GLfloat light0Position[]={-30,-30,90,1};
glLightfv(GL_LIGHT0,GL_POSITION,light0Position);
//Defining "diffuse" lighting properties for GL_LIGHT0
GLfloat light0Diffuse[]={1,1,1};
glLightfv(GL_LIGHT0,GL_DIFFUSE,light0Diffuse);
//Defining "specular" lighting properties for GL_LIGHT0
GLfloat light0Specular[]={1,1,1};
glLightfv(GL_LIGHT0,GL_SPECULAR,light0Specular);
glEnable(GL_LIGHT0);
}
and a part of my display is this…
if (x[i][j]=='*') {
glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
glEnable ( GL_COLOR_MATERIAL ) ;
glColor3f(1,0,0);
drawcube(cnt1,cnt2,temp1,temp2);
glDisable ( GL_COLOR_MATERIAL ) ;
}
....
else if (x[i][j]=='#') {
glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
glEnable ( GL_COLOR_MATERIAL ) ;
glColor3f(0,0,1);
drawsphere(cnt1,cnt2,temp1,temp2);
fan1=i;//apo8ikefsi 8eseon fantasmatos
fan2=j;
glDisable ( GL_COLOR_MATERIAL ) ;
}
the problem is: all the spheres appearing black … and all the cubes have some of thei sides black (back and their left one)
my result is this:
image