jogl on linux amd64? (EDIT: Partially solved)

Hello,

I am trying to use jogl on linux Mandrake AMD64 without any success so far…

First error was:
----------8<--------------------------------------------------
BUILD FAILED

/home/altrent/jogl/make/build.xml:1050:

Use a platform specific target: linux, macosx, solaris, win32.vc6, win32.vc7, win32.mingw
----------8<--------------------------------------------------
I modified the src/net/java/games/gluegen/StructLayout.java file adding “(os.startsWith(“linux”) && cpu.equals(“amd64”)) ||” to line 126.
It did the trick, but is probably not the best solution as now I have below 100 errors and I have no clue how to correct them…

----------8<--------------------------------------------------
java.compile:
[javac] Compiling 71 source files to /home/altrent/jogl/build/classes
[javac] /home/altrent/jogl/build/gensrc/classes/net/java/games/jogl/GL.java:56: cannot resolve symbol
[javac] symbol : class WGL
[javac] location: interface net.java.games.jogl.GL
[javac] public interface GL extends WGL, GLX, CGL
[javac] ^
[javac] /home/altrent/jogl/build/gensrc/classes/net/java/games/jogl/GL.java:56: cannot resolve symbol
[javac] symbol : class GLX
[javac] location: interface net.java.games.jogl.GL
[javac] public interface GL extends WGL, GLX, CGL
[javac] ^
[javac] /home/altrent/jogl/build/gensrc/classes/net/java/games/jogl/GL.java:56: cannot resolve symbol
[javac] symbol : class CGL
[javac] location: interface net.java.games.jogl.GL
[javac] public interface GL extends WGL, GLX, CGL
[javac] ^
[javac] /home/altrent/jogl/src/net/java/games/jogl/GLDrawable.java:104: cannot resolve symbol
[javac] symbol : class GLU
[javac] location: interface net.java.games.jogl.GLDrawable
[javac] public GLU getGLU();
[javac] ^

…stripped…
----------8<--------------------------------------------------

I would be glad to know that someone got this library to run on an AMD64 linux. :slight_smile:

Thanks in advance!

Hey,

We did mange to compile it on a dual opteron system running Gentoo with a 64 bit 2.6 kernel. The only thing we had to change was the StructLayout.java. Make sure you did a clean after changing the StructLayout.java, and make sure you have the versions of ant and antler that are specified in the build docs, the newer version will not work.

Although we got it to compile, we have not yet had a JOGL program run. We get errors saying the the canvas is already locked. I am pretty sure our problem is that we just picked an incorrect value for the StructLayout, but we haven’t had time to go back and figure out how gcc will layout a structure for the opterons.

Michael

Michael,

Thanks very much for the info, I was glad to know someone got it to compile on 64 bits linux.
I downgraded my version of antlr to the one required for the install, and after fixing a couple of things (adding -fPIC to the compiler, replacing i386 with amd64 inside build.xml) I got it to compile!! :slight_smile:

But now, same issue as you I guess:
Java 2 Runtime Environment: Version 1.4.2-rc1 by Blackdown Java-Linux Team
CANVAS GL IS: net.java.games.jogl.impl.x11.X11GLImpl
CANVAS GLU IS: net.java.games.jogl.impl.GLUImpl
net.java.games.jogl.GLException: Surface already locked
at net.java.games.jogl.impl.x11.X11OnscreenGLContext.lockSurface(X11OnscreenGLContext.java:148)
at net.java.games.jogl.impl.x11.X11OnscreenGLContext.makeCurrent(X11OnscreenGLContext.java:108)
at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:199)
at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:182)
at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)
at net.java.games.jogl.Animator$1.run(Animator.java:104)
at java.lang.Thread.run(Thread.java:534)

I will look at the code, and let you know if I find anything.

Thanks.

We talked to one of the jogl developers and got a bit farther (we think). We had to subclass net.java.games.gluegen.cgram.types.MachineDescription, which we called MachineDescription64Bit (we used 1,2,4,8,8,4,8,8 to init the class, see MachineDescription32Bit for an example). Then we modified GlueGen.java to create our 64Bit class rather then the 32Bit class.

After that we ran into a few problems, some of the methods would now return longs and we got type errors in the X11 context classes, trying to convert longs to ints. We “fixed” those errors by turning the local variables into longs. After that we got it to compile, but we crash when we try to run and the following is printed to the consol.

glLoadTransposeMatrixfARB() supported: True
Killed

Michael

Michael,

Thanks again for all the info.

I finally got jogl to compile and work on my amd64!! ;D

I had to create MachineDescription64Bit as you described it and did some other modifications as detailled in below patch.

Now, some demos works very well on my very old Geforce2 GTS (Infinite Shadow Volumes), but other won’t even start (Gears). Anyway, this is MUCH better than having nothing. :slight_smile:


Only in joglWorks/make: GnuCTreeParserTokenTypes.txt
Only in joglWorks/make: STDCTokenTypes.txt
diff -r jogl/make/build.xml joglWorks/make/build.xml
196c196
<         <property name="java.lib.dir.linux" value="${java.home.dir}/jre/lib/i386" />
---
>         <property name="java.lib.dir.linux" value="${java.home.dir}/jre/lib/amd64" />
354c354
<         <property name="c.compiler.optflags" value="-O2" />
---
>         <property name="c.compiler.optflags" value="-O2 -fPIC" />
424c424
<         <property name="c.linker.jogl.libs" value="-L&quot;${java.lib.dir.platform}&quot; -framework Cocoa -framework OpenGL -ljawt" />
---
>         <property name="c.linker.jogl.libs" value="-L&quot;${java.lib.dir.platform}&quot; -framework Cocoa -framework OpenGL " />
diff -r jogl/src/net/java/games/gluegen/GlueGen.java joglWorks/src/net/java/games/gluegen/GlueGen.java
144c144
<       MachineDescription machDesc = new MachineDescription32Bit();
---
>       MachineDescription machDesc = new MachineDescription64Bit();
diff -r jogl/src/net/java/games/gluegen/StructLayout.java joglWorks/src/net/java/games/gluegen/StructLayout.java
125a126
>         (os.startsWith("linux") && cpu.equals("amd64")) ||
Only in joglWorks/src/net/java/games/gluegen/cgram/types: MachineDescription64Bit.java
diff -r jogl/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java joglWorks/src/net/java/games/jogl/impl/x11/X11OffscreenGLContext.java
47c47
<   private int pixmap;
---
>   private long pixmap;
diff -r jogl/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java joglWorks/src/net/java/games/jogl/impl/x11/X11OnscreenGLContext.java
155c155
<     int res = ds.Lock();
---
>     long res = ds.Lock();
diff -r jogl/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java joglWorks/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
212c212
<     int tmpBuffer = GLX.glXCreatePbuffer(display, fbConfig, iattributes);
---
>     long tmpBuffer = GLX.glXCreatePbuffer(display, fbConfig, iattributes);

It’s great to hear that this port is actually working. Could you please submit a patch on the Issue Tracker on http://jogl.dev.java.net/ and make sure to include in particular any new files? It would be great if you could also make it work in such a way that the existing linux target isn’t broken. Maybe make linuxx86 and linuxamd64 targets?

We should integrate the OS/CPU autodetection from the JOAL build.xml into JOGL’s build.xml.

Good job! =)

I will have to try it again soon. I am going to assume that you are using the Blackdown JDK? Have you tried the Java 1.5 beta for AMD64 from Sun? I tried to use it, but it was extreamly flaky on my system (64bit gentoo).

Now I just need to get JAI ported to AMD64…

Michael

I finally had some free time so I applied the AMD 64 patch from Issue 88 to jogl to see if it worked. Which it sorta did, as long as you used the core of GL. Almost anything that used a dynamically looked up address would cause a crash. I say almost because the GLU functions worked fine, but the GL functions did not.

After much detective work I figured out that glXGetProcAddressARB did not always return the same function address. Calling it from the java method resetProcAddressTable(…) would return an invalid pointer (which was cached by jogl and used later, causing a crash). I then modified the native code dispatch_1glTexImage3D function to call glXGetProcAddressARB and print out the result, which was different the cached version and if I used that address to call the function I would not crash. I tried moving when the glProcAddressTable is populated to different times, and it always would get the incorrect values, even if I called it right before my display method was to be called.

It confused me for awhile that the GLU functions worked fine, until I looked at X11GLContext.java and saw that you use dlsym to look up the function points for the GLU functions. So rather then using glXGetProcAddressARB, I switched it to use dlsym for all of the symbol look up, and everything worked after that.

It looks to me that Nvidia has yet another bug with their driver/gl implementation. Although, C based programs seem to work fine…

So in short, to use jogl on a AMD64 with nvidia cards you have to patch dynamicLookupFunction in X11GLContext to use dlsym rather then glXGetProcAddressARB.

Michael

Could you add this information to the patch that’s on the JOGL Issues page? Thanks.