Developing OpenGL with NetBeans 6.0.1

Last semester I did a subject on my university where I needed to do a project with OpenGL. Our professor asked us to program a 3D graphic modeler – a program capable of drawing 3D figures, set material properties and scale, move, rotate, group and copy them. We could not use high level libraries like Java3D, he wanted us to program OpenGL, only that. Things got complicated, but NetBeans made my life easier... again!

A OpenGL code may became quite complicated if you do not take care. There are too many settings, many variables, matrices, transformations... and a little detail can turn things horrible if you don't know what you are doing. On this point, working with a great IDE may help you a lot!

Another fact is that I liked the way of programming openGL with JAVA.
On the most other programming languages, you should use callback functions to do things on openGL, for example: you may create a function display() that will draw things on the screen, in python:

def display():
“Draw a triangle”
“Set Color”
glColor3f (1.0, 1.0, 1.0)
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glVertex3f(1.0, -1.0, 0.0);
// Finished Drawing The Triangle

but then, you should say to openGL that display() is the one taking care of screen drawings, saying:


In JAVA there is no callback function, it's just Programming to an Interface style! It's really cool and make your code more comprehensive. My openGL project become more understandable having a Sphere class that extends Shape class and implements Drawable interface (you know, my sphere is actually a drawable shape!)! The openGL functions like display(), init(), reshape() can all be coded inside a class that implements the interface GLEventListener, just that... make more sense to me! In Java:

//Draw a triangle
public void display(GLAutoDrawable drawable)
GL gl = drawable.getGL();
// Clear the drawing area
gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top
gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
// Finished Drawing The Triangle
// Flush all drawing operations to the graphics card

This post is not about teaching OpenGL, it's just too complicated for a single post. But you may find your way through NetBeans6.0 OpenGl plugin and the following tutorial:

(and you may want to check the OpenGL red book too)

BUT LET'S START THIS GUIDE about turning JavaOpenGL ON at NetBeans6.0.1 and HAVE FUN!

The first step is to download the the cool JOGL plugin from page:

The file downloaded from above is zipped, unzip all the nbm files (that are inside the zip) on a directory.

Note: This plugin is really nice: check it's features list:
\* Editor for the OpenGL Shading Language (GLSL) with compiler error annotation, code folding, syntax highlighting, auto completion and documentation.
\* Easy access to the GLSL compiler and linker of your graphics driver integrated in the editor
\* OpenGL Capabilities Viewer
\* Integration of JOGL GUI components into the Matisse GUI builder
\* JOGL project templates
\* Ready to run JOGL demos and examples of the OpenGL Programming Guide (also known as Red Book)

Ready to use it? Let's install it!
Open you NetBeans IDE. Go to Tools > Plugins

On the window, go to "Downloaded" tab (it may be empty). Press the "Add Plugins..." button. Go to the directory you unzipped the plugin's nbm files, select ALL of them and press OK. The plugin items will appear on the list on the left just like the picture above. Leave all of them selected and press Install button.

You will go through some installation steps; accept the terms of agreement and press Install. The installer may alert you that the plugin is not signed (or something like that), just ask to install it anyway. In the end, you will need to restart your IDE.

Done. The JOGL plugin is installed. After NetBeans restart, you can go through File > New Project and see the OpenGL project option on Categories list.

The Simple JOGL Application is the perfect place to start doing your openGL project, it's an almost empty openGL application that you may increase.

You may have a look at the Demos too (to have an idea about what you can do with OpenGL and JOGL). This plugin cames with many JOGL demos and Red Book demos. So, if you are studing OpenGL using the Red Book, you will find the examples there. You just need to expand OpenGL categories on the New Project window to see the Demos folders:

JOGL Infinite Shadow Volumes Demo:

A very interesting point of the plugin is that it does integrate the OpenGL Panel and OpenGL Canvas to the Matisse system, so you can create your GUI using Matisse and put OpenGL elements on it.

Developing GUI on NetBeans is incredibly easy, and now you can include OpenGL elements on your projects! Quite nice!

Thats all! Hope you enjoy developing OpenGL on NetBeans6.0.1

Cheers! :)


Parabéns Jonas pela reportagem.... legal. Mas estou com mta dúvida no compilador, a gde maioria do pessoal da facu... utiliza o Windows... e não consigo fazer funcionar o cygwin, se vc puder me ajudar... legal...gostei mto...parabéns novamente

Posted by Ricardo Liyushiro Chikasawa on Março 28, 2008 at 09:16 AM BRT #

Nice tutorial, I was looking for some help with netbeans+opengl+java, and it seems I found the right one.

Keep up the good work

Posted by Michael on Julho 09, 2008 at 12:12 PM BRT #

This is great!
I was looking just for it!

Posted by Fernanda Castelo on Outubro 31, 2008 at 06:31 AM BRST #

Hi! I have just started learning OpenGL but the book i am referring is using C++, is there a way to program OpenGL with C++ in NetBeans or do i have to use Java instead?


Posted by Ayesha on Abril 29, 2009 at 09:11 AM BRT #

Hola a todos muy buen tutorial amigo pero bueno aqui hay 2 video de JOGL con NetBeans espero les sirva
para empezar con java y opengl…

Posted by dgh on Maio 17, 2009 at 05:08 PM BRT #

It's very very very very good! =DDD

Posted by Nathalia on Outubro 28, 2009 at 07:06 PM BRST #

Thank you for a very nice tutorial

Posted by Nick on Dezembro 30, 2009 at 07:42 AM BRST #

Ja fiz instalacao do JOGL plugin, mas ao executar os projectos exemplos, recibo um run-time error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/gluegen/runtime/DynamicLookupHelper
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(
at java.lang.ClassLoader.defineClass(
at Method)
at sun.misc.Launcher$ExtClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(
at java.lang.ClassLoader.defineClass(
at Method)
at sun.misc.Launcher$ExtClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at demos.vertexProgWarp.JOGLVertexBufferObjectDemo.main(
Caused by: java.lang.ClassNotFoundException: com.sun.gluegen.runtime.DynamicLookupHelper
at Method)
at sun.misc.Launcher$ExtClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 32 more
Java Result: 1

Tem ideia porqueo?

Posted by Daniel Davis on Março 01, 2010 at 07:58 AM BRT #

thanks a lot!

Posted by Shabab on Maio 31, 2010 at 08:06 AM BRT #

Got OpenGL running in netbeans. Cheers

Posted by Daedana on Novembro 26, 2010 at 04:20 PM BRST #

i want to know how to call display again and agian in jogl any calback function actually i am making game so to have animation in game i chage coordinates of the objects but then they are not redrawn on new coordinates.thanks

Posted by shahid farooq on Janeiro 09, 2011 at 12:05 AM BRST #

hi, nice tutorial, but i have a problem when installing GLSL editor. The other plugins installed well. I currently have netbeans 6.9.1
The plugin error is:

The plugin Editor Library is requested in version >= (release version 1) but only (of release version different from 1) was found.

Any help please?

Posted by Kurt Portelli on Fevereiro 17, 2011 at 05:24 AM BRST #

Post a Comment:
  • HTML Syntax: NOT allowed

Well... Let's keep this blog updated for now on!!


« Julho 2016