use of org.lwjgl.opengl.DisplayMode in project playn by threerings.
the class JavaGraphics method init.
protected void init() {
DisplayMode mode = Display.getDisplayMode();
ctx.setSize(mode.getWidth(), mode.getHeight());
ctx.init();
}
use of org.lwjgl.opengl.DisplayMode in project lwjgl by LWJGL.
the class DisplayTest method setDisplayModeTest.
/**
* Tests setting display modes
*/
private void setDisplayModeTest() throws LWJGLException {
DisplayMode mode = null;
DisplayMode[] modes = null;
System.out.println("==== Test setDisplayMode ====");
System.out.println("Retrieving available displaymodes");
modes = Display.getAvailableDisplayModes();
// no modes check
if (modes == null) {
System.out.println("FATAL: unable to find any modes!");
System.exit(-1);
}
// find a mode
System.out.print("Looking for 640x480...");
for (DisplayMode mode1 : modes) {
if (mode1.getWidth() == 640 && mode1.getHeight() == 480) {
mode = mode1;
System.out.println("found!");
break;
}
}
// no mode check
if (mode == null) {
System.out.println("error\nFATAL: Unable to find basic mode.");
System.exit(-1);
}
// change to mode, and wait a bit
System.out.print("Changing to mode...");
try {
Display.setDisplayMode(mode);
Display.setFullscreen(true);
Display.create();
} catch (Exception e) {
System.out.println("error\nFATAL: Error setting mode");
System.exit(-1);
}
System.out.println("done");
System.out.println("Resolution: " + Display.getDisplayMode().getWidth() + "x" + Display.getDisplayMode().getHeight() + "x" + Display.getDisplayMode().getBitsPerPixel() + "@" + Display.getDisplayMode().getFrequency() + "Hz");
pause(5000);
// reset
System.out.print("Resetting mode...");
try {
Display.setFullscreen(false);
} catch (LWJGLException e) {
e.printStackTrace();
}
System.out.println("done");
System.out.println("---- Test setDisplayMode ----");
}
use of org.lwjgl.opengl.DisplayMode in project lwjgl by LWJGL.
the class Gears method init.
/**
*
*/
private void init() throws LWJGLException {
// create Window of size 300x300
Display.setLocation((Display.getDisplayMode().getWidth() - 300) / 2, (Display.getDisplayMode().getHeight() - 300) / 2);
Display.setDisplayMode(new DisplayMode(300, 300));
Display.setTitle("Gears");
Display.create();
// setup ogl
FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f });
FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f });
FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f });
FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f });
pos.flip();
red.flip();
green.flip();
blue.flip();
glLight(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
/* make the gears */
gear1 = glGenLists(1);
glNewList(gear1, GL_COMPILE);
glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
glEndList();
gear2 = glGenLists(1);
glNewList(gear2, GL_COMPILE);
glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
glEndList();
gear3 = glGenLists(1);
glNewList(gear3, GL_COMPILE);
glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
glEndList();
glEnable(GL_NORMALIZE);
glMatrixMode(GL_PROJECTION);
System.err.println("LWJGL: " + Sys.getVersion() + " / " + LWJGLUtil.getPlatformName());
System.err.println("GL_VENDOR: " + glGetString(GL_VENDOR));
System.err.println("GL_RENDERER: " + glGetString(GL_RENDERER));
System.err.println("GL_VERSION: " + glGetString(GL_VERSION));
System.err.println();
System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
// --- not using extensions
glLoadIdentity();
} else {
// --- using extensions
final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(new float[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 });
identityTranspose.flip();
glLoadTransposeMatrixARB(identityTranspose);
}
float h = (float) 300 / (float) 300;
glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -40.0f);
}
use of org.lwjgl.opengl.DisplayMode in project lwjgl by LWJGL.
the class MacOSXDisplay method addDisplayMode.
public void addDisplayMode(Object modesList, int width, int height, int bitsPerPixel, int refreshRate) {
List<DisplayMode> modes = (List<DisplayMode>) modesList;
DisplayMode displayMode = new DisplayMode(width, height, bitsPerPixel, refreshRate);
modes.add(displayMode);
}
use of org.lwjgl.opengl.DisplayMode in project lwjgl by LWJGL.
the class WindowCreationTest method handleInput.
/**
* Handles the input
*/
private void handleInput() {
while (Keyboard.next()) {
// we only want key down events
if (!Keyboard.getEventKeyState()) {
continue;
}
// check for exit
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
running = false;
}
// check for listing of modes
if (Keyboard.getEventKey() == Keyboard.KEY_L) {
for (int i = 0; i < fixed_modes.length; i++) {
System.out.println("[" + i + "]: " + fixed_modes[i]);
}
}
// ================================
if (Keyboard.getEventKey() == Keyboard.KEY_0) {
setMode(0);
}
if (Keyboard.getEventKey() == Keyboard.KEY_1) {
setMode(1);
}
if (Keyboard.getEventKey() == Keyboard.KEY_2) {
setMode(2);
}
if (Keyboard.getEventKey() == Keyboard.KEY_3) {
setMode(3);
}
if (Keyboard.getEventKey() == Keyboard.KEY_4) {
setMode(4);
}
if (Keyboard.getEventKey() == Keyboard.KEY_5) {
setMode(5);
}
if (Keyboard.getEventKey() == Keyboard.KEY_6) {
setMode(6);
}
if (Keyboard.getEventKey() == Keyboard.KEY_7) {
setMode(7);
}
if (Keyboard.getEventKey() == Keyboard.KEY_8) {
setMode(8);
}
// ================================
if (Keyboard.getEventKey() == Keyboard.KEY_LEFT) {
if (!Display.isFullscreen()) {
Display.setLocation(window_x -= 10, window_y);
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT) {
if (!Display.isFullscreen()) {
Display.setLocation(window_x += 10, window_y);
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_UP) {
if (!Display.isFullscreen()) {
Display.setLocation(window_x, window_y -= 10);
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_DOWN) {
if (!Display.isFullscreen()) {
Display.setLocation(window_x, window_y += 10);
}
}
// check for fullscreen
if (Keyboard.getEventKey() == Keyboard.KEY_F) {
try {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
System.out.println("Performing Display.destroy()/create() cycle");
DisplayMode saved_mode = Display.getDisplayMode();
Display.destroy();
Display.setDisplayMode(saved_mode);
Display.setFullscreen(fullscreen = !fullscreen);
Display.create();
} else
Display.setFullscreen(fullscreen = !fullscreen);
} catch (LWJGLException lwjgle) {
lwjgle.printStackTrace();
}
}
}
}
Aggregations