]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/ddslib.h
Drop legacy Makefile
[xonotic/netradiant.git] / libs / ddslib.h
index 246e31be65b8160158ed7e64a6f8e97c0c1d8c60..4961f6ef6b17cca7817bf9f94c12d4edd7c3041f 100644 (file)
-/* -----------------------------------------------------------------------------\r
-\r
-DDS Library \r
-\r
-Based on code from Nvidia's DDS example:\r
-http://www.nvidia.com/object/dxtc_decompression_code.html\r
-\r
-Copyright (c) 2003 Randy Reddig\r
-All rights reserved.\r
-\r
-Redistribution and use in source and binary forms, with or without modification,\r
-are permitted provided that the following conditions are met:\r
-\r
-Redistributions of source code must retain the above copyright notice, this list\r
-of conditions and the following disclaimer.\r
-\r
-Redistributions in binary form must reproduce the above copyright notice, this\r
-list of conditions and the following disclaimer in the documentation and/or\r
-other materials provided with the distribution.\r
-\r
-Neither the names of the copyright holders nor the names of its contributors may\r
-be used to endorse or promote products derived from this software without\r
-specific prior written permission. \r
-\r
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\r
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\r
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
------------------------------------------------------------------------------ */\r
-\r
-\r
-\r
-/* marker */\r
-#ifndef DDSLIB_H\r
-#define DDSLIB_H\r
-\r
-\r
-\r
-/* dependencies */\r
-#include <stdio.h>\r
-#include <memory.h>\r
-\r
-\r
-\r
-/* c++ marker */\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-\r
-\r
-/* dds definition */\r
-typedef enum\r
-{\r
-       DDS_PF_ARGB8888,\r
-       DDS_PF_DXT1,\r
-       DDS_PF_DXT2,\r
-       DDS_PF_DXT3,\r
-       DDS_PF_DXT4,\r
-       DDS_PF_DXT5,\r
-       DDS_PF_UNKNOWN\r
-}\r
-ddsPF_t;\r
-\r
-\r
-/* 16bpp stuff */\r
-#define DDS_LOW_5              0x001F;\r
-#define DDS_MID_6              0x07E0;\r
-#define DDS_HIGH_5             0xF800;\r
-#define DDS_MID_555            0x03E0;\r
-#define DDS_HI_555             0x7C00;\r
-\r
-\r
-/* structures */\r
-typedef struct ddsColorKey_s\r
-{\r
-       unsigned int            colorSpaceLowValue;\r
-       unsigned int            colorSpaceHighValue;\r
-} \r
-ddsColorKey_t;\r
-\r
-\r
-typedef struct ddsCaps_s\r
-{\r
-       unsigned int            caps1;\r
-       unsigned int            caps2;\r
-       unsigned int            caps3;\r
-       unsigned int            caps4;\r
-} \r
-ddsCaps_t;\r
-\r
-\r
-typedef struct ddsMultiSampleCaps_s\r
-{\r
-       unsigned short          flipMSTypes;\r
-       unsigned short          bltMSTypes;\r
-}\r
-ddsMultiSampleCaps_t;\r
-\r
-\r
-typedef struct ddsPixelFormat_s\r
-{\r
-       unsigned int            size;\r
-       unsigned int            flags;\r
-       unsigned int            fourCC;\r
-       union\r
-       {\r
-               unsigned int    rgbBitCount;\r
-               unsigned int    yuvBitCount;\r
-               unsigned int    zBufferBitDepth;\r
-               unsigned int    alphaBitDepth;\r
-               unsigned int    luminanceBitCount;\r
-               unsigned int    bumpBitCount;\r
-               unsigned int    privateFormatBitCount;\r
-       };\r
-       union\r
-       {\r
-               unsigned int    rBitMask;\r
-               unsigned int    yBitMask;\r
-               unsigned int    stencilBitDepth;\r
-               unsigned int    luminanceBitMask;\r
-               unsigned int    bumpDuBitMask;\r
-               unsigned int    operations;\r
-       };\r
-       union\r
-       {\r
-               unsigned int    gBitMask;\r
-               unsigned int    uBitMask;\r
-               unsigned int    zBitMask;\r
-               unsigned int    bumpDvBitMask;\r
-               ddsMultiSampleCaps_t    multiSampleCaps;\r
-       };\r
-       union\r
-       {\r
-               unsigned int    bBitMask;\r
-               unsigned int    vBitMask;\r
-               unsigned int    stencilBitMask;\r
-               unsigned int    bumpLuminanceBitMask;\r
-       };\r
-       union\r
-       {\r
-               unsigned int    rgbAlphaBitMask;\r
-               unsigned int    yuvAlphaBitMask;\r
-               unsigned int    luminanceAlphaBitMask;\r
-               unsigned int    rgbZBitMask;\r
-               unsigned int    yuvZBitMask;\r
-       };\r
-}\r
-ddsPixelFormat_t;\r
-\r
-\r
-typedef struct ddsBuffer_s\r
-{\r
-       /* magic: 'dds ' */\r
-       char                            magic[ 4 ];\r
-       \r
-       /* directdraw surface */\r
-       unsigned int            size;\r
-       unsigned int            flags;\r
-       unsigned int            height;\r
-       unsigned int            width; \r
-       union\r
-       {\r
-               int                             pitch;\r
-               unsigned int    linearSize;\r
-       };\r
-       unsigned int            backBufferCount;\r
-       union\r
-       {\r
-               unsigned int    mipMapCount;\r
-               unsigned int    refreshRate;\r
-               unsigned int    srcVBHandle;\r
-       };\r
-       unsigned int            alphaBitDepth;\r
-       unsigned int            reserved;\r
-       void                            *surface;\r
-       union\r
-       {\r
-               ddsColorKey_t   ckDestOverlay;   \r
-               unsigned int    emptyFaceColor;\r
-       };\r
-       ddsColorKey_t           ckDestBlt;\r
-       ddsColorKey_t           ckSrcOverlay;    \r
-       ddsColorKey_t           ckSrcBlt;     \r
-       union\r
-       {\r
-               ddsPixelFormat_t        pixelFormat;\r
-               unsigned int    fvf;\r
-       };\r
-       ddsCaps_t                       ddsCaps;\r
-       unsigned int            textureStage;\r
-       \r
-       /* data (Varying size) */\r
-       unsigned char           data[ 4 ];\r
-}\r
-ddsBuffer_t;\r
-\r
-\r
-typedef struct ddsColorBlock_s\r
-{\r
-       unsigned short          colors[ 2 ];\r
-       unsigned char           row[ 4 ];\r
-}\r
-ddsColorBlock_t;\r
-\r
-\r
-typedef struct ddsAlphaBlockExplicit_s\r
-{\r
-       unsigned short          row[ 4 ];\r
-}\r
-ddsAlphaBlockExplicit_t;\r
-\r
-\r
-typedef struct ddsAlphaBlock3BitLinear_s\r
-{\r
-       unsigned char           alpha0;\r
-       unsigned char           alpha1;\r
-       unsigned char           stuff[ 6 ];\r
-}\r
-ddsAlphaBlock3BitLinear_t;\r
-\r
-\r
-typedef struct ddsColor_s\r
-{\r
-       unsigned char           r, g, b, a;\r
-}\r
-ddsColor_t;\r
-\r
-\r
-\r
-/* public functions */\r
-int                                            DDSGetInfo( ddsBuffer_t *dds, int *width, int *height, ddsPF_t *pf );\r
-int                                            DDSDecompress( ddsBuffer_t *dds, unsigned char *pixels );\r
-\r
-\r
-\r
-/* end marker */\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
+/* -----------------------------------------------------------------------------
+
+   DDS Library
+
+   Based on code from Nvidia's DDS example:
+   http://www.nvidia.com/object/dxtc_decompression_code.html
+
+   Copyright (c) 2003 Randy Reddig
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without modification,
+   are permitted provided that the following conditions are met:
+
+   Redistributions of source code must retain the above copyright notice, this list
+   of conditions and the following disclaimer.
+
+   Redistributions in binary form must reproduce the above copyright notice, this
+   list of conditions and the following disclaimer in the documentation and/or
+   other materials provided with the distribution.
+
+   Neither the names of the copyright holders nor the names of its contributors may
+   be used to endorse or promote products derived from this software without
+   specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+   ----------------------------------------------------------------------------- */
+
+
+
+/* marker */
+#ifndef DDSLIB_H
+#define DDSLIB_H
+
+
+
+/* dependencies */
+#include <stdio.h>
+#include <memory.h>
+
+
+
+/* c++ marker */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/* dds definition */
+typedef enum
+{
+       DDS_PF_ARGB8888,
+       DDS_PF_DXT1,
+       DDS_PF_DXT2,
+       DDS_PF_DXT3,
+       DDS_PF_DXT4,
+       DDS_PF_DXT5,
+       DDS_PF_UNKNOWN
+}
+ddsPF_t;
+
+
+/* 16bpp stuff */
+#define DDS_LOW_5       0x001F;
+#define DDS_MID_6       0x07E0;
+#define DDS_HIGH_5      0xF800;
+#define DDS_MID_555     0x03E0;
+#define DDS_HI_555      0x7C00;
+
+
+/* structures */
+typedef struct ddsColorKey_s
+{
+       unsigned int colorSpaceLowValue;
+       unsigned int colorSpaceHighValue;
+}
+ddsColorKey_t;
+
+
+typedef struct ddsCaps_s
+{
+       unsigned int caps1;
+       unsigned int caps2;
+       unsigned int caps3;
+       unsigned int caps4;
+}
+ddsCaps_t;
+
+
+typedef struct ddsMultiSampleCaps_s
+{
+       unsigned short flipMSTypes;
+       unsigned short bltMSTypes;
+}
+ddsMultiSampleCaps_t;
+
+
+typedef struct ddsPixelFormat_s
+{
+       unsigned int size;
+       unsigned int flags;
+       unsigned int fourCC;
+       union
+       {
+               unsigned int rgbBitCount;
+               unsigned int yuvBitCount;
+               unsigned int zBufferBitDepth;
+               unsigned int alphaBitDepth;
+               unsigned int luminanceBitCount;
+               unsigned int bumpBitCount;
+               unsigned int privateFormatBitCount;
+       };
+       union
+       {
+               unsigned int rBitMask;
+               unsigned int yBitMask;
+               unsigned int stencilBitDepth;
+               unsigned int luminanceBitMask;
+               unsigned int bumpDuBitMask;
+               unsigned int operations;
+       };
+       union
+       {
+               unsigned int gBitMask;
+               unsigned int uBitMask;
+               unsigned int zBitMask;
+               unsigned int bumpDvBitMask;
+               ddsMultiSampleCaps_t multiSampleCaps;
+       };
+       union
+       {
+               unsigned int bBitMask;
+               unsigned int vBitMask;
+               unsigned int stencilBitMask;
+               unsigned int bumpLuminanceBitMask;
+       };
+       union
+       {
+               unsigned int rgbAlphaBitMask;
+               unsigned int yuvAlphaBitMask;
+               unsigned int luminanceAlphaBitMask;
+               unsigned int rgbZBitMask;
+               unsigned int yuvZBitMask;
+       };
+}
+ddsPixelFormat_t;
+
+
+typedef struct ddsBuffer_s
+{
+       /* magic: 'dds ' */
+       char magic[ 4 ];
+
+       /* directdraw surface */
+       unsigned int size;
+       unsigned int flags;
+       unsigned int height;
+       unsigned int width;
+       union
+       {
+               int pitch;
+               unsigned int linearSize;
+       };
+       unsigned int backBufferCount;
+       union
+       {
+               unsigned int mipMapCount;
+               unsigned int refreshRate;
+               unsigned int srcVBHandle;
+       };
+       unsigned int alphaBitDepth;
+       unsigned int reserved;
+       void                *surface;
+       union
+       {
+               ddsColorKey_t ckDestOverlay;
+               unsigned int emptyFaceColor;
+       };
+       ddsColorKey_t ckDestBlt;
+       ddsColorKey_t ckSrcOverlay;
+       ddsColorKey_t ckSrcBlt;
+       union
+       {
+               ddsPixelFormat_t pixelFormat;
+               unsigned int fvf;
+       };
+       ddsCaps_t ddsCaps;
+       unsigned int textureStage;
+
+       /* data (Varying size) */
+       unsigned char data[ 4 ];
+}
+ddsBuffer_t;
+
+
+typedef struct ddsColorBlock_s
+{
+       unsigned short colors[ 2 ];
+       unsigned char row[ 4 ];
+}
+ddsColorBlock_t;
+
+
+typedef struct ddsAlphaBlockExplicit_s
+{
+       unsigned short row[ 4 ];
+}
+ddsAlphaBlockExplicit_t;
+
+
+typedef struct ddsAlphaBlock3BitLinear_s
+{
+       unsigned char alpha0;
+       unsigned char alpha1;
+       unsigned char stuff[ 6 ];
+}
+ddsAlphaBlock3BitLinear_t;
+
+
+typedef struct ddsColor_s
+{
+       unsigned char r, g, b, a;
+}
+ddsColor_t;
+
+
+
+/* public functions */
+int                     DDSGetInfo( ddsBuffer_t *dds, int *width, int *height, ddsPF_t *pf );
+int                     DDSDecompress( ddsBuffer_t *dds, unsigned char *pixels );
+
+
+
+/* end marker */
+#ifdef __cplusplus
+}
+#endif
+
+#endif