JavaGaming.org

July 30, 2010, 09:43:01 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
Advanced search  
Pages: 1 [2] 3 4   Go Down
Print
Author Topic: How to: Getting started with JOGL  (Read 94103 times)
0 Members and 2 Guests are viewing this topic.
nnevatie
Full Member
***
Offline Offline

Posts: 149


It is slightly better to be simple than correct.


View Profile WWW
« Reply #30 on: September 28, 2004, 03:40:10 am »

Quote

Damn it, isn't there a way to set the java.library.path without messing with windows environment variables ?


Actually, there is Smiley.

java -Djava.library.path=path/to/libraries mypackage.MyClass

Cheers
« Last Edit: September 28, 2004, 03:40:39 am by nnevatie » Logged

Awards:
- Nobel Prize in Physics for inventing his Doomsday Machine
- Nobel Peace Prize for not using it

http://www.g0dmode.com -- a collection of things not real
zingbat
JGO Ninja
*****
Offline Offline

Posts: 671


Java games rock!


View Profile
« Reply #31 on: September 28, 2004, 03:48:31 am »

Quote

Actually, there is Smiley.
java -Djava.library.path=path/to/libraries mypackage.MyClass
Cheers


Quote

At first i was trying to use -Djava.library.path=..\libs but it doesn't work.


It doesn't change anything. I assume the property is read-only.
Logged
nnevatie
Full Member
***
Offline Offline

Posts: 149


It is slightly better to be simple than correct.


View Profile WWW
« Reply #32 on: September 28, 2004, 04:52:12 am »

Quote

It doesn't change anything. I assume the property is read-only.


I don't quite follow.. Read-only, as in it cannot be set from Java code? What are you trying to accomplish? How would you like to alter the library path?
Logged

Awards:
- Nobel Prize in Physics for inventing his Doomsday Machine
- Nobel Peace Prize for not using it

http://www.g0dmode.com -- a collection of things not real
zingbat
JGO Ninja
*****
Offline Offline

Posts: 671


Java games rock!


View Profile
« Reply #33 on: September 29, 2004, 07:55:26 am »

OK never mind. There was a bug in my dos batch file.  Grin

It should have been:

@echo off
set CLASSPATH=.;..\libs\jogl.jar;..\libs\joal.jar
set LIBPATH=..\libs
set CMDARGS=-cp %CLASSPATH% -Djava.library.path=%LIBPATH% -server
java  Grin %CMDARGS% Grin  %1 %2 %3 %4 %5 %6 %7 %8 %9

« Last Edit: September 29, 2004, 07:56:16 am by zingbat » Logged
friism
JGO n00b
*
Offline Offline

Posts: 1


Java games rock!


View Profile
« Reply #34 on: September 29, 2004, 01:10:32 pm »

Hi

The 2004 releases doesn't seem to include jogl.so files... Are they needed for running applications, and if so, where do I get one?
Logged
denatus
JGO n00b
*
Offline Offline

Gender: Male
Posts: 1


Java games rock!


View Profile WWW
« Reply #35 on: November 04, 2004, 06:34:48 am »

Hello, I just installed jogl on gentoo linux.
I documented it on my wiki page. Feel free to check it out.
http://wiki.denatus.org/moin.cgi/Documentation/Tips
« Last Edit: November 04, 2004, 06:35:52 am by denatus » Logged

Nothing much!
Rokky
JGO n00b
*
Offline Offline

Posts: 1


Java games rock!


View Profile
« Reply #36 on: December 18, 2004, 03:52:11 am »

Hi all!
Can you help to novice in Jogl?
I was trying to compile end run such code:


import net.java.games.jogl.*;
import java.awt.*;

public class StartApp {
 public static void main (String args[]) {
   try {
       Frame window = new Frame("Jogl Demo 1");
       GLCapabilities capab = new GLCapabilities();
       GLCanvas context = GLDrawableFactory.getFactory().createGLCanvas(capab);
       window.add(context);
       window.setSize(300, 300);
       window.addWindowListener(new java.awt.event.WindowAdapter()
       {
               public void windowClosing(java.awt.event.WindowEvent e)
               {
               System.exit(0);
               }
       });
       window.setVisible(true);

   } catch (Exception e) {
     System.out.println(e);
   }
 }
}

and get an error:

java.lang.UnsatisfiedLinkError: CreateDummyWindow
       at net.java.games.jogl.impl.windows.WGL.CreateDummyWindow(Native Method)
       at net.java.games.jogl.impl.windows.WindowsGLContextFactory$NativeWindowThread.run(WindowsGLContextFactory.java:266)

Please tell me what is wrong?
I had installed Jogl exactly as described in tutorials, JDK 1.4.2, WinXP, NetBeans 3.6.
So what's wrong?
Logged
turquoise3232
Sr. Member
****
Offline Offline

Posts: 332

Java (games) rock!


View Profile
« Reply #37 on: December 18, 2004, 11:11:04 am »

Hi, this thread is certainly not the good one to ask this question but...
I think you need to add the .dll (or .so) file to your java.library.path, which can be done in some "expert" tab of Netbeans 3.6 execution properties.
Logged
branco
JGO n00b
*
Offline Offline

Posts: 1


Java games rock!


View Profile
« Reply #38 on: March 22, 2005, 09:47:15 am »

Im using linux
Whatś the problem? and the solution for this error???

Exception in thread "Thread-1" net.java.games.jogl.GLException: java.lang.reflect.InvocationTargetException
     at net.java.games.jogl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:225)
     at net.java.games.jogl.GLCanvas.display(GLCanvas.java:75)
     at net.java.games.jogl.Animator$1.run(Animator.java:107)
     at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.reflect.InvocationTargetException
     at java.awt.EventQueue.invokeAndWait(EventQueue.java:851)
     at net.java.games.jogl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:220)
     ... 3 more
Caused by: net.java.games.jogl.GLException: Error making context current
     at net.java.games.jogl.impl.x11.X11GLContext.makeCurrent(X11GLContext.java:173)
     at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:111)
     at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:246)
     at net.java.games.jogl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:258)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Logged
immano
JGO n00b
*
Offline Offline

Posts: 14


Java games rock!


View Profile
« Reply #39 on: March 30, 2005, 09:52:27 am »

Greetings. As a novice to OpenGL, I humbly come with a bit of confusion in my mind.

The example worked pretty well. Then I went to NeHe's tutorial and I thought I'd include bits of that in this example, and sure enough, coloured triangles and quads were soon spinning on my window. But not everything went ok.

The three points of this post:

1) The usual proportion for windows is 4:3 and so is the one proposed in this example, at 512x384. But that  kind of flattens the proportions of the objects, so how does one decouple the dimensions of the window from the ones of the drawing space?

2)NeHe uses a glTranslatef(float,float,float) line to translate (duh) stuff on the drawing space, but if I can't seem to make it work for the Z axis. Take the example in this thread exactly as it is and put a gl.glTranslatef(x,y,z) line before the glcolor. Changes to x and y will show up, but changes to z will be erratic. Between -1.0 and 1.0, it won't change at all, and any other value will make the triangle disappear. Is this something that requires more than the simple inits performed in this example, or is it something jogl-related?

(ok, I had forgotten the 3rd point)

3) Have the GL-types been implemented in jogl, or should one use standard java types?

Thanks for your time in advance.

Immano
« Last Edit: March 30, 2005, 09:54:03 am by immano » Logged
quintesse
Full Member
***
Offline Offline

Posts: 124


Java games rock!


View Profile
« Reply #40 on: April 04, 2005, 05:26:42 am »

1) I think putting this code in the reshape() will do what you want:

Code:

     public void reshape(GLDrawable gLDrawable, int x, int y, int width, int height) {
           final GL gl = gLDrawable.getGL();
           final GLU glu = gLDrawable.getGLU();

           if (height <= 0) // avoid a divide by zero error!
                 height = 1;
           final float h = (float)width / (float)height;
           gl.glViewport(0, 0, width, height);
           gl.glMatrixMode(GL.GL_PROJECTION);
           gl.glLoadIdentity();
           glu.gluPerspective(45.0f, h, 1.0, 20.0);
           gl.glMatrixMode(GL.GL_MODELVIEW);
           gl.glLoadIdentity();
     }



2) The example code in this thread is extremely simple and it seems though no perspective rendering has been set up, so it could be (I didn't check so I'm not sure at all) that   it defaults to orthogonal rendering. That way you would see no depth and therefore no difference when moving the object along the z-axes until it hits either the near or far clipping planes.


3) Just normal Java types as far as my experience goes (which isn't that much).
Logged
CodeDog
JGO n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #41 on: June 12, 2005, 11:22:14 pm »

I have been doing OpenGL in C++ for some time now and when I saw this site I thought about how cool it would be to make 3D applets, however I ran in to some issues.
I got it to work by putting the DLLs in the bin directory for my java run time, however it only works inside my IDE. When I make an applet and try and view it in a browser it has an error loading.
How can I make an applet with JOGL that I can put on a web page that will run seamlessly with no special installation knowledge necessary by the visitor?
Logged
Ken Russell
Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 3442


Java games rock!


View Profile
« Reply #42 on: June 13, 2005, 09:56:05 am »

The best way that I've found to deploy cross-platform programs using JOGL is as applications launched with Java Web Start. See for example the jogl-demos web page. I don't have a lot of experience writing applets but I think that in order to make JOGL work in an applet it is necessary to write some kind of signed installer that will drop the dlls into the right place in the user's JRE. Java Web Start takes care of all of this automatically and doesn't require you to sign your application, since we sign the JOGL jars. For followups to this topic, please start a new thread.

Logged
ASL
JGO n00b
*
Offline Offline

Posts: 25


View Profile
« Reply #43 on: June 13, 2005, 03:24:57 pm »

Gregory wrote: "At this point you might want to take a look at some OpenGL resources as it won't matter whether or not you're coding in C++ or Java as OpenGL is OpenGL and it will be simple to tell what needs to be syntactically changed to work with JOGL (or LWJGL for that matter)."

I have been looking around but its a jungle... Could some one please guide as to where I should begin? I have done the tutorial on http://www.genedavissoftware.com/books/jogl/index.html and I understand it all... I just dont know where to go from here

I have no 3D experience - but its 3D I want to learn! basics first.....  Where do I begin???
Logged
Ken Russell
Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 3442


Java games rock!


View Profile
« Reply #44 on: June 13, 2005, 04:56:47 pm »

You should probably get an introductory computer graphics textbook. I was taught from Foley and Van Dam's _Computer Graphics: Principles and Practice_. The OpenGL "red book" is also a good introduction to using OpenGL for most common operations. Reviewing trigonometry and some linear algebra for matrix and vector manipulation is helpful. I found the most difficult thing about 3D was understanding frames of reference, but once you have an intuition about how  transforms work you should be able to get new projects working quickly.
Logged
tonywang
JGO n00b
*
Offline Offline

Posts: 2


View Profile
« Reply #45 on: September 22, 2005, 06:08:49 am »

It is a simple example, and I want to say thank you  and that it maks me clear.


I am Chinese student , studied in USCT(University of Science&Technology Of China).Now ,I am working in Artificial Intelligence And Calculator Application Study Room,USTC.Now, I am study the implementation of 3d turning of the Arifiical Phisical Experiment  with jogl.Beleive ,I hava many chances to interchange ideas with you, and I am preparing for GRE and TOFEL.Maybe we can have a meet in some time later.

This is my MSN :tonywang@mail.ustc.edu.cn
 
Associate with me ,and help me to promote my level ,thank you. Wink
Logged
clivethebadger
JGO n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #46 on: November 01, 2005, 04:34:47 am »

Argh I'm going insane, what should be completely simply totally eludes me ~.~

I am on Windows XP and use TextPad to write my java code.
I have jogl.jar and the .dll's in C:\jogl\
I have added C:\jogl\jogl.jar to CLASSPATH
When i do System.out.println(System.getProperty("java.library.path")); C:\jogl\ is listed (so I assume that Java can find it)
But I cannot compile anything because it won't let me do - import net.java.games.jogl.*;
I just get
"C:\jogl\JOGL2DBasics.java:6: package net.java.games.jogl does not exist
import net.java.games.jogl.*;"

Please please please could somebody help, I just don't know what I'm doing wrong!
Thanks
Logged
Pegasus
JGO n00b
*
Offline Offline

Posts: 8


View Profile
« Reply #47 on: November 15, 2005, 04:28:53 pm »

May you update the tutorial to the jogl jsr-231 standard?
Thanks!
Logged
egcjava
JGO n00b
*
Offline Offline

Posts: 6


View Profile
« Reply #48 on: November 27, 2005, 06:37:03 pm »

Thanks for the info about getting started.  I have ran into a bit of trouble and could use some help getting around it.  My problem is that when I tried to download the jogl jar etc and import it into Eclipse I kept getting stuck and have not found a clue on my own as to what I am doing wrong.  I tried to do as the java download page suggested and instead the java download manager software and do it that way but for some reason i had no success either.  i guess i need a bit of hand holding.  if someone could post the steps to download the jogl jar and get it correctly imported into Eclipse i would appreciate it.
thanks
edward
Logged
skytomorrownow
Jr. Member
**
Offline Offline

Posts: 68


View Profile
« Reply #49 on: December 07, 2005, 10:07:44 am »

"C:\jogl\JOGL2DBasics.java:6: package net.java.games.jogl does not exist
import net.java.games.jogl.*;"

try javax.media.opengl.*;
Logged
inacioferrarini
JGO n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #50 on: December 10, 2005, 03:56:24 pm »

Test.java

Code:
import net.java.games.jogl.*;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Test
{
    public static void main( String[] args )
    {
        try
        {
            Frame testFrame = new Frame("TestFrame");
            testFrame.setSize( 512, 384 );

            GLCapabilities glCaps = new GLCapabilities();
            glCaps.setRedBits(8);
            glCaps.setBlueBits(8);
            glCaps.setGreenBits(8);
            glCaps.setAlphaBits(8);

            GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas( glCaps );

            testFrame.add( canvas );

            canvas.addGLEventListener(new TestRenderer());

            final Animator animator = new Animator( canvas);
            testFrame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                  animator.stop();
                  System.exit(0);
                }
              });
            testFrame.show();
            animator.start();
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
    }
}

TestRenderer.java

Code:
import net.java.games.jogl.GLEventListener;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLDrawable;
import net.java.games.jogl.DebugGL;


public class TestRenderer implements GLEventListener
{
    private GL              gl;
    private GLDrawable      glDrawable;

    public void init(GLDrawable drawable)
    {
        this.gl = drawable.getGL();
        this.glDrawable = drawable;

        drawable.setGL( new DebugGL(drawable.getGL() ));

        System.out.println("Init GL is " + gl.getClass().getName());
    }

    public void display(GLDrawable drawable)
    {
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
        gl.glLoadIdentity();

        gl.glColor3f(1.0f, 0.0f, 0.0f );

        gl.glBegin( GL.GL_TRIANGLES );
            gl.glVertex3f( 0.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 0.0f, 0.0f );
            gl.glVertex3f( 1.0f, 1.0f, 0.0f );
        gl.glEnd();
    }

    public void reshape(GLDrawable drawable, int x, int y, int width, int height)
    {
    }

    public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
    {
    }

}

Hi there,
sorry for the huge post.

This code works perfectly, but, if I change the block
Code:
       gl.glBegin( GL.GL_TRIANGLES );
           gl.glVertex3f( 0.0f, 0.0f, 0.0f );
           gl.glVertex3f( 1.0f, 0.0f, 0.0f );
           gl.glVertex3f( 1.0f, 1.0f, 0.0f );
       gl.glEnd();
for
Code:
gl.glBegin( gl.GL_QUADS );
gl.glVertex2i(100, 150);
gl.glVertex2i(100, 100);
gl.glColor3f(0.0f, 0.0f, 1.0f);
gl.glVertex2i(150, 100);
gl.glVertex2i(150, 150);
gl.glEnd();
it just doen´t do nothing ... (nothing but a black screen)
The only thing that changed was the fact that it is no longer a GL_TRIANGLE and it is glVertex2i instead of glVertex3f.
I am a newbie on OpenGL, so I would think it is wierd if I missed something on the rest of the code ...

Thanks for your attention and time,

Have a nice day,

 - Inácio Ferrarini.
Logged
zingbat
JGO Ninja
*****
Offline Offline

Posts: 671


Java games rock!


View Profile
« Reply #51 on: December 20, 2005, 10:43:59 am »

Here's some help for you:

http://www.opengl.org/documentation/red_book_1.0/

Im not giving you the straight answer because it's very easy to find it in the book above.
Logged
oravecz
JGO n00b
*
Offline Offline

Posts: 4


View Profile
« Reply #52 on: January 15, 2006, 10:07:01 am »

May you update the tutorial to the jogl jsr-231 standard?
Thanks!

I've used JOGL for about an hour, and I have no experience with OpenGL  so some of the changes I made may be totally screwy. Please take them with a grain of salt, or better yet, post an improvement. I've attempted to bring Gregory Pierce's original example up to date with the JSR-231 release of JOGL as Pegasus requested.

Gregory  (back in July 2003) used a factory to get the GLCanvas. I am using the latest release (JSR-231 beta 02 build) and these methods no longer exist. In addition, the demos that are distributed with this release use a simple default constructor call to instantiate a GLCanvas object. So I did that also.

The original code also stored the GL object in an instance variable. According to the JOGL User's Guide this isn't recommended because of potential threading conflicts. I realize that the initial code example won't have any multithreading issues, but it is a simple change that may help noobies use best practices from the start. Here's the snippet from the user's guide:

Quote
It is strongly recommended that applications always refetch the GL object out of the GLAutoDrawable upon each call to the init(), display() and reshape() methods and pass the GL object down on the stack to any drawing routines, as opposed to storing the GL in a field and referencing it from there. The reason is that multithreading issues inherent to the AWT toolkit make it difficult to reason about which threads certain operations are occurring on, and if the GL object is stored in a field it is unfortunately too easy to accidentally make OpenGL calls from a thread that does not have a current context. This will usually cause the application to crash.

Here is the revised code. Copy it into a file named Trangle.java.

Code:
import java.awt.*;
import java.awt.event.*;
import java.util.logging.*;
import javax.media.opengl.*;

import com.sun.opengl.utils.Animator;

public class Triangle implements GLEventListener {

// Statics -----------------------------------------------------------------

private final Logger LOG = Logger.getLogger(Triangle.class.getName());

public static void main(String[] args) {
Frame frame = new Frame("Triangle Demo");

GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new Triangle());

frame.add(canvas);
frame.setSize(512, 512);

final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
new Thread(new Runnable() {
public void run() {
animator.stop();
System.exit(0);
}
}).start();
}
});
frame.setVisible(true);
animator.start();
}

// Constructors ------------------------------------------------------------

public Triangle() {
}

// GLEventListener ---------------------------------------------------------

public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
if (LOG.isLoggable(Level.FINE))
LOG.fine("Init GL is " + gl.getClass().getName());
}

public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glColor3f(1F, 0F, 0F);

gl.glBegin(GL.GL_TRIANGLES);

gl.glVertex3f(0.0F, 0.0F, 0.0F);
gl.glVertex3f(1.0F, 0.0F, 0.0F);
gl.glVertex3f(1.0F, 1.0F, 0.0F);

gl.glEnd();
}

public void reshape(GLAutoDrawable drawable, int i, int i1, int i2, int i3) {
}

public void displayChanged(GLAutoDrawable drawable, boolean b, boolean b1) {
}
}

Some people were experiencing difficulties getting the code compiled or running. I downloaded the latest version of JOGL which was JSR-231 beta 02 build at the time I wrote this. Download jogj.jar to your local system.

Also, download the native library that is specific to your runtime environment. I'm using Windows, so I downloaded jogl-natives-win32.jar. This jar file contains DLL's that the Java Runtime environment must be able to load. I'm not sure why they are distributed as a jar file since that typically implies that the archive should remain compressed, however in our case, we want to expand the DLLs from within this archive. As far as I know, Java cannot load library files (DLLs in this case) from inside an archive. Use Java's jar utility to expand the contents of the native archive into a directory somewhere. You can also use any tool that can extract files from a ZIP archive. I ended up extracting 3 DLL files from the archive and put them in a local directory.

At this point, you have the jogl.jar (mine is in c:\jogl) and some native files in a directory (mine are in c:\jogl\native). You also should have the source code example in a file called Triangle.java (mine is in c:\jogl\examples\Triangle.java). To compile the source code from the command line (again in Windows). I'm in the c:\jogl\examples directory when I execute this:
Code:
javac -classpath c:\jogl\jogl.jar Triangle.java

When the compile finishes, there are 3 class files in the directory now. The main class is Triangle.class, and the other two classes are inner classes. If you followed Gregory Pierce's original suggestion and placed you native files in your Java environment's extension directory you can simply run the application using the following:
Code:
java -classpath c:\jogl\jogl.jar ;. Triangle

Usually, three things happen at this point. The app runs, hurrah. Or, the app fails with a "Exception in thread "main" java.lang.NoClassDefFoundError: Triangle" message. Or the application fails with a "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path" error.

If the app ran fine the first time, congratulations. You have caught up with me and we are both about to wade waist deep into the exciting and sometimes scary world of 3D development.

If you received the "Exception in thread "main" java.lang.NoClassDefFoundError: Triangle" error, fear not. You probably didn't notice the ";." I added on to the classpath attribute. In order for the Java runtime to discover the Triangle.class file, we have to add the directory this file resides in to the classpath. On Linux and Mac machines, the directories on the classpath are separated with a colon ":" instead of a semi-colon ";".

If you received the "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path" error, it indicates that the Java runtime was not able to find the native files that JOGL required. It also means that you didn't copy these files into your Java environment's extension directory. I don't usually do that either. I like to explicitly reference native libraries instead of the system finding them by magic. It especially helps to be explicit when you have multiple versions of native libraries in use like you might as the JOGL libraries evolve over time.

The Java runtime looks for the native files in the directories specified by the system property named "java.libary.path". This system library path can be set in many ways, but the easiest is on the command line as you execute the program:
Code:
\java -Djava.library.path=c:\jogl\native -classpath c:\jogl\jogl.jar ;. Triangle

I've uploaded an example of what you should see on your screen when this runs successfully. If you are as green as I am, the next thing to learn is why is the triangle positioned there? Why do we see it from this direction? How do we rotate a viewpoint around the camera. I've got so much to learn! Be sure to download the demos and their source. I feel that this will be an invaluable resource.

Other starting points that I am about to read are:
The OpenGL Redbook
Some intro code snippets at NeonHelium
and these forums, of course.


Jim Cook
Logged
chrisbatey
JGO n00b
*
Offline Offline

Posts: 4


View Profile
« Reply #53 on: February 02, 2006, 07:56:05 am »

thanks oravecz, helped alot, im just starting JOGL today with not much experience of OpenGL.
Logged
SluX
Full Member
***
Offline Offline

Gender: Male
Posts: 189



View Profile
« Reply #54 on: February 14, 2006, 06:43:07 am »

I ve fixed some of those old tutorials on nehe (replaced that GLAutoDrawable).

All works fine except one thing:when i try to use glTranslateF  and translate on z axis, i cant see anything. I translate bothj backwards and forwards, but nothing is visible.

The rest of the code worked fine with old jogl(gltranslatef 2)-examples 6 and 7.

Is there something else i m missing?
Logged

"Intelligence is the most beautiful gift and the greatest temptation which one life can receive from the gods."Me Cheesy
Play strategic football
bytor39
JGO n00b
*
Offline Offline

Posts: 6


View Profile
« Reply #55 on: March 06, 2006, 08:53:26 pm »

I ve fixed some of those old tutorials on nehe (replaced that GLAutoDrawable).

All works fine except one thing:when i try to use glTranslateF  and translate on z axis, i cant see anything. I translate bothj backwards and forwards, but nothing is visible.

The rest of the code worked fine with old jogl(gltranslatef 2)-examples 6 and 7.

Is there something else i m missing?
Think of your GLCanvas as a cube.  If you use eye coordinates, it will always stretch from -1.0 to 1.0 in every direction you can think of.  Therefore, anything drawn outside of that area will be clipped off of the viewspace.

But wait!  Don't the NeHe tutorials translate the eye over to -1.5, and then to 1.5!?  Yup.

So what's missing?

In a word, glOrtho() is missing.  What this function effectively does is widen the cube in which you can draw.

In short, you're drawing outside the box.  glOrtho will make the box larger. Smiley
Logged
kappa
JGO n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #56 on: June 07, 2006, 11:35:29 pm »

i have a problem about GLU.

Code:
final GLU glu = gLDrawable.getGLU();

it doesnt work now...
How to declare GLU?

Should i write like this style when i want to use mouseEvent
Code:
class OpenGLBody implements GLEventListener, KeyListener, MouseListener {
        GLU declaration
        ....
public void display(GLAutoDrawable gLAutoDrawable) {
        ....
       }
       ....
public void mouseDragged(MouseEvent e) {
                  ....
                  glu.glutPostRedisplay()
}
        ....
}


Logged
Ken Russell
Moderator
JGO Kernel
*****
Offline Offline

Gender: Male
Posts: 3442


Java games rock!


View Profile
« Reply #57 on: June 08, 2006, 08:33:55 am »

Just write "GLU glu = new GLU();" at the "GLU declaration" point in your program, then use it wherever necessary.

Take a look at the source code for the InfiniteShadowVolumes and other demos in the jogl-demos project.
Logged
ribot
Sr. Member
****
Offline Offline

Posts: 334


Ribot - mobile UI specialist


View Profile WWW
« Reply #58 on: July 14, 2006, 09:22:08 am »

Slightly revised so that the package name corresponds to the usage with the latest beta 05 release.

Code:
import java.awt.*;
import java.awt.event.*;
import java.util.logging.*;
import javax.media.opengl.*;

import com.sun.opengl.util.Animator;

public class Triangle implements GLEventListener {

// Statics -----------------------------------------------------------------

private final Logger LOG = Logger.getLogger(Triangle.class.getName());

public static void main(String[] args) {
Frame frame = new Frame("Triangle Demo");

GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new Triangle());

frame.add(canvas);
frame.setSize(512, 512);

final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
new Thread(new Runnable() {
public void run() {
animator.stop();
System.exit(0);
}
}).start();
}
});
frame.setVisible(true);
animator.start();
}

// Constructors ------------------------------------------------------------

public Triangle() {
}

// GLEventListener ---------------------------------------------------------

public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
if (LOG.isLoggable(Level.FINE))
LOG.fine("Init GL is " + gl.getClass().getName());
}

public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glColor3f(1F, 0F, 0F);

gl.glBegin(GL.GL_TRIANGLES);

gl.glVertex3f(0.0F, 0.0F, 0.0F);
gl.glVertex3f(1.0F, 0.0F, 0.0F);
gl.glVertex3f(1.0F, 1.0F, 0.0F);

gl.glEnd();
}

public void reshape(GLAutoDrawable drawable, int i, int i1, int i2, int i3) {
}

public void displayChanged(GLAutoDrawable drawable, boolean b, boolean b1) {
}
}
Logged

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
kaffiene
Sr. Member
****
Offline Offline

Gender: Male
Posts: 323



View Profile
« Reply #59 on: July 16, 2006, 09:36:20 pm »

Just write "GLU glu = new GLU();" at the "GLU declaration" point in your program, then use it wherever necessary.

Take a look at the source code for the InfiniteShadowVolumes and other demos in the jogl-demos project.

I recently discovered that change from Jogl to Jogl  JSR 231 myself.  The old advice with GL and GLU handles was not to cache them but to refresh them from the GLDrawable wherever the GLEventListener methods were called.  Now that the GLU handle is not sourced from the GLDrawable, can it be cached now or should it be created fresh wherever it is used?
Logged
Pages: 1 [2] 3 4   Go Up
Print
 
Jump to: