Thanks Ken
Hi.
Can anyone say why my app(one of the lastest jogl and jdk6, WinXP SP2) has these problems?
- After going fullscreen the bottom part of the screen(START button line) is under the “start” button.
- Before pressing alt-tab it draws a twice slimer line at the top of the screen, but after alt-tab this problem and the first problem will be solved.
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.media.opengl.*;
public class Test
extends JFrame
implements GLEventListener, KeyListener
{
private GLCapabilities caps;
private GLCanvas canvas;
GLAutoDrawable drawable;
int x = 50;
public Test()
{
super("Test");
caps = new GLCapabilities();
canvas = new GLCanvas(caps);
canvas.addGLEventListener(this);
canvas.addKeyListener(this);
getContentPane().add(canvas);
}
public void run()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUndecorated(true);
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
gd.setFullScreenWindow(this);
setVisible(true);
setLocationRelativeTo(null);
setVisible(true);
canvas.requestFocusInWindow();
}
public static void main(String[] args)
{
new Test().run();
}
public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
this.drawable = drawable;
float values[] = new float[2];
gl.glGetFloatv(GL.GL_LINE_WIDTH_GRANULARITY, values, 0);
gl.glGetFloatv(GL.GL_LINE_WIDTH_RANGE, values, 0);
gl.glEnable(GL.GL_LINE_SMOOTH);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_DONT_CARE);
gl.glLineWidth(1.5f);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glColor3f(0.0f, 1.0f, 0.0f);
gl.glPushMatrix();
drawBlocksAndBorder(drawable);
gl.glPopMatrix();
gl.glFlush();
}
private void drawBlocksAndBorder(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glBegin(gl.GL_QUADS); // Draw A Quad
gl.glVertex3f( getCoordX(0), getCoordY(0), 0.0f); // Top Left
gl.glVertex3f( getCoordX(800), getCoordY(0), 0.0f); // Top Right
gl.glVertex3f( getCoordX(800), getCoordY(25), 0.0f); // Bottom Right
gl.glVertex3f( getCoordX(0), getCoordY(25), 0.0f); // Bottom Left
gl.glEnd();
gl.glFlush();
}
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h)
{
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
boolean deviceChanged)
{
}
public void keyTyped(KeyEvent key)
{
}
public void keyPressed(KeyEvent key)
{
}
public void keyReleased(KeyEvent key)
{
}
public float getCoordX(float x)
{
if(x<640)
{
return -(640-x*1.6f)/640;
}
else if(x>640)
{
return (-640+x*1.6f)/640;
}
else
{
return 0;
}
}
public float getCoordY(float y)
{
if(y<512)
{
return (512-y*1.7066f)/512;
}
else if(y>512)
{
return -(-512+y*1.7066f)/512;
}
else
{
return 0;
}
}
}
The call to setLocationRelativeTo() is messing things up. Take it out and things should work fine.
Ok guys, hey there, n00b talking.
I am sure this issue has been addressed like a million times (and i see some far more serious questions aroud this thread) but i’ll risk asking here.
I have problems on setting JOGL.
I have winXP-32, JDK and JRE 1.6.0 installed and net beans 5.5
I have added my jdk bin path (normaly c:\program files\java\jdk1.6.0\bin) to the windows path.
I am now trying to set up jogl.
So i got
jogl.dll
jogl_cg.dll
jogl_awt.dll
copied in my bin folder and jogl.jar in lib/ext folder.
Now correct if i am wrong. at first i put them in the jre1.6.0 folders calles so, meaning:
…\jre1.6.0\bin &
…\jre1.6.0\lib\ext
That didn’t work for me, i got a compile time error: package net.java.games.jogl does not exist
I tried copying the files to other location like
…\jdk1.6.0\jre\bin &
…\jdk1.6.0\jre\lib\ext
and even …\jdk1.6.0\bin for the .dll(s) (just in case)
my “java.library.path” gives :
C:\Program Files\Java\jdk1.6.0\jre\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Python24.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Java\jdk1.6.0\jre\bin
Oh i also tried to add the jogl.jar to the project in net beans as described in the help file : Working with Projects–>Standard Projects–>Managing the classpath… nothing…
I know it must be something stupid that i do wrong or sth… so plz can someone tell me…what does this n00b do wrong?
Thank you in advance.
First remove every file related to jogl/gluegen jars and dlls you have spread across your system. Especially don’t ever install jogl to global locations such as jre\lib or c:\windows.
Since you are using netbeans, just use my module: http://www.java-gaming.org/forums/index.php?topic=12530.msg126787#msg126787
Note: If you already created a JOGL library inside Netbeans using |Tools| -> |Library Manager|, make sure to delete it prior to the module installation.
[quote]package net.java.games.jogl does not exist
[/quote]
I assume you are trying to compile examples from other sites. “net.java.games.jogl” is outdated and was replaced by “javax.media.opengl”
great! thanks! i’ll try it out asap and let ypu know if anything comes up.
thx a lot.
…got question though. is there a setting without using the module you linked? just asking out of curiosity.
(PS here, i found in many sites (outdated maybe) that i had to install the files in lib/ext and bin. Why is it that this is bad?)
thanks again
Yes there is.
- Downloaded the JOGL distribution for your platform (e.g. “jogl-1.1.0-rc3-windows-i586.zip”)
- Unzip it into a local folder (e.g. “C:\development\javalibs”)
- Start Netbeans, go to |Tools| -> |Library Manager|
- Click [New Library] and create a “Class Library” named “JOGL-DEPS” (don’t call it JOGL, since this breaks my module ;))
- Click [Add Jar/Folder] and select “jogl.jar” and “gluegen-rt.jar” from the “lib” directory of the unzipped JOGL distribution
- Close the Library Mananger using [OK]
- Create a “Java Application” from Netbeans “General” project templates
- Go to the “Libraries” node of the new project and right click “Add”
- Select “JOGL-DEPS” and close the dialog
- Open the project properties
- Go to the “run” node and add “-Djava.library.path=C:/development/javalibs/jogl-1.1.0-rc3-windows-i586/lib” to the VM options
That should be it. My module adds the ability to build distributions of your app and comes with a out of the box running example app.
It breaks Java Webstart deployment of JOGL apps, since the locally installed version has precedence over the one in the Webstart descriptor, so if the webstarted App needs a different version, it doesn’t run and you will have no clue, why…
Enlightening! Thanks a lot mate!
I have another probablly stupid question.
When i try to
import com.sun.opengl.utils.Animator;
i get a ‘package does not exist’ error during compile. Net beans indicate also that i have not Javadoc documentetion or haven’t added specified javadoc in my java platform manager.
should i get some specific javadoc, or .jar file and install or is it something else? Maybe it is also outdated? in fact i am really confused as of where to get correct examples of code that works.
Sorry for being so inadequate in this, i just moved here from C, things were clearer to me there :-[
I am really trying to get a going here :-\
thanks for any help.
Just remove the unknow import, place your cursor over a the read underlined usage of Animator in your code, wait for a yellow “light bulb” to apear on the left side of the editor, click on it and select “import …Animator”. The IDE does the rest.
Use this “technique” with outdated examples as well. Just remove the imports, search for red underlined class usages and let the imports be fixed by the IDE.
There are quite a lot of working examples in the jogl-demos distribution on the jogl-files page: https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=5971&expandFolder=5971
again you save me. I hope i will ask more content questions in the future if need be.
thanks a lot for bith patience and advice.
P.S. I must be blind to not see those zip files …god…
Okey,thanks to your advice and some more searching for an example as simple as it comes i think i am finally getting closer to actually running something in jogl…yay :-[
anyway, i still got a problem, hopefully the final one before going deeper into this stuff.
i got an example that creates a very basic JOGL GLEventListener.
It compiles with no errors (thx again), but i go tthis run time error:
Exception in thread “main” java.lang.UnsatisfiedLinkError: no jogl in java.library.path
I tried to correct this by adding: -Djava.library.path=C:\Program Files\javalib\jogl-1_0_0-windows-i586\lib
in the run tab of the project at VM options.
yet i get another error:
java.lang.NoClassDefFoundError: Files\javalib\jogl-1_0_0-windows-i586\lib
only this time i got no idea how to fix it. :-\
Also i am following the Java tutorials at java.sun.com/docs/books/tutorial/ in order to a grip of what’s goin on around java but i could use more that this (for example a good explanation on madules packets javadocs and stuff).
Thanks again in advance for any help.
- with java, always use forward slashes, even on windows
- theres a space in your path, so you have to quote the string
-Djava.library.path="c:/Program Files/javalib/jogl-1_0_0-windows-i586/lib"
thanks again. it seems to work with no problem using both " / " or " \ ".
hi
do you know some prog or anything that will make more simple running jogl prog, i know i can use bat file with -cp option but i was thinking is it posiible to make it more easier for end user who do not have any knowledge what classpath is etc
for example i would like to make it as simple like is eclipse made, you know estract downloaded zip and normally click eclipse etc
with normal java progs in jar without external libraries it is easy just 2xClick jar and it works but with jogl… it will not
i was thinking also is it possible to use jnlp file just locally but i do not have such experience with it :-\
for example now i am using such bat code:
java -jar M3G_MAKER.jar -cp "c:\jogl.jar;."
-Djava.library.path="c:\jogl"
-Dsun.java2d.noddraw=true
the problem is that manualy user must ceate jogl folder and than copy jogl files to it so when he clicks bat file prog will work
but how to make it simple?
for example lets imagine some directory where my prog jar is:
progDiectory:
--------lib/jogl
--------data
--------M3G_MAKER.jar
so main is progdirectory , lib , data are subdirectoiries of progDirectory and lets imagine that jogl must be in that lib directory and
and progDirectory can be anywhere on hdd…
you know what i mean? ;D
so how to make my prog not on fixed lib jogl directory dependent?
any ideas?
You can use the following tree :
prog/system/lib/jogl.dll
prog/system/lib/jogl_cg.dll
prog/system/lib/jogl_awt.dll
prog/system/lib/gluegen-rt.dll
prog/system/jogl.jar
prog/system/gluegen-rt.jar
prog/system/M3G_MAKER.jar
prog/data/*
prog/M3G_MAKER.bat
with the following M3G_MAKER.bat :
@echo off
cd system
java -Djava.library.path=lib -cp gluegen-rt.jar;jogl.jar;M3G_MAKER.jar -Dsun.java2d.noddraw=true M3G_MAKER.Main
that’s all good but after installing librarys my IntelliJIDEA do that:
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GL;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.DebugGL;
but i’m need to import not from javax, i’m need do implements library from net… like in exaples >:(
and import net.java.games.jogl.GL; is not avalible
because if i’m implements from javax then someone funcs is not avalible…for example : drawable.getGL()
This is a desperate plea. I have a VERY SIMPLE request:
Please pin a topic explaining the options and caveats for deploying JOGL apps. Failing that, please respond as to why this won’t happen. It would be greatly appreciated by many people.
The more detailed issue follows. Note how I’m giving a pretty good outline of the proposed HOWTO, sans the definitive answers…
Having searched around high and low, I have seen many explanations as to how to deploy JOGL apps. The majority consensus seems to be to use Java Web Start. In some places I’ve seen it recommended that the JOGL libraries (both JAR files and platform-specific native pieces) be added to the JRE’s standard extension directory; in other places I have seen dire warnings not to do this (with sketchy explanations given as to why not). The latter recommend either JWS or setting the system-wide CLASSPATH and platform-specific library path environment variables. I have also seen mention of a method to use JOGL in applets, but have not yet tried to do this myself.
Here are some problems with these suggestions:
-
In many situations, Java Web Start is not desirable. To name a few: you have a ginormous app you want to distribute on a CD or other media that uses JOGL; you want users to be able to run the app as a locally installed, offline application, since it has nothing to do with the internet; you are really lazy and don’t want to investigate the poorly documented JWS setup and write a big XML file; you don’t have access to a static web server host; you are using JOGL in an app containing other libraries that can not be deployed this way. I think I’ve made my point on this.
-
Setting the CLASSPATH and PATH does not appear to work. At least didn’t work for me. (JOGL 1.1.0, JRE 1.5.0_9, Windows XP) I cannot for the life of me think why it wouldn’t work, but it does not. I tried rebooting; nothing. I set both these variables to the location containing all the JOGL libraries (JARs and .DLLs). As I’ve seen documented. When I try to execute my simple JOGL app, either by double-clicking the JAR file or doing java -jar testapp.jar from the command line, I get an error. (In double-click case this error erroneously tells me that main class could not be found; by putting JOGL libraries into the JRE’s extension directory, the app runs just fine, indicating that in fact the main class is easy to find, and is specified correctly in the jar manifest, but this would seem to be a JRE issue.)
-
I can run by test app by giving a full java -classpath “.;%CLASSPATH%;C:\jogl\jogl.jar;C:\jogl\gluegen.jar” -jar testapp.jar . However this is a pain in the ass, and the whole point here is I am trying to allow end users to run this app. For that matter, even setting the system-wide CLASSPATH and PATH variables (or LD_LIBRARY_PATH on Linux, whatever it is on OS X) is not something users are going to do for the most part. (For development its also simple to let my IDE add the JARs to the build path and test within the IDE.)
-
Because of 1,2, and 3, I appear to be left with no options but to copy the JOGL libraries into my JRE’s lib/ext directory. Though this is discouraged with dire warnings, it works just fine for me so far. As for these dire warnings, I do understand that this method will break whenever the JRE is updated to another version (again, a JRE issue; IMHO it ought to be smart enough to keep already installed extensions when updating, or allow users to choose this option). I have also been warned that this causes a conflict when other apps using Java Web Start but using a different (or even same?) version of JOGL are loaded. So that’s no good…
-
When I’ve tried to have a couple friends test my app, they have had failures I cannot explain. One, also using Windows XP, was unable to get the app to run correctly when double-clicking even after placing the JOGL libraries in the JRE’s extension directory. She was able to run from the command-line though, doing java -jar testapp.jar, with the libraries in the extension dir. This mystifies me, as I am able to double-click the jar file. Another friend on OS X who out of paranoia has so far refused to place the libraries into the extension dir has had errors even when invoking from the command-line with the full classpath to the libraries specified, that he solved only by moving to the same directory as my app before invoking. The point is, it has been a pain in the ass to tell other users how to run the app.
-
So based on these points, it appears there is no reliable way to run JOGL apps, other than Java Web Start (see point #1). Correct me if I’m wrong, but isn’t deploying an app likely to be something all developers will want to do at some point? It seems there ought to be a simple way to allow users to have the same experience with a Java app (3D or otherwise) as with any other application. I am not averse to using an installer package like InstallAnywhere, or even writing my own batch and shell files for different target platforms so users can double-click something, but as this post details, I’m not sure where the JOGL stuff ought to be installed or what those scripts ought to contain.
I hope the detail here is helpful and not aggravating and that it is appreciated that the need for solid answers to these issues in a highly visible place is important to all potential JOGL users and developers. If such a resource exists, by all means point me to it and I will apologize for being redundant (but please pin it on these forums).
Thanks.
Jason Boyd
@hell32.dll
The net.java.games.jogl.GL is outdated and deprecated. Use the javax.media.opengl package. For examples try to work throught the jogl-demos, they are all reworked for the new api. Maybe see this thread for more information.
@jboyd99
Placing the jogl jars in the jre/ext directory is dangerous because of webstart conflicts with other jogl apps. I even consider this a non-option from the end-user perspective, too. Just create a directory tree like Agrv2236 suggested (note that M3G_MAKER has to be substituted with ), include the desired jogl-version in the package and use a bat or cmd-file to start. Another option would be to write an installer-script (innosetup or something) that creates a desktop/startmenu shortcut for starting the app. If you ship on cd, also packaging a JRE would be the safest thing to do.
Maybe your friend installed some software (like WinZIP, Nokia application installer etc.), that registers itself for the jar file type. This is a long standing problem with executable jars in general
We are developing a large scale traffic simulator for research purposes. We are using java/JOGL in Windows environment.
We are in the process of buying a new workstation for our lab. Is it a right decision to go with intel 64 bit quad core processor with Windows Vista? Would we expect any problems running JOGL on such platform?
What JOGL binaries should we use? if any?