* Remember, the MouseListener does not be added (it is already added Public class Tutorial1 extends GLAnimCanvas implements KeyListener, MouseMotionListener This two objects will be used for the initialisation, drawing. Glu (GLUFunc) : provides access to OpenGl utility library routine. Gl (GLFunc) : provides access to OpenGl functionality and graphics card extension. To have access to the OpenGl methods, we mainly use two objects of the GLAnimCanvas instance :
In which we will add the drawing code for the OpenGl scene. Method : this method is the drawing loop (loop for animation). You can put in it the initialisation of your data like importing texture, initialise OpenGl properties. The init method : this method initialise all you need. This method will be explicated in more details in the Lesson 1 & Lesson 2. These two properties are relative to how the scene is drawn into the screen. This method defines the Viewport and the Viewing Volume. The reshape method : called at each resizeĮvent (generally when the frame is resized). There are 3 importants methods to declare : reshape, init and display. This scene will just clear the background to black. Now the container is created, we will create our basic OpenGl scene. * Create our OpenGl scene and add it in the applet creates a layout to add our scene in the center an fit to the Applet Public class AppletContainer extends JApplet This can be done with this similar code : We can also load an OpenGl scene in an Applet (JApplet here). GetContentPane().add(glScene, BorderLayout.CENTER)
GlScene = new Tutorial1(getSize().width, getSize().height) * Creates our scene and add it in the frame SetLocationRelativeTo(null) //position the frame in the screen center GetContentPane().setLayout(new BorderLayout()) Public class FrameContainer extends JFrame The OpenGl animation is starten with the call start. Tutorial1 class is an instance of GLAnimCanvs, it can be added into our frame. This class extends (more precisely extends įirst, we have to create a frame, I used to use swing components, so let start with a JFrame This tutorial is composed of two classes : one for loading the frame (or an applet), the other for the OpenGl scene.Īn animated OpenGl scene can be created in a GLAnimCanvas component By learning OpenGL and looking at the following tutorials, it should be In the Tutorial 3, I will introduce a more complicated base code but I encouraged you to use thisįor people new in OpenGl, this could be hard to understand all of the code by the first reading. This is the base code for an OpenGl animated scene.
This first program load a frame with an empty OpenGl scene (ie black screen). home/java/j2sdk1.4.2_04/jre/lib/i386 //Linuxįor people who have difficulties to find gl4java => Go Now, Gl4java site ( is CLOSED, older version can be obtained at :Ĭ:\Java\jdk1.5.0_05\jre\lib\ext //Windows Gl4java development has been stopped since a lot of time. GL4JavaJauGljJNI14.dll GL4JavaJauGljJNI14.so The archives downloaded must contain these jar :Īnd these libraries (Windows): or for Linux :
Go to Gl4java page at and download Gl4java. You need to reboot your machine to takes this in account.Ĭopy these command line on a terminal (console) : If PATH already exist, add at the the begining ( is a path separator) :Ĭ:\Java\jdk1.5.0_05\bin C:\Java\jdk1.5.0_05\jre\bin His value is something like that (depends on your installation folder) :Ĭ:\Java\jdk1.5.0_05\bin C:\Java\jdk1.5.0_05\jre\bin In the Advanced tab, click on the Environment variable button.Ĭreate a new environment variable named PATH. "work station" or something like that in English). Go to the System Properties (properties of "Poste de Travail", Which folder he should search Java utilities like java, javac. This environment variable is used by your system to know where Java is installed and to know in (My installation is here : C:\Java\jdk1.5.0_05) Run the installation and add the environment variable PATH :
Install Java 1.5 (also known as 5.0) or later. Site and download the Java SDK (Software Development Kit). I use and modify the basic OpenGl loader created by Jeff Kirby and Darren Hodges and updated by Ron Sullivan.įirst, you have to install Java. Next tutorial and use the JOGL-JSR231 OpenGl API.
This tutorial will show you how to install Gl4java in your Java environment.Īfter this, I will explain you how to create an empty OpenGl scene in a Java application.