LWJGL when full screen texture toggles are not showing

Hi, this is my first post. I've been using LWJGL for a while now and I'm working on a game that has a full screen button. When it is clicked, the game goes into full screen mode, but the textures don't bind it to just the white screen.

Here is the code for the full screen transition I suspect is the problem:

package lifeLine.game;

import static org.lwjgl.opengl.GL11.*;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class FullscreenManager {

    boolean fsState;
    GameLoop gameLoop;

    public FullscreenManager(GameLoop gl, boolean defaultState) {

        gameLoop = gl;

        fsState = defaultState;

        Display.destroy();

        try {

            Display.setFullscreen(fsState);
            Display.setDisplayMode(new DisplayMode(gameLoop.WIDTH, gameLoop.HEIGHT));
            Display.setTitle("Life Line: 1.0");
            Display.create();

        } catch (LWJGLException e){

            e.printStackTrace();

        }

        initGL();

    }

    public void toggleFullscreen() {

        Display.destroy();

        try {


            Display.setDisplayMode(new DisplayMode(gameLoop.WIDTH,gameLoop.HEIGHT));

            Display.setFullscreen(!fsState);
            Display.create();
            Display.setVSyncEnabled(true);

            fsState = !fsState;

        } catch (LWJGLException e){

            Logger.getLogger(GameLoop.class.getName()).log(Level.SEVERE, null, e);

        }

        initGL();

    }

    public void setFullscreen(boolean state) {

        try {
            Display.destroy();

            if (!state) {

                Display.setDisplayMode(new DisplayMode(gameLoop.WIDTH, gameLoop.HEIGHT));

            }

            fsState = state;

            Display.setFullscreen(state);
            Display.create();
            Display.setVSyncEnabled(true);

        } catch (LWJGLException e){

            Logger.getLogger(GameLoop.class.getName()).log(Level.SEVERE, null, e);

        }

        initGL();

    }

    private void initGL() {

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, gameLoop.WIDTH, 0, gameLoop.HEIGHT, -1, 1);
        glMatrixMode(GL_MODELVIEW);

        glClearColor(0, 0, 0, 1);

        glDisable(GL_DEPTH_TEST);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    }

}

      

This causes an empty white color after one of the full screen functions.

Please, help!

Thanks in advance.

+3


source to share





All Articles