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(); }
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); }
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(); }
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(); }
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(); }
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"); }
@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); }
@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); } }
/** * 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(); }
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; }
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(); }
public final void run(PixelFormat format, ContextAttribs attribs) { try { Display.create(format, attribs); } catch(Exception exc) { exc.printStackTrace(); System.exit(1); } gameLoop(); }
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); }
@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); } } }
/** * 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(); }
public static BufferedImage renderImage(int width, int height, Runnable renderer) throws LWJGLException, IOException { synchronized (PBUFFER_LOCK) { ContextAttribs contextAtrributes = new ContextAttribs(1, 1); contextAtrributes.withForwardCompatible(true); Pbuffer pbuffer = new Pbuffer(width, height, new PixelFormat(), null, null, contextAtrributes); pbuffer.makeCurrent(); if (pbuffer.isBufferLost()) { pbuffer.destroy(); return null; } IntBuffer pixels = ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.nativeOrder()).asIntBuffer(); BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); renderer.run(); glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixels); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { bi.setRGB(x, y, pixels.get((height - y - 1) * width + x)); } } pbuffer.destroy(); return bi; } }
public ContextAttribs getAttribs() { return new ContextAttribs(openGlVersion[0], openGlVersion[1]).withForwardCompatible(true).withProfileCore(true); }
private static void createLWJGL() { try { final JumboLaunchConfig c = JumboSettings.launchConfig; // Dimension size = frame.getSize(); // frame.add(canvas); // canvas.setSize(size); // Display.setParent(canvas); // canvas.setMinimumSize(size); // canvas.setVisible(true); if (c.fullscreen) { Display.setFullscreen(true); Display.setDisplayMode(c.mode); } else { Display.setDisplayMode(c.mode); Display.setFullscreen(false); } Display.setTitle(c.title); Display.setResizable(c.resizable); if (c.icon != null) { final int iconnum = c.icon.length; final ByteBuffer[] list = new ByteBuffer[iconnum]; for (int i = 0; i < iconnum; i++) { list[i] = new ImageIOImageData().imageToByteBuffer(c.icon[i], false, false, null); } Display.setIcon(list); } if (c.fullscreen && c.vsync) { Display.setVSyncEnabled(true); } if (!Display.isCreated()) { final PixelFormat pixelFormat = new PixelFormat(); final ContextAttribs contextAtrributes = new ContextAttribs(3, 3).withProfileCompatibility(true); Display.create(pixelFormat, contextAtrributes); } if (!Mouse.isCreated()) { Mouse.create(); } if (!Keyboard.isCreated()) { Keyboard.create(); } } catch (LWJGLException e) { JumboErrorHandler.handle(e); } }
public final void run(boolean core, PixelFormat format) { run(format, core ? new ContextAttribs(3, 2).withProfileCore(true) : null); }
public final void run(int major, int minor, boolean core, PixelFormat format) { run(format, new ContextAttribs(major, minor).withProfileCore(core)); }
public final void run(ContextAttribs attribs) { run(new PixelFormat(), attribs); }
@Override protected void createDisplay() throws LWJGLException { ContextAttribs attribs = new ContextAttribs(1, 4); PixelFormat format = new PixelFormat(); Display.create(format, attribs); }
protected void createContext(AppSettings settings) throws LWJGLException{ DisplayMode displayMode = null; if (settings.getWidth() <= 0 || settings.getHeight() <= 0){ displayMode = Display.getDesktopDisplayMode(); settings.setResolution(displayMode.getWidth(), displayMode.getHeight()); }else if (settings.isFullscreen()){ displayMode = getFullscreenDisplayMode(settings.getWidth(), settings.getHeight(), settings.getBitsPerPixel(), settings.getFrequency()); if (displayMode == null) throw new RuntimeException("Unable to find fullscreen display mode matching settings"); }else{ displayMode = new DisplayMode(settings.getWidth(), settings.getHeight()); } PixelFormat pf = new PixelFormat(settings.getBitsPerPixel(), 0, settings.getDepthBits(), settings.getStencilBits(), settings.getSamples()); frameRate = settings.getFrameRate(); logger.log(Level.INFO, "Selected display mode: {0}", displayMode); boolean pixelFormatChanged = false; if (created.get() && (pixelFormat.getBitsPerPixel() != pf.getBitsPerPixel() ||pixelFormat.getDepthBits() != pf.getDepthBits() ||pixelFormat.getStencilBits() != pf.getStencilBits() ||pixelFormat.getSamples() != pf.getSamples())){ renderer.resetGLObjects(); Display.destroy(); pixelFormatChanged = true; } pixelFormat = pf; Display.setTitle(settings.getTitle()); if (displayMode != null){ if (settings.isFullscreen()){ Display.setDisplayModeAndFullscreen(displayMode); }else{ Display.setFullscreen(false); Display.setDisplayMode(displayMode); } }else{ Display.setFullscreen(settings.isFullscreen()); } if (settings.getIcons() != null) { Display.setIcon(imagesToByteBuffers(settings.getIcons())); } Display.setVSyncEnabled(settings.isVSync()); if (created.get() && !pixelFormatChanged){ Display.releaseContext(); Display.makeCurrent(); Display.update(); } if (!created.get() || pixelFormatChanged){ ContextAttribs attr = createContextAttribs(); if (attr != null){ Display.create(pixelFormat, attr); }else{ Display.create(pixelFormat); } renderable.set(true); if (pixelFormatChanged && pixelFormat.getSamples() > 1 && GLContext.getCapabilities().GL_ARB_multisample){ GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB); } } }
/** * 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); }
/** * 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)); }
/** * 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); }