JOGL 3D Triangle - JOGL

What is JOGL 3D Triangle?

In earlier section we have seen how to draw 3d shapes, this section teaches you how to draw 3d triangle and rotate it.
Below given is the program to draw a 3d triangle an rotate it.

When you compile and execute the overhead program, the resulting output is made. At this time, you have the snapshots of rotating 3D triangle. Meanwhile this program does not contain depth test, the triangle is made hollow.
triangle_3d

To make the triangle solid, you need to enable depth test by using glEnable(GL_DEPTH_TEST). Enabling the depth buffer gives you a blank screen. This can be cleared by clearing the color using glClear(GL_COLOR_BUFFERBIT | GL_DEPTH_BUFFER_BIT) method. To enable depth test in the init() method or in the glDisplay() method, write the following code –

Below given is the Program to draw a 3D triangle with depth test.

When you compile and execute the above program, the resulting output is produced.

At this time, you can see the snapshots of a rotating 3D triangle. Meanwhile this program comprises code for depth test, the triangle is generated solid.

triangle_depth_test

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JOGL Topics