forked from microsoft/graphics-driver-samples
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial check-in of boiler plate DX11 sample code.
- Loading branch information
Bart House
authored and
Bart House
committed
Jan 28, 2016
1 parent
1b8e03c
commit 24fc873
Showing
30 changed files
with
2,448 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ Release | |
*.vcxproj.user | ||
*.suo | ||
*.ipch | ||
*.opendb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
#include "pch.h" | ||
#include "App.h" | ||
|
||
#include <ppltasks.h> | ||
|
||
using namespace dolphin; | ||
|
||
using namespace concurrency; | ||
using namespace Windows::ApplicationModel; | ||
using namespace Windows::ApplicationModel::Core; | ||
using namespace Windows::ApplicationModel::Activation; | ||
using namespace Windows::UI::Core; | ||
using namespace Windows::UI::Input; | ||
using namespace Windows::System; | ||
using namespace Windows::Foundation; | ||
using namespace Windows::Graphics::Display; | ||
|
||
// The main function is only used to initialize our IFrameworkView class. | ||
[Platform::MTAThread] | ||
int main(Platform::Array<Platform::String^>^) | ||
{ | ||
auto direct3DApplicationSource = ref new Direct3DApplicationSource(); | ||
CoreApplication::Run(direct3DApplicationSource); | ||
return 0; | ||
} | ||
|
||
IFrameworkView^ Direct3DApplicationSource::CreateView() | ||
{ | ||
return ref new App(); | ||
} | ||
|
||
App::App() : | ||
m_windowClosed(false), | ||
m_windowVisible(true) | ||
{ | ||
} | ||
|
||
// The first method called when the IFrameworkView is being created. | ||
void App::Initialize(CoreApplicationView^ applicationView) | ||
{ | ||
// Register event handlers for app lifecycle. This example includes Activated, so that we | ||
// can make the CoreWindow active and start rendering on the window. | ||
applicationView->Activated += | ||
ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated); | ||
|
||
CoreApplication::Suspending += | ||
ref new EventHandler<SuspendingEventArgs^>(this, &App::OnSuspending); | ||
|
||
CoreApplication::Resuming += | ||
ref new EventHandler<Platform::Object^>(this, &App::OnResuming); | ||
|
||
// At this point we have access to the device. | ||
// We can create the device-dependent resources. | ||
m_deviceResources = std::make_shared<DX::DeviceResources>(); | ||
} | ||
|
||
// Called when the CoreWindow object is created (or re-created). | ||
void App::SetWindow(CoreWindow^ window) | ||
{ | ||
window->SizeChanged += | ||
ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &App::OnWindowSizeChanged); | ||
|
||
window->VisibilityChanged += | ||
ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &App::OnVisibilityChanged); | ||
|
||
window->Closed += | ||
ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &App::OnWindowClosed); | ||
|
||
DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); | ||
|
||
currentDisplayInformation->DpiChanged += | ||
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDpiChanged); | ||
|
||
currentDisplayInformation->OrientationChanged += | ||
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnOrientationChanged); | ||
|
||
DisplayInformation::DisplayContentsInvalidated += | ||
ref new TypedEventHandler<DisplayInformation^, Object^>(this, &App::OnDisplayContentsInvalidated); | ||
|
||
m_deviceResources->SetWindow(window); | ||
} | ||
|
||
// Initializes scene resources, or loads a previously saved app state. | ||
void App::Load(Platform::String^ entryPoint) | ||
{ | ||
if (m_main == nullptr) | ||
{ | ||
m_main = std::unique_ptr<dolphinMain>(new dolphinMain(m_deviceResources)); | ||
} | ||
} | ||
|
||
// This method is called after the window becomes active. | ||
void App::Run() | ||
{ | ||
while (!m_windowClosed) | ||
{ | ||
if (m_windowVisible) | ||
{ | ||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); | ||
|
||
m_main->Update(); | ||
|
||
if (m_main->Render()) | ||
{ | ||
m_deviceResources->Present(); | ||
} | ||
} | ||
else | ||
{ | ||
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); | ||
} | ||
} | ||
} | ||
|
||
// Required for IFrameworkView. | ||
// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView | ||
// class is torn down while the app is in the foreground. | ||
void App::Uninitialize() | ||
{ | ||
} | ||
|
||
// Application lifecycle event handlers. | ||
|
||
void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) | ||
{ | ||
// Run() won't start until the CoreWindow is activated. | ||
CoreWindow::GetForCurrentThread()->Activate(); | ||
} | ||
|
||
void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) | ||
{ | ||
// Save app state asynchronously after requesting a deferral. Holding a deferral | ||
// indicates that the application is busy performing suspending operations. Be | ||
// aware that a deferral may not be held indefinitely. After about five seconds, | ||
// the app will be forced to exit. | ||
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); | ||
|
||
create_task([this, deferral]() | ||
{ | ||
m_deviceResources->Trim(); | ||
|
||
// Insert your code here. | ||
|
||
deferral->Complete(); | ||
}); | ||
} | ||
|
||
void App::OnResuming(Platform::Object^ sender, Platform::Object^ args) | ||
{ | ||
// Restore any data or state that was unloaded on suspend. By default, data | ||
// and state are persisted when resuming from suspend. Note that this event | ||
// does not occur if the app was previously terminated. | ||
|
||
// Insert your code here. | ||
} | ||
|
||
// Window event handlers. | ||
|
||
void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) | ||
{ | ||
m_deviceResources->SetLogicalSize(Size(sender->Bounds.Width, sender->Bounds.Height)); | ||
m_main->CreateWindowSizeDependentResources(); | ||
} | ||
|
||
void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) | ||
{ | ||
m_windowVisible = args->Visible; | ||
} | ||
|
||
void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) | ||
{ | ||
m_windowClosed = true; | ||
} | ||
|
||
// DisplayInformation event handlers. | ||
|
||
void App::OnDpiChanged(DisplayInformation^ sender, Object^ args) | ||
{ | ||
// Note: The value for LogicalDpi retrieved here may not match the effective DPI of the app | ||
// if it is being scaled for high resolution devices. Once the DPI is set on DeviceResources, | ||
// you should always retrieve it using the GetDpi method. | ||
// See DeviceResources.cpp for more details. | ||
m_deviceResources->SetDpi(sender->LogicalDpi); | ||
m_main->CreateWindowSizeDependentResources(); | ||
} | ||
|
||
void App::OnOrientationChanged(DisplayInformation^ sender, Object^ args) | ||
{ | ||
m_deviceResources->SetCurrentOrientation(sender->CurrentOrientation); | ||
m_main->CreateWindowSizeDependentResources(); | ||
} | ||
|
||
void App::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args) | ||
{ | ||
m_deviceResources->ValidateDevice(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "pch.h" | ||
#include "Common\DeviceResources.h" | ||
#include "dolphinMain.h" | ||
|
||
namespace dolphin | ||
{ | ||
// Main entry point for our app. Connects the app with the Windows shell and handles application lifecycle events. | ||
ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView | ||
{ | ||
public: | ||
App(); | ||
|
||
// IFrameworkView Methods. | ||
virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); | ||
virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); | ||
virtual void Load(Platform::String^ entryPoint); | ||
virtual void Run(); | ||
virtual void Uninitialize(); | ||
|
||
protected: | ||
// Application lifecycle event handlers. | ||
void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); | ||
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args); | ||
void OnResuming(Platform::Object^ sender, Platform::Object^ args); | ||
|
||
// Window event handlers. | ||
void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); | ||
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); | ||
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); | ||
|
||
// DisplayInformation event handlers. | ||
void OnDpiChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); | ||
void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); | ||
void OnDisplayContentsInvalidated(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); | ||
|
||
private: | ||
std::shared_ptr<DX::DeviceResources> m_deviceResources; | ||
std::unique_ptr<dolphinMain> m_main; | ||
bool m_windowClosed; | ||
bool m_windowVisible; | ||
}; | ||
} | ||
|
||
ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource | ||
{ | ||
public: | ||
virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView(); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.87 KB
render-only-sample/tests/dolphin/Assets/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.61 KB
render-only-sample/tests/dolphin/Assets/Square44x44Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.23 KB
...-sample/tests/dolphin/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.13 KB
render-only-sample/tests/dolphin/Assets/Wide310x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.