1 ////// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
2 //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
3 //// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
4 //// PARTICULAR PURPOSE.
6 //// Copyright (c) Microsoft Corporation. All rights reserved
10 #include "DirectXBase.h"
11 #include "SampleOverlay.h"
12 #include "AutoThrottle.h"
13 #include "BasicSprites.h"
14 #include "BasicLoader.h"
15 #include "GameStateMachine.h"
16 #include "SoundManager.h"
18 namespace ShootingGame {
30 // ref class MainPage;
32 ref class GameMain : public DirectXBase
36 delegate void SubFrameFuncDelegate(Windows::UI::Xaml::Controls::Page^ p);
37 delegate void IsBackButtonEnabledDelgate(bool v);
41 virtual void CreateDeviceIndependentResources() override;
42 virtual void CreateDeviceResources() override;
43 virtual void CreateWindowSizeDependentResources() override;
44 virtual void Render() override;
47 _In_ Windows::UI::Core::CoreWindow^ window,
48 _In_ Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ swapChainPanel,
52 void Update(float timeTotal, float timeDelta);
54 static const float BACKBUFFER_WIDTH;
55 static const float BACKBUFFER_HEIGHT;
57 sf::SoundManager& GameMain::SoundManager()
59 return *soundManager_;
62 sf::SoundDriver& GameMain::SoundDriver()
67 BasicSprites::SpriteBatch^ GameMain::SpriteBatch()
72 ::AutoThrottle^ GameMain::AutoThrottle() {return autoThrottle_;}
73 ::SampleOverlay^ GameMain::SampleOverlay() {return sampleOverlay_;}
76 float RandFloat(float min, float max);
82 void LoadTexture(const std::wstring& filename,ID3D11Texture2D** texPtrAddr);
84 void Subframe(Windows::UI::Xaml::Controls::Page^ p)
89 void SetSubFrameFunc(SubFrameFuncDelegate^ func)
91 subFrameFunction_ = func;
94 ShootingGame::GameStateMachine& GameMain::GameStateMachine()
99 void SetIsBackButtonEnabledDelgate(IsBackButtonEnabledDelgate^ d)
101 isBackButtonEnabledDelgate_ = d;
104 void IsBackButtonEnabled(bool v)
106 isBackButtonEnabledDelgate_(v);
110 // std::function<void(Windows::UI::Xaml::Controls::Page^ p)> subFrameFunction_;
111 SubFrameFuncDelegate^ subFrameFunction_;
112 IsBackButtonEnabledDelgate^ isBackButtonEnabledDelgate_;
113 ShootingGame::GameStateMachine state_;
114 void ExecuteSoundThread();
115 ::SampleOverlay^ sampleOverlay_;
116 ::AutoThrottle^ autoThrottle_;
117 BasicSprites::SpriteBatch^ spriteBatch_;
118 Microsoft::WRL::ComPtr<ID3D11Texture2D> backBuffer_;
119 Microsoft::WRL::ComPtr<ID3D11RenderTargetView> backBufferRenderTargetView_;
120 // Microsoft::WRL::ComPtr<ID3D11DepthStencilView> backBufferDepthStencilView_;
121 // Microsoft::WRL::ComPtr<ID3D11DepthStencilState> backBufferDepthStencilState_;
123 CD3D11_VIEWPORT backBufferViewPort_;
124 CD3D11_VIEWPORT swapChainViewPort_;
125 std::vector<CharacterData> characters_;
127 Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel_;
128 std::unique_ptr<sf::SoundManager> soundManager_;
129 std::unique_ptr<sf::SoundDriver> soundDriver_;
130 concurrency::task<void> soundTask_;
131 sf::handle_holder eventHolder_;