We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Using PBO's (pixel buffer objects) in processing
Page Index Toggle Pages: 1
Using PBO's (pixel buffer objects) in processing (Read 282 times)
Using PBO's (pixel buffer objects) in processing
Oct 21st, 2008, 1:15am
 
I've been trying to speed up my texture transfers using pbo's but haven't been successful yet.  I can get the texture to display but they come out garbled.  here's a code snippet:


PImage texImage = loadImage(filename);
int tex = new int[1];
int pbo = new int[1];

gl.glGenTextures(1, tex, 0);
gl.glBindTexture(GL.GL_TEXTURE_2D, tex[0]);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_GENERATE_MIPMAP, GL.GL_TRUE);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR_MIPMAP_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, texImage.width,texImage.height, 0, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, null);

gl.glGenBuffers(1, pbo, 0);
gl.glBindBuffer(GL.GL_PIXEL_UNPACK_BUFFER, pbo[0]);
gl.glBufferData(GL.GL_PIXEL_UNPACK_BUFFER, texImage.height* texImage.width*BufferUtil.SIZEOF_FLOAT, IntBuffer.wrap(texImage.pixels),GL.GL_STATIC_DRAW);
gl.glMapBuffer(GL.GL_PIXEL_UNPACK_BUFFER, GL.GL_WRITE_ONLY);
gl.glUnmapBuffer(GL.GL_PIXEL_UNPACK_BUFFER);
gl.glBindBuffer(GL.GL_PIXEL_UNPACK_BUFFER, 0);
gl.glEnable(GL.GL_TEXTURE_2D);



I suspect the culprit is in the gl.glBufferData call where i state:

texImage.height* texImage.width*BufferUtil.SIZEOF_FLOAT.

While i was messing around i was able to get the texture to display properly by using:

texImage.height* texImage.width*7

but for some reason this only worked when i ran the sketch the first couple of times and now the texture is corrupted every time, weird.  Any help would be greatly appreciated.
Page Index Toggle Pages: 1