View Full Version : segmentation error with glTexImage3D

Elias OpenGL
07-29-2010, 02:00 PM

I need help you.

I am recovering pixels value of a image, 16 bits, single value, when I load a data to graphics card, I have a segmentation error.

My code is:

glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, width, heigth, depth, 0, GL_LUMINANCE,GL_UNSIGNED_SHORT , vol);

this parameters are, width, heigth, dept, and vol,

any suggestion? I was intended to load the data as LUMINANCE or INTENSITY, but also gives me error.


07-29-2010, 02:12 PM
are you sure *vol is big enough ?
2*4*width*height*depth bytes ?

07-29-2010, 02:29 PM
are you sure *vol is big enough ?
2*4*width*height*depth bytes ?
Doesnt luminance take single component?
There could be also the thing with pack/unpack alignment being 4 by default (depending on the texture dimensions).

07-29-2010, 03:06 PM
Yes, my bad, I stopped at the internal format GL_RGBA (why not GL_LUMINANCE8 by the way ?), the *4 should not be here.

And you are right, default alignment is 4 bytes, so that can matter if the 3D texture is non-power-of-two.

Try this otherwise :
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);