@Override public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // get the OpenGL graphics context glu = new GLU(); // get GL Utilities gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // set background (clear) color gl.glClearDepth(1.0f); // set clear depth value to farthest gl.glEnable(GL.GL_DEPTH_TEST); // enables depth testing gl.glDepthFunc(GL.GL_LEQUAL); // the type of depth test to do gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // best // perspective // correction gl.glShadeModel(GLLightingFunc.GL_SMOOTH); // blends colors nicely, and // smoothes out // lighting time = System.currentTimeMillis(); }
@SuppressWarnings("static-access") protected void initialize(GL2 gl2) { if (initialized_context_ == gl2) return; initialized_context_ = gl2; if (!gl2.getContext().isHardwareRasterizer()) { // Workaround for Windows Remote Desktop which requires pot textures. System.out.println("opengl rendering may be slow as hardware rendering isn't available"); use_draw_pixels_ = true; return; } gl2.glHint(gl2.GL_POLYGON_SMOOTH_HINT, gl2.GL_NICEST); gl2.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Necessary for non-power-of-2 textures to render correctly. gl2.glPixelStorei(gl2.GL_UNPACK_ALIGNMENT, 1); // Create the texture. gl2.glGenTextures(1, texture_id_, 0); assert(texture_id_[0] != 0); gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]); gl2.glTexParameteri(gl2.GL_TEXTURE_2D, gl2.GL_TEXTURE_MIN_FILTER, gl2.GL_NEAREST); gl2.glTexParameteri(gl2.GL_TEXTURE_2D, gl2.GL_TEXTURE_MAG_FILTER, gl2.GL_NEAREST); gl2.glTexEnvf(gl2.GL_TEXTURE_ENV, gl2.GL_TEXTURE_ENV_MODE, gl2.GL_MODULATE); }
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR_MIPMAP_LINEAR); gl.glHint(GL.GL_GENERATE_MIPMAP_HINT, GL.GL_NICEST); gl.glGenerateMipmap(GL.GL_TEXTURE_2D);
@Override public void init( final GLAutoDrawable drawable ) { final GL2 gl = drawable.getGL().getGL2(); gl.setSwapInterval( 1 ); gl.glEnable( GL.GL_DEPTH_TEST ); gl.glDepthFunc( GL.GL_LEQUAL ); gl.glShadeModel( GLLightingFunc.GL_SMOOTH ); gl.glHint( GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST ); // gl.glEnable( GL.GL_BLEND ); // gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ); gl.glEnable( GL2GL3.GL_POLYGON_SMOOTH ); final float w = this.window.getDrawableSurface().getWidth(); final float h = this.window.getDrawableSurface().getHeight(); // Set the projection matrix (only done once - just here) gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION ); gl.glLoadIdentity(); this.glu.gluPerspective( 50, (w / h), 0.01, 10 ); // Set the initial model matrix gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); gl.glLoadIdentity(); gl.glViewport( 0, 0, (int) w, (int) h ); /* viewport size in pixels */ }