PDA

View Full Version : glTexImage3D Memory Access Exception



Live_MusIc
10-18-2014, 10:11 AM
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..

Live_MusIc
10-18-2014, 11:27 AM
Found the solution. If an admin wants please close or delete the thread. The problem was that glTexImage3D was not defined yet so I got the "Unhandled exception at 0x00000000" as it direction was pointing to NULL.