Source code of Windows XP (NT5)
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.

105 lines
3.4 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: D3DApp.h
  3. //
  4. // Desc: Application class for the Direct3D samples framework library.
  5. //
  6. // Copyright (c) 1998-1999 Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef D3DAPP_H
  9. #define D3DAPP_H
  10. #define D3D_OVERLOADS
  11. #include <d3d.h>
  12. #include "D3DFrame.h"
  13. #include "D3DEnum.h"
  14. #include "D3DUtil.h"
  15. #include "D3DRes.h"
  16. //-----------------------------------------------------------------------------
  17. // Name: class CD3DApplication
  18. // Desc:
  19. //-----------------------------------------------------------------------------
  20. class CD3DApplication
  21. {
  22. // Internal variables and member functions
  23. CD3DFramework7* m_pFramework;
  24. BOOL m_bActive;
  25. BOOL m_bReady;
  26. BOOL m_bFrameMoving;
  27. BOOL m_bSingleStep;
  28. DWORD m_dwBaseTime;
  29. DWORD m_dwStopTime;
  30. HRESULT Initialize3DEnvironment();
  31. HRESULT Change3DEnvironment();
  32. HRESULT Render3DEnvironment();
  33. VOID Cleanup3DEnvironment();
  34. VOID DisplayFrameworkError(HRESULT, DWORD);
  35. protected:
  36. HWND m_hWnd;
  37. D3DEnum_DeviceInfo* m_pDeviceInfo;
  38. LPDIRECTDRAW7 m_pDD;
  39. LPDIRECT3D7 m_pD3D;
  40. LPDIRECT3DDEVICE7 m_pd3dDevice;
  41. LPDIRECTDRAWSURFACE7 m_pddsRenderTarget;
  42. LPDIRECTDRAWSURFACE7 m_pddsRenderTargetLeft; // For stereo modes
  43. DDSURFACEDESC2 m_ddsdRenderTarget;
  44. // Overridable variables for the app
  45. TCHAR* m_strWindowTitle;
  46. BOOL m_bAppUseZBuffer;
  47. BOOL m_bAppUseStereo;
  48. BOOL m_bShowStats;
  49. HRESULT (*m_fnConfirmDevice)(DDCAPS*, D3DDEVICEDESC7*);
  50. // Overridable functions for the 3D scene created by the app
  51. virtual HRESULT OneTimeSceneInit() { return S_OK; }
  52. virtual HRESULT InitDeviceObjects() { return S_OK; }
  53. virtual HRESULT DeleteDeviceObjects() { return S_OK; }
  54. virtual HRESULT Render() { return S_OK; }
  55. virtual HRESULT FrameMove(FLOAT) { return S_OK; }
  56. virtual HRESULT RestoreSurfaces() { return S_OK; }
  57. virtual HRESULT FinalCleanup() { return S_OK; }
  58. // Overridable power management (APM) functions
  59. virtual LRESULT OnQuerySuspend(DWORD dwFlags);
  60. virtual LRESULT OnResumeSuspend(DWORD dwData);
  61. // View control functions (for stereo-enabled applications)
  62. D3DMATRIX m_matLeftView;
  63. D3DMATRIX m_matRightView;
  64. D3DMATRIX m_matView;
  65. VOID SetAppLeftViewMatrix(D3DMATRIX mat) { m_matLeftView = mat; }
  66. VOID SetAppRightViewMatrix(D3DMATRIX mat) { m_matRightView = mat; }
  67. VOID SetAppViewMatrix(D3DMATRIX mat) { m_matView = mat; }
  68. VOID SetViewParams(D3DVECTOR* vEyePt, D3DVECTOR* vLookatPt,
  69. D3DVECTOR* vUpVec, FLOAT fEyeDistance);
  70. // Miscellaneous functions
  71. VOID ShowStats();
  72. VOID OutputText(DWORD x, DWORD y, TCHAR* str);
  73. public:
  74. // Functions to create, run, pause, and clean up the application
  75. virtual HRESULT Create(HINSTANCE, TCHAR*);
  76. virtual INT Run();
  77. virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  78. virtual VOID Pause(BOOL bPause);
  79. // Class constructor
  80. CD3DApplication();
  81. };
  82. #endif // D3DAPP_H