nnevatie
Full Member   Posts: 149
It is slightly better to be simple than correct.
|
 |
«
Reply #30 on:
2004-09-28 06:40:10 » |
|
Damn it, isn't there a way to set the java.library.path without messing with windows environment variables ?
Actually, there is  . 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
|
|
|
zingbat
JGO Ninja    Posts: 671 Medals: 1
Java games rock!
|
 |
«
Reply #31 on:
2004-09-28 06:48:31 » |
|
Actually, there is  . java -Djava.library.path=path/to/libraries mypackage.MyClass Cheers 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.
|
|
|
|
|
nnevatie
Full Member   Posts: 149
It is slightly better to be simple than correct.
|
 |
«
Reply #32 on:
2004-09-28 07:52:12 » |
|
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! Go get 'em!
|
|
zingbat
JGO Ninja    Posts: 671 Medals: 1
Java games rock!
|
 |
«
Reply #33 on:
2004-09-29 10:55:26 » |
|
OK never mind. There was a bug in my dos batch file.  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  %CMDARGS%  %1 %2 %3 %4 %5 %6 %7 %8 %9
|
|
|
|
|
friism
JGO n00b  Posts: 1
Java games rock!
|
 |
«
Reply #34 on:
2004-09-29 16: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?
|
|
|
|
|
|
|
Rokky
JGO n00b  Posts: 1
Java games rock!
|
 |
«
Reply #36 on:
2004-12-18 06: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?
|
|
|
|
|
turquoise3232
Sr. Member   Posts: 332
Java (games) rock!
|
 |
«
Reply #37 on:
2004-12-18 14: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.
|
|
|
|
|
branco
JGO n00b  Posts: 1
Java games rock!
|
 |
«
Reply #38 on:
2005-03-22 12: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)
|
|
|
|
|
immano
JGO n00b  Posts: 14
Java games rock!
|
 |
«
Reply #39 on:
2005-03-30 12: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! Go get 'em!
|
|
quintesse
Full Member   Posts: 124
Java games rock!
|
 |
«
Reply #40 on:
2005-04-04 08: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) 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).
|
|
|
|
|
CodeDog
JGO n00b  Posts: 1
|
 |
«
Reply #41 on:
2005-06-13 02: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?
|
|
|
|
|
Ken Russell
JGO Kernel      Posts: 3446 Medals: 3
Java games rock!
|
 |
«
Reply #42 on:
2005-06-13 12: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.
|
|
|
|
|
ASL
JGO n00b  Posts: 25
|
 |
«
Reply #43 on:
2005-06-13 18: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???
|
|
|
|
|
Ken Russell
JGO Kernel      Posts: 3446 Medals: 3
Java games rock!
|
 |
«
Reply #44 on:
2005-06-13 19: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.
|
|
|
|
|
tonywang
JGO n00b  Posts: 2
|
 |
«
Reply #45 on:
2005-09-22 09: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. 
|
|
|
|
|
clivethebadger
JGO n00b  Posts: 1
|
 |
«
Reply #46 on:
2005-11-01 07: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
|
|
|
|
|
Pegasus
JGO n00b  Posts: 8
|
 |
«
Reply #47 on:
2005-11-15 19:28:53 » |
|
May you update the tutorial to the jogl jsr-231 standard? Thanks!
|
|
|
|
|
egcjava
JGO n00b  Posts: 6
|
 |
«
Reply #48 on:
2005-11-27 21: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
|
|
|
|
|
skytomorrownow
Jr. Member   Posts: 68
|
 |
«
Reply #49 on:
2005-12-07 13:07:44 » |
|
"C:\jogl\JOGL2DBasics.java:6: package net.java.games.jogl does not exist import net.java.games.jogl.*;"
try javax.media.opengl.*;
|
|
|
|
|
inacioferrarini
JGO n00b  Posts: 1
|
 |
«
Reply #50 on:
2005-12-10 18: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.
|
|
|
|
|
|
|
oravecz
JGO n00b  Posts: 4
|
 |
«
Reply #52 on:
2006-01-15 13: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: 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 {
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(); }
public Triangle() { }
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 RedbookSome intro code snippets at NeonHeliumand these forums, of course. Jim Cook
|
|
|
|
|
chrisbatey
JGO n00b  Posts: 4
|
 |
«
Reply #53 on:
2006-02-02 10:56:05 » |
|
thanks oravecz, helped alot, im just starting JOGL today with not much experience of OpenGL.
|
|
|
|
|
SluX
Full Member   Posts: 189
|
 |
«
Reply #54 on:
2006-02-14 09: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 Play strategic football
|
|
|
bytor39
JGO n00b  Posts: 6
|
 |
«
Reply #55 on:
2006-03-06 23: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. 
|
|
|
|
|
Ken Russell
JGO Kernel      Posts: 3446 Medals: 3
Java games rock!
|
 |
«
Reply #56 on:
2006-06-08 11: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.
|
|
|
|
|
ribot
Sr. Member   Posts: 306
Ribot - mobile UI specialist
|
 |
«
Reply #57 on:
2006-07-14 12: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 {
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(); }
public Triangle() { }
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) { } } |
|
|
|
|
kaffiene
Sr. Member   Posts: 387 Medals: 1
|
 |
«
Reply #58 on:
2006-07-17 00: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?
|
|
|
|
|
Ken Russell
JGO Kernel      Posts: 3446 Medals: 3
Java games rock!
|
 |
«
Reply #59 on:
2006-07-17 02: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.
|
|
|
|
|
|