[OpenGL/SDL] 3D Textures
I want to use 3D textures for my terrain but didn't get the expected result so far.
Here is what I've done:
I loaded the address of the glTexImage3D function into the function pointer
PFNGLTEXIMAGE3DPROC glTexImage3D;
glTexImage3D = (PFNGLTEXIMAGE3DPROC) SDL_GL_GetProcAddress("glTexImage3D");
and stored the textures in different SDL_Surfaces.
My problem is now how do I get the pixel data of the surfaces suitable for the last argument of glTexImage3D(... , const GLvoid *pixels )
SDL_surfaces I assume are 2d only
thus if u pass the info to glTexImage3D its gonna be wrong, youre gonna haveta create the 3d texture data yourself eg it can be multiple 2d textures stacked
thus if u pass the info to glTexImage3D its gonna be wrong, youre gonna haveta create the 3d texture data yourself eg it can be multiple 2d textures stacked
Quote:Original post by zedz
SDL_surfaces I assume are 2d only
thus if u pass the info to glTexImage3D its gonna be wrong, youre gonna haveta create the 3d texture data yourself eg it can be multiple 2d textures stacked
yes, thats what I was trying to do. I stored 4 textures in 4 different surfaces but I don't know how I get this data suitable for glTexImage3D
I already tried to memcpy the surface->pixels to a char array, but this attempt ends up in garbage
unsigned char* image3D = new unsigned char[w*h*channels*depth];//depth can be the # of 2d textures//loop through first sdl 2d image and assign that data to image3D//loop through next image....glTexImage3D(..., image3D);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement