Render to VBO

Hello, Y’m implemetoing some renter to VBO with JOGL. I’m using the method:

  • Render to FBO
  • Transfer to VBO

The code in javais just a JOGLversion of the that I use in C++:


//Inside  transferiDatos()
        this.sistemaGrafico.glBindFramebufferEXT( GL.GL_FRAMEBUFFER_EXT, fbo.ID[0]);
        this.sistemaGrafico.glReadBuffer( GL.GL_COLOR_ATTACHMENT0_EXT );
        
        this.sistemaGrafico.glBindBuffer(GL.GL_PIXEL_PACK_BUFFER, vbo[0]);
	this.sistemaGrafico.glBufferData(GL.GL_PIXEL_PACK_BUFFER, fbo.width*fbo.height*4*4,null, GL.GL_STATIC_DRAW );
	
	this.sistemaGrafico.glReadPixels( 0,0, fbo.width, fbo.height, GL.GL_RGBA, GL.GL_FLOAT,null);
	
	this.sistemaGrafico.glReadBuffer(GL.GL_NONE);
	this.sistemaGrafico.glBindBuffer(GL.GL_PIXEL_PACK_BUFFER, 0 );

, where this.sistemaGrafico is a GL object. But I’m getting this exception:


Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: pack pixel_buffer_object must be disabled to call this method
        at com.sun.opengl.impl.GLImpl.checkBufferObject(GLImpl.java:30668)
        at com.sun.opengl.impl.GLImpl.checkPackPBODisabled(GLImpl.java:30695)
        at com.sun.opengl.impl.GLImpl.glReadPixels(GLImpl.java:17459)
        at com.fractal.Aplicacion.transferirDatos(Aplicacion.java:374)
        at com.fractal.Aplicacion.hazTodoElCalculo(Aplicacion.java:153)
        at com.fractal.Aplicacion.init(Aplicacion.java:451)
        at com.sun.opengl.impl.GLDrawableHelper.init(GLDrawableHelper.java:72)
        at javax.media.opengl.GLCanvas$InitAction.run(GLCanvas.java:418)
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:189)
        at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
        at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
        at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277)
        at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
        at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
        at sun.awt.RepaintArea.paint(RepaintArea.java:224)
        at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:683)
        at java.awt.Component.dispatchEventImpl(Component.java:4486)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


I don’t know what is going on. Please, some help please.


http://www.raul-art.blogspot.com/

Hi!
weel, I’ve solved the problem. Instead of sending NULL in the call glBufferData(), I use 0.
(Until now I didn’t know Java can accept int values where a object is expected )
Why this is different to many other parts of JOGL API.

You probably don’t realize what actually happened.

There is this feasture called ‘autoboxing’ in Java now. It wraps primitives into objects, when this is required to make a compilation successful.

Like:

Map<Integer, Integer> map = …;
map.put(13, 14); // this is changed to: map.put(Integer.valueOf(13), Integer.valueOf(14));

In your case, if the method is like:
glBufferData(…, Object obj);
and you call
glBufferData(…, 0);
you effectively call
glBufferData(…, Integer.valueOf(0));
which is probably not what you expected.

if
glBufferData(…, int off);
exists, it’s all fine ofcourse.

Ugh, don’t you just hate auto-boxing?
If I would have a say in it, I’d take autoboxing out of java yesterday.

Yup, and give us all permutations of Lists, Sets and Maps please :slight_smile:

thank you all, I did’nt know that! and thanks for your opinions too, I will investigate more on line.

Bye!