Hello Guest

How to use dds format in lwjgl2.9?

  • 1 Replies
  • 3437 Views
How to use dds format in lwjgl2.9?
« on: March 14, 2017, 08:17:59 »
found http://forum.lwjgl.org/index.php?topic=1264.msg8394#msg8394
API GL13.glCompressedTexImage2D is changed.Trying to change parameter such as
Code: [Select]
GL13.glCompressedTexImage2D(GL11.GL_TEXTURE_2D,0,dxtFormat,ddsDesc2.width,ddsDesc2.height,ddsDesc2.pitchOrLinearSize,imageData);
or
Code: [Select]
GL13.glCompressedTexImage2D(GL11.GL_TEXTURE_2D,0,dxtFormat,ddsDesc2.width,ddsDesc2.height,0,imageData);
It draws a black area on my lwjgl display,how to do it now?

Re: How to use dds format in lwjgl2.9?
« Reply #1 on: March 14, 2017, 14:12:05 »
Here is some old code i had which loaded DDS textures

Code: [Select]
        int width = dds.getHeader().getWidth();
        int height = dds.getHeader().getHeight();
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_FALSE);
        int mipMapCount = (dds.getHeader().getFlags() & dds.getHeader().DDSD_MIPMAPCOUNT) != 0 ? dds.getHeader().getMipMapCount() : 1;
        GL11.glTexParameteri (GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipMapCount-1);
        ByteBuffer data = BufferUtils.createByteBuffer(dds.getHeader().getData().length);
        data.put(dds.getHeader().getData());
        data.rewind();
        if (compressed)
        {
            for (int i = 0; i < mipMapCount; ++i)
            {                               
                int size = (Math.max(divSize, width) / divSize) * (Math.max(divSize, height) / divSize) * blockBytes;
                ByteBuffer mipMapData = BufferUtils.createByteBuffer(size);
                byte[] mipMapByte = new byte[size];
                data.get(mipMapByte);
                mipMapData.put(mipMapByte);
                mipMapData.rewind();
                GL13.glCompressedTexImage2D(GL11.GL_TEXTURE_2D, i, internalFormat, width, height, 0, mipMapData);
                width >>= 1;
                height >>= 1;

            }
        }