Tag Archives: JOGL

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

JSR-231 passed the Final Approval Ballot stage. Did you know Quake 2 has been ported to Java using JOGL? Here’s the website. The JOAL sound appears to be working now, and the graphics are great!. Welcome JOGL gaming!

Author’s Note (very old and unlikely needed): If you experience an “Unable to lock surface” error when running the code samples in this book, try backing out the JOGL build you are using to an April 2004 1.1 release and that should clear up your issue.

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis Continue reading Table of Contents: Learning Java Bindings for OpenGL (JOGL)

Appendix D: The JARs, Sources and a Brick Texture – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Appendix D: The JARs, Sources and a Brick Texture

Where is here?

I’m assembling the source and pre-compiled classes and/or JARs here that I made for the book. Also at the bottom is
the texture I made for chapter nine. Feel free to use or modify this code, but remember it is provided on an “as is” basis.

Examples for chapter 1

ch1.zip has some very basic JOGL apps with source and classes. Also, the ‘read_me.txt’
file contains instructions for running the compiled classes. If you want
code to help you determine if JOGL is installed properly, look at the HelloWorld class and java source file.
(‘ch1.zip’ updated June 2007)

Examples for chapter 2

ch2.zip contains samples of using trig with JOGL. Both classes and source code are
included.
(‘ch2.zip’ updated June 2007)

Examples for chapter 3

ch3.zip contains several loose class files as well as the bouncing example and the dial
example code and classes.
(‘ch3.zip’ updated June 2007)

Continue reading Appendix D: The JARs, Sources and a Brick Texture – Learning Java Bindings for OpenGL (JOGL)

Appendix B: OpenGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

This list of links is no longer maintained, but may give a starting point for searching for JOGL resources. 

Appendix B: OpenGL Online Resources

Various Web Resources

These links are all to C or C++ tutorials on OpenGL, but if you squint really hard it will look just like Java. So don’t let any C like gibberish put you out.

OpenGL Home Page: The Industry’s Foundation for High Performance Graphics

http://www.opengl.org/

 

OpenGL Survival Kit Tutorial by Nicole Deflaux Terry

http://www.cs.tulane.edu/www/Terry/OpenGL/Introduction.html

 

“Game Tutorials: Game Programming with Personality, From Start to Finish”

http://www.gametutorials.com/Tutorials/OpenGL/OpenGL_Pg1.htm

Continue reading Appendix B: OpenGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

Appendix A: JOGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

This list of links is no longer maintained, but may give a starting point for searching for JOGL resources. 

Appendix A: JOGL Online Resources

Various Web Resources

The JOGL Project

https://jogl.dev.java.net/

 

JSR 231: Java™ Bindings for OpenGL®

http://jcp.org/en/jsr/detail?id=231

 

The JOGL Project Forum

http://192.18.37.44/forums/index.php?board=25.0

 

“Jogl – User’s Guide”

https://jogl.dev.java.net/nonav/source/browse/*checkout*/jogl/doc/userguide/index.html?rev=HEAD&content-type=text/html

Continue reading Appendix A: JOGL Online Resources – Learning Java Bindings for OpenGL (JOGL)

Chapter 3: Animations – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Chapter 3: Animations

Java Thread Review

Hopefully you’ve used threads before, but I’m going to give you a brief refresher course just in case it is dim in your memory. Threading in pretty much every language comes in two varieties.

One type of threading is to have a timer that acts like an alarm clock. You set it up to go off at some regular interval. In Java, this type of threading can be accomplished with the java.util.Timer class.

Here is a brief example of Timer’s use.

import java.util.*;

/**
 * This sample shows the creation of a Java
 * Timer object. Timers need a task and a
 * set time to wake up and do that task.
 */
public class TimerExample {

    public static void main (String args[]) {

        //our timer
        Timer alarm = new Timer();

        //our task (really a TimerTask object)
        TaskExample te = new TaskExample();

        //we schedule the Timer to wake up
        //and do 'te' ever 2000 milliseconds
        //(every two seconds)
        alarm.scheduleAtFixedRate(te, 0, 2000);
    }
}

Next we have the actual task to perform.

import java.util.*;

/**
 * Timers need a task to perform. Like we need
 * to go to school or work when our alarm
 * clock goes off, the program needs a task
 * to do when it is woken up.
 */
public class TaskExample extends TimerTask {
    /**
     * The task is placed in the run method
     * and performed whenever it is scheduled
     * to do something.
     */
    public void run(){
        System.out.println("Wake up!!!");
    }
}

The other type of thread is used to do something right away. It is created in Java by using the java.lang.Thread class.

Continue reading Chapter 3: Animations – Learning Java Bindings for OpenGL (JOGL)

Chapter 2: Using What We’ve Seen – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Chapter 2: Using What We’ve Seen

Coordinate Systems

There is no sense in waiting until you know the best way to do things before using OpenGL. Sure you’re going to find out a few months later that there was a better way to do this or that, but you’ll never get to that point if you don’t use what you’ve learned. We’re going to take that principle to heart and start off showing you that you’ve already learned a lot.

Coordinate systems may be something that you’ve banished to the darker regions of your memory along with memories of Junior High School. It’s time to dust off those memories.

Do you remember the Cartesian coordinate system? It consists of two perpendicular axes [lines]. One is the y axis and the other is the x axis.

Here is a typical coordinate system with a point mapped out on it.

ch2_coordinate_system

 

You’ll notice that there are numbers all over the place. Usually, they’re not all written out, but they’re always there. All points on the coordinate system correspond to distances along the y axis or along the x axis away from the origin. The origin is where the two axes meet. We’ve marked the origin with an O.

So we’ve indicated the position of one point on the graph. It is (6, 10). The 6 corresponds to 6 on the x axis away from the origin. The 10 indicates the point is 10 from the origin on the y axis.

Notice some positions are negative and some are positive. It would get confusing if 2 left of the origin looked like 2 right of the origin when we mapped out points. If there wasn’t any negatives how would we be able to tell where the point (1, 2) was? It could be in four different places, however if negatives are used (-1, 2) is very easy to spot. Can you find it?

If you’re lost at this point, your in trouble. Find a good introduction to geometry or introduction to graphs and functions book and plan on reading some of it. I’d recommend checking out a college book store, or maybe a big general book store. If money’s an issue, check out the internet for tutorials. There are plenty out there.

You can continue reading either way, but plan on spending time on learning about graphs.

During this chapter we will be using the coordinate system extensively. We will also cover drawing lines and the old Trig. standbys — Sine, Cosine and Tangent. Eventually in your pursuit of graphics and JOGL, you will want to become thoroughly familiar with these, but that is then and now is now. I’ll explain briefly anything that matters, and you can always use this book for reference.

Continue reading Chapter 2: Using What We’ve Seen – Learning Java Bindings for OpenGL (JOGL)

Chapter 1: Hello JOGL – Learning Java Bindings for OpenGL (JOGL)

This book and the excerpts on this blog are from 2004. Obviously, the API has changed a bit since then. I provide the older information and book in the hope that it will be useful to some hobbyists.

Purchase Printed Book Learning Java Bindings for OpenGL (JOGL)

 

Table of Contents: Learning Java Bindings for OpenGL (JOGL)

This book describes JOGL which was approved as JSR 231 and will become the javax.media.opengl package.

-T. Gene Davis

 

 

copyright 2004 by Gene Davis of genedavissoftware.com

Chapter 1: Hello JOGL

First There Was OpenGL

For some years now, a programmer that wanted to create a graphics intensive program that could be sold to users of different Operating Systems had one choice — OpenGL. The GL stands for Graphics Library. OpenGL is a registered trademark of SGI. OpenGL manifests itself as a cross platform C programming API. In reality though, it is a hardware-independent specification for a programming interface.

Most of the reasons that people have given me over the years for the lack of a future for Java especially in the gaming industry was that you can’t use OpenGL in Java. They rightly pointed out that the fastest 2D and 3D applications use OpenGL.

OpenGL is for making graphics. It is fast. Most of the time it is hardware accelerated. It seems that OpenGL can do anything visually that you would want to do.

Unfortunately OpenGL is written for C. Let’s face it, C is not the most popular language for programming complex applications. One of the biggest drawbacks to OpenGL is that you can’t make it do anything without a window to put your graphics in, but OpenGL doesn’t provide a means for you to create windows. This makes OpenGL hard to learn for beginners.

Luckily GLUT was introduced and made dealling with windows, buttons and events generated by users easier to add to OpenGL heavy applications. Still learning OpenGL in C or even C++ can be painful for new programmers or programmers that want to use true Object Oriented Programming.

Continue reading Chapter 1: Hello JOGL – Learning Java Bindings for OpenGL (JOGL)