glGenBuffersARB problem

I am having a problem getting a handle to a buffer using glGenBuffersARB()

It’s pretty staright forward code:


    int[] tmp = new int[1];
    gl.glGenBuffersARB(1, tmp);
    int name = tmp[0];

When running with DebugGL turned on, I get this trace (which also looks odd because of so many GL_INVALID_OPERATION messsages):


net.java.games.jogl.GLException: glGetError() returned the following error codes after a call to glGenBuffersARB(): GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION GL_INVALID_OPERATION 
	at net.java.games.jogl.DebugGL.checkGLGetError(DebugGL.java:14844)
	at net.java.games.jogl.DebugGL.glGenBuffersARB(DebugGL.java:3535)
	at com.vorax.geometry.GeoObject.getVBOBuffer(GeoObject.java:1590)
	at com.vorax.geometry.GeoObject.allocateCoordsBuffer1(GeoObject.java:1697)
	at com.vorax.geometry.GeoObject.setTexCoords(GeoObject.java:252)
	at com.vorax.objloader.ObjectFile.makeScene(ObjectFile.java:1082)
	at com.vorax.objloader.ObjectFile.load(ObjectFile.java:1159)
	at com.vorax.objloader.ObjectFile.load(ObjectFile.java:581)
	at com.vorax.gameobjs.ships.Ship.loadShip(Ship.java:247)
	at com.vorax.gameobjs.ships.Ship.<init>(Ship.java:154)
	at com.vorax.gameobjs.ships.StarterShip.<init>(StarterShip.java:72)
	at com.vorax.objects.Player.loadModel(Player.java:135)
	at com.vorax.VoraxEngine.makePlayer(VoraxEngine.java:549)
	at com.vorax.VoraxEngine.doStartLevel(VoraxEngine.java:901)
	at com.vorax.VoraxEngine.access$0(VoraxEngine.java:861)
	at com.vorax.VoraxEngine$1.run(VoraxEngine.java:835)
	at java.lang.Thread.run(Thread.java:534)    

This is on the very first call to glGenBuffersARB. The only thing that I can think of that’s different is I am calling glGenBuffersARB within the display() method. That’s allowed isn’t it? Is this a JOGL bug, or am I on crack? ???

Any help is appreciated.

Judging from your stack trace above, I think you meant to say that you/re not calling glGenBuffersARB from within your display() method, and this is in fact your problem. You must call it only while one of your GLEventListeners’ methods is active on the stack.

Thanks Ken!

Yes - I forgot the not…your eyes are sharp.

That makes sense. I’ve had similar problems in the past with other calls due to threading, but didn’t clue in on this one.