Experiences of migrating from JOGL 1.1.1 to JSR231

OK, so my opinion has been registered. I can live with the extra comma and zero.

[quote]Some calls which used to allow a direct array argument now needs IntBuffer.wrap (array) (e.g., glDrawPixels)
[/quote]
One variant of glDrawPixels takes Buffer pixels and the other takes long pixels_buffer_offset . What is the difference, and how would you convert JOGL code to the latter?

Thanks.

glDrawPixels is one of the APIs affected by the ARB_pixel_buffer_extension. Take a look at the documentation for that extension to see how it is used. All APIs affected by the vertex_buffer_object and pixel_buffer_object extensions have additional overloadings taking the long offset into the buffer object for security reasons. There are checks in the JOGL implementation to make sure that the extension is appropriately enabled or disabled when each overloading is called.

Please never integrate any math package into GL/GLU directly. There are lots of diffrent math packages out there, and doing that would favor one. IMHO that’s no ok, even for javax.vecmath since OpenGL is math api independent.

@DaveLloyd
If it is the easy of use, you want. Just derivate from the GLU class and extend it with the methods for the vector classes you like.

I’m sorry, but I couldn’t disagree more! The greatest strength of Java is its broad and consistent set of APIs. When you have a task in front of you, unlike with C++, you don’t have to choose between half a dozen different APIs (e.g, STL or MFC? Just for lists and things), there is just one that all other packages work cleanly with. The real bane for me with 3D is that when I work with some new software package the odds are that it uses a different vector package (GLEEM uses its own for example) and all of a sudden I do not have portable code. Remember: write once, run anywhere!

Vector algebra is a real basic of what we’re doing here. Perhaps we need the JCP to reexamine the javax.vecmath package (which I agree is sufficient but not very useable - though Java’s lack of user defined operators doesn’t help there).

I already build ontop of LWJGL’s math libs.
I WISH JOGL had some in there.
You could even consider GLUT(Not confused with GLU) methods to be a total waste but they are in JOGL too.
So why not actually add something more helpful like a math library for vectors, quaternions and matrices?

What’s worse is that no one offers any buffered operations on math libs.

Vectors and matrices are fundamental data structures. I would like to see them added but as primitves with special suport by the java vm. Just adding a common non-accelerated math api would not make much sense.

I would like 3 sets of matrices in the library:
3x3
4x4
n x m

The question is who do we make the request to?

What is the problem with using javax.vecmath from the the java3d project?

It has Matrix3d, Matrix3f, Matrix4d, Matrix4f and GMatrix.

As I migrate my application to JSR231, I have a question about nio.Buffer performance. In many cases (e.g. glLightfv()), I have a choice to use a primitive array with the extra 0 offset parameter or to supply an nio.Buffer. Is there much of a performance hit in wrapping an array in an nio.Buffer? While I can’t imagine it would be faster to supply the nio.Buffer, there are some cases where the type of array is not specified (e.g. glReadPixels()) and so I am forced to provide one.

Thanks,

Jo.

The overhead of wrapping an array in a Buffer is negligible. The Buffer objects are small and will be quickly reclaimed during the next young generation garbage collection. This should save you the overhead of tracking both the Buffer and the array throughout your system.

Hi,

Seing the brand new release of jogl i have decided to shift my old version to the new one.
Made the changes which often made my code simpler and cleaner. So firstly thanks for that :wink:

However at run time i got a nasty crash at the moment i am trying to load one FloatBuffer into the VRAM.

if(hasVBO)
		{
		VBOs=BufferUtil.newIntBuffer(3);
		gl.glGenBuffersARB(3, VBOs);
		gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOs.get(0));
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, nvertex * 3 * BufferUtil.SIZEOF_FLOAT, vertices, GL.GL_STATIC_DRAW_ARB);  <-----------------
		gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOs.get(1));
		gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, nvertex * 2 * BufferUtil.SIZEOF_FLOAT, texCoords, GL.GL_STATIC_DRAW_ARB);

		gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOs.get(2));	
		gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, nvertex * 3 * BufferUtil.SIZEOF_FLOAT, normals, GL.GL_STATIC_DRAW_ARB);
	
		normals=null;
		vertices=null;
		texCoords=null;
		}

The crash i got is an ACCESS_VIOLATION_EXCEPTION with the trace as follow. This was working perfectly fine before so i do not know what new thing deep inside could cause this? any one got the same problem.

If need more information please tell me and i will post everything you would need to solve the prob.

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x69661988, pid=2260, tid=4000
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode)
# Problematic frame:
# C  [nvoglnt.dll+0x161988]
#

---------------  T H R E A D  ---------------

Current thread (0x0b1d4ad0):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=4000]

siginfo: ExceptionCode=0xc0000005, reading address 0x0beab004

Registers:
EAX=0x000761cc, EBX=0x0c75c800, ECX=0x00001d87, EDX=0x0bea90cc
ESP=0x0b7df520, EBP=0x0b7df53c, ESI=0x0beaafcc, EDI=0x0ebaaf00
EIP=0x69661988, EFLAGS=0x00010206

Top of Stack: (sp=0x0b7df520)
0x0b7df520:   0cd100c0 0cc6f400 0c75c800 00000000
0x0b7df530:   00000001 00000002 69638fdd 0cd18fe8
0x0b7df540:   6963830d 0eba9000 0bea90cc 000780cc
0x0b7df550:   0c75c800 00000000 00000000 00000000
0x0b7df560:   69639673 0cd100c0 0c75c800 00000000
0x0b7df570:   000780cc 0bea90cc 0c75c800 0cd100c0
0x0b7df580:   00008892 695671d7 0cd100c0 00008892
0x0b7df590:   000088e4 0c75c800 000780cc 00000000 

Instructions: (pc=0x69661988)
0x69661978:   e9 06 8d 9b 00 00 00 00 0f 10 46 10 0f 10 4e 20
0x69661988:   0f 10 56 30 0f 10 1e 0f 2b 1f 0f 2b 47 10 0f 2b 


Stack: [0x0b7a0000,0x0b7e0000),  sp=0x0b7df520,  free space=253k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [nvoglnt.dll+0x161988]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.opengl.impl.GLImpl.dispatch_glBufferDataARB0(IILjava/lang/Object;IIJ)V+0
j  com.sun.opengl.impl.GLImpl.glBufferDataARB(IILjava/nio/Buffer;I)V+52   <-----------------
j  Hege3D.banqueObjets.Arbre.InitArbre(Ljavax/media/opengl/GL;Z)V+118
j  Hege3D.banqueObjets.Objets.InitObjets(ZLjavax/media/opengl/GL;Ljavax/media/opengl/glu/GLU;)V+729
j  Hege3D.interfacesGraphique.Scene3D.init(Ljavax/media/opengl/GLAutoDrawable;)V+154

Thanks

Did you call rewind() on your vertices buffer before passing it down to OpenGL? The positions of Buffers are significant in JSR-231, which is a difference from earlier JOGL versions (in the net.java.games.jogl.* namespace).

rewind did the trick!

I think it is worth to say that it is general to any method from the JSR api that uses Buffers, all of them need to have a rewind() call before they are used for the first time ;-).

I have a project I haven’t worked on for sometime, and now I tried to import it to (from NetBeans) Eclipse and use JOGL 2. All seems fine, except some constants and methods aren’t found… I’ve searched and found really nothing on it although I’m sure the explanation is somewhere…
Well the problem is:

gl.glMatrixMode(GL.GL_PROJECTION); GL_PROJECTION not found, also GL_MODELVIEW_MATRIX not found.. and other..
gl.glLoadIdentity(); <- not found

  gl.glBegin(GL.GL_LINES); glBegin not found
    gl.glVertex3f(1.3f, -1.0f, 0.0f); glVertex... not found
    gl.glVertex3f(1.3f, -1.0f, 8.1f);
  gl.glEnd();

  gl.glPushMatrix(); not found.. pop not found also..

My imports…
import java.awt.event.;
import javax.media.opengl.GL;
import javax.media.opengl.
;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.;
import javax.swing.
;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextArea;
import javax.media.opengl.glu.GLU;
import java.util.Timer;
import java.util.TimerTask;
import com.sun.opengl.util.*;
import com.sun.opengl.util.gl2.GLUT;

Can anyone point me in the right direction? Thanks…! :slight_smile:

I am having the same problems. Has anyone found out the answers?

warning complete newbie advise: I’ve succeeded after some considerable pawing around for java demo source, to get Gears.java up and running through Eclipse. You might need to change your code around a bit.

I think the issue is that the APIs have changed:

GL2 gl = drawable.getGL().getGL2();

gl.glMatrixMode(GL2.GL_PROJECTION);

source: http://kenai.com/projects/jogl/sources/jogl-demos-git/content/src/demos/gears/Gears.java?rev=2d5f1650af2b64f7a8d25842b2b95192b3e4a4e9

@teacup775, @rbrown, @safari JOGL 2.0 public APIs have changed a lot as it is explained here. The main GL interface has been divided into several smaller ones as you can see in the documentation.

WTF this is exactly 3 years old!

This thread is now non-sticky in order to focus less attention on outdated information.