mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-18 12:54:10 +00:00
Linux support for AWTGLCanvas. Big refactor of context specific code into Context.java that is now shared between Display, Pbuffer and AWTGLCanvas. (Win32 and Mac OS X is now broken while I implement the same changes on those platforms)
This commit is contained in:
parent
8feec32e60
commit
fb5d89599b
47 changed files with 2598 additions and 653 deletions
|
|
@ -54,7 +54,7 @@ public class DisplayTest {
|
|||
/**
|
||||
* Runs the tests
|
||||
*/
|
||||
public void executeTest() {
|
||||
public void executeTest() throws LWJGLException {
|
||||
currentTest();
|
||||
queryModesTest();
|
||||
setDisplayModeTest();
|
||||
|
|
@ -80,7 +80,7 @@ public class DisplayTest {
|
|||
/**
|
||||
* Tests querying for modes
|
||||
*/
|
||||
private void queryModesTest() {
|
||||
private void queryModesTest() throws LWJGLException {
|
||||
DisplayMode[] modes = null;
|
||||
|
||||
System.out.println("==== Test query ====");
|
||||
|
|
@ -109,7 +109,7 @@ public class DisplayTest {
|
|||
/**
|
||||
* Tests setting display modes
|
||||
*/
|
||||
private void setDisplayModeTest() {
|
||||
private void setDisplayModeTest() throws LWJGLException {
|
||||
DisplayMode mode = null;
|
||||
DisplayMode[] modes = null;
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ public class DisplayTest {
|
|||
*
|
||||
* @param args ignored
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws LWJGLException {
|
||||
new DisplayTest().executeTest();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ package org.lwjgl.test;
|
|||
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -75,7 +76,11 @@ public class SysTest {
|
|||
}
|
||||
|
||||
// get some display modes, to force some debug info
|
||||
Display.getAvailableDisplayModes();
|
||||
try {
|
||||
Display.getAvailableDisplayModes();
|
||||
} catch (LWJGLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
System.out.println("---- Test Debug ----\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class WindowCreationTest {
|
|||
*
|
||||
* @param args ignored params to app
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws LWJGLException {
|
||||
// get avaialble modes, and print out
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
System.out.println("Found " + modes.length + " display modes");
|
||||
|
|
@ -138,10 +138,10 @@ public class WindowCreationTest {
|
|||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected static boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 640,
|
||||
"height=" + 480,
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ public class HWCursorTest {
|
|||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 640,
|
||||
"height=" + 480,
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ public class KeyboardTest {
|
|||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 640,
|
||||
"height=" + 480,
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ public class MouseCreationTest {
|
|||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 640,
|
||||
"height=" + 480,
|
||||
|
|
|
|||
|
|
@ -109,10 +109,10 @@ public abstract class BasicTest {
|
|||
* Sets the display mode for fullscreen mode
|
||||
*/
|
||||
protected boolean setDisplayMode() {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
try {
|
||||
// get modes
|
||||
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||
|
||||
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||
"width=" + 640,
|
||||
"height=" + 480,
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public class FullScreenWindowedTest {
|
|||
* Minimum required bits per pixel
|
||||
* @return
|
||||
*/
|
||||
private DisplayMode findDisplayMode(int width, int height, int bpp) {
|
||||
private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) {
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ public class PbufferTest {
|
|||
* @param bpp Minimum required bits per pixel
|
||||
* @return
|
||||
*/
|
||||
private DisplayMode findDisplayMode(int width, int height, int bpp) {
|
||||
private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
if (modes[i].getWidth() == width
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
package org.lwjgl.test.opengl.awt;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.AWTGLCanvas;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.glu.GLU;
|
||||
|
|
@ -30,31 +32,54 @@ public class AWTTest extends Frame {
|
|||
/**
|
||||
* C'tor
|
||||
*/
|
||||
public AWTTest() {
|
||||
public AWTTest() throws LWJGLException {
|
||||
setTitle("LWJGL AWT Canvas Test");
|
||||
setSize(640, 320);
|
||||
setLayout(null);
|
||||
add(canvas0 = new AWTGLCanvas() {
|
||||
protected void doPaint() {
|
||||
GL11.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||
public void paint(Graphics g) {
|
||||
try {
|
||||
makeCurrent();
|
||||
GL11.glViewport(0, 0, getWidth(), getHeight());
|
||||
GL11.glClearColor(1.0f, 0.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());
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor3f(1f, 1f, 0f);
|
||||
GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
|
||||
GL11.glRotatef(angle, 0f, 0f, 1.0f);
|
||||
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
||||
GL11.glPopMatrix();
|
||||
swapBuffers();
|
||||
} catch (LWJGLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
canvas0.setBounds(0, 0, 320, 320);
|
||||
add(canvas1 = new AWTGLCanvas() {
|
||||
protected void doPaint() {
|
||||
GL11.glViewport(0, 0, getWidth(), getHeight());
|
||||
GL11.glClearColor(1.0f, 0.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());
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
|
||||
GL11.glRotatef(angle, 0f, 0f, 1.0f);
|
||||
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
||||
GL11.glPopMatrix();
|
||||
public void paint(Graphics g) {
|
||||
try {
|
||||
makeCurrent();
|
||||
GL11.glViewport(0, 0, getWidth(), getHeight());
|
||||
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());
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(getWidth() / 2.0f, getHeight() / 2.0f, 0.0f);
|
||||
GL11.glRotatef(2*angle, 0f, 0f, -1.0f);
|
||||
GL11.glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
|
||||
GL11.glPopMatrix();
|
||||
swapBuffers();
|
||||
} catch (LWJGLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
canvas1.setBounds(320, 0, 320, 320);
|
||||
|
|
@ -64,6 +89,7 @@ public class AWTTest extends Frame {
|
|||
}
|
||||
});
|
||||
setResizable(true);
|
||||
setVisible(true);
|
||||
|
||||
new Thread() {
|
||||
{
|
||||
|
|
@ -72,6 +98,7 @@ public class AWTTest extends Frame {
|
|||
public void run() {
|
||||
for (;;) {
|
||||
angle += 1.0f;
|
||||
canvas0.repaint();
|
||||
canvas1.repaint();
|
||||
try {
|
||||
sleep(20);
|
||||
|
|
@ -83,7 +110,7 @@ public class AWTTest extends Frame {
|
|||
}.start();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AWTTest().setVisible(true);
|
||||
public static void main(String[] args) throws LWJGLException {
|
||||
new AWTTest();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ public final class PbufferTest {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
private DisplayMode findDisplayMode(int width, int height, int bpp) {
|
||||
private DisplayMode findDisplayMode(int width, int height, int bpp) throws LWJGLException {
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
for ( int i = 0; i < modes.length; i++ ) {
|
||||
if ( modes[i].getWidth() == width
|
||||
|
|
|
|||
|
|
@ -122,19 +122,19 @@ public final class ShadersTest {
|
|||
if ( args.length != 1 )
|
||||
argsError();
|
||||
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
|
||||
DisplayMode displayMode;
|
||||
|
||||
displayMode = chooseMode(modes, 1024, 768);
|
||||
if ( displayMode == null )
|
||||
displayMode = chooseMode(modes, 800, 600);
|
||||
if ( displayMode == null )
|
||||
displayMode = chooseMode(modes, 640, 480);
|
||||
if ( displayMode == null )
|
||||
kill("Failed to set an appropriate display mode.");
|
||||
|
||||
try {
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
|
||||
DisplayMode displayMode;
|
||||
|
||||
displayMode = chooseMode(modes, 1024, 768);
|
||||
if ( displayMode == null )
|
||||
displayMode = chooseMode(modes, 800, 600);
|
||||
if ( displayMode == null )
|
||||
displayMode = chooseMode(modes, 640, 480);
|
||||
if ( displayMode == null )
|
||||
kill("Failed to set an appropriate display mode.");
|
||||
|
||||
System.out.println("Setting display mode to: " + displayMode);
|
||||
Display.setDisplayMode(displayMode);
|
||||
Display.create(new PixelFormat(8, 24, 0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue