summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TestRegionRenderer01.java152
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/graph/TestTextRenderer01.java31
2 files changed, 173 insertions, 10 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRenderer01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRenderer01.java
new file mode 100644
index 000000000..35f0325c9
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestRegionRenderer01.java
@@ -0,0 +1,152 @@
+package test.com.jogamp.opengl.test.junit.graph;
+
+import java.io.IOException;
+
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLCapabilitiesImmutable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.jogamp.newt.opengl.GLWindow;
+
+import demo.GPURegionNewtDemo01;
+import demo.GPURegionNewtDemo02;
+import demo.GPURegionRendererListenerBase01;
+
+public class TestRegionRenderer01 {
+
+ public static void main(String args[]) throws IOException {
+ String tstname = TestRegionRenderer01.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
+ @BeforeClass
+ public static void initClass() {
+ GLProfile.initSingleton(true);
+ NativeWindowFactory.initSingleton(true);
+ }
+
+ static void destroyWindow(GLWindow window) {
+ if(null!=window) {
+ window.destroy();
+ }
+ }
+
+ static GLWindow createWindow(String title, GLCapabilitiesImmutable caps, int width, int height) {
+ Assert.assertNotNull(caps);
+
+ GLWindow window = GLWindow.create(caps);
+ window.setSize(width, height);
+ window.setPosition(10, 10);
+ window.setTitle(title);
+ Assert.assertNotNull(window);
+ window.setVisible(true);
+
+ return window;
+ }
+
+ @Test
+ public void testRegionRendererR2T01() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL3);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+ caps.setAlphaBits(4);
+
+ GLWindow window = createWindow("shape-r2t1-msaa0", caps, 800,400);
+
+ GPURegionNewtDemo02 demo02 = new GPURegionNewtDemo02();
+ GPURegionNewtDemo02.RegionGLListener demo02Listener = demo02.createRegionRendererListener(window);
+
+ RegionGLListener listener = new RegionGLListener(demo02Listener, window.getTitle(), "GPURegionNewtDemo02");
+ window.addGLEventListener(listener);
+
+ listener.setTech(-20, 00, 0f, -300, 400);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -150, 800);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -50, 1000);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ @Test
+ public void testRegionRendererMSAA01() throws InterruptedException {
+ GLProfile glp = GLProfile.get(GLProfile.GL2ES2);
+ GLCapabilities caps = new GLCapabilities(glp);
+ caps.setOnscreen(false);
+ caps.setAlphaBits(4);
+ caps.setSampleBuffers(true);
+ caps.setNumSamples(4);
+
+ GLWindow window = createWindow("shape-r2t0-msaa1", caps, 800, 400);
+
+ GPURegionNewtDemo01 demo01 = new GPURegionNewtDemo01();
+ GPURegionNewtDemo01.RegionGLListener demo01Listener = demo01.createRegionRendererListener(window);
+
+ RegionGLListener listener = new RegionGLListener(demo01Listener, window.getTitle(), "GPURegionNewtDemo01");
+ window.addGLEventListener(listener);
+
+ listener.setTech(-20, 00, 0f, -300, 400);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -150, 800);
+ window.display();
+
+ listener.setTech(-20, 00, 0f, -50, 1000);
+ window.display();
+
+ destroyWindow(window);
+ }
+
+ private class RegionGLListener implements GLEventListener {
+ String winTitle;
+ String name;
+ GPURegionRendererListenerBase01 impl;
+
+ public RegionGLListener(GPURegionRendererListenerBase01 impl, String title, String name) {
+ this.impl = impl;
+ this.winTitle = title;
+ this.name = name;
+ }
+
+ public void setTech(float xt, float yt, float angle, int zoom, int fboSize){
+ impl.setMatrix(xt, yt, angle, zoom, fboSize);
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ impl.init(drawable);
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ impl.display(drawable);
+
+ try {
+ impl.printScreen(drawable, "./", winTitle, name, false);
+ } catch (GLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ impl.dispose(drawable);
+
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ impl.reshape(drawable, x, y, width, height);
+
+ }
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRenderer01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRenderer01.java
index 501bdbb75..8f5174a89 100755
--- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRenderer01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRenderer01.java
@@ -16,14 +16,20 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.TextRenderer;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.opengl.SVertex;
import com.jogamp.newt.opengl.GLWindow;
-import demo.GPUTextGLListenerBase01;
+import demo.GPUTextRendererListenerBase01;
public class TestTextRenderer01 {
+ public static void main(String args[]) throws IOException {
+ String tstname = TestRegionRenderer01.class.getName();
+ org.junit.runner.JUnitCore.main(tstname);
+ }
+
@BeforeClass
public static void initClass() {
GLProfile.initSingleton(true);
@@ -51,14 +57,15 @@ public class TestTextRenderer01 {
@Test
public void testTextRendererR2T01() throws InterruptedException {
- GLProfile glp = GLProfile.get(GLProfile.GL3bc);
+ GLProfile glp = GLProfile.get(GLProfile.GL3);
GLCapabilities caps = new GLCapabilities(glp);
caps.setOnscreen(false);
caps.setAlphaBits(4);
- GLWindow window = createWindow("r2t1-msaa0", caps, 800,400);
+ GLWindow window = createWindow("text-r2t1-msaa0", caps, 800,400);
TextGLListener textGLListener = new TextGLListener(Region.TWO_PASS);
- textGLListener.attachTo(window);
+ textGLListener.attachInputListenerTo(window);
+ window.addGLEventListener(textGLListener);
textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0);
textGLListener.setTech(-400, -30, 0f, -1000, 400);
@@ -92,9 +99,10 @@ public class TestTextRenderer01 {
caps.setSampleBuffers(true);
caps.setNumSamples(4);
- GLWindow window = createWindow("r2t0-msaa1", caps, 800, 400);
+ GLWindow window = createWindow("text-r2t0-msaa1", caps, 800, 400);
TextGLListener textGLListener = new TextGLListener(Region.SINGLE_PASS);
- textGLListener.attachTo(window);
+ textGLListener.attachInputListenerTo(window);
+ window.addGLEventListener(textGLListener);
textGLListener.setFontSet(FontFactory.UBUNTU, 0, 0);
textGLListener.setTech(-400, -30, 0f, -1000, 0);
@@ -119,15 +127,15 @@ public class TestTextRenderer01 {
destroyWindow(window);
}
- private class TextGLListener extends GPUTextGLListenerBase01 {
+ private class TextGLListener extends GPUTextRendererListenerBase01 {
String winTitle;
public TextGLListener(int type) {
super(SVertex.factory(), type, false, false);
}
- public void attachTo(GLWindow window) {
- super.attachTo(window);
+ public void attachInputListenerTo(GLWindow window) {
+ super.attachInputListenerTo(window);
winTitle = window.getTitle();
}
public void setTech(float xt, float yt, float angle, int zoom, int fboSize){
@@ -139,6 +147,9 @@ public class TestTextRenderer01 {
super.init(drawable);
gl.setSwapInterval(1);
gl.glEnable(GL.GL_DEPTH_TEST);
+
+ final TextRenderer textRenderer = (TextRenderer) getRenderer();
+
textRenderer.init(gl);
textRenderer.setAlpha(gl, 1.0f);
textRenderer.setColor(gl, 0.0f, 0.0f, 0.0f);
@@ -148,7 +159,7 @@ public class TestTextRenderer01 {
super.display(drawable);
try {
- printScreen("./", winTitle, drawable.getWidth(), drawable.getHeight(), false);
+ printScreen(drawable, "./", winTitle, false);
} catch (GLException e) {
e.printStackTrace();
} catch (IOException e) {