mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-09 08:24:23 +00:00
static implementation - work in progress
This commit is contained in:
parent
315375dee5
commit
4c4d56e583
34 changed files with 2001 additions and 2008 deletions
|
|
@ -52,9 +52,6 @@ public class ControllerCreationTest {
|
|||
/** OpenGL instance */
|
||||
private GL gl;
|
||||
|
||||
/** GLU instance */
|
||||
private GLU glu;
|
||||
|
||||
/** position of quad to draw */
|
||||
private Vector2f position = new Vector2f(320.0f, 240.0f);
|
||||
|
||||
|
|
@ -65,7 +62,7 @@ public class ControllerCreationTest {
|
|||
public ControllerCreationTest() {
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
private void initialize(boolean fullscreen) {
|
||||
// find first display mode that allows us 640*480*16
|
||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||
for (int i = 0; i < modes.length; i++) {
|
||||
|
|
@ -75,18 +72,17 @@ public class ControllerCreationTest {
|
|||
displayMode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// create display and opengl
|
||||
setupDisplay(false);
|
||||
}
|
||||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
}
|
||||
|
||||
try {
|
||||
gl = new GL("ControllerCreationTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
if(fullscreen) {
|
||||
Display.setDisplayMode(displayMode);
|
||||
gl = new GL("MouseCreationTest", 16, 0, 0, 0);
|
||||
} else {
|
||||
gl = new GL("MouseCreationTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
}
|
||||
gl.create();
|
||||
|
||||
glu = new GLU(gl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
|
@ -94,14 +90,14 @@ public class ControllerCreationTest {
|
|||
|
||||
initializeOpenGL();
|
||||
}
|
||||
|
||||
|
||||
private void initializeOpenGL() {
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glu.ortho2D(0.0, Display.getWidth(), 0, Display.getHeight());
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLU.gluOrtho2D(0.0, 640, 0, 480);
|
||||
}
|
||||
|
||||
public void executeTest() {
|
||||
initialize();
|
||||
initialize(false);
|
||||
|
||||
System.out.println("Test ready:\n");
|
||||
|
||||
|
|
@ -121,7 +117,13 @@ public class ControllerCreationTest {
|
|||
System.out.println("success");
|
||||
|
||||
System.out.print("Entering fullscreen mode...");
|
||||
setupDisplay(true);
|
||||
try {
|
||||
gl.destroy();
|
||||
initialize(true);
|
||||
Display.setDisplayMode(displayMode);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("success");
|
||||
|
||||
|
||||
|
|
@ -197,24 +199,24 @@ public class ControllerCreationTest {
|
|||
}
|
||||
|
||||
private void render() {
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
gl.pushMatrix();
|
||||
gl.begin(GL.POLYGON);
|
||||
GL.glPushMatrix();
|
||||
GL.glBegin(GL.GL_POLYGON);
|
||||
{
|
||||
gl.color3f(0.0f, 1.0f, 1.0f);
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
GL.glColor3f(0.0f, 1.0f, 1.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
|
||||
gl.color3f(1.0f, 0.0f, 1.0f);
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
GL.glColor3f(1.0f, 0.0f, 1.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
|
||||
gl.color3f(1.0f, 1.0f, 0.0f);
|
||||
gl.vertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
GL.glColor3f(1.0f, 1.0f, 0.0f);
|
||||
GL.glVertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
}
|
||||
gl.end();
|
||||
gl.popMatrix();
|
||||
GL.glEnd();
|
||||
GL.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -80,8 +80,6 @@ public class ControllerTest {
|
|||
try {
|
||||
gl = new GL("ControllerTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
|
||||
glu = new GLU(gl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
|
@ -91,8 +89,8 @@ public class ControllerTest {
|
|||
}
|
||||
|
||||
private void initializeOpenGL() {
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glu.ortho2D(0.0, 640, 0, 480);
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLU.gluOrtho2D(0.0, 640, 0, 480);
|
||||
}
|
||||
|
||||
public void executeTest() {
|
||||
|
|
@ -172,9 +170,9 @@ public class ControllerTest {
|
|||
}
|
||||
|
||||
private void render() {
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
gl.begin(GL.POLYGON);
|
||||
GL.glBegin(GL.GL_POLYGON);
|
||||
{
|
||||
float color = 1.0f;
|
||||
int buttonDown = 0;
|
||||
|
|
@ -185,15 +183,15 @@ public class ControllerTest {
|
|||
System.out.println("Button " + i + " down");
|
||||
}
|
||||
}
|
||||
gl.color3f(color, color, color);
|
||||
GL.glColor3f(color, color, color);
|
||||
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ public class HWCursorTest {
|
|||
// start of in windowed mode
|
||||
gl = new GL("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
|
||||
glInit();
|
||||
|
||||
|
|
@ -139,7 +138,7 @@ public class HWCursorTest {
|
|||
try {
|
||||
if ((Mouse.getNativeCursorCaps() | Mouse.CURSOR_ANIMATION) == 0)
|
||||
num_images = 1;
|
||||
cursor = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, num_images, Sys.getDirectBufferAddress(cursor_images), Sys.getDirectBufferAddress(delays));
|
||||
cursor = new Cursor(Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize(), Mouse.getMaxCursorSize()/2, Mouse.getMaxCursorSize()/2, num_images, cursor_images, delays);
|
||||
Mouse.setNativeCursor(cursor);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -186,23 +185,23 @@ public class HWCursorTest {
|
|||
*/
|
||||
private void render() {
|
||||
//clear background
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// draw white quad
|
||||
gl.pushMatrix();
|
||||
GL.glPushMatrix();
|
||||
{
|
||||
gl.translatef(mouse_x, 600 - mouse_y, 0);
|
||||
gl.color3f(1.0f, 1.0f, 1.0f);
|
||||
gl.begin(GL.QUADS);
|
||||
GL.glTranslatef(mouse_x, 600 - mouse_y, 0);
|
||||
GL.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
GL.glBegin(GL.GL_QUADS);
|
||||
{
|
||||
gl.vertex2i(-50, -50);
|
||||
gl.vertex2i(50, -50);
|
||||
gl.vertex2i(50, 50);
|
||||
gl.vertex2i(-50, 50);
|
||||
GL.glVertex2i(-50, -50);
|
||||
GL.glVertex2i(50, -50);
|
||||
GL.glVertex2i(50, 50);
|
||||
GL.glVertex2i(-50, 50);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
gl.popMatrix();
|
||||
GL.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -236,8 +235,7 @@ public class HWCursorTest {
|
|||
Display.setDisplayMode(mode);
|
||||
gl = new GL("Test", mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
|
||||
|
||||
glInit();
|
||||
|
||||
Keyboard.create();
|
||||
|
|
@ -264,7 +262,6 @@ public class HWCursorTest {
|
|||
Display.resetDisplayMode();
|
||||
gl = new GL("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
|
||||
glInit();
|
||||
|
||||
|
|
@ -336,15 +333,15 @@ public class HWCursorTest {
|
|||
private void glInit() {
|
||||
// Go into orthographic projection mode.
|
||||
gl.determineAvailableExtensions();
|
||||
gl.matrixMode(GL.PROJECTION);
|
||||
gl.loadIdentity();
|
||||
glu.ortho2D(0, mode.width, 0, mode.height);
|
||||
gl.matrixMode(GL.MODELVIEW);
|
||||
gl.loadIdentity();
|
||||
gl.viewport(0, 0, mode.width, mode.height);
|
||||
GL.glMatrixMode(GL.GL_PROJECTION);
|
||||
GL.glLoadIdentity();
|
||||
GLU.gluOrtho2D(0, mode.width, 0, mode.height);
|
||||
GL.glMatrixMode(GL.GL_MODELVIEW);
|
||||
GL.glLoadIdentity();
|
||||
GL.glViewport(0, 0, mode.width, mode.height);
|
||||
|
||||
//set clear color to black
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
//sync frame (only works on windows)
|
||||
if (GL.WGL_EXT_swap_control) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ public class KeyboardTest {
|
|||
gl = new GL("KeyboardTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
|
||||
glu = new GLU(gl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
|
@ -94,8 +93,8 @@ public class KeyboardTest {
|
|||
}
|
||||
|
||||
private void initializeOpenGL() {
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glu.ortho2D(0.0, 640, 0, 480);
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLU.gluOrtho2D(0.0, 640, 0, 480);
|
||||
}
|
||||
|
||||
public void executeTest() {
|
||||
|
|
@ -195,21 +194,21 @@ public class KeyboardTest {
|
|||
}
|
||||
|
||||
private void render() {
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
gl.begin(GL.POLYGON);
|
||||
GL.glBegin(GL.GL_POLYGON);
|
||||
{
|
||||
float color = 1.0f;
|
||||
int buttonDown = 0;
|
||||
gl.color3f(color, color, color);
|
||||
GL.glColor3f(color, color, color);
|
||||
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ public class MouseCreationTest {
|
|||
}
|
||||
gl.create();
|
||||
|
||||
glu = new GLU(gl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
|
@ -96,8 +95,8 @@ public class MouseCreationTest {
|
|||
}
|
||||
|
||||
private void initializeOpenGL() {
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glu.ortho2D(0.0, 640, 0, 480);
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLU.gluOrtho2D(0.0, 640, 0, 480);
|
||||
}
|
||||
|
||||
public void executeTest() {
|
||||
|
|
@ -205,9 +204,9 @@ public class MouseCreationTest {
|
|||
}
|
||||
|
||||
private void render() {
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
gl.begin(GL.POLYGON);
|
||||
GL.glBegin(GL.GL_POLYGON);
|
||||
{
|
||||
float color = 1.0f;
|
||||
int buttonDown = 0;
|
||||
|
|
@ -218,15 +217,15 @@ public class MouseCreationTest {
|
|||
break;
|
||||
}
|
||||
}
|
||||
gl.color3f(color, color, color);
|
||||
GL.glColor3f(color, color, color);
|
||||
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ public class MouseTest {
|
|||
gl = new GL("MouseTest", 50, 50, 640, 480, 16, 0, 0, 0);
|
||||
gl.create();
|
||||
|
||||
glu = new GLU(gl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
|
@ -91,8 +90,8 @@ public class MouseTest {
|
|||
}
|
||||
|
||||
private void initializeOpenGL() {
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glu.ortho2D(0.0, 640, 0, 480);
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLU.gluOrtho2D(0.0, 640, 0, 480);
|
||||
}
|
||||
|
||||
public void executeTest() {
|
||||
|
|
@ -159,9 +158,9 @@ public class MouseTest {
|
|||
}
|
||||
|
||||
private void render() {
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
gl.begin(GL.POLYGON);
|
||||
GL.glBegin(GL.GL_POLYGON);
|
||||
{
|
||||
float color = 1.0f;
|
||||
int buttonDown = 0;
|
||||
|
|
@ -172,15 +171,15 @@ public class MouseTest {
|
|||
break;
|
||||
}
|
||||
}
|
||||
gl.color3f(color, color, color);
|
||||
GL.glColor3f(color, color, color);
|
||||
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
gl.vertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
gl.vertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
gl.vertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 0.0f);
|
||||
GL.glVertex2f(position.x + 0.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 30.0f);
|
||||
GL.glVertex2f(position.x + 60.0f, position.y + 15.f);
|
||||
GL.glVertex2f(position.x + 40.0f, position.y + 0.0f);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.openal.ALC;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
|
|
@ -46,15 +45,11 @@ import java.nio.IntBuffer;
|
|||
*/
|
||||
public class ALCTest extends BasicTest {
|
||||
|
||||
/** instance of alc */
|
||||
private ALC alc;
|
||||
|
||||
/**
|
||||
* Creates an instance of ALCTest
|
||||
*/
|
||||
public ALCTest() {
|
||||
super();
|
||||
alc = al.getALC();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -62,34 +57,34 @@ public class ALCTest extends BasicTest {
|
|||
*/
|
||||
protected void execute(String[] args) {
|
||||
//error stuff
|
||||
int lastError = ALC.NO_ERROR;
|
||||
int lastError = ALC.ALC_NO_ERROR;
|
||||
|
||||
//create attribute list for context creation
|
||||
IntBuffer buffer = createIntBuffer(7);
|
||||
|
||||
if ((lastError = alc.getError()) != ALC.NO_ERROR) {
|
||||
System.out.println("ALC Error: " + alc.getString(lastError));
|
||||
if ((lastError = ALC.alcGetError()) != ALC.ALC_NO_ERROR) {
|
||||
System.out.println("ALC Error: " + ALC.alcGetString(lastError));
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
//query
|
||||
System.out.println(
|
||||
"DEFAULT_DEVICE_SPECIFIER: "
|
||||
+ alc.getString(ALC.DEFAULT_DEVICE_SPECIFIER));
|
||||
+ ALC.alcGetString(ALC.ALC_DEFAULT_DEVICE_SPECIFIER));
|
||||
System.out.println(
|
||||
"DEVICE_SPECIFIER: " + alc.getString(ALC.DEVICE_SPECIFIER));
|
||||
System.out.println("EXTENSIONS: " + alc.getString(ALC.EXTENSIONS));
|
||||
"DEVICE_SPECIFIER: " + ALC.alcGetString(ALC.ALC_DEVICE_SPECIFIER));
|
||||
System.out.println("EXTENSIONS: " + ALC.alcGetString(ALC.ALC_EXTENSIONS));
|
||||
|
||||
//mo query
|
||||
buffer.rewind();
|
||||
alc.getIntegerv(
|
||||
ALC.MAJOR_VERSION,
|
||||
ALC.alcGetIntegerv(
|
||||
ALC.ALC_MAJOR_VERSION,
|
||||
4,
|
||||
Sys.getDirectBufferAddress(buffer));
|
||||
alc.getIntegerv(
|
||||
ALC.MINOR_VERSION,
|
||||
buffer);
|
||||
ALC.alcGetIntegerv(
|
||||
ALC.ALC_MINOR_VERSION,
|
||||
4,
|
||||
Sys.getDirectBufferAddress(buffer) + 4);
|
||||
((IntBuffer)buffer.position(4)).slice());
|
||||
|
||||
System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0));
|
||||
System.out.println("ALC_MINOR_VERSION: " + buffer.get(1));
|
||||
|
|
@ -100,7 +95,7 @@ public class ALCTest extends BasicTest {
|
|||
//get an enumerstion value
|
||||
System.out.println(
|
||||
"Value of ALC_MAJOR_VERSION: "
|
||||
+ alc.getEnumValue("ALC_MAJOR_VERSION"));
|
||||
+ ALC.alcGetEnumValue("ALC_MAJOR_VERSION"));
|
||||
|
||||
alExit();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -32,11 +32,11 @@
|
|||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.ALC;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -47,55 +47,62 @@ import java.nio.IntBuffer;
|
|||
* @version $Revision$
|
||||
*/
|
||||
public abstract class BasicTest {
|
||||
|
||||
/** OpenAL instance */
|
||||
protected AL al;
|
||||
|
||||
/** OpenALC instance */
|
||||
protected ALC alc;
|
||||
|
||||
/**
|
||||
* Creates an instance of PlayTest
|
||||
*/
|
||||
public BasicTest() {
|
||||
al = new AL();
|
||||
try {
|
||||
al.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdowns OpenAL
|
||||
*/
|
||||
protected void alExit() {
|
||||
al.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an integer buffer to hold specified ints
|
||||
* - strictly a utility method
|
||||
*
|
||||
* @param size how many int to contain
|
||||
* @return created IntBuffer
|
||||
*/
|
||||
protected IntBuffer createIntBuffer(int size) {
|
||||
ByteBuffer temp = ByteBuffer.allocateDirect(4*size);
|
||||
temp.order(ByteOrder.nativeOrder());
|
||||
|
||||
return temp.asIntBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits the test NOW, printing errorcode to stdout
|
||||
*
|
||||
* @param error Error code causing exit
|
||||
*/
|
||||
protected void exit(int error) {
|
||||
System.out.println("OpenAL Error: " + al.getString(error));
|
||||
alExit();
|
||||
System.exit(-1);
|
||||
|
||||
/**
|
||||
* Creates an instance of PlayTest
|
||||
*/
|
||||
public BasicTest() {
|
||||
try {
|
||||
AL.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdowns OpenAL
|
||||
*/
|
||||
protected void alExit() {
|
||||
AL.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an integer buffer to hold specified ints
|
||||
* - strictly a utility method
|
||||
*
|
||||
* @param size how many int to contain
|
||||
* @return created IntBuffer
|
||||
*/
|
||||
protected IntBuffer createIntBuffer(int size) {
|
||||
ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
|
||||
temp.order(ByteOrder.nativeOrder());
|
||||
|
||||
return temp.asIntBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a float buffer to hold specified floats
|
||||
* - strictly a utility method
|
||||
*
|
||||
* @param size how many floats to contain
|
||||
* @return created FloatBuffer
|
||||
*/
|
||||
protected FloatBuffer createFloatBuffer(int size) {
|
||||
ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
|
||||
temp.order(ByteOrder.nativeOrder());
|
||||
|
||||
return temp.asFloatBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits the test NOW, printing errorcode to stdout
|
||||
*
|
||||
* @param error Error code causing exit
|
||||
*/
|
||||
protected void exit(int error) {
|
||||
System.out.println("OpenAL Error: " + AL.alGetString(error));
|
||||
alExit();
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
|
@ -54,16 +54,14 @@ public class EAXTest extends BasicTest {
|
|||
* Runs the actual test, using supplied arguments
|
||||
*/
|
||||
protected void execute(String[] args) {
|
||||
EAX eax = new EAX();
|
||||
try {
|
||||
eax.create();
|
||||
System.out.print("Testing EAX support...");
|
||||
EAX.create();
|
||||
System.out.println("supported!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
System.out.println("no supported!");
|
||||
}
|
||||
System.out.print("EAX supported...");
|
||||
|
||||
//no errorchecking from now on, since our context is gone.
|
||||
//shutdown
|
||||
alExit();
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ package org.lwjgl.test.openal;
|
|||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.eax.*;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.opengl.GL;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -77,11 +77,10 @@ public class MovingSoundTest extends BasicTest {
|
|||
|
||||
|
||||
int lastError;
|
||||
float sourcex = 0.0f, sourcey = 0.0f, sourcez = 0.0f;
|
||||
float listenerx = 0.0f, listenery = 0.0f, listenerz = 0.0f;
|
||||
FloatBuffer sourcePosition = createFloatBuffer(3);
|
||||
FloatBuffer listenerPosition = createFloatBuffer(3);
|
||||
boolean eaxApplied = false;
|
||||
IntBuffer Env = null;
|
||||
EAXBufferProperties eaxBufferProp = null;
|
||||
EAXListenerProperties eaxListenerProp = null;
|
||||
|
||||
//initialize keyboard
|
||||
try {
|
||||
|
|
@ -96,13 +95,13 @@ public class MovingSoundTest extends BasicTest {
|
|||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenBuffers(1, buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.genSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenSources(1, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -110,13 +109,13 @@ public class MovingSoundTest extends BasicTest {
|
|||
WaveData wavefile = WaveData.create(args[0]);
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(
|
||||
AL.alBufferData(
|
||||
buffers.get(0),
|
||||
wavefile.format,
|
||||
Sys.getDirectBufferAddress(wavefile.data),
|
||||
wavefile.data,
|
||||
wavefile.data.capacity(),
|
||||
wavefile.samplerate);
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -124,36 +123,32 @@ public class MovingSoundTest extends BasicTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.sourcef(sources.get(0), AL.REFERENCE_DISTANCE, 1024.0f);
|
||||
al.sourcef(sources.get(0), AL.ROLLOFF_FACTOR, 0.5f);
|
||||
AL.alSourcef(sources.get(0), AL.AL_REFERENCE_DISTANCE, 1024.0f);
|
||||
AL.alSourcef(sources.get(0), AL.AL_ROLLOFF_FACTOR, 0.5f);
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//setup EAX if possible
|
||||
EAX eax = null;
|
||||
if (al.isExtensionPresent("EAX")) {
|
||||
eax = new EAX();
|
||||
if (AL.alIsExtensionPresent("EAX")) {
|
||||
try {
|
||||
eax.create();
|
||||
Env = createIntBuffer(1);
|
||||
eaxBufferProp = new EAXBufferProperties();
|
||||
EAX.create();
|
||||
eaxListenerProp = new EAXListenerProperties();
|
||||
} catch (Exception e) {
|
||||
eax = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,46 +160,36 @@ public class MovingSoundTest extends BasicTest {
|
|||
Keyboard.poll();
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
listenerx -= MOVEMENT;
|
||||
al.listener3f(AL.POSITION, listenerx, listenery, listenerz);
|
||||
System.out.println("listenerx: " + listenerx);
|
||||
listenerPosition.put(0, listenerPosition.get(0) - MOVEMENT);
|
||||
AL.alListenerfv(AL.AL_POSITION, listenerPosition);
|
||||
System.out.println("listenerx: " + listenerPosition.get(0));
|
||||
} else {
|
||||
sourcex -= MOVEMENT;
|
||||
al.source3f(sources.get(0), AL.POSITION, sourcex, sourcey, sourcez);
|
||||
System.out.println("sourcex: " + sourcex);
|
||||
sourcePosition.put(0, sourcePosition.get(0) - MOVEMENT);
|
||||
AL.alSourcefv(sources.get(0), AL.AL_POSITION, sourcePosition);
|
||||
System.out.println("sourcex: " + sourcePosition.get(0));
|
||||
}
|
||||
}
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
listenerx += MOVEMENT;
|
||||
al.listener3f(AL.POSITION, listenerx, listenery, listenerz);
|
||||
System.out.println("listenerx: " + listenerx);
|
||||
listenerPosition.put(0, listenerPosition.get(0) + MOVEMENT);
|
||||
AL.alListenerfv(AL.AL_POSITION, listenerPosition);
|
||||
System.out.println("listenerx: " + listenerPosition.get(0));
|
||||
} else {
|
||||
sourcex += MOVEMENT;
|
||||
al.source3f(sources.get(0), AL.POSITION, sourcex, sourcey, sourcez);
|
||||
System.out.println("sourcex: " + sourcex);
|
||||
sourcePosition.put(0, sourcePosition.get(0) + MOVEMENT);
|
||||
AL.alSourcefv(sources.get(0), AL.AL_POSITION, sourcePosition);
|
||||
System.out.println("sourcex: " + sourcePosition.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_E)) {
|
||||
if(eax != null) {
|
||||
if(eaxApplied) {
|
||||
Env.put(0, EAX.ENVIRONMENT_GENERIC);
|
||||
eax.eaxSet( EAX.LISTENER_GUID,
|
||||
EAXListenerProperties.ENVIRONMENT,
|
||||
0,
|
||||
Sys.getDirectBufferAddress(Env),
|
||||
4);
|
||||
eaxListenerProp.setEnvironment(EAX.EAX_ENVIRONMENT_GENERIC);
|
||||
EAX.eaxSetProperty(eaxListenerProp, EAXListenerProperties.EAXLISTENER_ENVIRONMENT, 0);
|
||||
} else {
|
||||
Env.put(0, EAX.ENVIRONMENT_HANGAR);
|
||||
eax.eaxSet( EAX.LISTENER_GUID,
|
||||
EAXListenerProperties.ENVIRONMENT,
|
||||
0,
|
||||
Sys.getDirectBufferAddress(Env),
|
||||
4);
|
||||
eaxListenerProp.setEnvironment(EAX.EAX_ENVIRONMENT_HANGAR);
|
||||
EAX.eaxSetProperty(eaxListenerProp, EAXListenerProperties.EAXLISTENER_ENVIRONMENT, 0);
|
||||
}
|
||||
eaxApplied = !eaxApplied;
|
||||
}
|
||||
}
|
||||
|
||||
if(gl.isCloseRequested()) {
|
||||
|
|
@ -218,19 +203,19 @@ public class MovingSoundTest extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteSources(1, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteBuffers(1, buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.ALC;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
|
@ -51,22 +48,15 @@ import java.nio.IntBuffer;
|
|||
*/
|
||||
public class OpenALCreationTest {
|
||||
|
||||
/** OpenAL instance */
|
||||
protected AL al;
|
||||
|
||||
/** OpenAL Context instance */
|
||||
protected ALC alc;
|
||||
|
||||
/**
|
||||
* Creates an instance of OpenALCreationTest
|
||||
*/
|
||||
public OpenALCreationTest() {
|
||||
al = new AL();
|
||||
}
|
||||
|
||||
public void alInitialize() {
|
||||
try {
|
||||
al.create();
|
||||
AL.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
|
|
@ -74,7 +64,7 @@ public class OpenALCreationTest {
|
|||
}
|
||||
|
||||
public void alExit() {
|
||||
al.destroy();
|
||||
AL.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,7 +87,7 @@ public class OpenALCreationTest {
|
|||
* @param error Error code causing exit
|
||||
*/
|
||||
protected void exit(int error) {
|
||||
System.out.println("OpenAL Error: " + al.getString(error));
|
||||
System.out.println("OpenAL Error: " + AL.alGetString(error));
|
||||
alExit();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
|
@ -133,7 +123,6 @@ public class OpenALCreationTest {
|
|||
System.out.print("shutdown...");
|
||||
alExit();
|
||||
System.out.println("success");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,13 +136,13 @@ public class OpenALCreationTest {
|
|||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenBuffers(1, buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.genSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenSources(1, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -161,13 +150,13 @@ public class OpenALCreationTest {
|
|||
WaveData wavefile = WaveData.create("Footsteps.wav");
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(
|
||||
AL.alBufferData(
|
||||
buffers.get(0),
|
||||
wavefile.format,
|
||||
Sys.getDirectBufferAddress(wavefile.data),
|
||||
wavefile.data,
|
||||
wavefile.data.capacity(),
|
||||
wavefile.samplerate);
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -175,20 +164,20 @@ public class OpenALCreationTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -201,19 +190,19 @@ public class OpenALCreationTest {
|
|||
System.out.println("done");
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteSources(1, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteBuffers(1, buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.openal.AL;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
|
@ -70,13 +69,13 @@ public class PlayTest extends BasicTest {
|
|||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenBuffers(1, buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.genSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenSources(1, sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -84,8 +83,8 @@ public class PlayTest extends BasicTest {
|
|||
WaveData wavefile = WaveData.create(args[0]);
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(buffers.get(0), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -93,20 +92,20 @@ public class PlayTest extends BasicTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -118,19 +117,19 @@ public class PlayTest extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteSources(1, sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteBuffers(1, buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.openal.AL;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
|
|
@ -74,13 +73,13 @@ public class PlayTestMemory extends BasicTest {
|
|||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenBuffers(1, buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.genSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenSources(1, sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -96,8 +95,8 @@ public class PlayTestMemory extends BasicTest {
|
|||
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(buffers.get(0), wavefile.format, Sys.getDirectBufferAddress(wavefile.data), wavefile.data.capacity(), wavefile.samplerate);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -105,20 +104,20 @@ public class PlayTestMemory extends BasicTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -130,19 +129,19 @@ public class PlayTestMemory extends BasicTest {
|
|||
}
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.get(0));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteSources(1, sources);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteBuffers(1, buffers);
|
||||
if((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.OpenALException;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
|
|
@ -71,11 +71,17 @@ public class SourceLimitTest extends BasicTest {
|
|||
}
|
||||
|
||||
System.out.print("Creating " + sourcesToCreate + " in one go...");
|
||||
CreateAllSources();
|
||||
try {
|
||||
CreateAllSources();
|
||||
} catch(OpenALException oale) {
|
||||
}
|
||||
|
||||
|
||||
System.out.print("Creating " + sourcesToCreate + " one at a time...");
|
||||
CreateSourcesStep();
|
||||
|
||||
try {
|
||||
CreateSourcesStep();
|
||||
} catch(Exception e) {
|
||||
}
|
||||
//shutdown
|
||||
alExit();
|
||||
}
|
||||
|
|
@ -90,14 +96,14 @@ public class SourceLimitTest extends BasicTest {
|
|||
IntBuffer sources = createIntBuffer(sourcesToCreate);
|
||||
|
||||
//Create sourcesToCreate sources in one fell swoop
|
||||
al.genSources(sourcesToCreate, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
System.out.println("failed to create " + sourcesToCreate + " sources");
|
||||
AL.alGenSources(sourcesToCreate, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
System.out.println("failed to create " + sourcesToCreate + " sources (" + AL.alGetString(lastError) + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
//delete sources
|
||||
al.deleteSources(sourcesToCreate, Sys.getDirectBufferAddress(sources));
|
||||
AL.alDeleteSources(sourcesToCreate, sources);
|
||||
|
||||
System.out.println("created " + sourcesToCreate + " sources successfully!");
|
||||
}
|
||||
|
|
@ -110,24 +116,25 @@ public class SourceLimitTest extends BasicTest {
|
|||
int sourcesCreated = 0;
|
||||
|
||||
//make bytbuffer that can hold sourcesToCreate sources
|
||||
IntBuffer sources = createIntBuffer(sourcesToCreate);
|
||||
IntBuffer[] sources = new IntBuffer[sourcesToCreate];
|
||||
|
||||
//create the sources
|
||||
for (int i = 0; i < sourcesToCreate; i++) {
|
||||
al.genSources(1, Sys.getDirectBufferAddress(sources) + (i * 4));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
for (int i = 0; i <= sourcesToCreate; i++) {
|
||||
sources[i] = createIntBuffer(1);
|
||||
AL.alGenSources(1, sources[i]);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
System.out.println("failed to create source: " + (i + 1));
|
||||
break;
|
||||
}
|
||||
sourcesCreated++;
|
||||
}
|
||||
|
||||
|
||||
//delete allocated sources
|
||||
for (int i = 0; i < sourcesCreated; i++) {
|
||||
//delete buffers and sources
|
||||
al.deleteSources(1, Sys.getDirectBufferAddress(sources) + (i * 4));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
System.out.println("failed to delete source: " + i);
|
||||
AL.alDeleteSources(1, sources[i]);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
System.out.println("failed to delete source: " + i + "(" + AL.alGetString(lastError) + ")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.openal.AL;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
|
|
@ -80,8 +79,8 @@ public class StressTest extends BasicTest {
|
|||
|
||||
private void createSources() {
|
||||
sources = createIntBuffer(4);
|
||||
al.genSources(4, Sys.getDirectBufferAddress(sources));
|
||||
if (al.getError() != AL.NO_ERROR) {
|
||||
AL.alGenSources(4, sources);
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
System.out.println("Unable to create 4 sources");
|
||||
alExit();
|
||||
}
|
||||
|
|
@ -89,29 +88,29 @@ public class StressTest extends BasicTest {
|
|||
|
||||
private void createBuffers() {
|
||||
buffers = createIntBuffer(10);
|
||||
al.genBuffers(10, Sys.getDirectBufferAddress(buffers));
|
||||
if (al.getError() != AL.NO_ERROR) {
|
||||
AL.alGenBuffers(10, buffers);
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
System.out.println("Unable to create 10 buffers");
|
||||
al.deleteSources(4, Sys.getDirectBufferAddress(sources));
|
||||
AL.alDeleteSources(4, sources);
|
||||
alExit();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSamples() throws Exception {
|
||||
al.getError();
|
||||
AL.alGetError();
|
||||
WaveData data = WaveData.create("ding.wav");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
al.bufferData(
|
||||
AL.alBufferData(
|
||||
buffers.get(i - 1),
|
||||
data.format,
|
||||
Sys.getDirectBufferAddress(data.data),
|
||||
data.data,
|
||||
data.data.capacity(),
|
||||
data.samplerate);
|
||||
|
||||
if (al.getError() != AL.NO_ERROR) {
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
System.out.println("Failed to load " + i + ".wav into buffer");
|
||||
al.deleteSources(4, Sys.getDirectBufferAddress(sources));
|
||||
al.deleteBuffers(10, Sys.getDirectBufferAddress(buffers));
|
||||
AL.alDeleteSources(4, sources);
|
||||
AL.alDeleteBuffers(10, buffers);
|
||||
alExit();
|
||||
}
|
||||
}
|
||||
|
|
@ -126,11 +125,11 @@ public class StressTest extends BasicTest {
|
|||
long startTime = System.currentTimeMillis();
|
||||
|
||||
//mark background source as looping
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
|
||||
//play background
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
al.sourcePlay(sources.get(0));
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
|
||||
while (System.currentTimeMillis() - startTime < (2000)) {
|
||||
|
||||
|
|
@ -138,22 +137,22 @@ public class StressTest extends BasicTest {
|
|||
System.out.println("random:" + randomBuffer);
|
||||
|
||||
//stop source at slot
|
||||
al.sourceStop(sources.get(nextSlot));
|
||||
if (al.getError() != AL.NO_ERROR) {
|
||||
AL.alSourceStop(sources.get(nextSlot));
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
System.out.println("Error stopping source.");
|
||||
}
|
||||
System.out.println("Stopped source: " + nextSlot);
|
||||
|
||||
//link source<->buffer
|
||||
al.sourcei(sources.get(nextSlot), AL.BUFFER, buffers.get(randomBuffer));
|
||||
if (al.getError() != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(nextSlot), AL.AL_BUFFER, buffers.get(randomBuffer));
|
||||
if (AL.alGetError() != AL.AL_NO_ERROR) {
|
||||
System.out.println("Error linking buffer and source.");
|
||||
}
|
||||
System.out.println("linked source " + nextSlot + " with buffer " + randomBuffer);
|
||||
|
||||
//start playing
|
||||
System.out.println("playing source " + nextSlot);
|
||||
al.sourcePlay(sources.get(nextSlot++));
|
||||
AL.alSourcePlay(sources.get(nextSlot++));
|
||||
if (nextSlot == 4) {
|
||||
nextSlot = startSlot;
|
||||
}
|
||||
|
|
@ -176,7 +175,7 @@ public class StressTest extends BasicTest {
|
|||
|
||||
//stop all sources
|
||||
for (int i = 0; i < 4; i++) {
|
||||
al.sourceStop(sources.get(i));
|
||||
AL.alSourceStop(sources.get(i));
|
||||
System.out.println("Stopping source " + (i+1));
|
||||
}
|
||||
|
||||
|
|
@ -192,8 +191,8 @@ public class StressTest extends BasicTest {
|
|||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
al.deleteSources(4, Sys.getDirectBufferAddress(sources));
|
||||
al.deleteBuffers(10, Sys.getDirectBufferAddress(buffers));
|
||||
AL.alDeleteSources(4, sources);
|
||||
AL.alDeleteBuffers(10, buffers);
|
||||
}
|
||||
|
||||
private int getRandomBuffer() {
|
||||
|
|
|
|||
|
|
@ -129,17 +129,17 @@ public class WaveData {
|
|||
int channels = 0;
|
||||
if (audioformat.getChannels() == 1) {
|
||||
if (audioformat.getSampleSizeInBits() == 8) {
|
||||
channels = AL.FORMAT_MONO8;
|
||||
channels = AL.AL_FORMAT_MONO8;
|
||||
} else if (audioformat.getSampleSizeInBits() == 16) {
|
||||
channels = AL.FORMAT_MONO16;
|
||||
channels = AL.AL_FORMAT_MONO16;
|
||||
} else {
|
||||
assert false : "Illegal sample size";
|
||||
}
|
||||
} else if (audioformat.getChannels() == 2) {
|
||||
if (audioformat.getSampleSizeInBits() == 8) {
|
||||
channels = AL.FORMAT_STEREO8;
|
||||
channels = AL.AL_FORMAT_STEREO8;
|
||||
} else if (audioformat.getSampleSizeInBits() == 16) {
|
||||
channels = AL.FORMAT_STEREO16;
|
||||
channels = AL.AL_FORMAT_STEREO16;
|
||||
} else {
|
||||
assert false : "Illegal sample size";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ public class FullScreenWindowedTest {
|
|||
// start of in windowed mode
|
||||
gl = new GL("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
|
||||
glInit();
|
||||
|
||||
|
|
@ -172,24 +171,24 @@ public class FullScreenWindowedTest {
|
|||
|
||||
private void render() {
|
||||
//clear background
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// draw white quad
|
||||
gl.pushMatrix();
|
||||
GL.glPushMatrix();
|
||||
{
|
||||
gl.translatef(quadPosition.x, quadPosition.y, 0);
|
||||
gl.rotated(angle, 0.0f, 0.0f, 1.0f);
|
||||
gl.color3f(1.0f, 1.0f, 1.0f);
|
||||
gl.begin(GL.QUADS);
|
||||
GL.glTranslatef(quadPosition.x, quadPosition.y, 0);
|
||||
GL.glRotated(angle, 0.0f, 0.0f, 1.0f);
|
||||
GL.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
GL.glBegin(GL.GL_QUADS);
|
||||
{
|
||||
gl.vertex2i(-50, -50);
|
||||
gl.vertex2i(50, -50);
|
||||
gl.vertex2i(50, 50);
|
||||
gl.vertex2i(-50, 50);
|
||||
GL.glVertex2i(-50, -50);
|
||||
GL.glVertex2i(50, -50);
|
||||
GL.glVertex2i(50, 50);
|
||||
GL.glVertex2i(-50, 50);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
gl.popMatrix();
|
||||
GL.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -208,7 +207,6 @@ public class FullScreenWindowedTest {
|
|||
Display.setDisplayMode(mode);
|
||||
gl = new GL("Test", mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
|
||||
glInit();
|
||||
|
||||
|
|
@ -227,7 +225,6 @@ public class FullScreenWindowedTest {
|
|||
Display.resetDisplayMode();
|
||||
gl = new GL("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
|
||||
glInit();
|
||||
|
||||
|
|
@ -314,15 +311,15 @@ public class FullScreenWindowedTest {
|
|||
private void glInit() {
|
||||
// Go into orthographic projection mode.
|
||||
gl.determineAvailableExtensions();
|
||||
gl.matrixMode(GL.PROJECTION);
|
||||
gl.loadIdentity();
|
||||
glu.ortho2D(0, mode.width, 0, mode.height);
|
||||
gl.matrixMode(GL.MODELVIEW);
|
||||
gl.loadIdentity();
|
||||
gl.viewport(0, 0, mode.width, mode.height);
|
||||
GL.glMatrixMode(GL.GL_PROJECTION);
|
||||
GL.glLoadIdentity();
|
||||
GLU.gluOrtho2D(0, mode.width, 0, mode.height);
|
||||
GL.glMatrixMode(GL.GL_MODELVIEW);
|
||||
GL.glLoadIdentity();
|
||||
GL.glViewport(0, 0, mode.width, mode.height);
|
||||
|
||||
//set clear color to black
|
||||
gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
//sync frame (only works on windows)
|
||||
if (GL.WGL_EXT_swap_control) {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ public final class Game {
|
|||
}
|
||||
|
||||
public static final GL gl = new GL("LWJGL Game Example", 16, 0, 0,0);
|
||||
public static final GLU glu = new GLU(gl);
|
||||
static {
|
||||
try {
|
||||
gl.create();
|
||||
|
|
@ -150,17 +149,17 @@ public final class Game {
|
|||
* All rendering is done in here
|
||||
*/
|
||||
private static void render() {
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
gl.pushMatrix();
|
||||
gl.translatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f);
|
||||
gl.rotatef(angle, 0, 0, 1.0f);
|
||||
gl.begin(GL.QUADS);
|
||||
gl.vertex2i(-50, -50);
|
||||
gl.vertex2i(50, -50);
|
||||
gl.vertex2i(50, 50);
|
||||
gl.vertex2i(-50, 50);
|
||||
gl.end();
|
||||
gl.popMatrix();
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
GL.glPushMatrix();
|
||||
GL.glTranslatef(Display.getWidth() / 2, Display.getHeight() / 2, 0.0f);
|
||||
GL.glRotatef(angle, 0, 0, 1.0f);
|
||||
GL.glBegin(GL.GL_QUADS);
|
||||
GL.glVertex2i(-50, -50);
|
||||
GL.glVertex2i(50, -50);
|
||||
GL.glVertex2i(50, 50);
|
||||
GL.glVertex2i(-50, 50);
|
||||
GL.glEnd();
|
||||
GL.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,16 +173,15 @@ public final class Game {
|
|||
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
||||
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
||||
// Go into orthographic projection mode.
|
||||
gl.matrixMode(GL.PROJECTION);
|
||||
gl.loadIdentity();
|
||||
glu.ortho2D(0, Display.getWidth(), 0, Display.getHeight());
|
||||
gl.matrixMode(GL.MODELVIEW);
|
||||
gl.loadIdentity();
|
||||
gl.viewport(0, 0, Display.getWidth(), Display.getHeight());
|
||||
GL.glMatrixMode(GL.GL_PROJECTION);
|
||||
GL.glLoadIdentity();
|
||||
GLU.gluOrtho2D(0, Display.getWidth(), 0, Display.getHeight());
|
||||
GL.glMatrixMode(GL.GL_MODELVIEW);
|
||||
GL.glLoadIdentity();
|
||||
GL.glViewport(0, 0, Display.getWidth(), Display.getHeight());
|
||||
ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4);
|
||||
num_tex_units_buf.order(ByteOrder.nativeOrder());
|
||||
int buf_addr = Sys.getDirectBufferAddress(num_tex_units_buf);
|
||||
gl.getIntegerv(GL.MAX_TEXTURE_UNITS_ARB, buf_addr);
|
||||
GL.glGetIntegerv(GL.GL_MAX_TEXTURE_UNITS_ARB, num_tex_units_buf.asIntBuffer());
|
||||
System.out.println("Number of texture units: " + num_tex_units_buf.getInt());
|
||||
// Fix the refresh rate to the display frequency.
|
||||
// gl.wglSwapIntervalEXT(1);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ public class Grass {
|
|||
}
|
||||
|
||||
public static final GL gl = new GL("LWJGL Grass", 50, 50, 640, 480, 16, 0, 0,0);
|
||||
public static final GLU glu = new GLU(gl);
|
||||
|
||||
static {
|
||||
try {
|
||||
|
|
@ -133,7 +132,7 @@ public class Grass {
|
|||
ByteBuffer byte_buf = ByteBuffer.allocateDirect(4);
|
||||
byte_buf.order(ByteOrder.nativeOrder());
|
||||
System.out.println("Vertex program supported: " + gl.NV_vertex_program);
|
||||
gl.genProgramsNV(1, Sys.getDirectBufferAddress(byte_buf));
|
||||
GL.glGenProgramsNV(1, byte_buf.asIntBuffer());
|
||||
IntBuffer int_buf = byte_buf.asIntBuffer();
|
||||
if (int_buf.get(0) == 0)
|
||||
throw new RuntimeException("Could not allocate new vertex program id!");
|
||||
|
|
@ -145,11 +144,11 @@ public class Grass {
|
|||
program_buf.rewind();
|
||||
program_buf.put(program);
|
||||
program_buf.rewind();
|
||||
gl.loadProgramNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glLoadProgramNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
program_handle,
|
||||
program_buf.remaining(),
|
||||
Sys.getDirectBufferAddress(program_buf));
|
||||
program_buf);
|
||||
/*gl.getIntegerv(GL.PROGRAM_ERROR_POSITION_NV, Sys.getDirectBufferAddress(int_buf));
|
||||
System.out.println("error position: " + int_buf.get(0));*/
|
||||
|
||||
|
|
@ -163,31 +162,31 @@ public class Grass {
|
|||
light_buf_f.rewind();
|
||||
light_buf_f.put(LightDiffuse);
|
||||
|
||||
gl.lightfv(
|
||||
GL.LIGHT0,
|
||||
GL.DIFFUSE,
|
||||
Sys.getDirectBufferAddress(light_buf_f));
|
||||
GL.glLightfv(
|
||||
GL.GL_LIGHT0,
|
||||
GL.GL_DIFFUSE,
|
||||
light_buf_f);
|
||||
light_buf_f.rewind();
|
||||
light_buf_f.put(LightPosition);
|
||||
gl.lightfv(
|
||||
GL.LIGHT0,
|
||||
GL.POSITION,
|
||||
Sys.getDirectBufferAddress(light_buf_f));
|
||||
gl.enable(GL.LIGHT0);
|
||||
GL.glLightfv(
|
||||
GL.GL_LIGHT0,
|
||||
GL.GL_POSITION,
|
||||
light_buf_f);
|
||||
GL.glEnable(GL.GL_LIGHT0);
|
||||
|
||||
gl.enable(GL.LIGHTING);
|
||||
GL.glEnable(GL.GL_LIGHTING);
|
||||
|
||||
gl.enable(GL.DEPTH_TEST);
|
||||
GL.glEnable(GL.GL_DEPTH_TEST);
|
||||
|
||||
gl.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA);
|
||||
gl.enable(GL.BLEND);
|
||||
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL.glEnable(GL.GL_BLEND);
|
||||
|
||||
gl.matrixMode(GL.PROJECTION);
|
||||
glu.perspective(40.0, 1.0, 1.0, 50.0);
|
||||
GL.glMatrixMode(GL.GL_PROJECTION);
|
||||
GLU.gluPerspective(40.0, 1.0, 1.0, 50.0);
|
||||
|
||||
gl.matrixMode(GL.MODELVIEW);
|
||||
GL.glMatrixMode(GL.GL_MODELVIEW);
|
||||
|
||||
glu.lookAt(14.0, 10.0, -16.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
|
||||
GLU.gluLookAt(14.0, 10.0, -16.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
aslod.angle = 2.6179935f;
|
||||
aslod.value = 0.2f;
|
||||
|
|
@ -201,7 +200,7 @@ public class Grass {
|
|||
degree *= (0.5 + myrand());
|
||||
|
||||
ptrAnimate(degree);
|
||||
gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//ptrDraw();
|
||||
|
||||
|
|
@ -247,16 +246,16 @@ public class Grass {
|
|||
fRigid = ((fRigid = myrand()) < 0.2f) ? 0.2f : fRigid;
|
||||
|
||||
if (myrand() < 0.3)
|
||||
gl.begin(GL.LINE_STRIP);
|
||||
GL.glBegin(GL.GL_LINE_STRIP);
|
||||
else
|
||||
gl.begin(GL.QUAD_STRIP);
|
||||
GL.glBegin(GL.GL_QUAD_STRIP);
|
||||
|
||||
for (cFaces = 0; cFaces < numFaces; cFaces++) {
|
||||
for (cWidth = frndWidth;
|
||||
cWidth >= -frndWidth;
|
||||
cWidth -= (frndWidth * 2.0f)) {
|
||||
gl.color4f(fX, fRigid, fZ, (float) cFaces / (float) numFaces);
|
||||
gl.vertex3f(
|
||||
GL.glColor4f(fX, fRigid, fZ, (float) cFaces / (float) numFaces);
|
||||
GL.glVertex3f(
|
||||
(float) (((cFaces - 2) * 0.1f)
|
||||
* java.lang.Math.cos(fRotate)
|
||||
+ (cWidth) * java.lang.Math.sin(fRotate)),
|
||||
|
|
@ -267,7 +266,7 @@ public class Grass {
|
|||
}
|
||||
frndWidth -= fDecWidth;
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -275,112 +274,112 @@ public class Grass {
|
|||
float cI, cJ, fArea;
|
||||
|
||||
fArea = 20.0f;
|
||||
mesh = gl.genLists(1);
|
||||
gl.newList(mesh, GL.COMPILE);
|
||||
mesh = GL.glGenLists(1);
|
||||
GL.glNewList(mesh, GL.GL_COMPILE);
|
||||
for (cI = -fArea / 2; cI < fArea / 2; cI += 0.25f) {
|
||||
for (cJ = -fArea / 2; cJ < fArea / 2; cJ += 0.25f) {
|
||||
genGrass(0.5f, 0.1f, cI, cJ);
|
||||
}
|
||||
}
|
||||
gl.endList();
|
||||
GL.glEndList();
|
||||
|
||||
}
|
||||
|
||||
private static void grsDraw() {
|
||||
gl.enable(GL.VERTEX_PROGRAM_NV);
|
||||
gl.bindProgramNV(GL.VERTEX_PROGRAM_NV, program_handle);
|
||||
gl.trackMatrixNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glEnable(GL.GL_VERTEX_PROGRAM_NV);
|
||||
GL.glBindProgramNV(GL.GL_VERTEX_PROGRAM_NV, program_handle);
|
||||
GL.glTrackMatrixNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
0,
|
||||
GL.MODELVIEW_PROJECTION_NV,
|
||||
GL.IDENTITY_NV);
|
||||
GL.GL_MODELVIEW_PROJECTION_NV,
|
||||
GL.GL_IDENTITY_NV);
|
||||
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
4,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
5,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
6,
|
||||
1.763609f,
|
||||
0.496495f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
7,
|
||||
-0.943599f,
|
||||
3.203737f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
8,
|
||||
4.101107f,
|
||||
0.943413f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
9,
|
||||
-1.218603f,
|
||||
6.259399f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
10,
|
||||
7.214299f,
|
||||
1.352961f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
11,
|
||||
-1.540748f,
|
||||
10.080958f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
12,
|
||||
10.880035f,
|
||||
1.759046f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
13,
|
||||
-1.852705f,
|
||||
14.468674f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
14,
|
||||
14.292879f,
|
||||
1.973329f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
15,
|
||||
-1.973387f,
|
||||
18.506531f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
16,
|
||||
(float) (java.lang.Math.sin(aslod.angle)
|
||||
* (aslod.value + aslod.ripple)),
|
||||
|
|
@ -389,54 +388,54 @@ public class Grass {
|
|||
* (aslod.value + aslod.ripple)),
|
||||
0.0f);
|
||||
|
||||
gl.programParameter4fNV(GL.VERTEX_PROGRAM_NV, 17, 1.7f, 5f, 2f, 0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 17, 1.7f, 5f, 2f, 0f);
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
18,
|
||||
-0.0187293f,
|
||||
0.074261f,
|
||||
0.2121144f,
|
||||
1.570729f);
|
||||
gl.programParameter4fNV(GL.VERTEX_PROGRAM_NV, 20, 0f, 0.5f, 1f, 0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 20, 0f, 0.5f, 1f, 0f);
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
21,
|
||||
0.25f,
|
||||
-9f,
|
||||
0.75f,
|
||||
0.1591549f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
22,
|
||||
24.9808f,
|
||||
-24.9808f,
|
||||
-60.14581f,
|
||||
60.14581f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
23,
|
||||
85.45379f,
|
||||
-85.45379f,
|
||||
-64.93935f,
|
||||
64.93935f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
24,
|
||||
19.73921f,
|
||||
-19.73921f,
|
||||
-1f,
|
||||
1f);
|
||||
gl.programParameter4fNV(GL.VERTEX_PROGRAM_NV, 25, 0f, 4f, 0f, 0f);
|
||||
gl.programParameter4fNV(
|
||||
GL.VERTEX_PROGRAM_NV,
|
||||
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 25, 0f, 4f, 0f, 0f);
|
||||
GL.glProgramParameter4fNV(
|
||||
GL.GL_VERTEX_PROGRAM_NV,
|
||||
19,
|
||||
1f,
|
||||
3.141593f,
|
||||
0.5f,
|
||||
1f);
|
||||
gl.programParameter4fNV(GL.VERTEX_PROGRAM_NV, 26, 0.7f, 0.4f, 0f, 0f);
|
||||
gl.callList(mesh);
|
||||
gl.disable(GL.VERTEX_PROGRAM_NV);
|
||||
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 26, 0.7f, 0.4f, 0f, 0f);
|
||||
GL.glCallList(mesh);
|
||||
GL.glDisable(GL.GL_VERTEX_PROGRAM_NV);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ public class PbufferTest {
|
|||
gl = new GL("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
// gl = new GL("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
|
||||
gl.create();
|
||||
glu = new GLU(gl);
|
||||
if ((Pbuffer.getPbufferCaps() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
|
||||
System.out.println("No Pbuffer support!");
|
||||
System.exit(1);
|
||||
|
|
@ -189,49 +188,49 @@ public class PbufferTest {
|
|||
pbuffer.makeCurrent();
|
||||
// Pbuffer rendering
|
||||
//clear background
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// draw white quad
|
||||
gl.pushMatrix();
|
||||
GL.glPushMatrix();
|
||||
{
|
||||
gl.translatef(quadPosition.x, quadPosition.y, 0);
|
||||
gl.rotated(angle, 0.0f, 0.0f, 1.0f);
|
||||
gl.color3f(1.0f, 1.0f, 1.0f);
|
||||
gl.begin(GL.QUADS);
|
||||
GL.glTranslatef(quadPosition.x, quadPosition.y, 0);
|
||||
GL.glRotated(angle, 0.0f, 0.0f, 1.0f);
|
||||
GL.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
GL.glBegin(GL.GL_QUADS);
|
||||
{
|
||||
gl.vertex2i(-50, -50);
|
||||
gl.vertex2i(50, -50);
|
||||
gl.vertex2i(50, 50);
|
||||
gl.vertex2i(-50, 50);
|
||||
GL.glVertex2i(-50, -50);
|
||||
GL.glVertex2i(50, -50);
|
||||
GL.glVertex2i(50, 50);
|
||||
GL.glVertex2i(-50, 50);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
gl.popMatrix();
|
||||
gl.copyTexImage2D(GL.TEXTURE_2D, 0, GL.RGB, 0, 0, 256, 256, 0);
|
||||
GL.glPopMatrix();
|
||||
GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, 0, 0, 256, 256, 0);
|
||||
Pbuffer.releaseContext();
|
||||
|
||||
// OpenGL window rendering
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
|
||||
// draw white quad
|
||||
gl.pushMatrix();
|
||||
GL.glPushMatrix();
|
||||
{
|
||||
gl.translatef(quadPosition.x, quadPosition.y, 0);
|
||||
gl.rotated(angle, 0.0f, 0.0f, 1.0f);
|
||||
gl.color3f(1.0f, 1.0f, 0.0f);
|
||||
gl.begin(GL.QUADS);
|
||||
GL.glTranslatef(quadPosition.x, quadPosition.y, 0);
|
||||
GL.glRotated(angle, 0.0f, 0.0f, 1.0f);
|
||||
GL.glColor3f(1.0f, 1.0f, 0.0f);
|
||||
GL.glBegin(GL.GL_QUADS);
|
||||
{
|
||||
gl.texCoord2f(0f, 0f);
|
||||
gl.vertex2i(-50, -50);
|
||||
gl.texCoord2f(1f, 0f);
|
||||
gl.vertex2i(50, -50);
|
||||
gl.texCoord2f(1f, 1f);
|
||||
gl.vertex2i(50, 50);
|
||||
gl.texCoord2f(0f, 1f);
|
||||
gl.vertex2i(-50, 50);
|
||||
GL.glTexCoord2f(0f, 0f);
|
||||
GL.glVertex2i(-50, -50);
|
||||
GL.glTexCoord2f(1f, 0f);
|
||||
GL.glVertex2i(50, -50);
|
||||
GL.glTexCoord2f(1f, 1f);
|
||||
GL.glVertex2i(50, 50);
|
||||
GL.glTexCoord2f(0f, 1f);
|
||||
GL.glVertex2i(-50, 50);
|
||||
}
|
||||
gl.end();
|
||||
GL.glEnd();
|
||||
}
|
||||
gl.popMatrix();
|
||||
GL.glPopMatrix();
|
||||
}
|
||||
|
||||
private void initPbuffer() {
|
||||
|
|
@ -239,7 +238,7 @@ public class PbufferTest {
|
|||
pbuffer = new Pbuffer(256, 256, mode.bpp, 0, 0, 0);
|
||||
pbuffer.makeCurrent();
|
||||
initGLState(256, 256, 0.5f);
|
||||
gl.bindTexture(GL.TEXTURE_2D, tex_handle);
|
||||
GL.glBindTexture(GL.GL_TEXTURE_2D, tex_handle);
|
||||
Pbuffer.releaseContext();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -267,7 +266,6 @@ public class PbufferTest {
|
|||
gl.create();
|
||||
glInit();
|
||||
initPbuffer();
|
||||
glu = new GLU(gl);
|
||||
|
||||
Keyboard.create();
|
||||
} catch (Exception e) {
|
||||
|
|
@ -289,7 +287,6 @@ public class PbufferTest {
|
|||
gl.create();
|
||||
glInit();
|
||||
initPbuffer();
|
||||
glu = new GLU(gl);
|
||||
|
||||
|
||||
Keyboard.create();
|
||||
|
|
@ -344,7 +341,7 @@ public class PbufferTest {
|
|||
private void destroyTexture() {
|
||||
IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
buffer.put(0, tex_handle);
|
||||
gl.deleteTextures(1, Sys.getDirectBufferAddress(buffer));
|
||||
GL.glDeleteTextures(1, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -379,15 +376,15 @@ public class PbufferTest {
|
|||
}
|
||||
|
||||
private void initGLState(int width, int height, float color) {
|
||||
gl.matrixMode(GL.PROJECTION);
|
||||
gl.loadIdentity();
|
||||
glu.ortho2D(0, mode.width, 0, mode.height);
|
||||
gl.matrixMode(GL.MODELVIEW);
|
||||
gl.loadIdentity();
|
||||
gl.viewport(0, 0, width, height);
|
||||
GL.glMatrixMode(GL.GL_PROJECTION);
|
||||
GL.glLoadIdentity();
|
||||
GLU.gluOrtho2D(0, mode.width, 0, mode.height);
|
||||
GL.glMatrixMode(GL.GL_MODELVIEW);
|
||||
GL.glLoadIdentity();
|
||||
GL.glViewport(0, 0, width, height);
|
||||
|
||||
//set clear color to black
|
||||
gl.clearColor(color, color, color, 0.0f);
|
||||
GL.glClearColor(color, color, color, 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -400,17 +397,17 @@ public class PbufferTest {
|
|||
if (GL.WGL_EXT_swap_control) {
|
||||
GL.wglSwapIntervalEXT(1);
|
||||
}
|
||||
gl.texEnvf(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.REPLACE);
|
||||
gl.enable(GL.TEXTURE_2D);
|
||||
GL.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
|
||||
GL.glEnable(GL.GL_TEXTURE_2D);
|
||||
// Create shared texture
|
||||
IntBuffer buffer = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
gl.genTextures(1, Sys.getDirectBufferAddress(buffer));
|
||||
GL.glGenTextures(1, buffer);
|
||||
tex_handle = buffer.get(0);
|
||||
gl.bindTexture(GL.TEXTURE_2D, tex_handle);
|
||||
gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP);
|
||||
gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP);
|
||||
gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR);
|
||||
gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.LINEAR);
|
||||
GL.glBindTexture(GL.GL_TEXTURE_2D, tex_handle);
|
||||
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
|
||||
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP);
|
||||
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
|
||||
GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
|
||||
initGLState(mode.width, mode.height, 0f);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue