Fullscreen Mode

Shouldn’t this make the window fullscreen? This is just BaseWindow, but everything that says fullscreen set to true.


import org.lwjgl.*;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLU;

public class BaseWindow
{

    public BaseWindow()
    {
        fullscreen = true;
        done = false;
    }

    protected void resizeGLScene(int i, int j)
    {
        gl.viewport(0, 0, i, j);
        gl.matrixMode(5889);
        gl.loadIdentity();
        glu.perspective(45D, (float)i / (float)j, 0.10000000149011612D, 100D);
        gl.matrixMode(5888);
        gl.loadIdentity();
    }

    protected void initGL()
        throws Exception
    {
        gl.shadeModel(7425);
        gl.clearColor(0.0F, 0.0F, 0.0F, 0.0F);
        gl.clearDepth(1.0D);
        gl.enable(2929);
        gl.depthFunc(515);
        gl.hint(3152, 4354);
    }

    protected boolean drawGLScene(float f)
    {
        gl.clear(16640);
        gl.loadIdentity();
        return true;
    }

    protected void killGLWindow()
    {
        Mouse.destroy();
        Keyboard.destroy();
        gl.destroy();
    }

    protected void createGLWindow(int i, int j, int k, boolean flag)
        throws Exception
    {
        fullscreen = flag;
        try
        {
            byte byte0 = -1;
            DisplayMode adisplaymode[] = Display.getAvailableDisplayModes();
            int i1 = 0;
            do
            {
                if(i1 >= adisplaymode.length)
                    break;
                if(adisplaymode[i1].width == i && adisplaymode[i1].height == j && adisplaymode[i1].bpp >= k)
                {
                    int l = i1;
                    break;
                }
                i1++;
            } while(true);
            gl = new GL("LWJGL Example", 50, 50, i, j, k, 0, 0, 0);
            gl.create();
            glu = new GLU(gl);
            Keyboard.create();
            Keyboard.enableBuffer();
            Mouse.create();
            resizeGLScene(i, j);
            initGL();
        }
        catch(Exception exception)
        {
            throw new Exception("Problem initialising Lesson", exception);
        }
    }

    protected void start(int i, int j, int k, boolean flag)
        throws Exception
    {
        long l = 0L;
        timerRes = Sys.getTimerResolution();
        if(timerRes == 0L)
            throw new Exception("There are no timers availible!");
        try
        {
            createGLWindow(i, j, k, flag);
            long l1;
            do
            {
                gl.tick();
                l1 = Sys.getTime();
                Sys.setTime(0L);
            } while(!loop((float)l1 / (float)timerRes));
            killGLWindow();
        }
        catch(Exception exception)
        {
            throw new Exception("Problem starting loop", exception);
        }
    }

    protected boolean loop(float f)
    {
        if(!drawGLScene(f))
        {
            return true;
        } else
        {
            gl.paint();
            input(f);
            return done;
        }
    }

    protected void input(float f)
    {
        Keyboard.poll();
        if(Keyboard.isKeyDown(1))
            done = true;
    }

    public static void main(String args[])
    {
        int i = 0;
        BaseWindow basewindow = new BaseWindow();
        try
        {
            basewindow.start(640, 480, 16, true);
        }
        catch(Exception exception)
        {
            i = 1;
            exception.printStackTrace();
        }
        System.exit(i);
    }

    protected GL gl;
    protected GLU glu;
    protected boolean fullscreen;
    protected boolean done;
    protected long timerRes;
}

There’s a loop in there choosing a DisplayMode to change to, but no line to do the actual switch.

You need a line like “Display.setDisplayMode(i1)” before the call to the GL constructor. You’ll also need to call a different GL constructor, one without position or size information.

The real problem is that it appears to be decompiled code. All the constants are numerical, the variables are badly named and the structure of the code is just nasty. The lines to set the DisplayMode correctly and call the other GL constructor were probably optimised away after the compiler decided they weren’t reachable.

You’re bound to have issues with that file (not least trying to decode lines like “gl.hint(3152, 4354);”), so I’d get the real version first and play with that if I were you! ;D

Thanks! It works! I’m in such a good mood.

You’re right, this is the decompiled version. I do get the decompiled and src mixed up a lot. Some day, I’ll get it cleared up…