Hello, I am writing a protein folding program. I was only planning to distribute it as a calculator machine but I decided to add graphics to it. Most of the graphics part is done except one problem that I cant get over with. It is the lighting... At first I had written a more complex lighting scheme but as I found out that I couldnt get light to be displayed, I simplified it more and more until it was practically not there... So to see my problem with the issue, I have exactly translated a C light tutorial to perl and the light is still not displayed on my screen. I am wondering what is the problem? Is it how I input my arguements to opengl functions? Atleast can someone with POGL module take this code and run it, maybe it is a problem with my graphics card. I will be really really grateful if you can help me. Here is the code (if you can get this to work, I will try to apply the same correction to my program):
use OpenGL qw(:all);
use strict;
our $Light_Position = pack("f4", 0.0, 0.0, 0.0, 5.0 );
our $Specular_Material = pack("f4",1.0, 1.0, 1.0, 1.0);
our $Shiny_Material = (50.0 );
our $newQuad = gluNewQuadric ();
our $window;
sub init {
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);
glMaterialfv_s(GL_FRONT, GL_SPECULAR, $Specular_Material);
glMaterialfv_s(GL_FRONT, GL_SHININESS, $Shiny_Material);
glLightfv_s(GL_LIGHT1, GL_POSITION, $Light_Position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT1);
}
sub ReSizeGLScene {
my ($w, $h) = @_;
glViewport (0, 0, $w, $h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
if ($w <= $h)
{
glOrtho (-1.5, 1.5, -1.5*$h / $w, 1.5*$h/$w, -10.0, 10.0);
}
else
{
glOrtho (-1.5*$w/$h,1.5*$w/$h, -1.5, 1.5, -10.0, 10.0);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
sub DrawGLScene {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluSphere($newQuad,1, 18, 18);
glFlush ();
}
glutInit();
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow("Window");
init();
glutDisplayFunc(\&DrawGLScene);
glutReshapeFunc(\&ReSizeGLScene);
glutMainLoop;
return 0;