Problems with Spotlights
Hello,
I''ve a problem with the spotlight. If I slowly change e.g. the cutoff angle, the light cone doesn''t seem to grow or melt smoothly, but in big steps or perhaps only alternatig between on and of. And I''ve a simular problem if I change the direction of an spotlight, it seems to jump in steps of 90 degrees.
Could it be that its a graphic card Problem. I''m working with a Vodoo3 2000 AGP driver version 1.07.00 (if I''ve found the right number out of all this stuff, I think its from dec 000) for Win98.
Could some of you please take the code I''ve posted, compile it and run it. And tell me wheter there is a smooth changing of the light cone, until it reaches 90 degrees, and then set it back to 0 degrees. Or tell me if there is a mistake in my code. This should set up an square that is centered to the light (and view) position, 4 units "in" the screen.
If the code runs to fast uncomment the Sleep function (and play around with it).
#include windows.h
#include gl/gl.h
#include gl/glu.h
#include gl/glut.h
int WINAPI WinMain(
HINSTANCE hInstance, // Handle der aktuellen Instanz
HINSTANCE hPrevInstance, // Handle der vorher gehenden Instanz (?allways zero?)
LPSTR pszCmdLine, // pointer to command line (if prog was started over a command line)
int nCmdShow // Fensterstatus
);
void init();
void display();
void keyboard(unsigned char key, int x, int y);
void reshape(int w, int h);
int WINAPI WinMain(
HINSTANCE hInstance, // Handle der aktuellen Instanz
HINSTANCE hPrevInstance, // Handle der vorher gehenden Instanz (?allways zero?)
LPSTR pszCmdLine, // pointer to command line (if prog was started over a command line)
int nCmdShow // Fensterstatus
)
{
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize (450, 450);
glutInitWindowPosition (150, 200);
glutCreateWindow("GL_Test");
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING);
glEnable(GL_CULL_FACE);
GLfloat lightBlack[4] ={0,0,0,0};
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lightBlack); // sets ambient light to black
GLfloat white[4] = {1.0,1.0,1.0,1.0};
glLightfv(GL_LIGHT1, GL_DIFFUSE, white);
GLfloat pos[4] = {0.0,0.0,0.0,1.0}; // make it positional light
glLightfv(GL_LIGHT1, GL_POSITION, pos);
glLighti(GL_LIGHT1, GL_SPOT_CUTOFF, 20);
GLfloat dir[3] = {0.0f,0.0f,-1.0f};
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, dir);
glEnable(GL_LIGHT1);
glEnable(GL_COLOR_MATERIAL);
}
void display(void)
{
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
static GLint cutoffAngle = 10;
GLint A[] = {-2,-2,-4};
GLint B[] = {2,-2,-4};
GLint C[] = {2,2,-4};
GLint D[] = {-2,2,-4};
glLighti(GL_LIGHT1, GL_SPOT_CUTOFF, cutoffAngle);
glBegin(GL_QUADS);
glColor3f(1.0f,0.5f,0.5f);
glNormal3i(0,0,1);
glVertex3iv(A);
glVertex3iv(B);
glVertex3iv(C);
glVertex3iv(D);
glEnd();
glutSwapBuffers();
if ( (cutoffAngle++)>90)
cutoffAngle = 0;
// Sleep(10);
glutPostRedisplay();
}
you have to tesselate your poly in order to have a nice looking spotlight! a few weeks ago i open a thread on the subject :
http://www.gamedev.net/community/forums/topic.asp?topic_id=41186
nice coding
lunasol =(star*)malloc(lunaRadius*sizeof(sun));
http://www.gamedev.net/community/forums/topic.asp?topic_id=41186
nice coding
lunasol =(star*)malloc(lunaRadius*sizeof(sun));
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement