2
votes

Here's what I want to do: I want to load a plain image file (.png, .tga, .bmp, etc), upload this image to OpenGL as a texture, tell OpenGL to generate mipmaps for the texture, tell OpenGL to compress the image (with S3TC/RGTC), then download the entire compressed/mipmapped texture, save it into a file, and later be able to load the entire texture into OpenGL at once.

I've already managed the first 3 steps. I use SDL2_Image to handle image loading, I can upload said image via glTexImage2D(), and I can create mipmaps using glGenerateMipmap(). From there, I'm pretty much lost, but I can figure out how to compress the images without much trouble.

What I need help with is the final bit - downloading the entire compressed+mipmapped texture as a single, contiguous block of data, saving it to file (at the content authoring stage), and later uploading the whole thing at once (at runtime). Any advice for where I can start?

PS. I'm using OpenGL 3.3 as my minimum version.

1

1 Answers

1
votes

You can compress to S3TC or DXT using rygDXT real time compressor, because there is no DXT compression embedded in the driver. Most DXT compressors are offline (not real time) and needs seconds or minutes to run.

You also have nvdxt, nvidia SDK provides full code sample to compress textures in DXT but its slow I warn you. ryg DXT should be faster.

Then for upward copy you should be able to copy the texture into a dynamic ("staging" in DX terms) buffer and then map the dynamic buffer to memory using some lock (glMapBuffer?) then memcopy.