summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRami Santina <[email protected]>2011-03-28 11:49:57 +0300
committerRami Santina <[email protected]>2011-03-28 11:49:57 +0300
commit3bf42d92a3baf5e506f553fc20c71c082c39790e (patch)
tree6bc1f76b2fd1461a29530c090e498fac25c85f20 /src
parent23646bedac2fe9ff27e35ac167e6872afb84fc50 (diff)
Added print screen to TGA file to be used in junit
Diffstat (limited to 'src')
-rw-r--r--src/demo/GPUTextGLListenerBase01.java14
-rw-r--r--src/demo/GPUTextNewtDemo01.java22
-rw-r--r--src/demo/GPUTextNewtDemo02.java20
3 files changed, 51 insertions, 5 deletions
diff --git a/src/demo/GPUTextGLListenerBase01.java b/src/demo/GPUTextGLListenerBase01.java
index b310f1069..7dffbd7d1 100644
--- a/src/demo/GPUTextGLListenerBase01.java
+++ b/src/demo/GPUTextGLListenerBase01.java
@@ -27,10 +27,14 @@
*/
package demo;
+import java.io.File;
+import java.io.IOException;
+
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLPipelineFactory;
import com.jogamp.graph.curve.text.HwTextRenderer;
@@ -39,6 +43,7 @@ import com.jogamp.graph.geom.Vertex;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.util.awt.Screenshot;
public abstract class GPUTextGLListenerBase01 implements GLEventListener {
Vertex.Factory<? extends Vertex> vfactory;
@@ -106,7 +111,7 @@ public abstract class GPUTextGLListenerBase01 implements GLEventListener {
dumpMatrix(true);
}
-
+ boolean printScreen = true;
public void display(GLAutoDrawable drawable) {
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -175,6 +180,11 @@ public abstract class GPUTextGLListenerBase01 implements GLEventListener {
window.removeKeyListener(keyAction);
}
+ public void printScreen(GLWindow window, String dir, String tech, boolean exportAlpha) throws GLException, IOException{
+ String filename = dir + tech + "-" + window.getWidth()+ "x" + window.getHeight() + "-" + texSize+ ".tga";
+ Screenshot.writeToTargaFile(new File(filename), window.getWidth(), window.getHeight(), exportAlpha);
+ }
+
public class KeyAction implements KeyListener {
public void keyPressed(KeyEvent arg0) {
if(arg0.getKeyCode() == KeyEvent.VK_1){
@@ -214,7 +224,7 @@ public abstract class GPUTextGLListenerBase01 implements GLEventListener {
}
else if(arg0.getKeyCode() == KeyEvent.VK_9){
rotate(-1);
- }
+ }
}
public void keyTyped(KeyEvent arg0) {}
public void keyReleased(KeyEvent arg0) {}
diff --git a/src/demo/GPUTextNewtDemo01.java b/src/demo/GPUTextNewtDemo01.java
index ad1020122..76593278f 100644
--- a/src/demo/GPUTextNewtDemo01.java
+++ b/src/demo/GPUTextNewtDemo01.java
@@ -27,9 +27,12 @@
*/
package demo;
+import java.io.IOException;
+
import javax.media.opengl.GL2ES2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import com.jogamp.graph.curve.Region;
@@ -47,7 +50,7 @@ public class GPUTextNewtDemo01 {
}
TextGLListener textGLListener = null;
-
+ GLWindow window;
public void testMe() {
GLProfile.initSingleton(true);
GLProfile glp = GLProfile.getGL2ES2();
@@ -57,7 +60,7 @@ public class GPUTextNewtDemo01 {
caps.setNumSamples(4); // 2 samples is not enough ..
System.out.println("Requested: "+caps);
- final GLWindow window = GLWindow.create(caps);
+ window = GLWindow.create(caps);
window.setPosition(10, 10);
window.setSize(500, 500);
@@ -95,5 +98,20 @@ public class GPUTextNewtDemo01 {
//gl.glEnable(GL2GL3.GL_SAMPLE_ALPHA_TO_ONE);
MSAATool.dump(drawable);
}
+
+ public void display(GLAutoDrawable drawable) {
+ super.display(drawable);
+
+ if(printScreen){
+ try {
+ super.printScreen(window, "./","r2t0-msaa1", false);
+ printScreen=false;
+ } catch (GLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
}
diff --git a/src/demo/GPUTextNewtDemo02.java b/src/demo/GPUTextNewtDemo02.java
index 1fbd253c9..4174da30b 100644
--- a/src/demo/GPUTextNewtDemo02.java
+++ b/src/demo/GPUTextNewtDemo02.java
@@ -27,10 +27,13 @@
*/
package demo;
+import java.io.IOException;
+
import javax.media.opengl.GL;
import javax.media.opengl.GL3;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import com.jogamp.graph.curve.Region;
@@ -53,6 +56,7 @@ public class GPUTextNewtDemo02 {
public static void main(String[] args) {
GPUTextNewtDemo02 test = new GPUTextNewtDemo02();
test.testMe();
+
}
GLWindow window;
@@ -85,7 +89,7 @@ public class GPUTextNewtDemo02 {
private class TextGLListener extends GPUTextGLListenerBase01 {
public TextGLListener() {
super(SVertex.factory(), Region.TWO_PASS, DEBUG, TRACE);
- setMatrix(-10, 10, 0f, -1000, 190);
+ setMatrix(-10, 10, 0f, -1000, 400);
}
public void init(GLAutoDrawable drawable) {
@@ -102,5 +106,19 @@ public class GPUTextNewtDemo02 {
//gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL3.GL_NICEST);
MSAATool.dump(drawable);
}
+ public void display(GLAutoDrawable drawable) {
+ super.display(drawable);
+
+ if(printScreen){
+ try {
+ super.printScreen(window, "./","r2t1-msaa0", false);
+ printScreen=false;
+ } catch (GLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
}