Esempio n. 1
0
        /**
         * Sets the GL lighting state to a white light originating from the eye position and pointed in the specified
         * direction, in model coordinates. The light direction is always relative to the current eye point and viewer
         * direction. If the direction is null, this the light direction defaults to (0, 0, -1), which points directly along
         * the forward vector form the eye point
         *
         * @param gl        the GL context.
         * @param light     the GL light name to set.
         * @param direction the light direction in model coordinates, may be null.
         *
         * @throws ArgumentException if the GL is null.
         */
        public static void applyLightingDirectionalFromViewer(GL2 gl, int light, Vec4 direction)
        {
            if (gl == null)
            {
                String message = Logging.getMessage("nullValue.GLIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (direction == null)
            {
                direction = DEFAULT_LIGHT_DIRECTION;
            }

            float[] ambient  = { 1f, 1f, 1f, 0f };
            float[] diffuse  = { 1f, 1f, 1f, 0f };
            float[] specular = { 1f, 1f, 1f, 0f };
            float[] position = { (float)direction.x, (float)direction.y, (float)direction.z, 0.0f };

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

            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushModelviewIdentity(gl);
            try
            {
                gl.glLightfv(light, GL2.GL_POSITION, position, 0);
            }
            finally
            {
                ogsh.pop(gl);
            }
        }
Esempio n. 2
0
 /** Constructs a new OGLRenderToTextureSupport, but otherwise does nothing. */
 public OGLRenderToTextureSupport()
 {
     this.isFramebufferObjectEnabled = true;
     this.stackHandler = new OGLStackHandler();
 }