views:

26

answers:

0

Hello guys, I'm using PBOs to load textures faster in my application. If I use an opengl 3 or better video card I can then easily build the mipmaps with a call to glGenerateMipmap and it works fine. But on my older opengl 2.1 card (radeon x800), that function is not available so i must use one of two legacy methods:

glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w,h, 0,GL_RGBA,GL_UNSIGNED_BYTE, src); 

or

gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA8, w,h, GL_RGBA,GL_UNSIGNED_BYTE, src);

The first method doesn't work fine even whitout the PBO, it introduces strange artifacts. The second one, whitout the PBO builds the correct mipmaps, and with the PBO generates a segfault. Anyone can help??

For completeness I attach the code I use for the PBO:

uint pixelBuffer;
glGenBuffers(1, &pixelBuffer);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixelBuffer);
glBufferData(GL_PIXEL_UNPACK_BUFFER, size*4, NULL, GL_STATIC_READ);
char *pixels = (char*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
... transfer data
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
... and then I use the buffer to create the texture

PS If I don't try to generate mipmaps, the pbo loading works on all my video cards.