This is a cry for help. I have been trying to figure out how to work openGL on java for 2 days. I want to be able to use a plain text editor to write a simple window call and add an openGL environment to it. No IDE. I compiled a java program with javac just fine but when I attempt a demo JOGL program it fails. It seems everything I have tried is ether unclear, outdated, or requires Eclipse.
It seems like the wiki for JOGL that explains how to work it assumes I know how to install this library. All I have done is the following. 1) Download java JDK 2)download and unpack JOGL 3)run test.sh and test_dbg.sh 4)attempt a basic tutorial that included a simple JOGL program. I could go on and on about what all I have been trying and reading, or talk about why I don't want to use a IDE, but really I just want to be able to start messing around with openGL. P.S I am so sick of half right tutorials and magical background stuff that articles never explain. I really wish I had someone I could ask about my coding problems and they could point out where things are going wrong. Instead I'm stuck with seemingly obsessive googling and constant "do this to make it work and don't worry about why it works." #WantAMentor |
Administrator
|
Hi
What is missing? What do you need currently? Have you looked at our wiki? http://jogamp.org/wiki/index.php/Main_Page We are here to help you, don't worry. Actually, there are some tutorials based on JOGL but there are a lot more OpenGL tutorials written in plain C. When you know how to "port" them, it is easier to learn OpenGL, you can use what you learn both in C/C++ and in Java with JOGL.
Julien Gouesse | Personal blog | Website
|
Administrator
|
In reply to this post by shadoworld56
To build outside any IDE: http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#vi_and_other_text_editors
Super-simple demo program that just draws one triangle: http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing |
This post was updated on .
OneTriangle.javaOneTriangleSwingGLJPanel.javaThank you guys for replying to me. I have tried following the tutorials from wade however I was getting errors due to the class path being weird. I would get errors about OneTriangle not being included properly in the second file. trying to compile the demo program using swing. once I got those errors to go away for some reason the jogl-all.jar wouldn't import properly into one of the .java though it worked fine in the first (the base)
currently I have managed to get both the OneTriangle errors gone and the jogl-all.jar errors gone but now I have these errors lib/OneTriangleSwingGLJPanel.java:22: error: cannot access WriteCloneable GLJPanel gljpanel = new GLJPanel( glcapabilities ); ^ class file for com.jogamp.common.type.WriteCloneable not found lib/OneTriangleSwingGLJPanel.java:41: error: cannot find symbol OneTriangle.render( glautodrawable.getGL().getGL2(), glautodrawable.getWidth(), glautodrawable.getHeight() ); ^ symbol: method getWidth() location: variable glautodrawable of type GLAutoDrawable lib/OneTriangleSwingGLJPanel.java:41: error: cannot find symbol OneTriangle.render( glautodrawable.getGL().getGL2(), glautodrawable.getWidth(), glautodrawable.getHeight() ); ^ symbol: method getHeight() location: variable glautodrawable of type GLAutoDrawable 3 errors any suggestions? here is my code. its placed in a dir with the jar folder with the required jars OneTriangle.java OneTriangleSwingGLJPanel.java javac -classpath "lib/jargluegen-rt.jar:lib/jar/jogl-all.jar" lib/*.java this is currently how i am getting them to compile. I am on a mac. edit: I have managed to get rid of 2 off the errors. lib/OneTriangleSwingGLJPanel.java:41: error: cannot find symbol OneTriangle.render( glautodrawable.getGL().getGL2(), glautodrawable.getWidth(), glautodrawable.getHeight() ); ^ symbol: method getWidth() location: variable glautodrawable of type GLAutoDrawable lib/OneTriangleSwingGLJPanel.java:41: error: cannot find symbol OneTriangle.render( glautodrawable.getGL().getGL2(), glautodrawable.getWidth(), glautodrawable.getHeight() ); ^ symbol: method getHeight() location: variable glautodrawable of type GLAutoDrawable 2 errors still getting these errors though. why would glautodrawable.getWidth() give an error? |
Administrator
|
I've duplicated your problem -- it looks like JOGL has changed since I wrote that wiki page :) I'm updating it now and will let you know when it works with JOGL 2.2.0.
|
Administrator
|
In reply to this post by shadoworld56
OK, long story short, just change getWidth()/getHeight() to getSurfaceWidth()/getSurfaceHeight(). These got changed recently in https://jogamp.org/bugzilla/show_bug.cgi?format=multiple&id=741, and I wasn't paying close enough attention to realize that meant I needed to change the wiki examples :)
Let me know if you have any remaining problems. |
thank you. the program now compiles completely. however I am to stupid to understand how to run this.
Jeremiahs-Mac-Pro:~ jeremiahdeckard$ javac -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/*.java Jeremiahs-Mac-Pro:~ jeremiahdeckard$ javac -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/*.java Jeremiahs-Mac-Pro:~ jeremiahdeckard$ java -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/* Error: Could not find or load main class lib.GLtest Jeremiahs-Mac-Pro:~ jeremiahdeckard$ java -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/OneTriangle Error: Could not find or load main class lib.OneTriangle Jeremiahs-Mac-Pro:~ jeremiahdeckard$ java -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/OneTriangleSwingGLJPanel Error: Could not find or load main class lib.OneTriangleSwingGLJPanel Jeremiahs-Mac-Pro:~ jeremiahdeckard$ java -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/OneTriangleSwingGLJPanel$1 Error: Could not find or load main class lib.OneTriangleSwingGLJPanel Jeremiahs-Mac-Pro:~ jeremiahdeckard$ java -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" lib/OneTriangleSwingGLJPanel$2 Error: Could not find or load main class lib.OneTriangleSwingGLJPanel Jeremiahs-Mac-Pro:~ jeremiahdeckard$ java -classpath "jar/gluegen-rt.jar:jar/jogl-all.jar:." lib/OneTriangleSwingGLJPanel Error: Could not find or load main class lib.OneTriangleSwingGLJPanel Jeremiahs-Mac-Pro:~ jeremiahdeckard$ currently I have a dir called lib that is where all the .java and .class live as well as housing the jar folder from the jogl download. I have tried running OneTriangle , OneTriangleSwingGLJPanel , OneTriangleSwingGLJPanel$1 , and OneTriangleSwingGLJPanel$2 . (all the class files that I have compiled and live in dir lib) if I just call java OneTriangleSwingGLJPanel then i get this error Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GLCapabilitiesImmutable at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2688) at java.lang.Class.privateGetMethodRecursive(Class.java:3035) at java.lang.Class.getMethod0(Class.java:3005) at java.lang.Class.getMethod(Class.java:1771) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLCapabilitiesImmutable at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more I don't know what is wrong but it seems like it can't find the main method in my .class when I use class path. but without class path it can't find the .jars for jogl to work. |
Administrator
|
Your files are both in the default package (since they have no "package" statement at the top), which means you can't put them in a subdirectory, because Java interprets the subdirectories as package names. You should either put your *.java files in the top directory (above "lib") or add a "package" statement to them and put them in the appropriate subdirectory (for example, if you put "package my.name.here;" at the top of both files, you'd put them both in the subdirectory "my/name/here", and you'd run by saying "java -classpath "lib/jar/gluegen-rt.jar:lib/jar/jogl-all.jar" my.name.here.OneTriangleSwingGLJPanel").
Use of the default package is not encouraged, I just didn't use a package in the examples because people normally already have a package that they want to put their files into. |
ok I have added both of the source files to a dir called joglDemo and added the line package joglDemo; to both at the very top.
so I have done what you said to the best of my abilities. am I doing something wrong here or am I missing a step? why is it still not working? |
Administrator
|
You're almost there -- I think you just need to add "lib" to your classpath instead of "lib/*".
|
I am still getting the complaint of it not being able to find the main method.
Jeremiahs-Mac-Pro:lib jeremiahdeckard$ java -classpath "jar/gluegen-rt.jar:jar/jogl-all.jar:joglDemo" joglDemo.OneTriangleSwingGLJPanel Error: Could not find or load main class joglDemo.OneTriangleSwingGLJPanel Jeremiahs-Mac-Pro:lib jeremiahdeckard$ I have tried being in the dir of lib (cd lib) and outside of it (cd) I have tried my package being joglDemo and lib.joglDemo I have added to the end of the class path "lib" and "lib.joglDemo" also the OneTriangleSwingGLJPanel.java file generates 3 .class files OneTriangleSwingGLJPanel.class OneTriangleSwingGLJPanel$1.class and OneTriangleSwingGLJPanel$2.class here is the joglDemo dir. it contains both the .java and the .class flies . I have this in a dir called lib on my home dir (the one calling cd sends me to and terminal opens up to on default) inside of the lib dir i have the jar dir containing the jogl jars joglDemo.zip |
Administrator
|
You might want to read up on how the Java classpath works, just so you're not trying stuff at random :) It's often confusing to newcomers, and it took me a while to fully understand.
There are lots of different ways to set up your source and class directories. Here's how I'd normally lay out the directory tree for your project: test jar gluegen-rt.jar gluegen-rt-natives-*.jar (one file per target OS) jogl-all.jar jogl-all-natives-*.jar (one file per target OS) src joglDemo OneTriangle.java OneTriangleSwingGLJPanel.java class joglDemo OneTriangle.class OneTriangleSwingGLJPanel.class OneTriangleSwingGLJPanel$1.class OneTriangleSwingGLJPanel$2.class Then I'd cd into the test directory and type "java -classpath "jar/gluegen-rt.jar:jar/jogl-all.jar:class" joglDemo.OneTriangleSwingGLJPanel", and it should run. Don't worry about the OneTriangleSwingGLJPanel$1.class and OneTriangleSwingGLJPanel$2.class files. The compiler generates those for the anonymous inner classes "new GLEventListener() {...}" and "new WindowAdapter() {...}" inside of OneTriangleSwingGLJPanel.java. Those extra class files are normal, and are needed to run the program. |
I reorganized as you suggested and it worked! still not very clear why it worked this way and not the other way though. I have tried to read up on class path but so far I haven't read anything that really cleared it up. your post made more sense than anything I have read so far. Now I have to learn more about writing openGL in java and move on to trying to write my own stuff.
Thank you so much for all your help and I am sure in the future I will need help again so know this isn't over yet :) If you have any suggestions on good tutorials or books to read to help me understand this intermediate level of coding I'm at that would be great. |
Administrator
|
Excellent, I'm glad it's working! As far as good tutorials go (other than my own :)) I don't have any specific recommendations at the moment.
My best bit of advice is this: always understand why something didn't work. For example, on this project, go back and fiddle around with it some more until you know what's really going on, and can re-arrange the files any way you want and have it still work. If you always take the time to do this when you finally get something working, you'll learn very quickly, and in a short time you'll be far ahead of where you are now. Good luck! |
So I have made leaps and bounds of progress! https://www.youtube.com/watch?v=jCXEejl7a8s
|
Administrator
|
Looking good! :)
|
Free forum by Nabble | Edit this page |