Browse Source

Documentation updates.
Reformatted the DirectDraw surface structures in Image.cpp.

Lasse Öörni 14 years ago
parent
commit
b78205cfe1
4 changed files with 99 additions and 118 deletions
  1. 1 1
      Engine/Audio/Audio.h
  2. 3 3
      Engine/Audio/Sound.cpp
  3. 5 20
      Engine/Core/Variant.h
  4. 90 94
      Engine/Resource/Image.cpp

+ 1 - 1
Engine/Audio/Audio.h

@@ -34,7 +34,7 @@ class AudioImpl;
 class Sound;
 class Sound;
 class SoundSource;
 class SoundSource;
 
 
-/// Audio subsystem
+/// Audio subsystem. Uses either DirectSound or SDL for sound output
 #ifndef USE_SDL
 #ifndef USE_SDL
 class Audio : public Object, public Thread
 class Audio : public Object, public Thread
 #else
 #else

+ 3 - 3
Engine/Audio/Sound.cpp

@@ -44,7 +44,7 @@ struct WavHeader
     unsigned char formatText_[4];
     unsigned char formatText_[4];
     unsigned formatLength_;
     unsigned formatLength_;
     unsigned short format_;
     unsigned short format_;
-    unsigned short soundSources_;
+    unsigned short channels_;
     unsigned frequency_;
     unsigned frequency_;
     unsigned avgBytes_;
     unsigned avgBytes_;
     unsigned short blockAlign_;
     unsigned short blockAlign_;
@@ -163,7 +163,7 @@ bool Sound::LoadWav(Deserializer& source)
     
     
     // Read the FORMAT chunk
     // Read the FORMAT chunk
     header.format_ = source.ReadUShort();
     header.format_ = source.ReadUShort();
-    header.soundSources_ = source.ReadUShort();
+    header.channels_ = source.ReadUShort();
     header.frequency_ = source.ReadUInt();
     header.frequency_ = source.ReadUInt();
     header.avgBytes_ = source.ReadUInt();
     header.avgBytes_ = source.ReadUInt();
     header.blockAlign_ = source.ReadUShort();
     header.blockAlign_ = source.ReadUShort();
@@ -198,7 +198,7 @@ bool Sound::LoadWav(Deserializer& source)
     // Allocate sound and load audio data
     // Allocate sound and load audio data
     unsigned length = header.dataLength_;
     unsigned length = header.dataLength_;
     SetSize(length);
     SetSize(length);
-    SetFormat(header.frequency_, header.bits_ == 16, header.soundSources_ == 2);
+    SetFormat(header.frequency_, header.bits_ == 16, header.channels_ == 2);
     source.Read(data_.GetPtr(), length);
     source.Read(data_.GetPtr(), length);
     
     
     // Convert 8-bit audio to signed
     // Convert 8-bit audio to signed

+ 5 - 20
Engine/Core/Variant.h

@@ -100,16 +100,10 @@ struct ResourceRef
     StringHash id_;
     StringHash id_;
     
     
     /// Test for equality with another reference
     /// Test for equality with another reference
-    bool operator == (const ResourceRef& rhs) const
-    {
-        return (type_ == rhs.type_) && (id_ == rhs.id_);
-    }
+    bool operator == (const ResourceRef& rhs) const { return (type_ == rhs.type_) && (id_ == rhs.id_); }
     
     
     /// Test for inequality with another reference
     /// Test for inequality with another reference
-    bool operator != (const ResourceRef& rhs) const
-    {
-        return (type_ != rhs.type_) || (id_ != rhs.id_);
-    }
+    bool operator != (const ResourceRef& rhs) const { return (type_ != rhs.type_) || (id_ != rhs.id_); }
 };
 };
 
 
 /// List of resource references of a specific type
 /// List of resource references of a specific type
@@ -138,16 +132,10 @@ struct ResourceRefList
     Vector<StringHash> ids_;
     Vector<StringHash> ids_;
     
     
     /// Test for equality with another reference list
     /// Test for equality with another reference list
-    bool operator == (const ResourceRefList& rhs) const
-    {
-        return (type_ == rhs.type_) && (ids_ == rhs.ids_);
-    }
+    bool operator == (const ResourceRefList& rhs) const { return (type_ == rhs.type_) && (ids_ == rhs.ids_); }
     
     
     /// Test for inequality with another reference list
     /// Test for inequality with another reference list
-    bool operator != (const ResourceRefList& rhs) const
-    {
-        return (type_ != rhs.type_) || (ids_ != rhs.ids_);
-    }
+    bool operator != (const ResourceRefList& rhs) const { return (type_ != rhs.type_) || (ids_ != rhs.ids_); }
 };
 };
 
 
 class Variant;
 class Variant;
@@ -485,10 +473,7 @@ public:
     bool operator == (const Variant& rhs) const;
     bool operator == (const Variant& rhs) const;
     
     
     /// Test for inequality with another variant
     /// Test for inequality with another variant
-    bool operator != (const Variant& rhs) const
-    {
-        return !(*this == rhs);
-    }
+    bool operator != (const Variant& rhs) const { return !(*this == rhs); }
     
     
     /// Test for equality with an integer. To return true, both the type and value must match
     /// Test for equality with an integer. To return true, both the type and value must match
     bool operator == (int rhs) const
     bool operator == (int rhs) const

+ 90 - 94
Engine/Resource/Image.cpp

@@ -34,14 +34,6 @@
 
 
 #include "DebugNew.h"
 #include "DebugNew.h"
 
 
-#ifndef DUMMYUNIONNAMEN
-#if defined(__cplusplus) || !defined(NONAMELESSUNION)
-#define DUMMYUNIONNAMEN(n)
-#else
-#define DUMMYUNIONNAMEN(n) u##n
-#endif
-#endif
-
 #ifndef MAKEFOURCC
 #ifndef MAKEFOURCC
 #define MAKEFOURCC(ch0, ch1, ch2, ch3) ((unsigned)(ch0) | ((unsigned)(ch1) << 8) | ((unsigned)(ch2) << 16) | ((unsigned)(ch3) << 24))
 #define MAKEFOURCC(ch0, ch1, ch2, ch3) ((unsigned)(ch0) | ((unsigned)(ch1) << 8) | ((unsigned)(ch2) << 16) | ((unsigned)(ch3) << 24))
 #endif
 #endif
@@ -52,118 +44,122 @@
 #define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
 #define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
 #define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))
 #define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))
 
 
-typedef struct _DDCOLORKEY
+/// DirectDraw surface color key
+struct DDColorKey
 {
 {
-    unsigned dwColorSpaceLowValue;
-    unsigned dwColorSpaceHighValue;
-} DDCOLORKEY;
+    unsigned dwColorSpaceLowValue_;
+    unsigned dwColorSpaceHighValue_;
+};
 
 
-typedef struct _DDPIXELFORMAT
+/// DirectDraw surface pixel format
+struct DDPixelFormat
 {
 {
-    unsigned dwSize;
-    unsigned dwFlags;
-    unsigned dwFourCC;
+    unsigned dwSize_;
+    unsigned dwFlags_;
+    unsigned dwFourCC_;
     union
     union
     {
     {
-        unsigned dwRGBBitCount;
-        unsigned dwYUVBitCount;
-        unsigned dwZBufferBitDepth;
-        unsigned dwAlphaBitDepth;
-        unsigned dwLuminanceBitCount;
-        unsigned dwBumpBitCount;
-        unsigned dwPrivateFormatBitCount;
-    } DUMMYUNIONNAMEN(1);
+        unsigned dwRGBBitCount_;
+        unsigned dwYUVBitCount_;
+        unsigned dwZBufferBitDepth_;
+        unsigned dwAlphaBitDepth_;
+        unsigned dwLuminanceBitCount_;
+        unsigned dwBumpBitCount_;
+        unsigned dwPrivateFormatBitCount_;
+    };
     union
     union
     {
     {
-        unsigned dwRBitMask;
-        unsigned dwYBitMask;
-        unsigned dwStencilBitDepth;
-        unsigned dwLuminanceBitMask;
-        unsigned dwBumpDuBitMask;
-        unsigned dwOperations;
-    } DUMMYUNIONNAMEN(2);
+        unsigned dwRBitMask_;
+        unsigned dwYBitMask_;
+        unsigned dwStencilBitDepth_;
+        unsigned dwLuminanceBitMask_;
+        unsigned dwBumpDuBitMask_;
+        unsigned dwOperations_;
+    };
     union
     union
     {
     {
-        unsigned dwGBitMask;
-        unsigned dwUBitMask;
-        unsigned dwZBitMask;
-        unsigned dwBumpDvBitMask;
+        unsigned dwGBitMask_;
+        unsigned dwUBitMask_;
+        unsigned dwZBitMask_;
+        unsigned dwBumpDvBitMask_;
         struct
         struct
         {
         {
-            unsigned short wFlipMSTypes;
-            unsigned short wBltMSTypes;
-        } MultiSampleCaps;
-    } DUMMYUNIONNAMEN(3);
+            unsigned short wFlipMSTypes_;
+            unsigned short wBltMSTypes_;
+        } multiSampleCaps_;
+    };
     union
     union
     {
     {
-        unsigned dwBBitMask;
-        unsigned dwVBitMask;
-        unsigned dwStencilBitMask;
-        unsigned dwBumpLuminanceBitMask;
-    } DUMMYUNIONNAMEN(4);
+        unsigned dwBBitMask_;
+        unsigned dwVBitMask_;
+        unsigned dwStencilBitMask_;
+        unsigned dwBumpLuminanceBitMask_;
+    };
     union
     union
     {
     {
-        unsigned dwRGBAlphaBitMask;
-        unsigned dwYUVAlphaBitMask;
-        unsigned dwLuminanceAlphaBitMask;
-        unsigned dwRGBZBitMask;
-        unsigned dwYUVZBitMask;
-    } DUMMYUNIONNAMEN(5);
-} DDPIXELFORMAT;
+        unsigned dwRGBAlphaBitMask_;
+        unsigned dwYUVAlphaBitMask_;
+        unsigned dwLuminanceAlphaBitMask_;
+        unsigned dwRGBZBitMask_;
+        unsigned dwYUVZBitMask_;
+    };
+};
 
 
-typedef struct _DDSCAPS2
+/// DirectDraw surface capabilities
+struct DDSCaps2
 {
 {
-    unsigned dwCaps;
-    unsigned dwCaps2;
-    unsigned dwCaps3;
+    unsigned dwCaps_;
+    unsigned dwCaps2_;
+    unsigned dwCaps3_;
     union
     union
     {
     {
-        unsigned dwCaps4;
-        unsigned dwVolumeDepth;
-    } DUMMYUNIONNAMEN(1);
-} DDSCAPS2;
+        unsigned dwCaps4_;
+        unsigned dwVolumeDepth_;
+    };
+};
 
 
-typedef struct _DDSURFACEDESC2
+/// DirectDraw surface description
+struct DDSurfaceDesc2
 {
 {
-    unsigned dwSize;
-    unsigned dwFlags;
-    unsigned dwHeight;
-    unsigned dwWidth;
+    unsigned dwSize_;
+    unsigned dwFlags_;
+    unsigned dwHeight_;
+    unsigned dwWidth_;
     union
     union
     {
     {
-        long lPitch;
-        unsigned dwLinearSize;
-    } DUMMYUNIONNAMEN(1);
+        long lPitch_;
+        unsigned dwLinearSize_;
+    };
     union
     union
     {
     {
-        unsigned dwBackBufferCount;
-        unsigned dwDepth;
-    } DUMMYUNIONNAMEN(5);
+        unsigned dwBackBufferCount_;
+        unsigned dwDepth_;
+    };
     union
     union
     {
     {
-        unsigned dwMipMapCount;
-        unsigned dwRefreshRate;
-        unsigned dwSrcVBHandle;
-    } DUMMYUNIONNAMEN(2);
-    unsigned dwAlphaBitDepth;
-    unsigned dwReserved;
-    void* lpSurface;
+        unsigned dwMipMapCount_;
+        unsigned dwRefreshRate_;
+        unsigned dwSrcVBHandle_;
+    };
+    unsigned dwAlphaBitDepth_;
+    unsigned dwReserved_;
+    void* lpSurface_;
     union
     union
     {
     {
-        DDCOLORKEY ddckCKDestOverlay;
-        unsigned dwEmptyFaceColor;
-    } DUMMYUNIONNAMEN(3);
-    DDCOLORKEY ddckCKDestBlt;
-    DDCOLORKEY ddckCKSrcOverlay;
-    DDCOLORKEY ddckCKSrcBlt;
+        DDColorKey ddckCKDestOverlay_;
+        unsigned dwEmptyFaceColor_;
+    };
+    DDColorKey ddckCKDestBlt_;
+    DDColorKey ddckCKSrcOverlay_;
+    DDColorKey ddckCKSrcBlt_;
     union
     union
     {
     {
-        DDPIXELFORMAT ddpfPixelFormat;
-        unsigned dwFVF;
-    } DUMMYUNIONNAMEN(4);
-    DDSCAPS2 ddsCaps;
-    unsigned dwTextureStage;
-} DDSURFACEDESC2;
+        DDPixelFormat ddpfPixelFormat_;
+        unsigned dwFVF_;
+    };
+    DDSCaps2 ddsCaps_;
+    unsigned dwTextureStage_;
+};
 
 
 OBJECTTYPESTATIC(Image);
 OBJECTTYPESTATIC(Image);
 
 
@@ -206,10 +202,10 @@ bool Image::Load(Deserializer& source)
     else
     else
     {
     {
         // DDS compressed format
         // DDS compressed format
-        DDSURFACEDESC2 ddsd;
+        DDSurfaceDesc2 ddsd;
         source.Read(&ddsd, sizeof(ddsd));
         source.Read(&ddsd, sizeof(ddsd));
         
         
-        switch (ddsd.ddpfPixelFormat.dwFourCC)
+        switch (ddsd.ddpfPixelFormat_.dwFourCC_)
         {
         {
         case FOURCC_DXT1:
         case FOURCC_DXT1:
             compressedFormat_ = CF_DXT1;
             compressedFormat_ = CF_DXT1;
@@ -233,9 +229,9 @@ bool Image::Load(Deserializer& source)
 
 
         unsigned dataSize = source.GetSize() - source.GetPosition();
         unsigned dataSize = source.GetSize() - source.GetPosition();
         data_ = new unsigned char[dataSize];
         data_ = new unsigned char[dataSize];
-        width_ = ddsd.dwWidth;
-        height_ = ddsd.dwHeight;
-        numCompressedLevels_ = ddsd.dwMipMapCount;
+        width_ = ddsd.dwWidth_;
+        height_ = ddsd.dwHeight_;
+        numCompressedLevels_ = ddsd.dwMipMapCount_;
         if (!numCompressedLevels_)
         if (!numCompressedLevels_)
             numCompressedLevels_ = 1;
             numCompressedLevels_ = 1;
         SetMemoryUse(dataSize);
         SetMemoryUse(dataSize);