com.jogamp.opengl.GL2ES1 Java Examples

The following examples show how to use com.jogamp.opengl.GL2ES1. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NEWTWindow.java    From WarpPI with Apache License 2.0 5 votes vote down vote up
@Override
public void init(final GLAutoDrawable drawable) {
	final GL2ES1 gl = drawable.getGL().getGL2ES1();
	onGLContext.submit(gl);

	if (WarpPI.getPlatform().getSettings().isDebugEnabled())
		//Vsync
		gl.setSwapInterval(1);
	else
		//Vsync
		gl.setSwapInterval(2);

	//Textures
	gl.glEnable(GL.GL_TEXTURE_2D);

	//Transparency
	gl.glEnable(GL.GL_BLEND);
	gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
	gl.glShadeModel(GLLightingFunc.GL_FLAT);

	//Multisampling
	//gl.glEnable(GL.GL_MULTISAMPLE);

	try {
		renderer.currentTex = ((JOGLSkin) engine.loadSkin("/test.png")).t;
	} catch (final Exception e) {
		e.printStackTrace();
	}

	if (onInitialized != null) {
		onInitialized.run();
		onInitialized = null;
	}

	System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities());
	System.err.println("INIT GL IS: " + gl.getClass().getName());
	System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
	System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
	System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
}
 
Example #2
Source File: Gl_300_test_alpha.java    From jogl-samples with MIT License 5 votes vote down vote up
protected boolean initTest(GL3 gl3) {

        gl3.glEnable(GL_ALPHA_TEST);
        ((GL2ES1) gl3).glAlphaFunc(GL_GREATER, 0.2f);

        //To test alpha blending:
//        gl3.glEnable(GL_BLEND);
//        gl3.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        return checkError(gl3, "initTest");
    }
 
Example #3
Source File: OpenGL.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public void initializeGLStates(final Color bg) {
	gl.glClearColor(bg.getRed() / 255.0f, bg.getGreen() / 255.0f, bg.getBlue() / 255.0f, 1.0f);
	gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

	// Putting the swap interval to 0 (instead of 1) seems to cure some of
	// the problems of resizing of views.
	gl.setSwapInterval(0);

	// Enable smooth shading, which blends colors nicely, and smoothes out
	// lighting.
	gl.glShadeModel(GLLightingFunc.GL_SMOOTH);
	// Enabling the depth buffer & the depth testing
	gl.glClearDepth(1.0f);
	gl.glEnable(GL.GL_DEPTH_TEST); // enables depth testing
	gl.glDepthFunc(GL.GL_LEQUAL); // the type of depth test to do
	// Whether face culling is enabled or not
	if (GamaPreferences.Displays.ONLY_VISIBLE_FACES.getValue()) {
		gl.glEnable(GL.GL_CULL_FACE);
		gl.glCullFace(GL.GL_BACK);
	}
	// Turn on clockwise direction of vertices as an indication of "front" (important)
	gl.glFrontFace(GL.GL_CW);

	// Hints
	gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
	gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
	gl.glHint(GL2.GL_POINT_SMOOTH_HINT, GL.GL_NICEST);
	gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST);
	gl.glHint(GL2.GL_MULTISAMPLE_FILTER_HINT_NV, GL2.GL_NICEST);
	// Enable texture 2D
	gl.glEnable(GL.GL_TEXTURE_2D);
	// Blending & alpha control
	gl.glEnable(GL.GL_BLEND);
	gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
	gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
	gl.glEnable(GL2.GL_ALPHA_TEST);
	gl.glAlphaFunc(GL2.GL_GREATER, 0.01f);
	// Disabling line smoothing to only rely on FSAA
	 gl.glEnable(GL.GL_LINE_SMOOTH);
	 gl.glEnable(GL2.GL_POINT_SMOOTH);
	 gl.glEnable(GL2.GL_POLYGON_SMOOTH);
	// Enabling forced normalization of normal vectors (important)
	gl.glEnable(GL2.GL_NORMALIZE);
	// Enabling multi-sampling (necessary ?)
	// if (USE_MULTI_SAMPLE) {
	gl.glEnable(GL2.GL_MULTISAMPLE);
	// }
	initializeShapeCache();

}