Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ddutil.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------- 00002 // File: ddutil.cpp 00003 // 00004 // Desc: Routines for loading bitmap and palettes from resources 00005 // 00006 // Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved. 00007 //----------------------------------------------------------------------------- 00008 #ifndef DDUTIL_H 00009 #define DDUTIL_H 00010 00011 #include <ddraw.h> 00012 #include <d3d.h> 00013 00014 00015 00016 00017 //----------------------------------------------------------------------------- 00018 // Classes defined in this header file 00019 //----------------------------------------------------------------------------- 00020 class CDisplay; 00021 class CSurface; 00022 00023 00024 00025 00026 //----------------------------------------------------------------------------- 00027 // Flags for the CDisplay and CSurface methods 00028 //----------------------------------------------------------------------------- 00029 #define DSURFACELOCK_READ 00030 #define DSURFACELOCK_WRITE 00031 00032 00033 00034 00035 //----------------------------------------------------------------------------- 00036 // Name: class CDisplay 00037 // Desc: Class to handle all DDraw aspects of a display, including creation of 00038 // front and back buffers, creating offscreen surfaces and palettes, 00039 // and blitting surface and displaying bitmaps. 00040 //----------------------------------------------------------------------------- 00041 class CDisplay 00042 { 00043 protected: 00044 LPDIRECTDRAW7 m_pDD; 00045 LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer; 00046 LPDIRECTDRAWSURFACE7 m_pddsBackBuffer; 00047 LPDIRECTDRAWSURFACE7 m_pddsBackBufferLeft; // For stereo modes 00048 00049 HWND m_hWnd; 00050 RECT m_rcWindow; 00051 BOOL m_bWindowed; 00052 BOOL m_bStereo; 00053 00054 public: 00055 CDisplay(); 00056 ~CDisplay(); 00057 00058 // Access functions 00059 HWND GetHWnd() { return m_hWnd; } 00060 LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; } 00061 LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; } 00062 LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; } 00063 LPDIRECTDRAWSURFACE7 GetBackBufferLEft() { return m_pddsBackBufferLeft; } 00064 00065 // Status functions 00066 BOOL IsWindowed() { return m_bWindowed; } 00067 BOOL IsStereo() { return m_bStereo; } 00068 00069 // Creation/destruction methods 00070 HRESULT CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight, 00071 DWORD dwBPP ); 00072 HRESULT CreateWindowedDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight ); 00073 HRESULT InitClipper(); 00074 HRESULT UpdateBounds(); 00075 virtual HRESULT DestroyObjects(); 00076 00077 // Methods to create child objects 00078 HRESULT CreateSurface( CSurface** ppSurface, DWORD dwWidth, 00079 DWORD dwHeight ); 00080 HRESULT CreateSurfaceFromBitmap( CSurface** ppSurface, TCHAR* strBMP, 00081 DWORD dwDesiredWidth, 00082 DWORD dwDesiredHeight ); 00083 HRESULT CreateSurfaceFromText( CSurface** ppSurface, HFONT hFont, 00084 TCHAR* strText, 00085 COLORREF crBackground, 00086 COLORREF crForeground ); 00087 HRESULT CreatePaletteFromBitmap( LPDIRECTDRAWPALETTE* ppPalette, const TCHAR* strBMP ); 00088 00089 // Display methods 00090 HRESULT Clear( DWORD dwColor = 0L ); 00091 HRESULT ColorKeyBlt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds, 00092 RECT* prc = NULL ); 00093 HRESULT Blt( DWORD x, DWORD y, LPDIRECTDRAWSURFACE7 pdds, 00094 RECT* prc=NULL, DWORD dwFlags=0 ); 00095 HRESULT Blt( DWORD x, DWORD y, CSurface* pSurface, RECT* prc = NULL ); 00096 HRESULT ShowBitmap( HBITMAP hbm, LPDIRECTDRAWPALETTE pPalette=NULL ); 00097 HRESULT SetPalette( LPDIRECTDRAWPALETTE pPalette ); 00098 HRESULT Present(); 00099 }; 00100 00101 00102 00103 00104 //----------------------------------------------------------------------------- 00105 // Name: class CSurface 00106 // Desc: Class to handle aspects of a DirectDrawSurface. 00107 //----------------------------------------------------------------------------- 00108 class CSurface 00109 { 00110 LPDIRECTDRAWSURFACE7 m_pdds; 00111 DDSURFACEDESC2 m_ddsd; 00112 BOOL m_bColorKeyed; 00113 00114 public: 00115 LPDIRECTDRAWSURFACE7 GetDDrawSurface() { return m_pdds; } 00116 BOOL IsColorKeyed() { return m_bColorKeyed; } 00117 00118 HRESULT DrawBitmap( HBITMAP hBMP, DWORD dwBMPOriginX = 0, DWORD dwBMPOriginY = 0, 00119 DWORD dwBMPWidth = 0, DWORD dwBMPHeight = 0 ); 00120 HRESULT DrawBitmap( TCHAR* strBMP, DWORD dwDesiredWidth, DWORD dwDesiredHeight ); 00121 HRESULT DrawText( HFONT hFont, TCHAR* strText, DWORD dwOriginX, DWORD dwOriginY, 00122 COLORREF crBackground, COLORREF crForeground ); 00123 00124 HRESULT SetColorKey( DWORD dwColorKey ); 00125 DWORD ConvertGDIColor( COLORREF dwGDIColor ); 00126 static HRESULT GetBitMaskInfo( DWORD dwBitMask, DWORD* pdwShift, DWORD* pdwBits ); 00127 00128 HRESULT Create( LPDIRECTDRAW7 pDD, DDSURFACEDESC2* pddsd ); 00129 HRESULT Create( LPDIRECTDRAWSURFACE7 pdds ); 00130 HRESULT Destroy(); 00131 00132 CSurface(); 00133 ~CSurface(); 00134 }; 00135 00136 00137 00138 00139 #endif // DDUTIL_H 00140

Generated on Fri May 21 19:22:36 2004 for LIBELL by doxygen 1.3.7