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

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    gsCScreen
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    12/03/00
  8. //
  9. // Base:    gsCVisual
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_GS_SCREEN_H
  16. #define _INCLUDE_GS_SCREEN_H
  17.  
  18. #include "gs_object.h"
  19. #include "gs_colour.h"
  20. #include "gs_visual.h"
  21. #include "gs_image.h"
  22. #include "gs_tiledimage.h"
  23. #include "gs_timer.h"
  24.  
  25. //-------------------------------------------------------------
  26.  
  27. typedef enum {
  28.     gsBLIT_NORMAL,            // normal blit
  29.     gsBLIT_NORMAL_MASKED,    // don't draw pixels = colour_key
  30.     gsBLIT_SHADOW,            // don't draw pixels = colour_key, draw all other pixels in tint_colour
  31.     gsBLIT_REPLACE,            // replace pixels = source_colour with tint_colour
  32.     gsBLIT_REPLACE_MASKED,    // don't draw pixels = colour_key, replace pixels = source_colour with tint_colour
  33. } gsBlitMode;
  34.  
  35. //-------------------------------------------------------------
  36.  
  37. class gsCScreen : public gsCVisual
  38. {
  39.     friend class gsCColour;
  40.     friend class gsCImage;
  41.     friend class gsCTiledImage;
  42.  
  43.     private:
  44.         static gsLPDIRECTDRAWSURFACE m_primary_surface;
  45.         static gsLPDIRECTDRAWSURFACE m_back_surface;
  46.         static gsLPDIRECTDRAWCLIPPER m_clipper;
  47.         static gsLPDIRECTDRAWPALETTE m_palette;
  48.  
  49.         static DDBLTFX m_ddbltfx;
  50.  
  51.         static bool m_isWindowed;
  52.            static gsCRect m_window_rect;
  53.         static gsCRect m_viewport_rect;
  54.         static gsCRect m_screen_rect;
  55.  
  56.         static bool m_display_mode_set;
  57.         static int m_bpp;
  58.  
  59.         void findBPP();
  60.  
  61.         gsDDSURFACEDESC m_ddsd;
  62.         bool m_isLocked;
  63.  
  64.         bool createDefaultPalette();
  65.  
  66.     protected:
  67.  
  68.         gsLPDIRECTDRAWSURFACE getBackSurface() const;
  69.         gsLPDIRECTDRAWSURFACE getPrimarySurface() const;
  70.  
  71.         PALETTEENTRY m_palette_colours[256];
  72.  
  73.         bool lock();
  74.         void unlock();
  75.  
  76.         void draw_pixel(const gsCPoint& position,const gsCColour& colour);
  77.         void draw_pixels(int num_points,const gsCPoint *position,const gsCColour *colour,bool clip = true);
  78.  
  79.         void draw_hline(int x1,int x2,int y,const gsCColour& colour);
  80.         void draw_vline(int x,int y1,int y2,const gsCColour& colour);
  81.  
  82.         bool bltSolid(const gsCRect& dest,gsDDSURFACEDESC& source_ddsd,const gsCRect& source,const gsCColour& fill_colour);
  83.         bool bltTinted(const gsCRect& dest,gsDDSURFACEDESC& source_ddsd,const gsCRect& source,const gsCColour& tint_colour);
  84.  
  85.     public:
  86.         gsCScreen();
  87.         virtual ~gsCScreen();
  88.  
  89.         bool createFullScreen(HWND window,const gsCPoint& size,gsDWORD bitdepth);
  90.         bool createWindowed(HWND window);
  91.         bool destroy();
  92.  
  93.         bool flip();
  94.  
  95.         void updateRect(HWND window);
  96.  
  97.         gsCPoint getSize() const;
  98.         gsCRect getRect() const;
  99.  
  100.         int getBytesPerPixel();
  101.         
  102.         void clear(const gsCColour& colour);
  103.  
  104.         void drawPoint(const gsCPoint& position,const gsCColour& colour);
  105.         void drawLine(const gsCPoint& from,const gsCPoint& to,const gsCColour& colour);
  106.         void drawRect(const gsCRect& rect,const gsCColour& colour);
  107.         bool drawSolidRect(const gsCRect& rect,const gsCColour& colour);
  108.         void drawPoints(int count,const gsCPoint *points,const gsCColour *colours,bool clip = true);
  109.         void drawLines(int count,const gsCPoint *points,const gsCColour *colours);
  110.  
  111.         bool loadPalette(const char *filename);
  112. };
  113.  
  114. //-------------------------------------------------------------
  115.  
  116. inline gsLPDIRECTDRAWSURFACE gsCScreen::getBackSurface() const
  117. {
  118.     return m_back_surface;
  119. }
  120.  
  121. //-------------------------------------------------------------
  122.  
  123. inline gsLPDIRECTDRAWSURFACE gsCScreen::getPrimarySurface() const
  124. {
  125.     return m_primary_surface;
  126. }
  127.  
  128. //-------------------------------------------------------------
  129.  
  130. inline gsCPoint gsCScreen::getSize() const
  131. {
  132.     return m_screen_rect.getSize();
  133. }
  134.  
  135. //-------------------------------------------------------------
  136.  
  137. inline gsCRect gsCScreen::getRect() const
  138. {
  139.     return gsCRect(gsCPoint(0,0),getSize());
  140. }
  141.  
  142. //-------------------------------------------------------------
  143.  
  144. #endif
  145.  
  146.