Trouble setting DisplayMode properties to resize the Display.

Started by atrus6, February 04, 2012, 15:25:53

Previous topic - Next topic

atrus6

I essentially stole to following method from that Space Invaders game

private void setDisplayMode()
{
	try
	{
		System.out.println(size);
		DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(size.width, size.height, -1, -1, -1, -1, 60, 60);

		org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
				"width="+size.width,
				"height="+size.height,
				"freq=60",
				"bpp="+org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
		});
	}
	catch(Exception e)
	{
		e.printStackTrace();
		System.err.println("Unable to enter into fullscreen, continuing in windowed mode.");
	}
}


and my "creation" method looks like the following:

try
{
	lastLoopTime = getTime();
	setDisplayMode();
//	Display.setDisplayMode(new DisplayMode(size.width, size.height));
	Display.setTitle(title);
	Display.setFullscreen(fullscreen);
	Display.create();
			
	render = new LWJGLRenderer(); 
	gui = new GUI(root, render);
			
        setTheme(null);

//	Mouse.setGrabbed(true);

	glEnable(GL_TEXTURE_2D); //Enable textures in 2D mode.
	glDisable(GL_DEPTH_TEST); //Disable depth test as we are only doing 2D items.
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glOrtho(0, size.width, size.height, 0, -1, 1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glViewport(0, 0, size.width, size.height);
}


Running as it, it will always display at ~960x600, no matter what size "size" is. I currently have it at 100x100. However, if I uncomment "Display.setDisplayMode(new DisplayMode(size.width, size.height));" it will conform to any size I give it.

What exactly did I do wrong here?