Google News
logo
JOGL Interview Questions
JOGL is an open source wrapper library that allows us to use the functionality of OpenGL within Java program. Thus, it provides a platform where a programmer can quickly build and design computer graphic using java program.
OpenGL is a standard specification that provides cross-platform API to draw 2D and 3D graphics images.
The advantages of OpenGL over other API's are listed below :

* For drawing calls and state changes, OpenGL has lower CPU overhead than the other API's.
* There is more detailed documentation for OpenGL while other API's don't have such detailed documentation.
* OpenGL is more functional than any other API.
* OpenGL is portable.
* It is a cross-platform API, i.e. it can be used on various platforms such as- windows, WindowsMac, and some handheld devices.
* It is more extensible, i.e. new hardware features are exposed quickly.
* It has a stable interface until some bigger changes are made.
While rendering objects, OpenGL makes use of a sequence of steps and this sequence of steps is known as rendering pipeline. Firstly, the rendering pipeline prepares the vertex array data and then renders it. A vertex shader acts upon each data and then the processed is turned into an output vertex. Now, these outputs are shifted to different locations. Primitive assembly is made. Now, the scan conversion and primitive parameter interpolation generate a number of fragments. Now, the fragment shader processes each fragment and numbers of outputs are generated. Various tests are conducted in the per-sample processing and hence the final output is obtained.
In JOGL, JNI provides the platform through which java program can easily access the features of OpenGL.
Both GLEventListener and GLAutoDrawable interface is present in javax.media.opengl package.
The GLEventListener interface is used to provide the graphical functionality to Java program.
Following are the four methods of GLEventListener interface that are required to override :
 
* display(GLAutodrawable drawable)
* init(GLAutoDrawable drawable)
* void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
* void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)

The GLAutoDrawable interface provides an event-based mechanism to generate an image.
GLCanvas :
It is a heavy-weight component.
It is more compatible with AWT.

GLJPanel :
* It is a light-weight component.
* It is more compatible with Swing.
In vertex transformation, the vertices are transformed to their final clip space position in the vertex shader. The various major stages of vertex transformation are :
 
* Getting to the eye coordinates- the vertex provided to the GL is considered to be in the object space.
* Getting to clip coordinate- when the vertex is transformed by the projection matrix, then we get the clip matrix.
* Getting to normalized device coordinates- when each component is multiplied by 1/w, then we get the normalized device coordinates. It is mainly inside the clipping planes.
* Getting to window space- this is the final stage of the transformation pipeline. Everything out of the range is clipped away.
Drawing color pictures in a window on the screen is the main goal and application of OpenGL. Every calculation done in OpenGL is done to determine the final color of every pixel that is to be drawn in the window. We all know that light is composed of various photons and each photon travels along its own path and vibrates along its own frequency.

When certain cells in the retina of the human eye get excited after being struck by the photon, then it perceives color. This process is known as color perception. Similarly, if we talk about the computer screen, each pixel emits the different amount of red, green, and blue light on the screen. Since the color maps are controlled by the window system, so it becomes a bit difficult to do this with the help of OpenGL commands.
The GLCapabilities class is used to define the capabilities of OpenGL such as OpenGL profile, color depth, etc.
JOGL primitives are inbuilt parameters used to draw two-dimensional and three-dimensional graphics objects.
Following are the various types of primitives used by JOGL :
 
* GL_LIMES
* GL_LINES_STRIP
* GL_LINES_LOOP
* GL_TRIANGLE
* GL_TRIANGLE_FAN
* GL_TRIANGLE_STRIP
* GL_QUADS
* GL_QUAD_STRIP
* GL_POLYGON
The display() method used to draw and display graphics objects. Thus, it contains the primitive parameters with the methods containing the dimensions and all other attributes used to provide the special effect to an image such as coloring, scaling, rotating, etc.
In JOGL, an image can be diminished by using glScalef() method of GLMATRIXFUNC interface.
Animator class is a subclass of FPSAnimator class. It is used to rotate an object at the rate of frame per second.