DDDevice.h
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:6k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1998-1999 DXGuide. All Rights Reserved.
- // File: DDDevice.h
- #ifndef _DDDEVICE__H
- #define _DDDEVICE__H
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- #include <ddraw.h>
- // turn off warnings for /W4
- #pragma warning(disable: 4201)
- #include <d3d.h>
- #pragma warning(default: 4201)
- #include "DDModeInfoObject.h"
- #include "D3DDeviceInfoObject.h"
- #include "DXDriverInfoObject.h" // base class define
- #include <afxtempl.h>
- class CDDSurface;
- class CDDPalette;
- class CPackFileManager;
- class CDDDevice : public CDXDriverInfoObject
- {
- friend class CDirectDraw;
- friend class CDDSurface;
- friend class CDDPalette;
- public:
- // Flags for DDInit
- enum DDInitFlag
- {
- DDIF_ENABLED = 0x00000001L,
- DDIF_WINDOWED = 0x00000002L,
- DDIF_NO_FLIP = 0x00000004L,
- DDIF_NO_BACKBUFFER = 0x00000008L, // Don't create and use a backbuffer
- DDIF_BACKBUFFERINSYSTEMMEMORY = 0x00000010L, // create backbuffer in system memory
- DDIF_TRIPLEBUFFER = 0x00000020L, // using triple buffering
- DDIF_3D = 0x00000100L,
- DDIF_MULTIMON = 0x00000200L,
- DDIF_SETDEVICEWND = 0x00000400L,
- D3DIF_NO_FPUSETUP = 0x00010000L, // Don't use default DDSCL_FPUSETUP flag
- D3DIF_ZBUFFER = 0x00020000L, // Create and use a zbuffer
- D3DIF_STENCILBUFFER = 0x00040000L, // Use a z-buffer w/stenciling
- };
- protected:
- CDDDevice(void);
- virtual ~CDDDevice();
- protected:
- virtual bool Create(HWND hWnd, DWORD dwFlags);
- public:
- // inline functions.
- DWORD GetWidth(void) const;
- DWORD GetHeight(void) const;
- DWORD GetBPP(void) const;
- CDDSurface* GetFront(void) const;
- CDDSurface* GetBack(void) const;
- CDDSurface* GetRenderSurface(void) const;
- CDDPalette* GetPalette(void) const;
- // Does this driver have 3D hardware capabilites?
- bool IsSupport3D(void) const;
- bool IsSupportGDI(void) const;
- bool IsCanRenderWindowed(void) const;
- bool IsCanFlipNoVsync(void) const;
- void SetCaps(const DDCAPS* pDDCapsHAL, const DDCAPS* pDDCapsHEL);
- DDCAPS* GetCaps(void) const;
- bool SelectD3DDevice(int nPos);
- protected:
- void SetEnabled(void);
- protected:
- DDCAPS* m_pDDCapsHAL;
- DDCAPS* m_pDDCapsHEL;
- protected:
- // DDraw interface pointers
- LPDIRECTDRAW7 m_lpDD;
- // descriptive data structures
- HMONITOR m_hMonitor;
- MONITORINFOEX m_MonitorInfo;
- LPRECT m_lpMonitorRect;
- DWORD m_dwWidth; // Dimensions of the render target
- DWORD m_dwHeight;
- protected:
- DWORD m_dwDDInitFlags;
- HWND m_hWnd;
- CDDSurface* m_pDDSFront; // The primary surface
- CDDSurface* m_pDDSBack; // The backbuffer surface
- CDDSurface* m_pDDSRenderTarget; // The render target surface
- CDDPalette* m_pPalette;
- LPDIRECTDRAWCLIPPER m_lpClipper;
- DWORD m_dwBPP; // Bit depth of the current display mode
- int m_nMonitorNo;
- RECT m_rcScreenRect; // Screen rect for window
- RECT m_rcViewportRect; // Offscreen rect for VPort
- protected:
- bool CreateDirectDrawInterface(GUID FAR* lpGuid);
- public:
- void Move(int x, int y);
- // Functions for managing viewport bounds
- const RECT* GetViewportRect(void) const;
- const RECT* GetScreenRect(void) const;
- public:
- bool LoadPalette(LPCTSTR lpszFileName,
- CPackFileManager* pPackFileManager = NULL,
- bool bFromDIB = true);
- HRESULT Flip(void);
- public:
- HRESULT SetCooperativeLevel(HWND hWnd, DWORD dwFlags);
- HRESULT TestCooperativeLevel(void);
- DWORD GetMonitorFrequency(void) const;
- DWORD GetScanLine(void) const;
- bool GetVerticalBlankStatus(void) const;
- HRESULT WaitForVerticalBlank(DWORD dwFlags) const;
- HRESULT GetAvailableVidMem(DWORD dwCaps, DWORD& dwTotal,
- DWORD& dwFree) const;
- DWORD GetGDIMem(void) const;
- HRESULT RestoreDisplayMode(void);
- HRESULT SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP,
- DWORD dwRefreshRate, DWORD dwFlags);
- HRESULT GetDisplayMode(LPDDSURFACEDESC2 lpDDSurfaceDesc);
- HRESULT FlipToGDISurface(void);
- HRESULT GetDeviceIdentifier(
- LPDDDEVICEIDENTIFIER2 lpdddi, DWORD dwFlags) const;
- protected:
- HRESULT CreatePalette(DWORD dwFlags,
- LPPALETTEENTRY lpDDColorArray,
- LPDIRECTDRAWPALETTE FAR* lplpDDPalette);
- HRESULT CreateSurface(
- LPDDSURFACEDESC2 lpDDSurfaceDesc2,
- LPDIRECTDRAWSURFACE7 FAR* lplpDDSurface);
- public:
- bool LoadD3DDeviceInfos(LPDIRECT3D7 lpD3D);
- CD3DDeviceInfoObject* GetSelectedD3DDeviceInfoObject(void) const;
- bool SelectD3DDevice(const _GUID* const lpGuid);
- bool SelectDefaultD3DDevice(void);
- int GetD3DDeviceNumber(void) const;
- protected:
- void AddD3DDeviceInfo(
- LPSTR lpDeviceDescription,
- LPSTR lpDeviceName,
- LPD3DDEVICEDESC7 lpD3DDesc);
- static HRESULT CALLBACK D3DEnumDevicesCallback7(
- LPSTR lpDeviceDescription,
- LPSTR lpDeviceName,
- LPD3DDEVICEDESC7 lpD3DDeviceDesc,
- LPVOID lpContext);
- protected:
- CTypedPtrArray<CObArray, CD3DDeviceInfoObject*> m_d3dDeviceInfoArray;
- int m_nSelectedD3DDeviceInfoPos;
- public:
- bool IsEnabled(void) const;
- bool LoadDisplayModeInfos(void);
- protected:
- CDDModeInfoObject* GetSelectedModeInfoObject(void) const;
- public:
- bool SelectDisplayMode(int nPos);
- bool SelectDisplayMode(bool bFullScreen,
- DWORD dwWidth, DWORD dwHeight, DWORD dwBPP);
- bool SelectDisplayMode(const DDSURFACEDESC2* pDDSD);
- int GetModeNumber(void) const;
- protected:
- static HRESULT WINAPI EnumModesCallback2(
- LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext);
- void AddModeInfo(const DDSURFACEDESC2* pDDSD);
- protected:
- CTypedPtrArray<CObArray, CDDModeInfoObject*> m_ddDisplayModeInfoArray;
- int m_nSelectedDisplayModeInfoPos;
- };
- #include "DDDevice.inl"
- #endif // _DDDEVICE__H