mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 06:25:46 +00:00
Added fullscreen switching to DisplayParentTest
This commit is contained in:
parent
8d5e9695a5
commit
2c0137eff8
1 changed files with 15 additions and 5 deletions
|
|
@ -79,19 +79,26 @@ public class DisplayParentTest extends Frame {
|
|||
Display.create();
|
||||
float angle = 0f;
|
||||
|
||||
int current_height = 0;
|
||||
int current_width = 0;
|
||||
while (isVisible()) {
|
||||
angle += 1.0f;
|
||||
GL11.glViewport(0, 0, display_parent.getWidth(), display_parent.getHeight());
|
||||
int width;
|
||||
int height;
|
||||
if (!Display.isFullscreen()) {
|
||||
width = display_parent.getWidth();
|
||||
height = display_parent.getHeight();
|
||||
} else {
|
||||
width = Display.getDisplayMode().getWidth();
|
||||
height = Display.getDisplayMode().getHeight();
|
||||
}
|
||||
GL11.glViewport(0, 0, width, height);
|
||||
GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
GLU.gluOrtho2D(0.0f, (float) getWidth(), 0.0f, (float) getHeight());
|
||||
GLU.gluOrtho2D(0.0f, (float) width, 0.0f, (float) height);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
|
||||
GL11.glTranslatef(width / 2.0f, height / 2.0f, 0.0f);
|
||||
GL11.glRotatef(2*angle, 0f, 0f, -1.0f);
|
||||
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
||||
GL11.glPopMatrix();
|
||||
|
|
@ -107,6 +114,9 @@ public class DisplayParentTest extends Frame {
|
|||
if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
|
||||
Mouse.setGrabbed(!Mouse.isGrabbed());
|
||||
}
|
||||
if(Keyboard.getEventKey() == Keyboard.KEY_F && Keyboard.getEventKeyState()) {
|
||||
Display.setFullscreen(!Display.isFullscreen());
|
||||
}
|
||||
}
|
||||
/* while (Mouse.next()) {
|
||||
System.out.println(" Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue