diff --git a/pom.xml b/pom.xml
index 856126b..3262fcf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,11 @@
+
+ com.aparapi
+ aparapi
+ 3.0.0
+
diff --git a/src/sig/Panel.java b/src/sig/Panel.java
index 8f50ab8..a3c1298 100644
--- a/src/sig/Panel.java
+++ b/src/sig/Panel.java
@@ -2,6 +2,9 @@ package sig;
import java.awt.Graphics;
import javax.swing.JPanel;
+
+import com.aparapi.Range;
+
import java.awt.image.ColorModel;
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsConfiguration;
@@ -18,7 +21,10 @@ public class Panel extends JPanel implements Runnable {
public int height=SigKeeper.SCREEN_HEIGHT;
private Image imageBuffer;
private MemoryImageSource mImageProducer;
- public int pixel[];
+ public int[] pixel;
+ public float[] triPoints;
+
+ RenderKernel renderer;
public Panel() {
super(true);
@@ -33,6 +39,7 @@ public class Panel extends JPanel implements Runnable {
}
public void init(){
+ triPoints = new float[120000000];
cm = getCompatibleColorModel();
width = getWidth();
height = getHeight();
@@ -40,20 +47,48 @@ public class Panel extends JPanel implements Runnable {
SigKeeper.SCREEN_HEIGHT=getHeight();
int screenSize = width * height;
if(pixel == null || pixel.length < screenSize){
- pixel = new int[screenSize];
+ pixel = new int[screenSize];
}
mImageProducer = new MemoryImageSource(width, height, cm, pixel,0, width);
mImageProducer.setAnimated(true);
mImageProducer.setFullBufferUpdates(true);
- imageBuffer = Toolkit.getDefaultToolkit().createImage(mImageProducer);
+ renderer = new RenderKernel(pixel,triPoints,SigKeeper.SCREEN_WIDTH,SigKeeper.SCREEN_HEIGHT);
+ renderer.setExplicit(true);
+ imageBuffer = Toolkit.getDefaultToolkit().createImage(mImageProducer);
if(thread.isInterrupted() || !thread.isAlive()){
thread.start();
}
+ //renderer.setExplicit(true);
+ //renderer.put(pixel);
}
public /* abstract */ void render(){
int[] p = pixel; // this avoid crash when resizing
- if(p.length != width * height) return;
+ if(p!=null && p.length != width * height) return;
+ for (int x=0;x=0&&x1=0&&y1=0&&x2=0&&y2=0&&x3=0&&y3 tris = new ArrayList();
+
SigKeeper() {
+
frame = new JFrame("SigKeeper");
panel = new Panel();
@@ -44,19 +49,15 @@ public class SigKeeper implements WindowFocusListener,KeyListener,MouseListener,
invisibleCursor = frame.getToolkit().createCustomCursor(new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB),new Point(),null);
panel.setCursor(invisibleCursor);
- frame.setVisible(true);
GraphicsDevice screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
frame.setLocation((screen.getDisplayMode().getWidth()-SCREEN_WIDTH)/2,(screen.getDisplayMode().getHeight()-SCREEN_HEIGHT)/2);
+ frame.setVisible(true);
panel.init();
- for (int x=30;x<=100;x++) {
- for (int y=30;y<=100;y++) {
- if (y==30||y==100) {
- panel.pixel[y*SCREEN_WIDTH+x]=0xFF;
- } else
- if (x==30||x==100){
- panel.pixel[y*SCREEN_WIDTH+x]=0xFF00;
- }
- }
+
+ for (int i=0;i<1000000;i++) {
+ tris.add(new Triangle(new Vertex((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100),
+ new Vertex((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100),
+ new Vertex((float)Math.random()*SCREEN_WIDTH,(float)Math.random()*SCREEN_HEIGHT,(float)Math.random()*100)));
}
new Thread() {
diff --git a/src/sig/Triangle.java b/src/sig/Triangle.java
new file mode 100644
index 0000000..24a20fd
--- /dev/null
+++ b/src/sig/Triangle.java
@@ -0,0 +1,12 @@
+package sig;
+
+public class Triangle {
+ Vertex A;
+ Vertex B;
+ Vertex C;
+ public Triangle(Vertex a, Vertex b, Vertex c) {
+ A = a;
+ B = b;
+ C = c;
+ }
+}
diff --git a/src/sig/Vertex.java b/src/sig/Vertex.java
new file mode 100644
index 0000000..dcc73e3
--- /dev/null
+++ b/src/sig/Vertex.java
@@ -0,0 +1,20 @@
+package sig;
+
+public class Vertex {
+ float x,y,z,w;
+
+ public Vertex() {
+ this(0,0,0,1);
+ }
+
+ public Vertex(float x, float y, float z) {
+ this(x,y,z,1);
+ }
+
+ public Vertex(float x, float y, float z,float w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+}