Hello there.
I wanted to play a video using a quad-stretched texture and for the test I made a simple class that gets a ByteBuffer with the first frame of the video and creates a texture from it. However, when I tried to do the same with PBO (which will allow me to update the texture faster in the future), only a solid white rectangle was displayed.
Here is my texture class now:
public class VidTexture {
int w, h, textureId, pbo;
VidTexture(int w, int h, ByteBuffer buf) {
this.w = w;
this.h = h;
buf.flip();
pbo = glGenBuffers();
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*3L, GL_STREAM_DRAW);
ByteBuffer bb = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
bb.put(buf);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
textureId = glGenTextures();
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindTexture(GL_TEXTURE_2D, textureId);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w,
h, 0, GL_BGR, GL_UNSIGNED_BYTE, 0);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, -1);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
buf.clear();
}
//Here is cleanUp and bind functions
}
Can anyone help me, please?