Java Code Examples for javax.media.opengl.GL#isExtensionAvailable()

The following examples show how to use javax.media.opengl.GL#isExtensionAvailable() . 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: Env.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Check current graphic card/drivers OpenGL capabilities to see if they match those required by WorldWind to work
 * @return true if we are good, false otherwise
 */
public boolean isOpenGLAvailable() {
	if (_openGlAvailable == null) {
		synchronized (this) {
			if (_openGlAvailable == null) {
				try {
					// create an offscreen context with the current graphic device
					final GLProfile glProfile = GLProfile.getDefault(GLProfile.getDefaultDevice());
					final GLCapabilities caps = new GLCapabilities(glProfile);
					caps.setOnscreen(false);
					caps.setPBuffer(false);
					final GLDrawable offscreenDrawable = GLDrawableFactory.getFactory(glProfile).createOffscreenDrawable(null, caps,
							new DefaultGLCapabilitiesChooser(), 1, 1);
					offscreenDrawable.setRealized(true);
					final GLContext context = offscreenDrawable.createContext(null);
					final int additionalCtxCreationFlags = 0;
					context.setContextCreationFlags(additionalCtxCreationFlags);
					context.makeCurrent();
					final GL gl = context.getGL();
					// WWJ will need those to render the globe
					_openGlAvailable = gl.isExtensionAvailable(GLExtensions.EXT_texture_compression_s3tc)
							|| gl.isExtensionAvailable(GLExtensions.NV_texture_compression_vtc);
				} catch (final Throwable e) {
					_openGlAvailable = false;
				}
			}
		}
	}
	return _openGlAvailable;
}
 
Example 2
Source File: BloomOpenGL.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void init(GLAutoDrawable glAutoDrawable) {
    GL gl = glAutoDrawable.getGL();

    if (texture == null) {
        texture = TextureIO.newTexture(image, false);
    }

    // create the blur shader
    blurShader = createFragmentProgram(gl, new String[] { blurShaderSource });
    gl.glUseProgramObjectARB(blurShader);
    int loc = gl.glGetUniformLocationARB(blurShader, "baseImage");
    gl.glUniform1iARB(loc, 0);
    gl.glUseProgramObjectARB(0);

    // create the bright-pass shader
    brightPassShader = createFragmentProgram(gl, new String[] { brightPassShaderSource });
    gl.glUseProgramObjectARB(brightPassShader);
    loc = gl.glGetUniformLocationARB(brightPassShader, "baseImage");
    gl.glUniform1iARB(loc, 0);
    gl.glUseProgramObjectARB(0);

    // create the FBOs
    if (gl.isExtensionAvailable("GL_EXT_framebuffer_object")) {
        int[] fboId = new int[1];
        int[] texId = new int[1];

        createFrameBufferObject(gl, fboId, texId,
                                image.getWidth(), image.getHeight());
        frameBufferObject1 = fboId[0];
        frameBufferTexture1 = texId[0];

        createFrameBufferObject(gl, fboId, texId,
                                image.getWidth(), image.getHeight());
        frameBufferObject2 = fboId[0];
        frameBufferTexture2 = texId[0];
    }
}