mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-01-09 10:19:57 +01:00
Added nicer resizing to AWT tests
This commit is contained in:
parent
8698cf68f3
commit
12d445c7ec
|
|
@ -76,10 +76,11 @@ public class AWTGears extends Frame {
|
|||
public AWTGears() throws LWJGLException {
|
||||
setTitle("Gears");
|
||||
setSize(300, 300);
|
||||
setLayout(null);
|
||||
add(canvas0 = new AWTGLCanvas() {
|
||||
long startTime = 0;
|
||||
long fps = 0;
|
||||
long fps = 0;
|
||||
int current_width;
|
||||
int current_height;
|
||||
public void paintGL() {
|
||||
|
||||
if(startTime == 0) {
|
||||
|
|
@ -89,6 +90,11 @@ public class AWTGears extends Frame {
|
|||
|
||||
try {
|
||||
angle += 2.0f;
|
||||
if (getWidth() != current_width || getHeight() != current_height) {
|
||||
current_width = getWidth();
|
||||
current_height = getHeight();
|
||||
GL11.glViewport(0, 0, current_width, current_height);
|
||||
}
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
package org.lwjgl.test.opengl.awt;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
|
|
@ -61,11 +62,17 @@ public class AWTTest extends Frame {
|
|||
public AWTTest() throws LWJGLException {
|
||||
setTitle("LWJGL AWT Canvas Test");
|
||||
setSize(640, 320);
|
||||
setLayout(null);
|
||||
setLayout(new GridLayout(1, 2));
|
||||
add(canvas0 = new AWTGLCanvas() {
|
||||
int current_height;
|
||||
int current_width;
|
||||
public void paintGL() {
|
||||
try {
|
||||
makeCurrent();
|
||||
if (getWidth() != current_width || getHeight() != current_height) {
|
||||
current_width = getWidth();
|
||||
current_height = getHeight();
|
||||
GL11.glViewport(0, 0, current_width, current_height);
|
||||
}
|
||||
GL11.glViewport(0, 0, getWidth(), getHeight());
|
||||
GL11.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
|
@ -88,10 +95,16 @@ public class AWTTest extends Frame {
|
|||
});
|
||||
canvas0.setBounds(0, 0, 320, 320);
|
||||
add(canvas1 = new AWTGLCanvas() {
|
||||
int current_height;
|
||||
int current_width;
|
||||
public void paintGL() {
|
||||
try {
|
||||
angle += 1.0f;
|
||||
makeCurrent();
|
||||
if (getWidth() != current_width || getHeight() != current_height) {
|
||||
current_width = getWidth();
|
||||
current_height = getHeight();
|
||||
GL11.glViewport(0, 0, current_width, current_height);
|
||||
}
|
||||
GL11.glViewport(0, 0, getWidth(), getHeight());
|
||||
GL11.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
|
|
|||
Loading…
Reference in a new issue