org.lwjgl.opengl.ContextAttribs Java Examples

The following examples show how to use org.lwjgl.opengl.ContextAttribs. 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: DisplayManager.java    From OpenGL-Animation with The Unlicense 6 votes vote down vote up
public static void createDisplay() {
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		ContextAttribs attribs = new ContextAttribs(3, 2).withProfileCore(true).withForwardCompatible(true);
		Display.create(new PixelFormat().withDepthBits(24).withSamples(4), attribs);
		Display.setTitle(TITLE);
		Display.setInitialBackground(1, 1, 1);
		GL11.glEnable(GL13.GL_MULTISAMPLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.err.println("Couldn't create display!");
		System.exit(-1);
	}
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
	lastFrameTime = getCurrentTime();
}
 
Example #2
Source File: OpenGL3_TheQuadTextured.java    From ldparteditor with MIT License 6 votes vote down vote up
private void setupOpenGL() {
    // Setup an OpenGL context with API version 3.2
    try {
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
            .withForwardCompatible(true)
            .withProfileCore(true);
         
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle(WINDOW_TITLE);
        Display.create(pixelFormat, contextAtrributes);
         
        GL11.glViewport(0, 0, WIDTH, HEIGHT);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }
     
    // Setup an XNA like background color
    GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);
     
    // Map the internal OpenGL coordinate system to the entire screen
    GL11.glViewport(0, 0, WIDTH, HEIGHT);
     
    this.exitOnGLError("setupOpenGL");
}
 
Example #3
Source File: DisplayManager.java    From OpenGL-Tutorial-1 with The Unlicense 5 votes vote down vote up
/**
 * Creates a display window on which we can render our game. The dimensions
 * of the window are determined by setting the display mode. By using
 * "glViewport" we tell OpenGL which part of the window we want to render
 * our game onto. We indicated that we want to use the entire window.
 */
public static void createDisplay() {
	ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		Display.create(new PixelFormat(), attribs);
		Display.setTitle(TITLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
}
 
Example #4
Source File: GLProgram.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Initializes the context with its attributes and PixelFormat supplied.
 * 
 * This method does not return until the game loop ends.
 * 
 * @param format The PixelFormat specifying the buffers.
 * @param attribs The context attributes.
 */
public final void run(PixelFormat format, ContextAttribs attribs) {
	try {
		Display.create(format, attribs);
	} catch(Exception exc) {
		exc.printStackTrace();
		System.exit(1);
	}
	
	gameLoop();
}
 
Example #5
Source File: Context.java    From LowPolyWater with The Unlicense 4 votes vote down vote up
public ContextAttribs getAttribs() {
	return new ContextAttribs(openGlVersion[0], openGlVersion[1]).withForwardCompatible(true).withProfileCore(true);
}
 
Example #6
Source File: GLProgram.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Initializes the context depending on the value of <code>core</code> and the supplied PixelFormat.
 * 
 * This method does not return until the game loop ends.
 * 
 * @param core <code>True</code> requests the Core profile, while <code>false</code> keeps default settings.
 * @param format The PixelFormat specifying the buffers.
 */
public final void run(boolean core, PixelFormat format) {
	run(format, core ? new ContextAttribs(3, 2).withProfileCore(true) : null);
}
 
Example #7
Source File: GLProgram.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Initializes the context depending on the value of <code>core</code>, the supplied PixelFormat, and the specified
 * OpenGL version in the format: <code>major.minor</code>
 * 
 * This method does not return until the game loop ends.
 * 
 * @param major
 * @param minor
 * @param core <<code>True</code> requests the Core profile, while <code>false</code> requests the Compatibility profile.
 * @param format The PixelFormat specifying the buffers.
 */
public final void run(int major, int minor, boolean core, PixelFormat format) {
	run(format, core ? new ContextAttribs(major, minor).withProfileCore(core) : new ContextAttribs(major, minor));
}
 
Example #8
Source File: GLProgram.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Initializes the context with its attributes supplied.
 * 
 * This method does not return until the game loop ends.
 * 
 * @param attribs The context attributes.
 */
public final void run(ContextAttribs attribs) {
	run(new PixelFormat(), attribs);
}