javax.media.opengl.GLProfile Java Examples

The following examples show how to use javax.media.opengl.GLProfile. 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: JoglPanel.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JoglPanel(final TestbedModel model, final TestbedController controller) {
  super(new GLCapabilities(GLProfile.getDefault()));
  this.controller = controller;
  setSize(600, 600);
  setPreferredSize(new Dimension(600, 600));
  setAutoSwapBufferMode(true);
  addGLEventListener(this);
  AWTPanelHelper.addHelpAndPanelListeners(this, model, controller, SCREEN_DRAG_BUTTON);
}
 
Example #3
Source File: JoglAbstractDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected void initGLCanvas() {
    device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

    GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
    caps.setHardwareAccelerated(true);
    caps.setDoubleBuffered(true);
    caps.setStencilBits(settings.getStencilBits());
    caps.setDepthBits(settings.getDepthBits());

    if (settings.getSamples() > 1) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(settings.getSamples());
    }

    canvas = new GLCanvas(caps) {
        @Override
        public void addNotify() {
            super.addNotify();
            onCanvasAdded();
        }

        @Override
        public void removeNotify() {
            onCanvasRemoved();
            super.removeNotify();
        }
    };
    // TODO: add a check on the settings
    // set the size of the canvas as early as possible to avoid further useless reshape attempts
    canvas.setSize(settings.getWidth(), settings.getHeight());
    if (settings.isVSync()) {
        GLContext.getCurrentGL().setSwapInterval(1);
    }
    canvas.setFocusable(true);
    canvas.setIgnoreRepaint(true);
    canvas.addGLEventListener(this);

    // N.B: it is too early to get the GL instance from the canvas
    // if (false){
    // trace mode
    // jME already uses err stream, use out instead
    // gl = new TraceGL(gl, System.out);
    // }else if (false){
    // debug mode
    // gl = new DebugGL(gl);
    // }else{
    // production mode
    // }
    renderer = new JoglRenderer();
}