setup opengl Context - Java javax.media.opengl

Java examples for javax.media.opengl:GL

Description

setup opengl Context

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 setupContext(GL2 gl) {
        gl.glShadeModel(GL2.GL_SMOOTH);/* ww  w  .  j a v a 2 s  .c  o  m*/
        gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);

        gl.glClearDepth(1.0f);
        gl.glEnable(GL2.GL_DEPTH_TEST);
        gl.glEnable(GL2.GL_BLEND);
        gl.glEnable(GL2.GL_ALPHA_TEST);
        gl.glEnable(GL2.GL_LIGHTING);
        gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE,
                GL2.GL_MODULATE);
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
        gl.glDepthFunc(GL2.GL_LEQUAL);
        //gl.glEnable(GL2.GL_COLOR_MATERIAL);
        //gl.glColorMaterial(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE);

        gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
        gl.glHint(GL2.GL_FOG_HINT, GL2.GL_NICEST);
        gl.glHint(GL2.GL_GENERATE_MIPMAP_HINT, GL2.GL_NICEST);
        gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST);
        gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL2.GL_NICEST);
    }
}

Related Tutorials