Experiences of migrating from JOGL 1.1.1 to JSR231

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.