Professional Documents
Culture Documents
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;
import java.lang.Math;
import javax.swing.JFrame;
/**
*/
/**
*/
GL2 gl = gld.getGL().getGL2();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
/**
*/
GL2 gl = drawable.getGL().getGL2();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
int ldigitid = 3;
if (ldigitid % 2 == 1) {
X0 = -100;
Y0 = 100;
X1 = -100;
Y1 = -100;
gl.glBegin(GL2.GL_LINES);
gl.glVertex2d(100, 100);
gl.glVertex2d(100, -100);
gl.glVertex2d(-100, 0);
gl.glVertex2d(100, 0);
gl.glEnd();
} else {
gl.glBegin(GL2.GL_LINES);
gl.glVertex2d(100, 100);
gl.glVertex2d(-100, 100);
gl.glEnd();
X0 = 0;
Y0 = 100;
X1 = 0;
Y1 = -100;
public void DDA (GLAutoDrawable drawable, int X0, int Y0, int X1, int Y1) {
GL2 gl = drawable.getGL().getGL2();
int dx = X1 - X0;
int dy = Y1 - Y0;
int steps = 0;
if(abs(dx) > abs(dy)) {
steps = abs(dx);
else {
steps = abs(dy);
float X = X0;
float Y = Y0;
gl.glBegin(GL2.GL_POINTS);
gl.glVertex2d((float)X,(float)Y);
X += Xi;
Y += Yi;
gl.glEnd();
int height) {
}
// The canvas
glcanvas.addGLEventListener(b);
glcanvas.setSize(400, 400);
//creating frame
frame.add(glcanvas);
frame.setSize(640,480);
frame.setVisible(true);
}