0001: //-----------------------------------------------------------------------------
0002: // File: DirectX9Application1.h
0003: //
0004: // Desc: Header file DirectX9Application1 sample app
0005: //-----------------------------------------------------------------------------
0006: #pragma once
0007: 
0008: 
0009: 
0010: 
0011: //-----------------------------------------------------------------------------
0012: // Defines, and constants
0013: //-----------------------------------------------------------------------------
0014: // TODO: change "DirectX AppWizard Apps" to your name or the company name
0015: #define DXAPP_KEY        TEXT("Software\\DirectX AppWizard Apps\\DirectX9Application1")
0016: 
0017: // DirectInput action mapper reports events only when buttons/axis change
0018: // so we need to remember the present state of relevant axis/buttons for 
0019: // each DirectInput device.  The CInputDeviceManager will store a 
0020: // pointer for each device that points to this struct
0021: struct InputDeviceState
0022: {
0023:     // TODO: change as needed
0024:     FLOAT fAxisRotateLR;
0025:     BOOL  bButtonRotateLeft;
0026:     BOOL  bButtonRotateRight;
0027: 
0028:     FLOAT fAxisRotateUD;
0029:     BOOL  bButtonRotateUp;
0030:     BOOL  bButtonRotateDown;
0031: 
0032:     BOOL  bButtonPlaySoundButtonDown;
0033: };
0034: 
0035: 
0036: // Struct to store the current input state
0037: struct UserInput
0038: {
0039:     // TODO: change as needed
0040:     FLOAT fAxisRotateUD;
0041:     FLOAT fAxisRotateLR;
0042:     BOOL bPlaySoundButtonDown;
0043:     BOOL bDoConfigureInput;
0044:     BOOL bDoConfigureDisplay;
0045: };
0046: 
0047: 
0048: 
0049: 
0050: //-----------------------------------------------------------------------------
0051: // Name: class CMyD3DApplication
0052: // Desc: Application class. The base class (CD3DApplication) provides the 
0053: //       generic functionality needed in all Direct3D samples. CMyD3DApplication 
0054: //       adds functionality specific to this sample program.
0055: //-----------------------------------------------------------------------------
0056: class CMyD3DApplication : public CD3DApplication
0057: {
0058:     // ★シェーダが書かれたエフェクト
0059:     LPD3DXEFFECT     m_pEffect;      // ★シェーダが書かれたエフェクト
0060:     D3DXHANDLE       m_hmWVP;        // ★ワールド×ビュー×射影行列
0061: 
0062:     // ★計算で使う行列
0063:     D3DXMATRIX m_matWorld;
0064:     D3DXMATRIX m_matView;
0065:     D3DXMATRIX m_matProj;
0066: 
0067:     BOOL                    m_bLoadingApp;          // TRUE, if the app is loading
0068:     CD3DFont*               m_pFont;                // Font for drawing text
0069:     ID3DXMesh*              m_pD3DXMesh;            // D3DX mesh to store teapot
0070:     CInputDeviceManager*    m_pInputDeviceManager;  // DirectInput device manager
0071:     DIACTIONFORMAT          m_diafGame;             // Action format for game play
0072:     LPDIRECT3DSURFACE9      m_pDIConfigSurface;     // Surface for config'ing DInput devices
0073:     UserInput               m_UserInput;            // Struct for storing user input 
0074: 
0075:     FLOAT                   m_fSoundPlayRepeatCountdown; // Sound repeat timer
0076:     CMusicManager*          m_pMusicManager;        // DirectMusic manager class
0077:     CMusicSegment*          m_pBounceSound;         // Bounce sound
0078:     FLOAT                   m_fWorldRotX;           // World rotation state X-axis
0079:     FLOAT                   m_fWorldRotY;           // World rotation state Y-axis
0080: 
0081: protected:
0082:     virtual HRESULT OneTimeSceneInit();
0083:     virtual HRESULT InitDeviceObjects();
0084:     virtual HRESULT RestoreDeviceObjects();
0085:     virtual HRESULT InvalidateDeviceObjects();
0086:     virtual HRESULT DeleteDeviceObjects();
0087:     virtual HRESULT Render();
0088:     virtual HRESULT FrameMove();
0089:     virtual HRESULT FinalCleanup();
0090:     virtual HRESULT ConfirmDevice( D3DCAPS9*, DWORD, D3DFORMAT );
0091:     VOID    Pause( bool bPause );
0092: 
0093:     HRESULT RenderText();
0094: 
0095:     HRESULT InitInput( HWND hWnd );
0096:     void    UpdateInput( UserInput* pUserInput );
0097:     void    CleanupDirectInput();
0098:     HRESULT InitAudio( HWND hWnd );
0099: 
0100:     VOID    ReadSettings();
0101:     VOID    WriteSettings();
0102: 
0103: public:
0104:     LRESULT MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
0105:     CMyD3DApplication();
0106:     virtual ~CMyD3DApplication();
0107: 
0108:     HRESULT InputAddDeviceCB( CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi );
0109:     static HRESULT CALLBACK StaticInputAddDeviceCB( CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID pParam );   
0110:     BOOL    ConfigureInputDevicesCB( IUnknown* pUnknown );
0111:     static BOOL CALLBACK StaticConfigureInputDevicesCB( IUnknown* pUnknown, VOID* pUserData );
0112: };
0113: 
0114: