-
Notifications
You must be signed in to change notification settings - Fork 0
/
JOGL-3.java
61 lines (46 loc) · 1.79 KB
/
JOGL-3.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 javax.swing.JFrame;
public class Line implements GLEventListener{
static GLProfile profile = GLProfile.get(GLProfile.GL2);
static GLCapabilities capabilities = new GLCapabilities(profile);
// The canvas
static GLCanvas glcanvas = new GLCanvas(capabilities);
public static void main(String[] args) {
//getting the capabilities object of GL2 profile
Line l = new Line();
//creating frame
glcanvas.addGLEventListener(l);
glcanvas.setSize(700, 600);//resolution
final JFrame frame = new JFrame ("straight Line");
//adding canvas to frame
frame.getContentPane().add(glcanvas);
frame.setSize(frame.getContentPane().getPreferredSize());
frame.setVisible(true);
}
public void display(GLAutoDrawable drawable) {
final GL2 gl = drawable.getGL().getGL2();
gl.glPointSize(30);//SIZE OF THE DOTS
gl.glBegin (GL2.GL_POINTS);//static field (MAIN THINGS)
gl.glVertex2d(0.5f,0.5f);//f means floating
gl.glVertex2d(0.5f,-0.5f);//If there is no f then it is a double data type
gl.glVertex2d(-0.5f,0.5f);
gl.glVertex2d(-0.5f,-0.5f);
gl.glEnd();
}
public void dispose(GLAutoDrawable arg0) {
//method body
}
public void init(GLAutoDrawable drawable) {
// method body
//4. drive the display() in a loop
}
public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
// method body
}
//end of main
}//end of classimport javax.media.opengl.GL2;