JOGL ClassesIn this section, we will learn about the classes provided by JOGL. Through these classes, we can add the functionality of OpenGL in Java code. Following are the important classes provided by JOGL: - - GLCanvas Class
- GLJPanel Class
- GLProfile Class
- GLCapabilities Class
GLCanvas and GLJPanel class are GUI classes that implements GLAutoDrawable interface and utilized as drawing surfaces for Open GL commands.
GLCanvas Class- GLCanvas class is a heavy-weight AWT component present in javax.media.opengl.awt package.
- It extends the functionality of Canvas class and provides OpenGL rendering support.
- Being an AWT component, GLCanvas is much compatible with AWT in comparison to Swing.
- Due to hardware acceleration, it executes OpenGL operations rapidly.
GLCanvas ConstructorsConstructor | Description |
---|
GLCanvas() | It creates a new GLCanvas component with default set of OpenGL capabilities by using the mechanism of default OpenGL capabilities on the default screen device. | GLCanvas(GLCapabilities cap) | It creates a new GLCanvas component with requested set of OpenGL capabilities by using the mechanism of default OpenGL capabilities on the default screen device. |
GLCanvas MethodsMethod | Description |
---|
void addGLEventListener(GLEventListener listener) | It adds GLEventListener to this drawable. | void display() | It causes OpenGL rendering for GLAutoDrawable interface. | void removeGLEventListener(GLEventListener listener) | It removes GLEventListener to this drawable. |
GLJPanel Class- GLCanvas class is a light-weight Swing component present in javax.media.opengl.awt package.
- It extends JPanel interface and provide OpenGL rendering support.
- It uses hardware-accelerated rendering through pbuffers. As pbuffer cannot be resized, sometimes problem may occurs during resize operations.
GLCanvas ConstructorConstructor | Description |
---|
GLJPanel() | It creates a new GLJPanel component with default set of OpenGL capabilities by using the mechanism of default OpenGL capabilities on the default screen device. | GLJPanel (GLCapabilities cap) | It creates a new GLJPanel component with requested set of OpenGL capabilities by using the mechanism of default OpenGL capabilities on the default screen device. |
GLCanvas ConstructorMethod | Description |
---|
void addGLEventListener(GLEventListener listener) | It adds GLEventListener to this drawable. | void display() | It causes OpenGL rendering for GLAutoDrawable interface. | void removeGLEventListener(GLEventListener listener) | It removes GLEventListener to this drawable. |
GLProfile ClassThe OpenGL interfaces such as GL2, GL3, GL4 contains all the core method of a particular version. The role of GLProfile class is to specify the particular OpenGL interface on the basis of version required. GLProfile MethodsMethod | Description |
---|
GLProfile get(String profile) | It is used to return an object of GLProfile. | boolean isGL3() | It is used to indicate whether profile is capable of GL2 or not. | boolean isGL3() | It is used to indicate whether profile is capable of GL3 or not. |
GLCapibilities ClassGLCapibilities class is used to specify the capabilities of OpenGL such as OpenGL profile, color depth etc. The object of GLProfile class is passed as a parameter to this class. GLCapibilities MethodMethod | Description |
---|
GLProfilegetGLProfile() | It is used to return the required GLProfile. | booleanisStereo() | It is used to indicate whether stereo is enabled or disabled |
|