buffer.clear(); buffer.put(posParam); buffer.flip(); GL.glLightfv(index, GL.GL_POSITION, buffer);
    public void set() {        int quantity = getQuantity();        if (quantity > 0) {            GL.glEnable(GL.GL_LIGHTING);            float[] ambient = { 0.0f, 0.0f, 0.0f, 1.0f };            float[] color = new float[4];            color[3] = 1.0f;            for (int i = 0; i < quantity; i++) {                                Light light = get(i);                if (light.isEnabled()) {                    int index = GL.GL_LIGHT0 + i;                    GL.glEnable(index);                    color[0] = light.getAmbient().r;                    color[1] = light.getAmbient().g;                    color[2] = light.getAmbient().b;                    buffer.clear();                    buffer.put(color);                    buffer.flip();                    GL.glLightfv(index, GL.GL_AMBIENT, buffer);                    color[0] = light.getDiffuse().r;                    color[1] = light.getDiffuse().g;                    color[2] = light.getDiffuse().b;                    buffer.clear();                    buffer.put(color);                    buffer.flip();                    GL.glLightfv(index, GL.GL_DIFFUSE, buffer);                    color[0] = light.getSpecular().r;                    color[1] = light.getSpecular().g;                    color[2] = light.getSpecular().b;                    buffer.clear();                    buffer.put(color);                    buffer.flip();                    GL.glLightfv(index, GL.GL_SPECULAR, buffer);                    if (light.isAttenuate()) {                        GL.glLightf(                            index,                            GL.GL_CONSTANT_ATTENUATION,                            light.getConstant());                        GL.glLightf(                            index,                            GL.GL_LINEAR_ATTENUATION,                            light.getLinear());                        GL.glLightf(                            index,                            GL.GL_QUADRATIC_ATTENUATION,                            light.getQuadratic());                    } else {                        GL.glLightf(index, GL.GL_CONSTANT_ATTENUATION, 1.0f);                        GL.glLightf(index, GL.GL_LINEAR_ATTENUATION, 0.0f);                        GL.glLightf(index, GL.GL_QUADRATIC_ATTENUATION, 0.0f);                    }                    if (light.getType() == Light.LT_AMBIENT) {                        ambient[0] += light.getAmbient().r;                        ambient[1] += light.getAmbient().g;                        ambient[2] += light.getAmbient().b;                    }                    float[] posParam = new float[4];                    switch (light.getType()) {                        case Light.LT_DIRECTIONAL :                            {                                DirectionalLight pkDL =                                    (DirectionalLight) light;                                posParam[0] = -pkDL.getDirection().x;                                posParam[1] = -pkDL.getDirection().y;                                posParam[2] = -pkDL.getDirection().z;                                posParam[3] = 0.0f;                                buffer.clear();                                buffer.put(posParam);                                buffer.flip();                                GL.glLightfv(index, GL.GL_POSITION, buffer);                                break;                            }                        case Light.LT_POINT :                        case Light.LT_SPOT :                            {                                PointLight pkPL = (PointLight) light;                                posParam[0] = pkPL.getLocation().x;                                posParam[1] = pkPL.getLocation().y;                                posParam[2] = pkPL.getLocation().z;                                posParam[3] = 1.0f;                                break;                            }                    }                    if (light.getType() == Light.LT_SPOT) {                        SpotLight spot = (SpotLight) light;                        GL.glLightf(                            index,                            GL.GL_SPOT_CUTOFF,                            180.0f * spot.getAngle() / (float) Math.PI);                        buffer.clear();                        float[] spotDir =                            {                                spot.getDirection().x,                                spot.getDirection().y,                                spot.getDirection().z };                        buffer.put(spotDir);                        buffer.flip();                        GL.glLightfv(index, GL.GL_SPOT_DIRECTION, buffer);                        GL.glLightf(                            index,                            GL.GL_SPOT_EXPONENT,                            spot.getExponent());                    } else {                        float[] afDefaultDirection = { 0.0f, 0.0f, -1.0f };                        GL.glLightf(index, GL.GL_SPOT_CUTOFF, 180.0f);                        buffer.clear();                        buffer.put(afDefaultDirection);                        buffer.flip();                        GL.glLightfv(index, GL.GL_SPOT_DIRECTION, buffer);                        GL.glLightf(index, GL.GL_SPOT_EXPONENT, 0.0f);                    }                }            }            buffer.clear();            buffer.put(ambient);            buffer.flip();            GL.glLightModel(GL.GL_LIGHT_MODEL_AMBIENT, buffer);            for (int i = quantity; i < MAX_LIGHTS_ALLOWED; i++)                GL.glDisable((GL.GL_LIGHT0 + i));        } else {            GL.glDisable(GL.GL_LIGHTING);        }    }