Java Code Examples for org.lwjgl.opengl.Display

The following are top voted examples for showing how to use org.lwjgl.opengl.Display. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: trashjam2017   File: AppletGameContainer.java   Source Code and License 6 votes vote down vote up
/**
 * Start a thread to run LWJGL in
 */
public void startLWJGL() {
   if (gameThread != null) {
      return;
   }
   
   gameThread = new Thread() {
      public void run() {
         try {
            canvas.start();
         }
         catch (Exception e) {
            e.printStackTrace();
            if (Display.isCreated()) {
               Display.destroy();
            }
            displayParent.setVisible(false);//removeAll();
            add(new ConsolePanel(e));
            validate();
         }
      }
   };
   
   gameThread.start();
}
 
Example 2
Project: BaseClient   File: Minecraft.java   Source Code and License 6 votes vote down vote up
protected void checkWindowResize() {
	if (!this.fullscreen && Display.wasResized()) {
		int i = this.displayWidth;
		int j = this.displayHeight;
		this.displayWidth = Display.getWidth();
		this.displayHeight = Display.getHeight();

		if (this.displayWidth != i || this.displayHeight != j) {
			if (this.displayWidth <= 0) {
				this.displayWidth = 1;
			}

			if (this.displayHeight <= 0) {
				this.displayHeight = 1;
			}

			this.resize(this.displayWidth, this.displayHeight);
		}
	}
}
 
Example 3
Project: Backmemed   File: Minecraft.java   Source Code and License 6 votes vote down vote up
/**
 * Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen
 * currently displayed
 */
public void setIngameFocus()
{
    if (Display.isActive())
    {
        if (!this.inGameHasFocus)
        {
            if (!IS_RUNNING_ON_MAC)
            {
                KeyBinding.updateKeyBindState();
            }

            this.inGameHasFocus = true;
            this.mouseHelper.grabMouseCursor();
            this.displayGuiScreen((GuiScreen)null);
            this.leftClickCounter = 10000;
        }
    }
}
 
Example 4
Project: trashjam2017   File: PBufferGraphics.java   Source Code and License 6 votes vote down vote up
/**
 * Initialise the PBuffer that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
		
		final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
		pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);

		// Initialise state of the pbuffer context.
		pbuffer.makeCurrent();

		initGL();
		GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
		pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
		image.draw(0,0);
		image.setTexture(tex);
		
		Display.makeCurrent();
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
	}
}
 
Example 5
Project: trashjam2017   File: PBufferUniqueGraphics.java   Source Code and 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 6
Project: trashjam2017   File: ParticleGame.java   Source Code and License 6 votes vote down vote up
public void update(GameContainer container, int delta)
		throws SlickException {
	if (!paused) {
		ypos += delta * 0.002 * systemMove;
		if (ypos > 300) {
			ypos = -300;
		}
		if (ypos < -300) {
			ypos = 300;
		}

		for (int i = 0; i < emitters.size(); i++) {
			((ConfigurableEmitter) emitters.get(i)).replayCheck();
		}
		for (int i = 0; i < delta; i++) {
			system.update(1);
		}
	}

	Display.sync(100);
}
 
Example 7
Project: OpenGL-Bullet-engine   File: ShaderRenderer.java   Source Code and License 6 votes vote down vote up
protected Matrix4f getProjection(){
	Renderer r=getRenderer();
	if(r!=null) return r.getProjection();
	
	float farPlane=1000,nearPlane=0.1F;
	float aspectRatio=(float)Display.getWidth()/(float)Display.getHeight();
	float y_scale=(float)(1f/Math.tan(Math.toRadians(60/2f))*aspectRatio);
	float x_scale=y_scale/aspectRatio;
	float frustum_length=farPlane-nearPlane;
	
	NULL_PROJECTION.setIdentity();
	NULL_PROJECTION.m00=x_scale;
	NULL_PROJECTION.m11=y_scale;
	NULL_PROJECTION.m22=-((farPlane+nearPlane)/frustum_length);
	NULL_PROJECTION.m23=-1;
	NULL_PROJECTION.m32=-(2*nearPlane*farPlane/frustum_length);
	NULL_PROJECTION.m33=0;
	
	return NULL_PROJECTION;
}
 
Example 8
Project: Backmemed   File: Minecraft.java   Source Code and License 6 votes vote down vote up
public void addServerStatsToSnooper(Snooper playerSnooper)
{
    playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
    playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
    playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat("current_action", this.getCurrentAction());
    playerSnooper.addClientStat("language", this.gameSettings.language == null ? "en_us" : this.gameSettings.language);
    String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
    playerSnooper.addClientStat("endianness", s);
    playerSnooper.addClientStat("subtitles", Boolean.valueOf(this.gameSettings.showSubtitles));
    playerSnooper.addClientStat("touch", this.gameSettings.touchscreen ? "touch" : "mouse");
    playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
    int i = 0;

    for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
    {
        playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
    }

    if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    {
        playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    }
}
 
Example 9
Project: BaseClient   File: PBufferGraphics.java   Source Code and License 6 votes vote down vote up
/**
 * Initialise the PBuffer that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
		
		final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
		pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);

		// Initialise state of the pbuffer context.
		pbuffer.makeCurrent();

		initGL();
		GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
		pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
		image.draw(0,0);
		image.setTexture(tex);
		
		Display.makeCurrent();
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
	}
}
 
Example 10
Project: BaseClient   File: Minecraft.java   Source Code and License 6 votes vote down vote up
/**
 * Shuts down the minecraft applet by stopping the resource downloads, and
 * clearing up GL stuff; called when the application (or web page) is exited.
 */
public void shutdownMinecraftApplet() {
	try {
		this.stream.shutdownStream();
		logger.info("Stopping!");

		Client.getClient().onDisable();

		try {
			this.loadWorld((WorldClient) null);
		} catch (Throwable var5) {
			;
		}

		this.mcSoundHandler.unloadSounds();
	} finally {
		Display.destroy();

		if (!this.hasCrashed) {
			System.exit(0);
		}
	}

	System.gc();
}
 
Example 11
Project: Proyecto-DASI   File: VideoHook.java   Source Code and 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 {
        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 12
Project: Progetto-C   File: AppGameContainer.java   Source Code and 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 13
Project: BaseClient   File: PBufferGraphics.java   Source Code and 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 14
Project: BaseClient   File: Minecraft.java   Source Code and License 6 votes vote down vote up
protected void checkWindowResize()
{
    if (!this.fullscreen && Display.wasResized())
    {
        int i = this.displayWidth;
        int j = this.displayHeight;
        this.displayWidth = Display.getWidth();
        this.displayHeight = Display.getHeight();

        if (this.displayWidth != i || this.displayHeight != j)
        {
            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }

            this.resize(this.displayWidth, this.displayHeight);
        }
    }
}
 
Example 15
Project: featurea   File: MyLwjglCanvas.java   Source Code and License 6 votes vote down vote up
protected int getFrameRate() {
    int frameRate = Display.isActive() ? this.graphics.config.foregroundFPS : this.graphics.config.backgroundFPS;
    if (frameRate == -1) {
        frameRate = 10;
    }

    if (frameRate == 0) {
        frameRate = this.graphics.config.backgroundFPS;
    }

    if (frameRate == 0) {
        frameRate = 30;
    }

    return frameRate;
}
 
Example 16
Project: BaseClient   File: Minecraft.java   Source Code and License 6 votes vote down vote up
public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
{
    playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
    playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
    playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat("current_action", this.func_181538_aA());
    String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
    playerSnooper.addClientStat("endianness", s);
    playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
    int i = 0;

    for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
    {
        playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
    }

    if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    {
        playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    }
}
 
Example 17
Project: BaseClient   File: Minecraft.java   Source Code and License 6 votes vote down vote up
public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper) {
	playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
	playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
	playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
	playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
	playerSnooper.addClientStat("run_time", Long.valueOf(
			(MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
	playerSnooper.addClientStat("current_action", this.func_181538_aA());
	String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
	playerSnooper.addClientStat("endianness", s);
	playerSnooper.addClientStat("resource_packs",
			Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
	int i = 0;

	for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository
			.getRepositoryEntries()) {
		playerSnooper.addClientStat("resource_pack[" + i++ + "]",
				resourcepackrepository$entry.getResourcePackName());
	}

	if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null) {
		playerSnooper.addClientStat("snooper_partner",
				this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
	}
}
 
Example 18
Project: CustomWorldGen   File: SplashProgress.java   Source Code and License 6 votes vote down vote up
/**
 * @deprecated not a stable API, will break, don't use this yet
 */
@Deprecated
public static void resume()
{
    if(!enabled) return;
    checkThreadState();
    pause = false;
    try
    {
        Display.getDrawable().releaseContext();
        d.makeCurrent();
    }
    catch (LWJGLException e)
    {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    lock.unlock();
}
 
Example 19
Project: BaseClient   File: Config.java   Source Code and License 6 votes vote down vote up
public static DisplayMode getDisplayMode(Dimension p_getDisplayMode_0_) throws LWJGLException
{
    DisplayMode[] adisplaymode = Display.getAvailableDisplayModes();

    for (int i = 0; i < adisplaymode.length; ++i)
    {
        DisplayMode displaymode = adisplaymode[i];

        if (displaymode.getWidth() == p_getDisplayMode_0_.width && displaymode.getHeight() == p_getDisplayMode_0_.height && (desktopDisplayMode == null || displaymode.getBitsPerPixel() == desktopDisplayMode.getBitsPerPixel() && displaymode.getFrequency() == desktopDisplayMode.getFrequency()))
        {
            return displaymode;
        }
    }

    return desktopDisplayMode;
}
 
Example 20
Project: CustomWorldGen   File: Minecraft.java   Source Code and License 6 votes vote down vote up
protected void checkWindowResize()
{
    if (!this.fullscreen && Display.wasResized())
    {
        int i = this.displayWidth;
        int j = this.displayHeight;
        this.displayWidth = Display.getWidth();
        this.displayHeight = Display.getHeight();

        if (this.displayWidth != i || this.displayHeight != j)
        {
            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }

            this.resize(this.displayWidth, this.displayHeight);
        }
    }
}
 
Example 21
Project: DecompiledMinecraft   File: Minecraft.java   Source Code and License 6 votes vote down vote up
protected void checkWindowResize()
{
    if (!this.fullscreen && Display.wasResized())
    {
        int i = this.displayWidth;
        int j = this.displayHeight;
        this.displayWidth = Display.getWidth();
        this.displayHeight = Display.getHeight();

        if (this.displayWidth != i || this.displayHeight != j)
        {
            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }

            this.resize(this.displayWidth, this.displayHeight);
        }
    }
}
 
Example 22
Project: DecompiledMinecraft   File: Minecraft.java   Source Code and License 6 votes vote down vote up
public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
{
    playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
    playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
    playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat("current_action", this.func_181538_aA());
    String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
    playerSnooper.addClientStat("endianness", s);
    playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
    int i = 0;

    for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
    {
        playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
    }

    if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    {
        playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    }
}
 
Example 23
Project: ThunderingSky   File: Play.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    AppGameContainer gameContainer;
    try {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        width = (int)screenSize.getWidth();
        height = (int)screenSize.getHeight();
        gameContainer = new AppGameContainer(new Play(gamename));
        gameContainer.setVSync(true); // Should probably stay true for performance
        gameContainer.setDisplayMode(width, height, true);
        gameContainer.setTargetFrameRate(fps);
        gameContainer.setShowFPS(showFps);
        Display.setInitialBackground(1, 1, 1);
        gameContainer.start();
    } catch(SlickException e) {
        e.printStackTrace();
    }
}
 
Example 24
Project: Towan   File: Boot.java   Source Code and License 5 votes vote down vote up
public Boot(){
	
	// BeginSession Call initializes OpenGL calls
	BeginSession();

	// Main game loop
	while(!Display.isCloseRequested()){
		Clock.Update();
		StateManager.Update();
		Display.update();
		Display.sync(60);
	}
	Display.destroy();
}
 
Example 25
Project: OpenGL-Animation   File: DisplayManager.java   Source Code and License 5 votes vote down vote up
public static void update() {
	Display.sync(FPS_CAP);
	Display.update();
	long currentFrameTime = getCurrentTime();
	delta = (currentFrameTime - lastFrameTime) / 1000f;
	lastFrameTime = currentFrameTime;
}
 
Example 26
Project: BaseClient   File: Config.java   Source Code and License 5 votes vote down vote up
public static DisplayMode[] getFullscreenDisplayModes()
{
    try
    {
        DisplayMode[] adisplaymode = Display.getAvailableDisplayModes();
        List list = new ArrayList();

        for (int i = 0; i < adisplaymode.length; ++i)
        {
            DisplayMode displaymode = adisplaymode[i];

            if (desktopDisplayMode == null || displaymode.getBitsPerPixel() == desktopDisplayMode.getBitsPerPixel() && displaymode.getFrequency() == desktopDisplayMode.getFrequency())
            {
                list.add(displaymode);
            }
        }

        DisplayMode[] adisplaymode1 = (DisplayMode[])((DisplayMode[])list.toArray(new DisplayMode[list.size()]));
        Comparator comparator = new Comparator()
        {
            public int compare(Object p_compare_1_, Object p_compare_2_)
            {
                DisplayMode displaymode1 = (DisplayMode)p_compare_1_;
                DisplayMode displaymode2 = (DisplayMode)p_compare_2_;
                return displaymode1.getWidth() != displaymode2.getWidth() ? displaymode2.getWidth() - displaymode1.getWidth() : (displaymode1.getHeight() != displaymode2.getHeight() ? displaymode2.getHeight() - displaymode1.getHeight() : 0);
            }
        };
        Arrays.sort(adisplaymode1, comparator);
        return adisplaymode1;
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
        return new DisplayMode[] {desktopDisplayMode};
    }
}
 
Example 27
Project: trashjam2017   File: AppletGameContainer.java   Source Code and License 5 votes vote down vote up
/**
 * The running game loop
 * 
 * @throws Exception Indicates a failure within the game's loop rather than the framework
 */
public void runloop() throws Exception {
   while (running) {
      int delta = getDelta();

      updateAndRender(delta);

      updateFPS();
      Display.update();
   }

   Display.destroy();
}
 
Example 28
Project: lwjgl_collection   File: StateDemo.java   Source Code and License 5 votes vote down vote up
private StateDemo() {
    
	try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Game States");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    while (!Display.isCloseRequested()) {
        // Render Code here
        glClear(GL_COLOR_BUFFER_BIT);
        
        render();
        checkInput();
        
        Display.update();
        Display.sync(60);
    }
    
    Display.destroy();
    System.exit(0);
}
 
Example 29
Project: CustomWorldGen   File: Minecraft.java   Source Code and License 5 votes vote down vote up
private void setInitialDisplayMode() throws LWJGLException
{
    if (this.fullscreen)
    {
        Display.setFullscreen(true);
        DisplayMode displaymode = Display.getDisplayMode();
        this.displayWidth = Math.max(1, displaymode.getWidth());
        this.displayHeight = Math.max(1, displaymode.getHeight());
    }
    else
    {
        Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
    }
}
 
Example 30
Project: Zombe-Modpack   File: Minecraft.java   Source Code and License 5 votes vote down vote up
private void setWindowIcon()
{
    Util.EnumOS util$enumos = Util.getOSType();

    if (util$enumos != Util.EnumOS.OSX)
    {
        InputStream inputstream = null;
        InputStream inputstream1 = null;

        try
        {
            inputstream = this.mcDefaultResourcePack.getInputStreamAssets(new ResourceLocation("icons/icon_16x16.png"));
            inputstream1 = this.mcDefaultResourcePack.getInputStreamAssets(new ResourceLocation("icons/icon_32x32.png"));

            if (inputstream != null && inputstream1 != null)
            {
                Display.setIcon(new ByteBuffer[] {this.readImageToBuffer(inputstream), this.readImageToBuffer(inputstream1)});
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t set icon", (Throwable)ioexception);
        }
        finally
        {
            IOUtils.closeQuietly(inputstream);
            IOUtils.closeQuietly(inputstream1);
        }
    }
}
 
Example 31
Project: EcoSystem-Official   File: Window.java   Source Code and License 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 32
Project: BaseClient   File: Config.java   Source Code and License 5 votes vote down vote up
public static void checkInitialized()
{
    if (!initialized)
    {
        if (Display.isCreated())
        {
            initialized = true;
            checkOpenGlCaps();
            startVersionCheckThread();
        }
    }
}
 
Example 33
Project: trashjam2017   File: TestUtils.java   Source Code and 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);
}
 
Example 34
Project: MRCEngine   File: MasterRenderer.java   Source Code and License 5 votes vote down vote up
private void createProjectionMatrix() {
	float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
	float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
	float x_scale = y_scale / aspectRatio;
	float frustum_lenght = FAR_PLANE - NEAR_PLANE;
	
	projectionMatrix = new Matrix4f();
	projectionMatrix.m00 = x_scale;
	projectionMatrix.m11 = y_scale;
	projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_lenght);
	projectionMatrix.m23 = -1;
	projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_lenght);
	projectionMatrix.m33 = 0;
}
 
Example 35
Project: EcoSystem-Official   File: Window.java   Source Code and License 5 votes vote down vote up
private void getSuitableFullScreenModes() throws LWJGLException {
    DisplayMode[] resolutions = Display.getAvailableDisplayModes();
    DisplayMode desktopResolution = Display.getDesktopDisplayMode();
    for (DisplayMode resolution : resolutions) {
        if (isSuitableFullScreenResolution(resolution, desktopResolution)) {
            availableResolutions.add(resolution);
        }
    }
}
 
Example 36
Project: BaseClient   File: AppGameContainer.java   Source Code and License 5 votes vote down vote up
public Object run() {
    		try {
    			Display.getDisplayMode();
    		} catch (Exception e) {
    			Log.error(e);
    		}
return null;
        }
 
Example 37
Project: Terrain   File: MasterRenderer.java   Source Code and License 5 votes vote down vote up
private void createProjectionMatrix() {
	float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
	float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
	float x_scale = y_scale / aspectRatio;
	float frustum_length = FAR_PLANE - NEAR_PLANE;

	projectionMatrix = new Matrix4f();
	projectionMatrix.m00 = x_scale;
	projectionMatrix.m11 = y_scale;
	projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
	projectionMatrix.m23 = -1;
	projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
	projectionMatrix.m33 = 0;
}
 
Example 38
Project: FreeWorld   File: FreeWorld.java   Source Code and License 5 votes vote down vote up
private void run(){
    long lns = System.nanoTime();
    double ns = 1000000000.0/20.0;
    long ls = System.currentTimeMillis();
    int fps = 0, tps = 0;


    while (!Display.isCloseRequested() && running) {
        if(System.nanoTime() - lns > ns){
            lns+=ns;
            tps++;
            update();
        }else{
            fps++;
            render();
            Display.update();
        }

        if(System.currentTimeMillis() - ls >= 1000){
            ls = System.currentTimeMillis();
            Display.setTitle(title+" | FPS : "+fps+" | TPS : "+tps);
            fps = 0; tps = 0;
        }
    }

    Display.destroy();
    System.exit(0);
}
 
Example 39
Project: FreeWorld   File: FreeWorld.java   Source Code and License 5 votes vote down vote up
private void render(){
    if(Display.wasResized()) glViewport(0, 0, Display.getWidth(), Display.getHeight());

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);

    GLU.gluPerspective(70.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.01f, 1000.0f);

    glEnable(GL_DEPTH_TEST);
    glPopMatrix();
        glPushAttrib(GL_TRANSFORM_BIT);

            glRotatef(player.getLocation().getYaw(), 1, 0, 0);
            glRotatef(player.getLocation().getPitch(), 0, 1, 0);
            glTranslatef(-player.getLocation().getX(), -player.getLocation().getY(), -player.getLocation().getZ());

            Renderer.renderWorld(world);
            Renderer.renderRayCast(player);

        glPopAttrib();
    glPopMatrix();
    glDisable(GL_DEPTH_TEST);

    renderGUI();
}
 
Example 40
Project: Zombe-Modpack   File: Minecraft.java   Source Code and License 5 votes vote down vote up
private void createDisplay() throws LWJGLException
{
    Display.setResizable(true);
    Display.setTitle("Minecraft 1.11");

    try
    {
        Display.create((new PixelFormat()).withDepthBits(24));
    }
    catch (LWJGLException lwjglexception)
    {
        LOGGER.error((String)"Couldn\'t set pixel format", (Throwable)lwjglexception);

        try
        {
            Thread.sleep(1000L);
        }
        catch (InterruptedException var3)
        {
            ;
        }

        if (this.fullscreen)
        {
            this.updateDisplayMode();
        }

        Display.create();
    }
}