home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / CDX.ZIP / Src / Cdx / CDX.h next >
Encoding:
C/C++ Source or Header  |  1998-09-14  |  3.9 KB  |  142 lines

  1. //////////////////////////////////////////////////////////////////////////////////
  2. // Project Name: [ CDX Class Library - CDX.lib ]
  3. // Author:       [ Dan Farley - 97308096@brookes.ac.uk ]
  4. // Source File:  [ Main Header File ]
  5. // Revision:     [ 1.6 ]
  6. //////////////////////////////////////////////////////////////////////////////////
  7. #ifndef CDX_H
  8. #define CDX_H
  9.  
  10. #include <stdio.h>
  11. #include <ddraw.h>
  12. #include <d3d.h>
  13.  
  14. //////////////////////////////////////////////////////////////////////////////////
  15. // Definied Types
  16. //////////////////////////////////////////////////////////////////////////////////
  17.  
  18. #define SAFE_RELEASE(x) if(x != NULL) { x->Release(); x = NULL; }
  19. #define SAFE_DELETE(x) if(x != NULL) { delete x; x = NULL; }
  20.  
  21. #define CDXCREATE_FULLSCREEN   0x00000001L
  22. #define CDXCREATE_NO_FPUSETUP  0x00000002L
  23. #define CDXCREATE_ZBUFFER      0x00000004L
  24. #define CDXCREATE_3D           0x00000008L
  25.  
  26. class CDX_Surface;
  27.  
  28. //////////////////////////////////////////////////////////////////////////////////
  29. // CDX_Screen Class
  30. //////////////////////////////////////////////////////////////////////////////////
  31.  
  32. class CDX_Screen
  33. {
  34. public:
  35.     CDX_Screen(void);
  36.     ~CDX_Screen(void);
  37.  
  38.     HRESULT Create(HWND hwnd, DWORD width, DWORD height, DWORD bpp, DWORD flags);
  39.     HRESULT Restore(void);
  40.     HRESULT Flip(void);
  41.  
  42.     LPDIRECTDRAW4 GetDD(void) { return m_DirectDraw; }
  43.     LPDIRECT3D3 GetD3D(void) { return m_Direct3D; }
  44.     LPDIRECT3DDEVICE3 GetDevice(void) { return m_Device; }
  45.     LPDIRECT3DVIEWPORT3 GetViewport(void) { return m_Viewport; }
  46.  
  47.     CDX_Surface* GetFront(void) { return m_FrontBuffer; }
  48.     CDX_Surface* GetBack(void)  { return m_BackBuffer; }
  49.     CDX_Surface* GetDepth(void) { return m_DepthBuffer; }
  50.  
  51.     int GetWidth(void) { return m_Width; }
  52.     int GetHeight(void) { return m_Height; }
  53.     int GetBpp(void) { return m_Bpp; }
  54.  
  55. public:
  56.     void Initialise(void);
  57.     void Finalise(void);
  58.  
  59.     HRESULT CreateDirectDraw(void);
  60.     HRESULT CreateBuffers(void);
  61.     HRESULT CreateZBuffer(void);
  62.     HRESULT CreateDirect3D(void);
  63.     HRESULT CreateDevice(void);
  64.     HRESULT CreateViewport(void);
  65.  
  66.     LPDIRECTDRAW4 m_DirectDraw;
  67.     LPDIRECT3D3 m_Direct3D;
  68.     LPDIRECT3DDEVICE3 m_Device;
  69.     LPDIRECT3DVIEWPORT3 m_Viewport;
  70.  
  71.     D3DDEVICEDESC m_DeviceDesc;
  72.     DDPIXELFORMAT m_PixelFormat;
  73.     DWORD m_MemoryType;
  74.  
  75.     CDX_Surface* m_FrontBuffer;
  76.     CDX_Surface* m_BackBuffer;
  77.     CDX_Surface* m_DepthBuffer;
  78.  
  79.     HWND  m_Hwnd;
  80.     DWORD m_Width;
  81.     DWORD m_Height;
  82.     DWORD m_Bpp;
  83.     RECT  m_ScreenRect;
  84.     RECT  m_ViewportRect;
  85.     BOOL  m_IsFullScreen;
  86.     BOOL  m_Is3D;
  87.     BOOL  m_IsFPU;
  88. };
  89.  
  90. //////////////////////////////////////////////////////////////////////////////////
  91. // CDX_Surface Class
  92. //////////////////////////////////////////////////////////////////////////////////
  93.  
  94. class CDX_Surface
  95. {
  96. public:
  97.     CDX_Surface();
  98.     ~CDX_Surface();
  99.  
  100.     void Initialise(void);
  101.     void Finalise(void);
  102.  
  103.     HRESULT Create(CDX_Screen*);
  104.     HRESULT Create(CDX_Screen*, int , int);
  105.  
  106.     HRESULT LoadBitmap(CDX_Screen*, const char*);
  107.      HRESULT CopyBitmap(HBITMAP, int, int, int, int);
  108.     HRESULT Restore(void);
  109.     HRESULT Lock(void);
  110.     HRESULT UnLock(void);
  111.     HRESULT GetDC(void) { return m_Surface->GetDC(&m_DC); }
  112.     HRESULT ReleaseDC(void) { return m_Surface->ReleaseDC(m_DC); }
  113.     HRESULT Fill(DWORD);
  114.     HRESULT SetColorKey(COLORREF);
  115.     HRESULT SetFont(const char*, int, int, int Attributes = FW_NORMAL);
  116.     HRESULT TextXY(int X, int Y, COLORREF, const char*);
  117.     virtual HRESULT Draw(CDX_Surface* Dest, DWORD Flags);
  118.     virtual HRESULT DrawFast(int X, int Y, CDX_Surface* Dest, DWORD Flags);
  119.  
  120.     void SetSrc(int, int, int, int);
  121.     void SetDest(int, int, int, int);
  122.     int  GetWidth(void)  { return m_Width; }
  123.     int  GetHeight(void) { return m_Height; }
  124.     LPDIRECTDRAWSURFACE4 GetSurface(void) { return m_Surface; }
  125.  
  126. public:
  127.     LPDIRECTDRAWSURFACE4 m_Surface;
  128.     DDSURFACEDESC2 m_Desc;
  129.     DDSCAPS2 m_Caps;
  130.  
  131.     int  m_Width;
  132.     int  m_Height;
  133.     RECT m_SrcRect;
  134.     RECT m_DestRect;
  135.  
  136.     HDC m_DC;
  137.     HFONT m_Font;
  138.     const char* m_Filename;
  139. };
  140.  
  141. #endif
  142.