Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2] 3 4 5
  ignore  |  Print  
  How to: Getting started with JOGL  (Read 149887 times)
0 Members and 1 Guest are viewing this topic.
Offline nnevatie

Junior Member




It is slightly better to be simple than correct.


« Reply #30 - Posted 2004-09-28 10:40:10 »

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

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
Offline zingbat

Senior Member




Java games rock!


« Reply #31 - Posted 2004-09-28 10:48:31 »

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.
Offline nnevatie

Junior Member




It is slightly better to be simple than correct.


« Reply #32 - Posted 2004-09-28 11:52:12 »

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?

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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zingbat

Senior Member




Java games rock!


« Reply #33 - Posted 2004-09-29 14:55:26 »

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

Offline friism

Innocent Bystander




Java games rock!


« Reply #34 - Posted 2004-09-29 20:10:32 »

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?
Offline denatus

Innocent Bystander




Java games rock!


« Reply #35 - Posted 2004-11-04 14:34:48 »

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

Nothing much!
Offline Rokky

Innocent Bystander




Java games rock!


« Reply #36 - Posted 2004-12-18 11:52:11 »

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?
Offline turquoise3232

Junior Member




Java (games) rock!


« Reply #37 - Posted 2004-12-18 19:11:04 »

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.
Offline branco

Innocent Bystander




Java games rock!


« Reply #38 - Posted 2005-03-22 17:47:15 »

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)

Offline immano

Senior Newbie




Java games rock!


« Reply #39 - Posted 2005-03-30 17:52:27 »

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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline quintesse

Junior Member




Java games rock!


« Reply #40 - Posted 2005-04-04 12:26:42 »

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
      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).
Offline CodeDog

Innocent Bystander





« Reply #41 - Posted 2005-06-13 06:22:14 »

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?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #42 - Posted 2005-06-13 16:56:05 »

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.

Offline ASL

Senior Newbie





« Reply #43 - Posted 2005-06-13 22:24:57 »

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???
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #44 - Posted 2005-06-13 23:56:47 »

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.
Offline tonywang

Junior Newbie





« Reply #45 - Posted 2005-09-22 13:08:49 »

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
Offline clivethebadger

Innocent Bystander





« Reply #46 - Posted 2005-11-01 12:34:47 »

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
Offline Pegasus

Senior Newbie





« Reply #47 - Posted 2005-11-16 00:28:53 »

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

Junior Newbie





« Reply #48 - Posted 2005-11-28 02:37:03 »

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
Offline skytomorrownow

Junior Member





« Reply #49 - Posted 2005-12-07 18:07:44 »

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

try javax.media.opengl.*;
Offline inacioferrarini

Innocent Bystander





« Reply #50 - Posted 2005-12-10 23:56:24 »

Test.java

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  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
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

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  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
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
1  
2  
3  
4  
5  
       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
1  
2  
3  
4  
5  
6  
7  
      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.
Offline zingbat

Senior Member




Java games rock!


« Reply #51 - Posted 2005-12-20 18:43:59 »

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.
Offline oravecz

Junior Newbie





« Reply #52 - Posted 2006-01-15 18:07:01 »

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.

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  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
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:
1  
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:
1  
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:
1  
\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
Offline chrisbatey

Junior Newbie





« Reply #53 - Posted 2006-02-02 15:56:05 »

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

Junior Member





« Reply #54 - Posted 2006-02-14 14:43:07 »

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?

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

Junior Newbie





« Reply #55 - Posted 2006-03-07 04:53:26 »

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
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #56 - Posted 2006-06-08 15:33:55 »

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.
Offline ribot

Junior Member




Ribot - mobile UI specialist


« Reply #57 - Posted 2006-07-14 16:22:08 »

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

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  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
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) {
   }
}

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline kaffiene
« Reply #58 - Posted 2006-07-17 04:36:20 »

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?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #59 - Posted 2006-07-17 06:35:52 »

It can be cached but you need to keep in mind that the GLU implementation is not thread-safe so you should make sure the GLU instance can not be shared between threads. In general this probably means one GLU per GLEventListener instance. The new GLU now fetches the OpenGL pipeline from the current context using GLU.getCurrentGL() which is how it was decoupled from the GLDrawable without adding GL parameters everywhere to the method signatures.
Pages: 1 [2] 3 4 5
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (22 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (26 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!