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;

In reply to Daunting Problem With Perl Opengl Lighting by iSina

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.