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”
glClear(GL_COLOR_BUFFER_BIT)
“Set Color”
glColor3f (1.0, 1.0, 1.0)
glBegin(GL_TRIANGLES);
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
glEnd();
glutSwapBuffers()

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

glutDisplayFunc(display)

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.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glBegin(GL.GL_TRIANGLES);
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
gl.glEnd();
// Flush all drawing operations to the graphics card
gl.glFlush();
}

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:

http://jerome.jouvie.free.fr/OpenGl/Tutorials1-5.php

(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 NetBeans.org page:

http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3260

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! :)

Comments:

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!
Thanks.

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?

Thanks.

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…

http://www.youtube.com/watch?v=tHcsaJVWmxU
http://www.youtube.com/watch?v=rOKvkLm0c3I

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(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:520)
at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131)
at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:90)
at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
at demos.vertexProgWarp.JOGLVertexBufferObjectDemo.main(JOGLVertexBufferObjectDemo.java:87)
Caused by: java.lang.ClassNotFoundException: com.sun.gluegen.runtime.DynamicLookupHelper
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 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 >= 1.29.2.8.2 (release version 1) but only 2.10.2.10.2 (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
About

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

Search

Categories
Archives
« Abril 2014
SegTerQuaQuiSexSábDom
 
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
    
       
Today