How to use dds format in lwjgl2.9?

Started by rtmsoft, March 14, 2017, 08:17:59

Previous topic - Next topic

rtmsoft

found http://forum.lwjgl.org/index.php?topic=1264.msg8394#msg8394
API GL13.glCompressedTexImage2D is changed.Trying to change parameter such as
GL13.glCompressedTexImage2D(GL11.GL_TEXTURE_2D,0,dxtFormat,ddsDesc2.width,ddsDesc2.height,ddsDesc2.pitchOrLinearSize,imageData);

or
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?

darkyellow

Here is some old code i had which loaded DDS textures

        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;

            }
        }