Java源码示例:org.lwjgl.opengl.ContextAttribs
示例1
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();
}
示例2
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");
}
示例3
/**
* 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);
}
示例4
/**
* 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();
}
示例5
public ContextAttribs getAttribs() {
return new ContextAttribs(openGlVersion[0], openGlVersion[1]).withForwardCompatible(true).withProfileCore(true);
}
示例6
/**
* 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);
}
示例7
/**
* 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));
}
示例8
/**
* 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);
}