Java Code Examples for org.lwjgl.opengl.Display#setDisplayMode()
The following examples show how to use
org.lwjgl.opengl.Display#setDisplayMode() .
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: LwJglRenderingEngine.java From Gaalop with GNU Lesser General Public License v3.0 | 7 votes |
/** * Starts the lwjgl engine and shows a window, where the point clouds are rendered */ public void startEngine() { int width = 800; int height = 600; try { Display.setDisplayMode(new DisplayMode(width, height)); Display.setFullscreen(false); Display.setTitle("Gaalop Visualization Window"); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); changeSize(width, height); GL11.glDisable(GL11.GL_LIGHTING); // init OpenGL GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective((float) 65.0, (float) width / (float) height, (float) 0.1, 100); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
Example 2
Source File: HyperiumMinecraft.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
public void fullScreenFix(boolean fullscreen, int displayWidth, int displayHeight) throws LWJGLException { if (Settings.WINDOWED_FULLSCREEN) { if (fullscreen) { System.setProperty("org.lwjgl.opengl.Window.undecorated", "true"); Display.setDisplayMode(Display.getDesktopDisplayMode()); Display.setLocation(0, 0); Display.setFullscreen(false); } else { System.setProperty("org.lwjgl.opengl.Window.undecorated", "false"); Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight)); } } else { Display.setFullscreen(fullscreen); System.setProperty("org.lwjgl.opengl.Window.undecorated", "false"); } Display.setResizable(false); Display.setResizable(true); }
Example 3
Source File: HyperiumMinecraft.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
public void displayFix(CallbackInfo ci, boolean fullscreen, int displayWidth, int displayHeight) throws LWJGLException { Display.setFullscreen(false); if (fullscreen) { if (Settings.WINDOWED_FULLSCREEN) { System.setProperty("org.lwjgl.opengl.Window.undecorated", "true"); } else { Display.setFullscreen(true); DisplayMode displaymode = Display.getDisplayMode(); parent.displayWidth = Math.max(1, displaymode.getWidth()); parent.displayHeight = Math.max(1, displaymode.getHeight()); } } else { if (Settings.WINDOWED_FULLSCREEN) { System.setProperty("org.lwjgl.opengl.Window.undecorated", "false"); } else { Display.setDisplayMode(new DisplayMode(displayWidth, displayHeight)); } } Display.setResizable(false); Display.setResizable(true); // effectively overwrites the method ci.cancel(); }
Example 4
Source File: DisplayManager.java From OpenGL-Animation with The Unlicense | 6 votes |
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 5
Source File: VideoHook.java From malmo with MIT License | 6 votes |
/** * Resizes the window and the Minecraft rendering if necessary. Set renderWidth and renderHeight first. */ private void resizeIfNeeded() { // resize the window if we need to int oldRenderWidth = Display.getWidth(); int oldRenderHeight = Display.getHeight(); if( this.renderWidth == oldRenderWidth && this.renderHeight == oldRenderHeight ) return; try { int old_x = Display.getX(); int old_y = Display.getY(); Display.setLocation(old_x, old_y); Display.setDisplayMode(new DisplayMode(this.renderWidth, this.renderHeight)); System.out.println("Resized the window"); } catch (LWJGLException e) { System.out.println("Failed to resize the window!"); e.printStackTrace(); } forceResize(this.renderWidth, this.renderHeight); }
Example 6
Source File: OpenGL3_TheQuadTextured.java From ldparteditor with MIT License | 6 votes |
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 7
Source File: TestUtils.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initialise the GL display * * @param width The width of the display * @param height The height of the display */ private void initGL(int width, int height) { try { Display.setDisplayMode(new DisplayMode(width,height)); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,width,height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
Example 8
Source File: Window.java From 3DGameEngine with Apache License 2.0 | 5 votes |
public static void CreateWindow(int width, int height, String title) { Display.setTitle(title); try { Display.setDisplayMode(new DisplayMode(width, height)); Display.create(); Keyboard.create(); Mouse.create(); } catch (LWJGLException e) { e.printStackTrace(); } }
Example 9
Source File: Game.java From FEMultiplayer with GNU General Public License v3.0 | 5 votes |
public void init(int width, int height, String name) { time = System.nanoTime(); windowWidth = width*scaleX; windowHeight = height*scaleY; try { Display.setDisplayMode(new DisplayMode(windowWidth, windowHeight)); Display.create(); Display.setTitle(name); Keyboard.create(); Keyboard.enableRepeatEvents(true); Mouse.create(); glContextExists = true; } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } //init OpenGL glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.01f); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearDepth(1.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport(0, 0, windowWidth, windowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, windowWidth/scaleX, windowHeight/scaleY, 0, 1, -1); //It's basically a camera glMatrixMode(GL_MODELVIEW); keys = new ArrayList<KeyboardEvent>(); mouseEvents = new ArrayList<MouseEvent>(); }
Example 10
Source File: GLProgram.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initializes a windowed application. The framerate is set to 60 and can be modified using <code>setFPS(int fps)</code>. * * @param name The title of the window. * @param width The width of the window. * @param height The height of the window. * @param resizable Enables/disables the ability to resize the window. */ public GLProgram(String name, int width, int height, boolean resizable) { Display.setTitle(name); try { Display.setDisplayMode(new DisplayMode(width, height)); } catch(Exception exc) { exc.printStackTrace(); } Display.setResizable(resizable); fps = 60; }
Example 11
Source File: SerializableDisplayMode.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
private final static void nativeSetMode(DisplayMode mode) throws LWJGLException { if (!Display.getDisplayMode().equals(mode)) { System.out.println("setting mode = " + mode); Display.setDisplayMode(mode); Renderer.resetInput(); } }
Example 12
Source File: TwlTest.java From tablelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main (String[] args) throws Exception { System.setProperty("org.lwjgl.librarypath", new File("lib/natives").getAbsolutePath()); Display.setTitle("TWL Examples"); Display.setDisplayMode(new DisplayMode(800, 600)); Display.setVSyncEnabled(true); Display.create(); new TwlTest(); }
Example 13
Source File: LwjglGraphicsModule.java From tprogers2048game with GNU General Public License v3.0 | 5 votes |
private void initOpengl() { try { /* Задаём размер будущего окна */ Display.setDisplayMode(new DisplayMode(Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT)); /* Задаём имя будущего окна */ Display.setTitle(Constants.SCREEN_NAME); /* Создаём окно */ Display.create(); } catch (LWJGLException e) { ErrorCatcher.graphicsFailure(e); } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, Constants.SCREEN_WIDTH,0, Constants.SCREEN_HEIGHT,1,-1); glMatrixMode(GL_MODELVIEW); /* Для поддержки текстур */ glEnable(GL_TEXTURE_2D); /* Для поддержки прозрачности */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* Белый фоновый цвет */ glClearColor(1,1,1,1); }
Example 14
Source File: Window.java From LowPolyWater with The Unlicense | 5 votes |
public void setResolution(DisplayMode resolution, boolean fullscreen) { try { Display.setDisplayMode(resolution); this.resolution = resolution; if (fullscreen && resolution.isFullscreenCapable()) { Display.setFullscreen(true); this.fullScreen = fullscreen; } } catch (LWJGLException e) { e.printStackTrace(); } }
Example 15
Source File: DisplayManager.java From OpenGL-Tutorial-1 with The Unlicense | 5 votes |
/** * 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 16
Source File: ShoveTargetTest.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 4 votes |
@Before public void globalDisplayBefore() throws org.lwjgl.LWJGLException { Display.setDisplayMode(new org.lwjgl.opengl.DisplayMode(5, 5)); Display.create(); }
Example 17
Source File: ClientProxy.java From Fullscreen-Windowed-Minecraft with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void toggleFullScreen(boolean goFullScreen, int desiredMonitor) { //Set value if it isn't set already. if(System.getProperty("org.lwjgl.opengl.Window.undecorated") == null){ System.setProperty("org.lwjgl.opengl.Window.undecorated", "false"); } //If we're in actual fullscreen right now, then we need to fix that. if(Display.isFullscreen()) { fullscreen = true; } String expectedState = goFullScreen ? "true":"false"; // If all state is valid, there is nothing to do and we just exit. if(fullscreen == goFullScreen && !Display.isFullscreen()//Display in fullscreen mode: Change required && System.getProperty("org.lwjgl.opengl.Window.undecorated") == expectedState // Window not in expected state ) return; //Save our current display parameters Rectangle currentCoordinates = new Rectangle(Display.getX(), Display.getY(), Display.getWidth(), Display.getHeight()); if(goFullScreen && !Display.isFullscreen()) _savedWindowedBounds = currentCoordinates; //Changing this property and causing a Display update will cause LWJGL to add/remove decorations (borderless). System.setProperty("org.lwjgl.opengl.Window.undecorated",expectedState); //Get the fullscreen dimensions for the appropriate screen. Rectangle screenBounds = getAppropriateScreenBounds(currentCoordinates, desiredMonitor); //This is the new bounds we have to apply. Rectangle newBounds = goFullScreen ? screenBounds : _savedWindowedBounds; if(newBounds == null) newBounds = screenBounds; if(goFullScreen == false && ClientProxy.fullscreen == false) { newBounds = currentCoordinates; _savedWindowedBounds = currentCoordinates; } try { fullscreen = goFullScreen; client.fullscreen = fullscreen; if( client.gameSettings.fullScreen != fullscreen) { client.gameSettings.fullScreen = fullscreen; client.gameSettings.saveOptions(); } Display.setFullscreen(false); Display.setResizable(!goFullScreen); Display.setDisplayMode(new DisplayMode((int) newBounds.getWidth(), (int) newBounds.getHeight())); Display.setLocation(newBounds.x, newBounds.y); client.resize((int) newBounds.getWidth(), (int) newBounds.getHeight()); Display.setVSyncEnabled(client.gameSettings.enableVsync); client.updateDisplay(); } catch (LWJGLException e) { e.printStackTrace(); } }
Example 18
Source File: Game.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 4 votes |
/** * Inits the. * * @param width the width * @param height the height * @param name the name */ public void init(int width, int height, String name) { Game.logicalWidth = width; Game.logicalHeight = height; Game.scale = FEResources.getWindowScale(); final int windowWidth = Math.round(logicalWidth * scale); final int windowHeight = Math.round(logicalHeight * scale); try { Display.setDisplayMode(new DisplayMode(windowWidth, windowHeight)); Display.create(); Display.setTitle(name); Keyboard.create(); Keyboard.enableRepeatEvents(true); Mouse.create(); glContextExists = true; } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } //init OpenGL glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.01f); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearDepth(1.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport(0, 0, windowWidth, windowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, width, height, 0, 1, -1); //It's basically a camera glMatrixMode(GL_MODELVIEW); keys = new ArrayList<KeyboardEvent>(); mouseEvents = new ArrayList<MouseEvent>(); }
Example 19
Source File: Renderer.java From AnyaBasic with MIT License | 4 votes |
Renderer( int screenWidth, int screenHeight ) { try { Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight)); Display.create(); Display.setTitle( "AnyaBasic 0.4.0 beta" ); } catch( LWJGLException e ) { e.printStackTrace(); } this.screenWidth = screenWidth; this.screenHeight = screenHeight; GL11.glViewport( 0, 0, screenWidth, screenHeight ); GL11.glMatrixMode( GL11.GL_PROJECTION ); GL11.glLoadIdentity(); GL11.glOrtho( 0, screenWidth, screenHeight, 0, 1, -1 ); GL11.glMatrixMode( GL11.GL_MODELVIEW ); GL11.glLoadIdentity(); GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT) GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer) GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable( GL11.GL_ALPHA_TEST ); GL11.glAlphaFunc(GL11.GL_GREATER, 0); GL11.glEnable( GL11.GL_BLEND ); GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA ); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glMatrixMode( GL11.GL_MODELVIEW ); GL11.glLoadIdentity(); GL11.glTranslatef( 0.375f, 0.375f, 0 ); // magic trick }
Example 20
Source File: TestWithDisplay.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
@BeforeClass public void createDisplay() throws LWJGLException { Display.setDisplayMode(new DisplayMode(1, 1)); Display.create(); }