setup opengl Light - Java javax.media.opengl

Java examples for javax.media.opengl:Light

Description

setup opengl Light

Demo Code


import javax.media.opengl.GL2;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.charset.Charset;

public class Main{
    public static void setupLight(GL2 gl, int light, float[][] lights) {
        float[] ambient = { lights[0][0], lights[0][1], lights[0][2],
                lights[0][3] };//from   www. j av  a 2s.co m
        float[] diffuse = { lights[1][0], lights[1][1], lights[1][2],
                lights[1][3] };
        float[] specular = { lights[2][0], lights[2][1], lights[2][2],
                lights[2][3] };
        float[] position = { lights[3][0], lights[3][1], lights[3][2],
                lights[3][3] };

        gl.glLightfv(light, GL2.GL_AMBIENT, ambient, 0);
        gl.glLightfv(light, GL2.GL_DIFFUSE, diffuse, 0);
        gl.glLightfv(light, GL2.GL_SPECULAR, specular, 0);
        gl.glLightfv(light, GL2.GL_POSITION, position, 0);
    }
}

Related Tutorials