Jump to content
  • Advertisement
Sign in to follow this  
yoggie

OpenGL [OpenGL/SDL] 3D Textures

This topic is 3455 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 )

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites


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);


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!