Due to the nature of my application, most of the textures being loaded aren't packaged with the application itself and are loaded on the fly. Therefore, they can't be compressed before-hand. When I load new textures, I package everything onto atlases with glTexSubImage2D. I've recently found out the amount of textures I have can take up quite a bit of memory and so I'm trying to get "on the fly" texture compression working.
Here's the simple version of my (C#) code:
Code :// Load textures from disk //... // Create the atlas GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); // Copy the textures to the atlas GL.TexSubImage2D(TextureTarget.Texture2D, 0, (int)x, (int)y, (int)Width, (int)Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmpData.Scan0);
Now what I've tried doing is switching the atlas' internal format to CompressedRgbaS3tcDxt3Ext instead of Rgba. That works fine, it's only after I try subbing the texture into the atlas is when I get a GL_INVALID_OPERATION error.
I've googled the issue and there doesn't seem to be anything out there explaining this situation and how to properly sub uncompressed images into a compressed format.