Hi everyone. Im trying to load an image data into a GL_TEXTURE_3D target, the basic code is as follows:
#define XSIZE 128
#define YSIZE 32
#define ZSIZE 32
------------------------------------------------------------------------------[/INDENT]
unsigned char* buffer = new unsigned char[XSIZE * YSIZE * ZSIZE];[INDENT]GLuint image = 0;
//Load buffer data
for (unsigned int i = 0; i < XSIZE * YSIZE * ZSIZE; i++){buffer[i] = 1;}
glEnable(GL_TEXTURE_3D);
glGenTextures(1, &image);
glBindTexture(GL_TEXTURE_3D, image);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY , XSIZE, YSIZE, ZSIZE, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, buffer);
Simple as that, but while executing the program just crashes at this last line with: Unhandled exception at 0x00000000 in App.exe: 0xC0000005: Access violation.
I tried using glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); before glTexImage3D (as im using 1byte per texel, read about this fix somewhere), but the result is the same…