GL class compilation with Eclipse
Answered
- Need more info
- Answered
- Working on it
import processing.core.*;
import javax.media.opengl.GL;
import processing.opengl.PGraphicsOpenGL;
public class Test0 extends PApplet{
PGraphicsOpenGL pgl;
GL gl;
ClassTest0 mTest;
public void setup(){
size(400,400,OPENGL);
pgl = (PGraphicsOpenGL) g;
gl = pgl.beginGL();
mTest=new ClassTest0(this);
mTest.randd();
}
public void draw(){
gl=pgl.beginGL();
background(255);
mTest.draw();
//
// gl.glLineWidth(5.0f);
// gl.glColor4f(0.1f, 0.5f, 0.5f, 0.1f);
// gl.glBegin(GL.GL_LINES);
// gl.glVertex2f(0.0f, 0.0f);
// gl.glVertex2f(width,height);
// gl.glEnd();
//
pgl.endGL();
}
}
import processing.core.*;
import javax.media.opengl.GL;
import processing.opengl.PGraphicsOpenGL;
public class ClassTest0 {
PApplet pa;
PGraphicsOpenGL pgl;
GL gl;
float x1,x2,y1,y2;
ClassTest0(PApplet pa){
this.pa=pa;
}
public void randd(){
x1=pa.random(0.0f,pa.width/2.0f);
y1=pa.random(0.0f,pa.height/2.0f);
x2=pa.random(pa.width/2.0f,pa.width);
y2=pa.random(pa.height/2.0f,pa.height);
}
public void draw(){
//gl=pgl.beginGL();
gl.glLineWidth(5.0f);
gl.glColor4f(0.1f, 0.5f, 0.5f, 0.1f);
gl.glBegin(GL.GL_LINES);
gl.glVertex2f(x1, y1);
gl.glVertex2f(x2,y2);
gl.glEnd();
//pgl.endGL();
}
}
Exception in thread "Animation Thread" java.lang.NullPointerException
at ClassTest0.draw(ClassTest0.java:28)
at Test0.draw(Test0.java:22)
at processing.core.PApplet.handleDraw(PApplet.java:1606)
at processing.core.PApplet.run(PApplet.java:1503)
at java.lang.Thread.run(Thread.java:680)