Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
6.3 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //-----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgDirectDrawDisplay.h
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of LgDirectDrawDisplay.h
  13. //-----------------------------------------------------------------------------
  14. //-----------------------------------------------------------------------------
  15. // File: ddutil.cpp
  16. //
  17. // Desc: Routines for loading bitmap and palettes from resources
  18. //
  19. // Copyright (C) 1998-2001 Microsoft Corporation. All Rights Reserved.
  20. //-----------------------------------------------------------------------------
  21. #ifndef DDUTIL_H
  22. #define DDUTIL_H
  23. #include <ddraw.h>
  24. #include <d3d.h>
  25. #include "..\LgImageDIB.h"
  26. #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
  27. #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
  28. //-----------------------------------------------------------------------------
  29. // Classes defined in this header file
  30. //-----------------------------------------------------------------------------
  31. class CLgDirectDrawDisplay;
  32. class CLgDirectDrawSurface;
  33. //-----------------------------------------------------------------------------
  34. // Flags for the CLgDirectDrawDisplay and CLgDirectDrawSurface methods
  35. //-----------------------------------------------------------------------------
  36. #define DSURFACELOCK_READ
  37. #define DSURFACELOCK_WRITE
  38. //-----------------------------------------------------------------------------
  39. // Name: class CLgDirectDrawDisplay
  40. // Desc: Class to handle all DDraw aspects of a display, including creation of
  41. // front and back buffers, creating offscreen surfaces and palettes,
  42. // and blitting surface and displaying bitmaps.
  43. //-----------------------------------------------------------------------------
  44. class CLgDirectDrawDisplay
  45. {
  46. protected:
  47. LPDIRECTDRAW7 m_pDD;
  48. LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer;
  49. LPDIRECTDRAWSURFACE7 m_pddsBackBuffer;
  50. LPDIRECTDRAWSURFACE7 m_pddsBackBufferLeft; // For stereo modes
  51. HWND m_hWnd;
  52. RECT m_rcWindow;
  53. BOOL m_bWindowed;
  54. BOOL m_bStereo;
  55. public:
  56. CLgDirectDrawDisplay();
  57. ~CLgDirectDrawDisplay();
  58. // Access functions
  59. HWND GetHWnd() { return m_hWnd; }
  60. LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; }
  61. LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; }
  62. LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; }
  63. LPDIRECTDRAWSURFACE7 GetBackBufferLeft() { return m_pddsBackBufferLeft; }
  64. // Status functions
  65. BOOL IsWindowed() { return m_bWindowed; }
  66. BOOL IsStereo() { return m_bStereo; }
  67. // Creation/destruction methods
  68. HRESULT CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight,
  69. DWORD dwBPP );
  70. HRESULT CreateWindowedDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight );
  71. HRESULT InitClipper();
  72. HRESULT UpdateBounds();
  73. virtual HRESULT DestroyObjects();
  74. // Methods to create child objects
  75. HRESULT CreateSurface( CLgDirectDrawSurface** ppSurface, DWORD dwWidth,
  76. DWORD dwHeight );
  77. HRESULT CreateSurfaceFromBitmap( CLgDirectDrawSurface** ppSurface, TCHAR* strBMP,
  78. DWORD dwDesiredWidth,
  79. DWORD dwDesiredHeight );
  80. HRESULT CreateSurfaceFromText( CLgDirectDrawSurface** ppSurface, HFONT hFont,
  81. TCHAR* strText,
  82. COLORREF crBackground,
  83. COLORREF crForeground );
  84. HRESULT CreatePaletteFromBitmap( LPDIRECTDRAWPALETTE* ppPalette, const TCHAR* strBMP );
  85. // Display methods
  86. HRESULT Clear( DWORD dwColor = 0L );
  87. HRESULT ColorKeyBlt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds,
  88. RECT* prc = NULL );
  89. HRESULT Blt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds,
  90. RECT* prc=NULL, DWORD dwFlags=0 );
  91. HRESULT Blt( DWORD x, DWORD y, CLgDirectDrawSurface* pSurface, RECT* prc = NULL );
  92. HRESULT Blt( CLgDirectDrawSurface *pSurface, PRECT pDstRect = NULL, RECT* prc = NULL, DWORD dwFlags = 0 );
  93. HRESULT ShowBitmap( HBITMAP hbm, LPDIRECTDRAWPALETTE pPalette=NULL );
  94. HRESULT SetPalette( LPDIRECTDRAWPALETTE pPalette );
  95. HRESULT Present();
  96. HRESULT RestoreAllSurfaces();
  97. HRESULT BackBufferDrawText( HFONT hFont, TCHAR* strText, PRECT pRect, DWORD dwFlags, COLORREF crForeground, BOOL bTransparent = TRUE, COLORREF crBackground = RGB(0,0,0) );
  98. };
  99. //-----------------------------------------------------------------------------
  100. // Name: class CLgDirectDrawSurface
  101. // Desc: Class to handle aspects of a DirectDrawSurface.
  102. //-----------------------------------------------------------------------------
  103. class CLgDirectDrawSurface
  104. {
  105. LPDIRECTDRAWSURFACE7 m_pdds;
  106. DDSURFACEDESC2 m_ddsd;
  107. BOOL m_bColorKeyed;
  108. public:
  109. LPDIRECTDRAWSURFACE7 GetDDrawSurface() { return m_pdds; }
  110. BOOL IsColorKeyed() { return m_bColorKeyed; }
  111. HRESULT DrawBitmap( HBITMAP hBMP, DWORD dwBMPOriginX = 0, DWORD dwBMPOriginY = 0,
  112. DWORD dwBMPWidth = 0, DWORD dwBMPHeight = 0 );
  113. HRESULT DrawBitmap( CLgImageDIB *pImageDIB );
  114. HRESULT DrawBitmap( TCHAR* strBMP, DWORD dwDesiredWidth, DWORD dwDesiredHeight );
  115. HRESULT DrawText( HFONT hFont, TCHAR* strText, DWORD dwOriginX, DWORD dwOriginY,
  116. COLORREF crBackground, COLORREF crForeground, BOOL bTransparent );
  117. HRESULT SetColorKey( DWORD dwColorKey );
  118. DWORD ConvertGDIColor( COLORREF dwGDIColor );
  119. static HRESULT GetBitMaskInfo( DWORD dwBitMask, DWORD* pdwShift, DWORD* pdwBits );
  120. HRESULT Clear( DWORD dwColor );
  121. HRESULT Create( LPDIRECTDRAW7 pDD, DDSURFACEDESC2* pddsd );
  122. HRESULT Create( LPDIRECTDRAWSURFACE7 pdds );
  123. HRESULT Destroy();
  124. CLgDirectDrawSurface();
  125. ~CLgDirectDrawSurface();
  126. public:
  127. SIZE GetSize() { SIZE size = { m_ddsd.dwWidth, m_ddsd.dwHeight }; return size; }
  128. };
  129. #endif // DDUTIL_H