Java Code Examples for org.lwjgl.opengl.Display#setResizable()

The following examples show how to use org.lwjgl.opengl.Display#setResizable() . 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: 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 2
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 3
Source File: VideoHook.java    From malmo with MIT License 5 votes vote down vote up
/**
 * Stop sending video.
 */
public void stop(MissionDiagnostics diags)
{
    if( !this.isRunning )
    {
        return;
    }
    if (this.videoProducer != null)
        this.videoProducer.cleanup();

    // stop sending video frames
    try
    {
        MinecraftForge.EVENT_BUS.unregister(this);
    }
    catch(Exception e)
    {
        System.out.println("Failed to unregister video hook: " + e);
    }
    // Close our TCP socket:
    this.connection.close();
    this.isRunning = false;

    // allow the user to resize the window again
    Display.setResizable(true);

    // And fill in some diagnostic data:
    if (diags != null)
    {
        VideoData vd = new VideoData();
        vd.setFrameType(this.videoProducer.getVideoType().toString());
        vd.setFramesSent((int) this.framesSent);
        if (this.timeOfLastFrame == this.timeOfFirstFrame)
            vd.setAverageFpsSent(new BigDecimal(0));
        else
            vd.setAverageFpsSent(new BigDecimal(1000.0 * this.framesSent / (this.timeOfLastFrame - this.timeOfFirstFrame)));
        diags.getVideoData().add(vd);
    }
}
 
Example 4
Source File: GLProgram.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 5
Source File: VideoHook.java    From malmo with MIT License 4 votes vote down vote up
/**
 * Resize the rendering and start sending video over TCP.
 */
public void start(MissionInit missionInit, IVideoProducer videoProducer, VideoProducedObserver observer, MalmoEnvServer envServer)
{
    if (videoProducer == null)
    {
        return; // Don't start up if there is nothing to provide the video.
    }

    videoProducer.prepare(missionInit);
    this.missionInit = missionInit;
    this.videoProducer = videoProducer;
    this.observer = observer;
    this.envServer = envServer;
    this.buffer = BufferUtils.createByteBuffer(this.videoProducer.getRequiredBufferSize());
    this.headerbuffer = ByteBuffer.allocate(20).order(ByteOrder.BIG_ENDIAN);
    this.renderWidth = videoProducer.getWidth();
    this.renderHeight = videoProducer.getHeight();
    resizeIfNeeded();
    Display.setResizable(false); // prevent the user from resizing using the window borders

    ClientAgentConnection cac = missionInit.getClientAgentConnection();
    if (cac == null)
        return;	// Don't start up if we don't have any connection details.

    String agentIPAddress = cac.getAgentIPAddress();
    int agentPort = 0;
    switch (videoProducer.getVideoType())
    {
    case LUMINANCE:
        agentPort = cac.getAgentLuminancePort();
        break;
    case DEPTH_MAP:
        agentPort = cac.getAgentDepthPort();
        break;
    case VIDEO:
        agentPort = cac.getAgentVideoPort();
        break;
    case COLOUR_MAP:
        agentPort = cac.getAgentColourMapPort();
        break;
    }

    this.connection = new TCPSocketChannel(agentIPAddress, agentPort, "vid");
    this.failedTCPSendCount = 0;

    try
    {
        MinecraftForge.EVENT_BUS.register(this);
    }
    catch(Exception e)
    {
        System.out.println("Failed to register video hook: " + e);
    }
    this.isRunning = true;
}
 
Example 6
Source File: ClientProxy.java    From Fullscreen-Windowed-Minecraft with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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();
    }

}