home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / gamesystem / includes / gs_colour.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-18  |  2.8 KB  |  143 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    gsCColour
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    12/03/00
  8. //
  9. // Base:    gsCObject
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_GS_COLOUR_H
  16. #define _INCLUDE_GS_COLOUR_H
  17.  
  18. #include "gs_types.h"
  19. #include "gs_object.h"
  20. #include "gs_screen.h"
  21.  
  22. //-------------------------------------------------------------
  23. // Some useful colour constants
  24.  
  25. #define gsBLACK          0,  0,  0
  26. #define gsRED        255,  0,  0
  27. #define gsGREEN          0,255,  0
  28. #define gsBLUE          0,  0,255
  29. #define gsMAGENTA    255,  0,255
  30. #define gsCYAN          0,255,255
  31. #define gsYELLOW    255,255,  0
  32. #define gsWHITE        255,255,255
  33. #define gsORANGE    255,128,  0
  34. #define gsPINK        255,255,128
  35. #define gsBROWN        128, 64,  0
  36. #define gsDARKGREY     64, 64, 64
  37. #define gsMIDGREY    128,128,128
  38. #define gsLIGHTGREY    192,192,192
  39.  
  40. //-------------------------------------------------------------
  41. // Colour
  42.  
  43. class gsCColour : public gsCObject
  44. {
  45.     friend class gsCImage;
  46.     friend class gsCScreen;
  47.  
  48.     private:
  49.         gsUBYTE m_r;
  50.         gsUBYTE m_g;
  51.         gsUBYTE m_b;
  52.         gsUDWORD m_raw;
  53.  
  54.         static PALETTEENTRY *m_palette;
  55.         static int m_rshift;
  56.         static int m_gshift;
  57.         static int m_bshift;
  58.         static int m_rbits;
  59.         static int m_gbits;
  60.         static int m_bbits;
  61.         static int m_rmask;
  62.         static int m_bmask;
  63.         static int m_gmask;
  64.  
  65.         void updateRawColour();
  66.  
  67.     protected:
  68.  
  69.         static void setupColourConversion(gsCScreen *screen);
  70.  
  71.     public:
  72.         gsCColour();
  73.         gsCColour(int r,int g,int b);
  74.         gsCColour(const gsCColour& colour);
  75.         virtual ~gsCColour();
  76.  
  77.         void setRed(int r);
  78.         void setGreen(int g);
  79.         void setBlue(int b);
  80.  
  81.         int getRed() const;
  82.         int getGreen() const;
  83.         int getBlue() const;
  84.  
  85.         gsUDWORD getRaw() const;
  86. };
  87.  
  88. //-------------------------------------------------------------
  89.  
  90. inline void gsCColour::setRed(int r)
  91. {
  92.     m_r = (gsUBYTE) r;
  93.     updateRawColour();
  94. }
  95.  
  96. //-------------------------------------------------------------
  97.  
  98. inline void gsCColour::setGreen(int g)
  99. {
  100.     m_g = (gsUBYTE) g;
  101.     updateRawColour();
  102. }
  103.  
  104. //-------------------------------------------------------------
  105.  
  106. inline void gsCColour::setBlue(int b)
  107. {
  108.     m_b = (gsUBYTE) b;
  109.     updateRawColour();
  110. }
  111.  
  112. //-------------------------------------------------------------
  113.  
  114. inline int gsCColour::getRed() const
  115. {
  116.     return m_r;
  117. }
  118.  
  119. //-------------------------------------------------------------
  120.  
  121. inline int gsCColour::getGreen() const
  122. {
  123.     return m_g;
  124. }
  125.  
  126. //-------------------------------------------------------------
  127.  
  128. inline int gsCColour::getBlue() const
  129. {
  130.     return m_b;
  131. }
  132.  
  133. //-------------------------------------------------------------
  134.  
  135. inline gsUDWORD gsCColour::getRaw() const
  136. {
  137.     return m_raw;
  138. }
  139.  
  140. //-------------------------------------------------------------
  141.  
  142. #endif
  143.