org.lwjgl.opengl.GLCapabilities Java Examples

The following examples show how to use org.lwjgl.opengl.GLCapabilities. 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: OpenGLUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void onModelRegistryEvent(ModelRegistryEvent event) {
    GLCapabilities caps = GL.getCapabilities();
    openGL20 = caps.OpenGL20;
    openGL21 = caps.OpenGL21;
    openGL32 = caps.OpenGL32;
    openGL40 = caps.OpenGL40;
    openGL43 = caps.OpenGL43;
    openGL44 = caps.OpenGL44;
    openGL45 = caps.OpenGL45;
    openGL46 = caps.OpenGL46;
}
 
Example #2
Source File: GLContainer.java    From settlers-remake with MIT License 5 votes vote down vote up
public void wrapNewContext() {
	if(cc instanceof JAWTContextCreator) ((JAWTContextCreator)cc).makeCurrent(true);
	if(context != null) context.disposeAll();

	GLCapabilities caps = GL.createCapabilities();

	if(caps.OpenGL20) {
		context = new LWJGL20DrawContext(caps, debug);
	} else if(caps.OpenGL15 && caps.GL_ARB_texture_non_power_of_two) {
		context = new LWJGL15DrawContext(caps, debug);
	} else {
		context = null;
		errorGLVersion();
	}
}
 
Example #3
Source File: DesktopMini2DxGame.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
/**
 * Enables or disables GL debug messages for the specified severity level. Returns false if the severity
 * level could not be set (e.g. the NOTIFICATION level is not supported by the ARB and AMD extensions).
 *
 * See {@link Lwjgl3ApplicationConfiguration#enableGLDebugOutput(boolean, PrintStream)}
 */
public static boolean setGLDebugMessageControl (GLDebugMessageSeverity severity, boolean enabled) {
	GLCapabilities caps = GL.getCapabilities();
	final int GL_DONT_CARE = 0x1100; // not defined anywhere yet

	if (caps.OpenGL43) {
		GL43.glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, severity.gl43, (IntBuffer) null, enabled);
		return true;
	}

	if (caps.GL_KHR_debug) {
		KHRDebug.glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, severity.khr, (IntBuffer) null, enabled);
		return true;
	}

	if (caps.GL_ARB_debug_output && severity.arb != -1) {
		ARBDebugOutput.glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, severity.arb, (IntBuffer) null, enabled);
		return true;
	}

	if (caps.GL_AMD_debug_output && severity.amd != -1) {
		AMDDebugOutput.glDebugMessageEnableAMD(GL_DONT_CARE, severity.amd, (IntBuffer) null, enabled);
		return true;
	}

	return false;
}
 
Example #4
Source File: Window.java    From LWJGUI with MIT License 4 votes vote down vote up
public GLCapabilities getCapabilities() {
	return this.capabilities;
}
 
Example #5
Source File: Composite3D.java    From ldparteditor with MIT License 4 votes vote down vote up
public GLCapabilities getCapabilities() {
    return capabilities;
}
 
Example #6
Source File: CompositePrimitive.java    From ldparteditor with MIT License 4 votes vote down vote up
public GLCapabilities getCapabilities() {
    return capabilities;
}
 
Example #7
Source File: LwjglContextVR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void initContextFirstTime() {
    final GLCapabilities capabilities = createCapabilities(settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32));

    if (!capabilities.OpenGL20) {
        throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine");
    }

    if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2)
            || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL32)) {
        GL gl = new LwjglGL();
        GLExt glext = new LwjglGLExt();
        GLFbo glfbo;

        if (capabilities.OpenGL30) {
            glfbo = new LwjglGLFboGL3();
        } else {
            glfbo = new LwjglGLFboEXT();
        }

        if (settings.getBoolean("GraphicsDebug")) {
            gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class);
            glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class);
            glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class);
        }

        if (settings.getBoolean("GraphicsTiming")) {
            GLTimingState timingState = new GLTimingState();
            gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class);
            glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class);
            glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class);
        }

        if (settings.getBoolean("GraphicsTrace")) {
            gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class);
            glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class);
            glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class);
        }

        renderer = new GLRenderer(gl, glext, glfbo);
        renderer.initialize();
    } else {
        throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer());
    }

    if (capabilities.GL_ARB_debug_output && settings.getBoolean("GraphicsDebug")) {
        ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0);
    }
    
    renderer.setMainFrameBufferSrgb(settings.isGammaCorrection());
    renderer.setLinearizeSrgbImages(settings.isGammaCorrection());

    // Init input
    if (keyInput != null) {
        keyInput.initialize();
    }

    if (mouseInput != null) {
        mouseInput.initialize();
    }

    if (joyInput != null) {
        joyInput.initialize();
    }
    renderable.set(true);
}
 
Example #8
Source File: LwjglContext.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void initContextFirstTime() {

        final String renderer = settings.getRenderer();
        final GLCapabilities capabilities = createCapabilities(!renderer.equals(AppSettings.LWJGL_OPENGL2));

        if (!capabilities.OpenGL20) {
            throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine");
        } else if (!SUPPORTED_RENDERS.contains(renderer)) {
            throw new UnsupportedOperationException("Unsupported renderer: " + renderer);
        }

        GL gl = new LwjglGL();
        GLExt glext = new LwjglGLExt();
        GLFbo glfbo;

        if (capabilities.OpenGL30) {
            glfbo = new LwjglGLFboGL3();
        } else {
            glfbo = new LwjglGLFboEXT();
        }

        if (settings.getBoolean("GraphicsDebug")) {
            gl = (GL) GLDebug.createProxy(gl, gl, GL.class, GL2.class, GL3.class, GL4.class);
            glext = (GLExt) GLDebug.createProxy(gl, glext, GLExt.class);
            glfbo = (GLFbo) GLDebug.createProxy(gl, glfbo, GLFbo.class);
        }

        if (settings.getBoolean("GraphicsTiming")) {
            GLTimingState timingState = new GLTimingState();
            gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class);
            glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class);
            glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class);
        }

        if (settings.getBoolean("GraphicsTrace")) {
            gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class);
            glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class);
            glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class);
        }

        this.renderer = new GLRenderer(gl, glext, glfbo);
        this.renderer.initialize();

        if (capabilities.GL_ARB_debug_output && settings.getBoolean("GraphicsDebug")) {
            ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0);
        }

        this.renderer.setMainFrameBufferSrgb(settings.isGammaCorrection());
        this.renderer.setLinearizeSrgbImages(settings.isGammaCorrection());

        // Init input
        if (keyInput != null) {
            keyInput.initialize();
        }

        if (mouseInput != null) {
            mouseInput.initialize();
        }

        if (joyInput != null) {
            joyInput.initialize();
        }

        GLFW.glfwSetJoystickCallback(new GLFWJoystickCallback() {
            @Override
            public void invoke(int jid, int event) {

                // Invoke the disconnected event before we reload the joysticks or we lose the reference to it.
                // Invoke the connected event after we reload the joysticks to obtain the reference to it.

                if ( event == GLFW.GLFW_CONNECTED ) {
                    joyInput.reloadJoysticks();
                    joyInput.fireJoystickConnectedEvent(jid);
                }
                else {
                    joyInput.fireJoystickDisconnectedEvent(jid);
                    joyInput.reloadJoysticks();
                }
            }
        });

        renderable.set(true);
    }
 
Example #9
Source File: LWJGL20DrawContext.java    From settlers-remake with MIT License 4 votes vote down vote up
public LWJGL20DrawContext(GLCapabilities glcaps, boolean debug) {
	super(glcaps, debug);
	global.identity();

}
 
Example #10
Source File: LWJGL15DrawContext.java    From settlers-remake with MIT License 3 votes vote down vote up
public LWJGL15DrawContext(GLCapabilities glcaps, boolean debug) {
	this.glcaps = glcaps;

	if(debug) debugOutput = new LWJGLDebugOutput(this);

	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glDepthFunc(GL11.GL_LEQUAL);

	GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

	init();
}