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 6 of 6

Thread: Lighting issues (very basic)

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2014
    Posts
    11

    Lighting issues (very basic)

    Hello,

    I'm getting started with opengl, and I'm facing issues with the lighting. My problem is that I'm drawing a red shape, but it is rendered white. I'm sure I missing something elementary...

    I'm developing in Java using the JOGL libraries.

    Here is how I setup the lighting in the init method:

    Code :
            gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_AMBIENT, new float[]{.5f, .5f, .5f, .5f}, 0);
            gl.glEnable(GL2ES1.GL_LIGHTING);
            gl.glEnable(GL2ES1.GL_LIGHT0);

    and here is how I draw a red triangle:

    Code :
            gl.glBegin(GL.GL_TRIANGLES);
     
            gl.glColor3f(1, 0, 0);
     
            gl.glNormal3f(0f, 0f, 1f);
            gl.glVertex3f(0, 0, -5);
            gl.glVertex3f(1, 0, -5);
            gl.glVertex3f(0, 1, -5);
     
            gl.glEnd();


    Like I said, the triangle is rendered completely white. What am I doing wrong?


    I'm attaching the entire code if it can help.

    Any help would be appreciated.
    Attached Files Attached Files

Posting Permissions

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