本文整理汇总了Java中org.lwjgl.opengl.ContextAttribs类的典型用法代码示例。如果您正苦于以下问题:Java ContextAttribs类的具体用法?Java ContextAttribs怎么用?Java ContextAttribs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContextAttribs类属于org.lwjgl.opengl包,在下文中一共展示了ContextAttribs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
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("MRCEngine");
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
示例2: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
// OpenGL version used
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);
}
示例3: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
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();
}
示例4: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
ContextAttribs attribs = new ContextAttribs(3, 3)
.withForwardCompatible(true)
.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create(new PixelFormat(), attribs);
Display.setTitle("Our First Display!");
GL11.glEnable(GL13.GL_MULTISAMPLE);
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
示例5: init
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public void init() throws Exception {
try {
System.setProperty("org.lwjgl.opengl.Display.noinput", "true");
PixelFormat pixFormat = new PixelFormat();
ContextAttribs contextAttribs = new ContextAttribs(3, 2)
.withForwardCompatible(true)
.withProfileCore(true);
Display.setResizable(true);
Display.setParent(glCanvas);
Display.create(pixFormat, contextAttribs);
// TODO: Find the reason why this hack is necessary and fix it
// Without this, the menu bar will be below the canvas and isMouseInsideWindow
// will return false unless it left and re-entered the frame once
SwingUtilities.invokeLater(() -> {
Component root = SwingUtilities.getRoot(glCanvas);
root.setSize(root.getWidth(), root.getHeight() + 1);
root.setSize(root.getWidth(), root.getHeight() - 1);
});
initGL();
} catch (LWJGLException e) {
log.log(Level.SEVERE, "Couldn't create display: " + e.getMessage(), e);
throw e;
}
lastFPSReport = game.getTimeMillis();
}
示例6: setupOpenGL
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
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");
}
示例7: create
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
@Override
public void create() {
try {
// Get the desktop display mode
final DisplayMode mode = Display.getDesktopDisplayMode();
// Create the pixel format
final PixelFormat format = new PixelFormat(mode.getBitsPerPixel(), 8, 8, 0, 0);
// Create the context attrib
ContextAttribs attribs = new ContextAttribs(getGLVersion().getMajor(), getGLVersion().getMinor());
attribs = attribs.withProfileCore(true);
attribs = attribs.withDebug(true);
// Create the display
Display.create(format, attribs);
super.create();
} catch (LWJGLException ex) {
throw new IllegalStateException("Unable to create display!", ex);
}
setWindowTitle("Fusion Engine | Version: " + Engine.ENGINE_VERSION);
setClearColour(0.0f, 0.35f, 0.75f);
setWindowSize(800, 600);
enableVSync(true);
}
示例8: create
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
@Override
public void create(String title) {
setTitle(title);
enableResize(true);
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
.withForwardCompatible(true)
.withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(getWidth(), getHeight()));
Display.create(pixelFormat, contextAtrributes);
Keyboard.create();
Mouse.create();
AL.create();
drawBuffer = glGetInteger(GL_DRAW_BUFFER);
readBuffer = glGetInteger(GL_READ_BUFFER);
} catch (LWJGLException e) {
LOGGER.error("Error setting up input and window", e);
}
}
示例9: create
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
/**
* Creates the OpenGL context window with the given parameters. <br>
* <i>Note: the QuadEngine runs on OpenGL 3.2</i>
*
* @param width The width of the window.
* @param height The height of the window.
* @param title The title of the game.
*/
public static void create(int width, int height, String title) {
ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
desktop = Display.getDesktopDisplayMode();
refreshRate = desktop.getFrequency();
try {
Display.setDisplayMode(new DisplayMode(width, height));
Display.create(new PixelFormat(), attribs);
Display.setTitle(title);
Keyboard.create();
Mouse.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, width, height);
lastFrameTime = Util.getTime();
}
示例10: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
ContextAttribs attribs = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCore(true);
try {
//Display.setResizable(true); // whether our window is resizable
Display.setDisplayMode(new DisplayMode(Settings.WINDOW_WIDTH, Settings.WINDOW_HEIGHT));
Display.setVSyncEnabled(Settings.VSYNC); // whether hardware VSync
// is enabled
Display.setFullscreen(Settings.FULL_SCREEN); // whether fullscreen
// is
// enabled
if (Settings.ENABLE_ANTIALIASING) {
Display.create(new PixelFormat().withDepthBits(24), attribs);
System.out.println(GL11.glGetInteger(GL11.GL_DEPTH_BITS));
GL11.glEnable(GL13.GL_MULTISAMPLE);
} else {
Display.create(new PixelFormat(), attribs);
}
Display.setTitle(WINDOWNAME);
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, Settings.WINDOW_WIDTH, Settings.WINDOW_HEIGHT);
lastFrameTime = getCurrentTime();
lastFPS = lastFrameTime;
}
示例11: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
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("Our first display!");
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, WIDTH, HEIGHT);
lastFrameTime = getCurrentTime();
}
示例12: run
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public final void run(PixelFormat format, ContextAttribs attribs) {
try {
Display.create(format, attribs);
} catch(Exception exc) {
exc.printStackTrace();
System.exit(1);
}
gameLoop();
}
示例13: createDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay(int width, int height) {
ContextAttribs attribs = new ContextAttribs(4, 1).withForwardCompatible(true).withProfileCore(true);
try {
Display.setDisplayMode(new DisplayMode(width, height));
Display.create(new PixelFormat(), attribs);
Display.setTitle("MRL LWJGL GUI");
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glViewport(0, 0, width, height);
}
示例14: initDisplay
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
private void initDisplay(boolean core) {
try {
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCompatibility(true);
if (core) contextAtrributes = contextAtrributes.withProfileCore(true);
Display.setDisplayMode(new DisplayMode(game.getSettings().getWidth(), game.getSettings().getHeight()));
ClientHelper.setDisplaySize(new Vec2i(game.getSettings().getWidth(), game.getSettings().getHeight()));
Display.setResizable(true);
Display.create(pixelFormat, contextAtrributes);
GLHelper.checkForErrors();
int vao = GL30.glGenVertexArrays();
GL30.glBindVertexArray(vao);
initGL();
GLHelper.checkForErrors();
} catch (Exception ex) {
if (!core) {
initDisplay(true);
} else {
new KatamaException("Could not init display!").printStackTrace();
System.exit(-1);
}
}
}
示例15: run
import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
/**
* 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();
}