PDA

View Full Version : lighting problem



ehsan_cs
05-13-2012, 01:18 PM
I have a problem in determining the source of lighting and destination of lighting
I have sun in my program I want to be a source of lighting and lighting focus in a specific place
can u edited to this code


void inta(){

glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
// Set lighting intensity and color
GLfloat qaAmbientLight[] = {0.2f, 0.2f, 0.2f, 1.0f};
GLfloat qaDiffuseLight[] = {0.8f, 0.8f, 0.8f, 1.0f};
GLfloat qaSpecularLight[] = {0.5f, 0.5f, 0.5, 1.0f};
GLfloat qaLightPosition[] = {-12.5f,5.0f, -4.0f, 1.0};
// Set the light position
glLightfv(GL_LIGHT0, GL_AMBIENT, qaAmbientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, qaDiffuseLight);

glLightfv(GL_LIGHT0, GL_SPECULAR, qaSpecularLight);
glLightfv(GL_LIGHT0, GL_POSITION, qaLightPosition);




}

void ss(){
glClear(GL_COLOR_BUFFER_BIT);

// Set material properties;
GLfloat qaBlack[] = {1.0f, 0.0f, 0.1f, 1.0f};
GLfloat qaGreen[] = {0.0f, 1.0f, 0.0f, 1.0f};
GLfloat qaWhite[] = {1.0, 1.0, 0.0, 0.0};
glMaterialfv(GL_FRONT, GL_AMBIENT, qaWhite);
glMaterialfv(GL_FRONT, GL_DIFFUSE, qaGreen);
glMaterialfv(GL_FRONT, GL_SPECULAR, qaWhite);
glMaterialf(GL_FRONT, GL_SHININESS, 10.0);

}
//drow sun
void drawCircle(double x, double y, double radius){
int i;
int triangleAmount = 20; //# of triangles used to draw circle
//glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
//GLfloat radius = 0.8f; //radius
double twicePi = 2.0f *3.14;
glColor3f(0.0f, 1.0f, 0.0f);
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x, y); // center of circle
for(i = 0; i <= triangleAmount;i++) {
glVertex2f(
x + (radius * cos(i * twicePi / triangleAmount)),
y + (radius * sin(i * twicePi / triangleAmount))
);
}
glEnd();
}

ehsan_cs
05-14-2012, 01:32 AM
56 views no reply :dejection: