Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: lighting problem

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    3

    lighting problem

    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
    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();
    }

  2. #2
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    3
    56 views no reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •