org.lwjgl.LWJGLException Java Examples

The following examples show how to use org.lwjgl.LWJGLException. 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 vote down vote up
/**
 * 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: PBufferGraphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.Graphics#disable()
 */
protected void disable() {
	GL.flush();
	
	// Bind the texture after rendering.
	GL.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
	pbuffer.bindTexImage(Pbuffer.FRONT_LEFT_BUFFER);
	
	try {
		Display.makeCurrent();
	} catch (LWJGLException e) {
		Log.error(e);
	}
	
	SlickCallable.leaveSafeBlock();
}
 
Example #3
Source File: VideoHook.java    From malmo with MIT License 6 votes vote down vote up
/**
 * 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 #4
Source File: GLHelper.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
/**
 * from org.newdawn.slick.AppGameContainer#setDisplayMode
 */
public static DisplayMode findFullscreenDisplayMode(int targetBPP, int targetFrequency, int width, int height) throws LWJGLException {
	DisplayMode[] modes = Display.getAvailableDisplayModes();
	DisplayMode foundMode = null;
	int freq = 0;
	int bpp = 0;

	for (DisplayMode current : modes) {
		if (current.getWidth() != width || current.getHeight() != height) {
			continue;
		}

		if (current.getBitsPerPixel() == targetBPP && current.getFrequency() == targetFrequency) {
			return current;
		}

		if (current.getFrequency() >= freq && (foundMode == null || current.getBitsPerPixel() >= bpp)) {
			foundMode = current;
			freq = foundMode.getFrequency();
			bpp = foundMode.getBitsPerPixel();
		}
	}
	return foundMode;
}
 
Example #5
Source File: Window.java    From LowPolyWater with The Unlicense 6 votes vote down vote up
protected Window(Context context, WindowBuilder settings) {
	this.fpsCap = settings.getFpsCap();
	try {
		getSuitableFullScreenModes();
		DisplayMode resolution = getStartResolution(settings);
		Display.setInitialBackground(1, 1, 1);
		this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
		setResolution(resolution, settings.isFullScreen());
		if (settings.hasIcon()) {
			Display.setIcon(settings.getIcon());
		}
		Display.setVSyncEnabled(settings.isvSync());
		Display.setTitle(settings.getTitle());
		Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
		GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
}
 
Example #6
Source File: LwjglDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected DisplayMode getFullscreenDisplayMode(int width, int height, int bpp, int freq){
    try {
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        for (DisplayMode mode : modes){
            if (mode.getWidth() == width
             && mode.getHeight() == height
             && (mode.getBitsPerPixel() == bpp || (bpp==24&&mode.getBitsPerPixel()==32))
             && mode.getFrequency() == freq){
                return mode;
            }
        }
    } catch (LWJGLException ex) {
        listener.handleError("Failed to acquire fullscreen display mode!", ex);
    }
    return null;
}
 
Example #7
Source File: HyperiumMinecraft.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #8
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 #9
Source File: FastDMM.java    From FastDMM with GNU General Public License v3.0 6 votes vote down vote up
public static final void main(String[] args) throws IOException, LWJGLException {
	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException
			| IllegalAccessException e) {
		e.printStackTrace();
	}

	FastDMM fastdmm = new FastDMM();

	fastdmm.initSwing();
	fastdmm.interface_dmi = new DMI(Util.getFile("interface.dmi"));

	try {
		fastdmm.init();
		fastdmm.loop();
	} catch (Exception ex) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		ex.printStackTrace(pw);
		JOptionPane.showMessageDialog(fastdmm, sw.getBuffer(), "Error", JOptionPane.ERROR_MESSAGE);
		System.exit(1);
	} finally {
		Display.destroy();
	}
}
 
Example #10
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 #11
Source File: SerializableDisplayMode.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
private final static void createWindow() throws LWJGLException {
	int[] depth_array = new int[]{24, 16};
	int[] samples_array = new int[]{/*Settings.getSettings().samples, */0};
	LWJGLException last_exception = new LWJGLException("Could not find a suitable pixel format");
	for (int d = 0; d < depth_array.length; d++)
		for (int s = 0; s < samples_array.length; s++) {
			int depth = depth_array[d];
			int samples = samples_array[s];
			try {
				Display.create(new PixelFormat(0, depth, 0, samples));
				return;
			} catch (LWJGLException e) {
				last_exception = e;
				System.out.println("Failed window: depthbits = " + depth + " | samples = " + samples + " with exception " + e);
			}
		}
	throw last_exception;
}
 
Example #12
Source File: HyperiumMinecraft.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #13
Source File: PbufferRenderer.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
PbufferRenderer(int width, int height, PixelFormat format, boolean use_copyteximage, OffscreenRendererFactory factory) throws LWJGLException {
	super(width, height, use_copyteximage);
	this.factory = factory;
	pbuffer = new Pbuffer(width, height, format, null, null);
	GLStateStack state_stack = new GLStateStack();
	pbuffer.makeCurrent();
	GLStateStack.setCurrent(state_stack);
	try {
		pbuffer.makeCurrent();
		Renderer.dumpWindowInfo();
		init();
		if (!GLUtils.getGLBoolean(GL11.GL_DOUBLEBUFFER)) {
			GL11.glReadBuffer(GL11.GL_FRONT);
			GL11.glDrawBuffer(GL11.GL_FRONT);
		}
	} catch (LWJGLException e) {
		pbuffer.destroy();
		throw e;
	}
}
 
Example #14
Source File: PBufferUniqueGraphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.Graphics#disable()
 */
protected void disable() {
	// Bind the texture after rendering.
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
	GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, 
						  image.getTexture().getTextureWidth(), 
						  image.getTexture().getTextureHeight(), 0);
	
	try {
		Display.makeCurrent();
	} catch (LWJGLException e) {
		Log.error(e);
	}
	
	SlickCallable.leaveSafeBlock();
}
 
Example #15
Source File: CursorLoader.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get a cursor based on a set of image data
 * 
 * @param imageData The data from which the cursor can read it's contents
 * @param x The x-coordinate of the cursor hotspot (left -> right)
 * @param y The y-coordinate of the cursor hotspot (bottom -> top)
 * @return The create cursor
 * @throws IOException Indicates a failure to load the image
 * @throws LWJGLException Indicates a failure to create the hardware cursor
 */
public Cursor getCursor(ImageData imageData,int x,int y) throws IOException, LWJGLException {
	ByteBuffer buf = imageData.getImageBufferData();
	for (int i=0;i<buf.limit();i+=4) {
		byte red = buf.get(i);
		byte green = buf.get(i+1);
		byte blue = buf.get(i+2);
		byte alpha = buf.get(i+3);
		
		buf.put(i+2, red);
		buf.put(i+1, green);
		buf.put(i, blue);
		buf.put(i+3, alpha);
	}
	
	try {
		int yspot = imageData.getHeight() - y - 1;
		if (yspot < 0) {
			yspot = 0;
		}
		return new Cursor(imageData.getTexWidth(), imageData.getTexHeight(), x, yspot, 1, buf.asIntBuffer(), null);
	} catch (Throwable e) {
		Log.info("Chances are you cursor is too small for this platform");
		throw new LWJGLException(e);
	}
}
 
Example #16
Source File: CursorLoader.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Get a cursor based on a set of image data
 * 
 * @param buf The image data (stored in RGBA) to load the cursor from
 * @param x The x-coordinate of the cursor hotspot (left -> right)
 * @param y The y-coordinate of the cursor hotspot (bottom -> top)
 * @param width The width of the image data provided
 * @param height The height of the image data provided
 * @return The create cursor
 * @throws IOException Indicates a failure to load the image
 * @throws LWJGLException Indicates a failure to create the hardware cursor
 */
public Cursor getCursor(ByteBuffer buf,int x,int y,int width,int height) throws IOException, LWJGLException {
	for (int i=0;i<buf.limit();i+=4) {
		byte red = buf.get(i);
		byte green = buf.get(i+1);
		byte blue = buf.get(i+2);
		byte alpha = buf.get(i+3);
		
		buf.put(i+2, red);
		buf.put(i+1, green);
		buf.put(i, blue);
		buf.put(i+3, alpha);
	}
	
	try {
		int yspot = height - y - 1;
		if (yspot < 0) {
			yspot = 0;
		}
		return new Cursor(width,height, x, yspot, 1, buf.asIntBuffer(), null);
	} catch (Throwable e) {
		Log.info("Chances are you cursor is too small for this platform");
		throw new LWJGLException(e);
	}
}
 
Example #17
Source File: AppGameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Indicate whether we want to be in fullscreen mode. Note that the current
 * display mode must be valid as a fullscreen mode for this to work
 * 
 * @param fullscreen True if we want to be in fullscreen mode
 * @throws SlickException Indicates we failed to change the display mode
 */
public void setFullscreen(boolean fullscreen) throws SlickException {
	if (isFullscreen() == fullscreen) {
		return;
	}
	
	if (!fullscreen) {
		try {
			Display.setFullscreen(fullscreen);
		} catch (LWJGLException e) {
			throw new SlickException("Unable to set fullscreen="+fullscreen, e);
		}
	} else {
		setDisplayMode(width, height, fullscreen);
	}
	getDelta();
}
 
Example #18
Source File: OpenALMODPlayer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
* Initialise OpenAL LWJGL styley
*/
  public void init() {
  	try {
	AL.create();
	soundWorks = true;
} catch (LWJGLException e) {
	System.err.println("Failed to initialise LWJGL OpenAL");
	soundWorks = false;
	return;
}

if (soundWorks) {
	IntBuffer sources = BufferUtils.createIntBuffer(1);
	AL10.alGenSources(sources);
	
	if (AL10.alGetError() != AL10.AL_NO_ERROR) {
		System.err.println("Failed to create sources");
		soundWorks = false;
	} else {
		source = sources.get(0);
	}
	
}
  }
 
Example #19
Source File: AppletGameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Start the game container
 * 
 * @throws Exception Failure to create display
 */
public void start() throws Exception {
   Display.setParent(displayParent);
   Display.setVSyncEnabled(true);
   
   try {
      createDisplay();
   } catch (LWJGLException e) {
      e.printStackTrace();
      // failed to create Display, apply workaround (sleep for 1 second) and try again
      Thread.sleep(1000);
      createDisplay();
   }
   
   initGL();
   displayParent.requestFocus();
   container.runloop();
}
 
Example #20
Source File: LwjglDisplay.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void runLoop(){
    // This method is overriden to do restart
    if (needRestart.getAndSet(false)) {
        try {
            createContext(settings);
        } catch (LWJGLException ex) {
            logger.log(Level.SEVERE, "Failed to set display settings!", ex);
        }
        listener.reshape(settings.getWidth(), settings.getHeight());
        logger.fine("Display restarted.");
    } else if (Display.wasResized()) {
        int newWidth = Display.getWidth();
        int newHeight = Display.getHeight();
        settings.setResolution(newWidth, newHeight);
        listener.reshape(newWidth, newHeight);
    }

    super.runLoop();
}
 
Example #21
Source File: LwjglDisplay.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected DisplayMode getFullscreenDisplayMode(int width, int height, int bpp, int freq){
    try {
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        for (DisplayMode mode : modes) {
            if (mode.getWidth() == width
                    && mode.getHeight() == height
                    && (mode.getBitsPerPixel() == bpp || (bpp == 24 && mode.getBitsPerPixel() == 32))
                    && (mode.getFrequency() == freq || (freq == 60 && mode.getFrequency() == 59))) {
                return mode;
            }
        }
    } catch (LWJGLException ex) {
        listener.handleError("Failed to acquire fullscreen display mode!", ex);
    }
    return null;
}
 
Example #22
Source File: LwjglMouseInput.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void initialize() {
    if (!context.isRenderable())
        return;

    try {
        Mouse.create();
        logger.fine("Mouse created.");
        supportHardwareCursor = (Cursor.getCapabilities() & Cursor.CURSOR_ONE_BIT_TRANSPARENCY) != 0;

        // Recall state that was set before initialization
        Mouse.setGrabbed(!cursorVisible);
    } catch (LWJGLException ex) {
        logger.log(Level.SEVERE, "Error while creating mouse", ex);
    }

    if (listener != null) {
        sendFirstMouseEvent();
    }
}
 
Example #23
Source File: Cursor.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initializes the class.
 * @param container the game container
 * @param game the game object
 */
public static void init(GameContainer container, StateBasedGame game) {
	Cursor.container = container;
	Cursor.game = game;
	Cursor.input = container.getInput();

	// create empty cursor to simulate hiding the cursor
	try {
		int min = org.lwjgl.input.Cursor.getMinCursorSize();
		IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
		emptyCursor = new org.lwjgl.input.Cursor(min, min, min/2, min/2, 1, tmp, null);
	} catch (LWJGLException e) {
		ErrorHandler.error("Failed to create hidden cursor.", e, true);
	}
}
 
Example #24
Source File: Game.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: SeventhGame.java    From seventh with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hide the Mouse cursor
 * 
 * @param visible
 */
private void setHWCursorVisible(boolean visible) {
    if (Gdx.app.getType() != ApplicationType.Desktop && Gdx.app instanceof LwjglApplication) {
        return;
    }

    try {
        /* make sure the mouse doesn't move off the screen */
        seventh.client.gfx.Cursor cursor = this.uiManager.getCursor();
        cursor.setClampEnabled(config.getVideo().isFullscreen());
        Gdx.input.setCursorCatched(config.getVideo().isFullscreen());
        
        //Gdx.input.setCursorCatched(true);
        //Gdx.input.setCursorPosition(getScreenWidth()/2, getScreenHeight()/2);
        
        Cursor emptyCursor = null;
        if (Mouse.isCreated()) {
            int min = org.lwjgl.input.Cursor.getMinCursorSize();
            IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
            emptyCursor = new org.lwjgl.input.Cursor(min, min, min / 2, min / 2, 1, tmp, null);
        } else {
            Cons.println("Could not create empty cursor before Mouse object is created");
        }
    
        if (/*Mouse.isInsideWindow() &&*/ emptyCursor != null) {
            Mouse.setNativeCursor(visible ? null : emptyCursor);
        }
    }
    catch(LWJGLException e) {
        Cons.println("*** Unable to hide cursor: " + e);
    }
}
 
Example #26
Source File: InteractiveRenderer.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public InteractiveRenderer(Configuration args, final int displayWidth, final int displayHeight) throws LWJGLException
{
	rasteriser = RasteriserFactory.createRasteriser(args.getRasteriserType(), DisplayType.Window, displayWidth, displayHeight, 24, 8, 24, 4);
	System.out.println("Using rasteriser: "+rasteriser);
	rasteriser.printInfo();
	
	viewMode = ViewMode.OrthoView;

	orthoCamPosition = new Vector3f();
	
	orthoCamera = new OrthoCamera(rasteriser, displayWidth, displayHeight);
	perspectiveCamera = new PerspectiveCamera(rasteriser, displayWidth, displayHeight);
	
	views = new ArrayList<SignEntity>();
}
 
Example #27
Source File: DesktopLauncher.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private void hideCursor() {
	Cursor emptyCursor;

	int min = org.lwjgl.input.Cursor.getMinCursorSize();
	IntBuffer tmp = BufferUtils.createIntBuffer(min * min);
	try {
		emptyCursor = new org.lwjgl.input.Cursor(min, min, min / 2,
				min / 2, 1, tmp, null);

		Mouse.setNativeCursor(emptyCursor);
	} catch (LWJGLException e) {
		EditorLogger.printStackTrace(e);
	}

}
 
Example #28
Source File: GameContainer.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Enable shared OpenGL context. After calling this all containers created 
 * will shared a single parent context
 * 
 * @throws SlickException Indicates a failure to create the shared drawable
 */
public static void enableSharedContext() throws SlickException {
	try {
		SHARED_DRAWABLE = new Pbuffer(64, 64, new PixelFormat(8, 0, 0), null);
	} catch (LWJGLException e) {
		throw new SlickException("Unable to create the pbuffer used for shard context, buffers not supported", e);
	}
}
 
Example #29
Source File: Window.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
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 #30
Source File: TestUtils.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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);
}