Initial Upload
This commit is contained in:
31
Graphics2.sln
Normal file
31
Graphics2.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27004.2009
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Graphics2", "Graphics2\Graphics2.vcxproj", "{E4F72E0B-F014-43F1-BC2A-EA26230158F9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Debug|x64.Build.0 = Debug|x64
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Debug|x86.Build.0 = Debug|Win32
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Release|x64.ActiveCfg = Release|x64
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Release|x64.Build.0 = Release|x64
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Release|x86.ActiveCfg = Release|Win32
|
||||
{E4F72E0B-F014-43F1-BC2A-EA26230158F9}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {EF90D084-277F-4434-9B4A-DA8B2C2E8FD6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
7
Graphics2/Core.h
Normal file
7
Graphics2/Core.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
#include "Resource.h"
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include "HelperFunctions.h"
|
11
Graphics2/DirectXCore.h
Normal file
11
Graphics2/DirectXCore.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include <d3d11.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <DirectXColors.h>
|
||||
#include <wrl.h>
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
230
Graphics2/DirectXFramework.cpp
Normal file
230
Graphics2/DirectXFramework.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
#include "DirectXFramework.h"
|
||||
|
||||
// DirectX libraries that are needed
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
#pragma comment(lib, "d3dcompiler.lib")
|
||||
|
||||
DirectXFramework * _dxFramework = nullptr;
|
||||
|
||||
DirectXFramework::DirectXFramework() : DirectXFramework(800, 600)
|
||||
{
|
||||
}
|
||||
|
||||
DirectXFramework::DirectXFramework(unsigned int width, unsigned int height) : Framework(width, height)
|
||||
{
|
||||
_dxFramework = this;
|
||||
|
||||
// Set default background colour
|
||||
_backgroundColour[0] = 0.0f;
|
||||
_backgroundColour[1] = 0.0f;
|
||||
_backgroundColour[2] = 0.0f;
|
||||
_backgroundColour[3] = 0.0f;
|
||||
|
||||
// Initialise vectors used to create camera. We will move these
|
||||
// to a separate Camera class later
|
||||
_eyePosition = XMFLOAT4(0.0f, 1.0f, -15.0f, 0.0f);
|
||||
_focalPointPosition = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
_upVector = XMFLOAT4(0.0f, 1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
DirectXFramework * DirectXFramework::GetDXFramework()
|
||||
{
|
||||
return _dxFramework;
|
||||
}
|
||||
|
||||
XMMATRIX DirectXFramework::GetViewTransformation()
|
||||
{
|
||||
return XMLoadFloat4x4(&_viewTransformation);
|
||||
}
|
||||
|
||||
XMMATRIX DirectXFramework::GetProjectionTransformation()
|
||||
{
|
||||
return XMLoadFloat4x4(&_projectionTransformation);
|
||||
}
|
||||
|
||||
void DirectXFramework::SetBackgroundColour(XMFLOAT4 backgroundColour)
|
||||
{
|
||||
_backgroundColour[0] = backgroundColour.x;
|
||||
_backgroundColour[1] = backgroundColour.y;
|
||||
_backgroundColour[2] = backgroundColour.z;
|
||||
_backgroundColour[3] = backgroundColour.w;
|
||||
}
|
||||
|
||||
void DirectXFramework::CreateSceneGraph()
|
||||
{
|
||||
}
|
||||
|
||||
void DirectXFramework::UpdateSceneGraph()
|
||||
{
|
||||
}
|
||||
|
||||
bool DirectXFramework::Initialise()
|
||||
{
|
||||
// The call to CoInitializeEx is needed if we are using
|
||||
// textures since the WIC library used requires it, so we
|
||||
// take care of initialising it here
|
||||
if FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!GetDeviceAndSwapChain())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
OnResize(SIZE_RESTORED);
|
||||
|
||||
// Create camera and projection matrices (we will look at how the
|
||||
// camera matrix is created from vectors later)
|
||||
XMStoreFloat4x4(&_projectionTransformation, XMMatrixPerspectiveFovLH(XM_PIDIV4, (float)GetWindowWidth() / GetWindowHeight(), 1.0f, 10000.0f));
|
||||
_sceneGraph = make_shared<SceneGraph>();
|
||||
CreateSceneGraph();
|
||||
return _sceneGraph->Initialise();
|
||||
}
|
||||
|
||||
void DirectXFramework::Shutdown()
|
||||
{
|
||||
// Required because we called CoInitialize above
|
||||
_sceneGraph->Shutdown();
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
void DirectXFramework::Update()
|
||||
{
|
||||
// Do any updates to the scene graph nodes
|
||||
UpdateSceneGraph();
|
||||
// Now apply any updates that have been made to world transformations
|
||||
// to all the nodes
|
||||
_sceneGraph->Update(XMMatrixIdentity());
|
||||
}
|
||||
|
||||
void DirectXFramework::Render()
|
||||
{
|
||||
// Clear the render target and the depth stencil view
|
||||
_deviceContext->ClearRenderTargetView(_renderTargetView.Get(), _backgroundColour);
|
||||
_deviceContext->ClearDepthStencilView(_depthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
|
||||
// Now recurse through the scene graph, rendering each object
|
||||
_sceneGraph->Render();
|
||||
// Now display the scene
|
||||
ThrowIfFailed(_swapChain->Present(0, 0));
|
||||
}
|
||||
|
||||
void DirectXFramework::OnResize(WPARAM wParam)
|
||||
{
|
||||
// Update view and projection matrices to allow for the window size change
|
||||
XMStoreFloat4x4(&_viewTransformation, XMMatrixLookAtLH(XMLoadFloat4(&_eyePosition), XMLoadFloat4(&_focalPointPosition), XMLoadFloat4(&_upVector)));
|
||||
XMStoreFloat4x4(&_projectionTransformation, XMMatrixPerspectiveFovLH(XM_PIDIV4, (float)GetWindowWidth() / GetWindowHeight(), 1.0f, 10000.0f));
|
||||
|
||||
// This will free any existing render and depth views (which
|
||||
// would be the case if the window was being resized)
|
||||
_renderTargetView = nullptr;
|
||||
_depthStencilView = nullptr;
|
||||
_depthStencilBuffer = nullptr;
|
||||
|
||||
ThrowIfFailed(_swapChain->ResizeBuffers(1, GetWindowWidth(), GetWindowHeight(), DXGI_FORMAT_R8G8B8A8_UNORM, 0));
|
||||
|
||||
// Create a drawing surface for DirectX to render to
|
||||
ComPtr<ID3D11Texture2D> backBuffer;
|
||||
ThrowIfFailed(_swapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer)));
|
||||
ThrowIfFailed(_device->CreateRenderTargetView(backBuffer.Get(), NULL, _renderTargetView.GetAddressOf()));
|
||||
|
||||
// The depth buffer is used by DirectX to ensure
|
||||
// that pixels of closer objects are drawn over pixels of more
|
||||
// distant objects.
|
||||
|
||||
// First, we need to create a texture (bitmap) for the depth buffer
|
||||
D3D11_TEXTURE2D_DESC depthBufferTexture = { 0 };
|
||||
depthBufferTexture.Width = GetWindowWidth();
|
||||
depthBufferTexture.Height = GetWindowHeight();
|
||||
depthBufferTexture.ArraySize = 1;
|
||||
depthBufferTexture.MipLevels = 1;
|
||||
depthBufferTexture.SampleDesc.Count = 4;
|
||||
depthBufferTexture.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
depthBufferTexture.Usage = D3D11_USAGE_DEFAULT;
|
||||
depthBufferTexture.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
|
||||
// Create the depth buffer.
|
||||
ComPtr<ID3D11Texture2D> depthBuffer;
|
||||
ThrowIfFailed(_device->CreateTexture2D(&depthBufferTexture, NULL, depthBuffer.GetAddressOf()));
|
||||
ThrowIfFailed(_device->CreateDepthStencilView(depthBuffer.Get(), 0, _depthStencilView.GetAddressOf()));
|
||||
|
||||
// Bind the render target view buffer and the depth stencil view buffer to the output-merger stage
|
||||
// of the pipeline.
|
||||
_deviceContext->OMSetRenderTargets(1, _renderTargetView.GetAddressOf(), _depthStencilView.Get());
|
||||
|
||||
// Specify a viewport of the required size
|
||||
D3D11_VIEWPORT viewPort;
|
||||
viewPort.Width = static_cast<float>(GetWindowWidth());
|
||||
viewPort.Height = static_cast<float>(GetWindowHeight());
|
||||
viewPort.MinDepth = 0.0f;
|
||||
viewPort.MaxDepth = 1.0f;
|
||||
viewPort.TopLeftX = 0;
|
||||
viewPort.TopLeftY = 0;
|
||||
_deviceContext->RSSetViewports(1, &viewPort);
|
||||
}
|
||||
|
||||
bool DirectXFramework::GetDeviceAndSwapChain()
|
||||
{
|
||||
UINT createDeviceFlags = 0;
|
||||
|
||||
// We are going to only accept a hardware driver or a WARP
|
||||
// driver
|
||||
D3D_DRIVER_TYPE driverTypes[] =
|
||||
{
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
D3D_DRIVER_TYPE_WARP
|
||||
};
|
||||
unsigned int totalDriverTypes = ARRAYSIZE(driverTypes);
|
||||
|
||||
D3D_FEATURE_LEVEL featureLevels[] =
|
||||
{
|
||||
D3D_FEATURE_LEVEL_11_0
|
||||
};
|
||||
unsigned int totalFeatureLevels = ARRAYSIZE(featureLevels);
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
|
||||
swapChainDesc.BufferCount = 1;
|
||||
swapChainDesc.BufferDesc.Width = GetWindowWidth();
|
||||
swapChainDesc.BufferDesc.Height = GetWindowHeight();
|
||||
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
// Set the refresh rate to 0 and let DXGI determine the best option (refer to DXGI best practices)
|
||||
swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
|
||||
swapChainDesc.BufferDesc.RefreshRate.Denominator = 0;
|
||||
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChainDesc.OutputWindow = GetHWnd();
|
||||
// Start out windowed
|
||||
swapChainDesc.Windowed = true;
|
||||
// Enable multi-sampling to give smoother lines (set to 1 if performance becomes an issue)
|
||||
swapChainDesc.SampleDesc.Count = 4;
|
||||
swapChainDesc.SampleDesc.Quality = 0;
|
||||
|
||||
// Loop through the driver types to determine which one is available to us
|
||||
D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_UNKNOWN;
|
||||
|
||||
for (unsigned int driver = 0; driver < totalDriverTypes && driverType == D3D_DRIVER_TYPE_UNKNOWN; driver++)
|
||||
{
|
||||
if (SUCCEEDED(D3D11CreateDeviceAndSwapChain(0,
|
||||
driverTypes[driver],
|
||||
0,
|
||||
createDeviceFlags,
|
||||
featureLevels,
|
||||
totalFeatureLevels,
|
||||
D3D11_SDK_VERSION,
|
||||
&swapChainDesc,
|
||||
_swapChain.GetAddressOf(),
|
||||
_device.GetAddressOf(),
|
||||
0,
|
||||
_deviceContext.GetAddressOf()
|
||||
)))
|
||||
|
||||
{
|
||||
driverType = driverTypes[driver];
|
||||
}
|
||||
}
|
||||
if (driverType == D3D_DRIVER_TYPE_UNKNOWN)
|
||||
{
|
||||
// Unable to find a suitable device driver
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
63
Graphics2/DirectXFramework.h
Normal file
63
Graphics2/DirectXFramework.h
Normal file
@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "Framework.h"
|
||||
#include "DirectXCore.h"
|
||||
#include "SceneGraph.h"
|
||||
|
||||
class DirectXFramework : public Framework
|
||||
{
|
||||
public:
|
||||
DirectXFramework();
|
||||
DirectXFramework(unsigned int width, unsigned int height);
|
||||
|
||||
virtual void CreateSceneGraph();
|
||||
virtual void UpdateSceneGraph();
|
||||
|
||||
bool Initialise();
|
||||
void Update();
|
||||
void Render();
|
||||
void OnResize(WPARAM wParam);
|
||||
void Shutdown();
|
||||
|
||||
static DirectXFramework * GetDXFramework();
|
||||
|
||||
inline SceneGraphPointer GetSceneGraph() { return _sceneGraph; }
|
||||
inline ComPtr<ID3D11Device> GetDevice() { return _device; }
|
||||
inline ComPtr<ID3D11DeviceContext> GetDeviceContext() { return _deviceContext; }
|
||||
|
||||
XMMATRIX GetViewTransformation();
|
||||
XMMATRIX GetProjectionTransformation();
|
||||
|
||||
void SetBackgroundColour(XMFLOAT4 backgroundColour);
|
||||
|
||||
private:
|
||||
ComPtr<ID3D11Device> _device;
|
||||
ComPtr<ID3D11DeviceContext> _deviceContext;
|
||||
ComPtr<IDXGISwapChain> _swapChain;
|
||||
ComPtr<ID3D11Texture2D> _depthStencilBuffer;
|
||||
ComPtr<ID3D11RenderTargetView> _renderTargetView;
|
||||
ComPtr<ID3D11DepthStencilView> _depthStencilView;
|
||||
|
||||
D3D11_VIEWPORT _screenViewport;
|
||||
|
||||
// Our vectors and matrices. Note that we cannot use
|
||||
// XMVECTOR and XMMATRIX for class variables since they need
|
||||
// to be aligned on 16-byte boundaries and the compiler cannot
|
||||
// guarantee this for class variables
|
||||
|
||||
// For now, we are storing our camera vectors and matrix here.
|
||||
// We will move it to a separate Camera class later
|
||||
XMFLOAT4 _eyePosition;
|
||||
XMFLOAT4 _focalPointPosition;
|
||||
XMFLOAT4 _upVector;
|
||||
|
||||
XMFLOAT4X4 _viewTransformation;
|
||||
XMFLOAT4X4 _projectionTransformation;
|
||||
|
||||
SceneGraphPointer _sceneGraph;
|
||||
|
||||
float _backgroundColour[4];
|
||||
|
||||
bool GetDeviceAndSwapChain();
|
||||
};
|
||||
|
233
Graphics2/Framework.cpp
Normal file
233
Graphics2/Framework.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
#include "Framework.h"
|
||||
|
||||
#define DEFAULT_FRAMERATE 60
|
||||
#define DEFAULT_WIDTH 800
|
||||
#define DEFAULT_HEIGHT 600
|
||||
|
||||
// Reference to ourselves - primarily used to access the message handler correctly
|
||||
// This is initialised in the constructor
|
||||
Framework * _thisFramework = NULL;
|
||||
|
||||
// Forward declaration of our window procedure
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// We can only run if an instance of a class that inherits from Framework
|
||||
// has been created
|
||||
if (_thisFramework)
|
||||
{
|
||||
return _thisFramework->Run(hInstance, nCmdShow);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Framework::Framework() : Framework(DEFAULT_WIDTH, DEFAULT_HEIGHT)
|
||||
{
|
||||
}
|
||||
|
||||
Framework::Framework(unsigned int width, unsigned int height)
|
||||
{
|
||||
_thisFramework = this;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
{
|
||||
}
|
||||
|
||||
int Framework::Run(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
int returnValue;
|
||||
|
||||
_hInstance = hInstance;
|
||||
if (!InitialiseMainWindow(nCmdShow))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
returnValue = MainLoop();
|
||||
Shutdown();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
// Main program loop.
|
||||
|
||||
int Framework::MainLoop()
|
||||
{
|
||||
MSG msg;
|
||||
HACCEL hAccelTable = LoadAccelerators(_hInstance, MAKEINTRESOURCE(IDC_GRAPHICS2));
|
||||
LARGE_INTEGER counterFrequency;
|
||||
LARGE_INTEGER nextTime;
|
||||
LARGE_INTEGER currentTime;
|
||||
LARGE_INTEGER lastTime;
|
||||
bool updateFlag = true;
|
||||
|
||||
// Initialise timer
|
||||
QueryPerformanceFrequency(&counterFrequency);
|
||||
DWORD msPerFrame = (DWORD)(counterFrequency.QuadPart / DEFAULT_FRAMERATE);
|
||||
double timeFactor = 1.0 / counterFrequency.QuadPart;
|
||||
QueryPerformanceCounter(&nextTime);
|
||||
lastTime = nextTime;
|
||||
|
||||
// Main message loop:
|
||||
msg.message = WM_NULL;
|
||||
while (msg.message != WM_QUIT)
|
||||
{
|
||||
if (updateFlag)
|
||||
{
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
_timeSpan = (currentTime.QuadPart - lastTime.QuadPart) * timeFactor;
|
||||
lastTime = currentTime;
|
||||
Update();
|
||||
updateFlag = false;
|
||||
}
|
||||
QueryPerformanceCounter(¤tTime);
|
||||
// Is it time to render the frame?
|
||||
if (currentTime.QuadPart > nextTime.QuadPart)
|
||||
{
|
||||
Render();
|
||||
// Set time for next frame
|
||||
nextTime.QuadPart += msPerFrame;
|
||||
// If we get more than a frame ahead, allow one to be dropped
|
||||
// Otherwise, we will never catch up if we let the error accumulate
|
||||
// and message handling will suffer
|
||||
if (nextTime.QuadPart < currentTime.QuadPart)
|
||||
{
|
||||
nextTime.QuadPart = currentTime.QuadPart + msPerFrame;
|
||||
}
|
||||
updateFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
// Register the window class, create the window and
|
||||
// create the bitmap that we will use for rendering
|
||||
|
||||
bool Framework::InitialiseMainWindow(int nCmdShow)
|
||||
{
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
WCHAR windowTitle[MAX_LOADSTRING];
|
||||
WCHAR windowClass[MAX_LOADSTRING];
|
||||
|
||||
LoadStringW(_hInstance, IDS_APP_TITLE, windowTitle, MAX_LOADSTRING);
|
||||
LoadStringW(_hInstance, IDC_GRAPHICS2, windowClass, MAX_LOADSTRING);
|
||||
|
||||
WNDCLASSEXW wcex;
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = _hInstance;
|
||||
wcex.hIcon = LoadIcon(_hInstance, MAKEINTRESOURCE(IDI_GRAPHICS2));
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wcex.lpszMenuName = nullptr;
|
||||
wcex.lpszClassName = windowClass;
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||
if (!RegisterClassExW(&wcex))
|
||||
{
|
||||
MessageBox(0, L"Unable to register window class", 0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now work out how large the window needs to be for our required client window size
|
||||
RECT windowRect = { 0, 0, static_cast<LONG>(_width), static_cast<LONG>(_height) };
|
||||
AdjustWindowRect(&windowRect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||
_width = windowRect.right - windowRect.left;
|
||||
_height = windowRect.bottom - windowRect.top;
|
||||
|
||||
_hWnd = CreateWindowW(windowClass,
|
||||
windowTitle,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, _width, _height,
|
||||
nullptr, nullptr, _hInstance, nullptr);
|
||||
if (!_hWnd)
|
||||
{
|
||||
MessageBox(0, L"Unable to create window", 0, 0);
|
||||
return false;
|
||||
}
|
||||
if (!Initialise())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ShowWindow(_hWnd, nCmdShow);
|
||||
UpdateWindow(_hWnd);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The WndProc for the current window. This cannot be a method, but we can
|
||||
// redirect all messages to a method.
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (_thisFramework != NULL)
|
||||
{
|
||||
// If framework is started, then we can call our own message proc
|
||||
return _thisFramework->MsgProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise, we just pass control to the default message proc
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
// Our main WndProc
|
||||
|
||||
LRESULT Framework::MsgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_PAINT:
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
OnKeyDown(wParam);
|
||||
return 0;
|
||||
|
||||
case WM_KEYUP:
|
||||
OnKeyUp(wParam);
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_MOVE:
|
||||
Render();
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
_width = LOWORD(lParam);
|
||||
_height = HIWORD(lParam);
|
||||
OnResize(wParam);
|
||||
Render();
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
55
Graphics2/Framework.h
Normal file
55
Graphics2/Framework.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include "Core.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Framework
|
||||
{
|
||||
public:
|
||||
Framework();
|
||||
Framework(unsigned int width, unsigned int height);
|
||||
virtual ~Framework();
|
||||
|
||||
int Run(HINSTANCE hInstance, int nCmdShow);
|
||||
|
||||
LRESULT MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
inline unsigned int GetWindowWidth() { return _width; }
|
||||
inline unsigned int GetWindowHeight() { return _height; }
|
||||
inline HWND GetHWnd() { return _hWnd; }
|
||||
|
||||
// Initialise the application. Called after the window and bitmap has been
|
||||
// created, but before the main loop starts
|
||||
//
|
||||
// Return false if the application cannot be initialised.
|
||||
virtual bool Initialise() { return true; }
|
||||
|
||||
// Perform any updates to the structures that will be used
|
||||
// to render the window (i.e. transformation matrices, etc).
|
||||
virtual void Update() {}
|
||||
|
||||
// Render the contents of the window.
|
||||
virtual void Render() {};
|
||||
|
||||
// Perform any application shutdown or cleanup that is needed
|
||||
virtual void Shutdown() {}
|
||||
|
||||
// Handlers for Windows messages. If you need more, add them
|
||||
// here and call them from MsgProc.
|
||||
virtual void OnKeyDown(WPARAM wParam) {}
|
||||
virtual void OnKeyUp(WPARAM wParam) {}
|
||||
virtual void OnResize(WPARAM wParam) {}
|
||||
|
||||
private:
|
||||
HINSTANCE _hInstance;
|
||||
HWND _hWnd;
|
||||
unsigned int _width;
|
||||
unsigned int _height;
|
||||
|
||||
// Used in timing loop
|
||||
double _timeSpan;
|
||||
|
||||
bool InitialiseMainWindow(int nCmdShow);
|
||||
int MainLoop();
|
||||
};
|
||||
|
18
Graphics2/Graphics2.cpp
Normal file
18
Graphics2/Graphics2.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "Graphics2.h"
|
||||
|
||||
Graphics2 app;
|
||||
|
||||
void Graphics2::CreateSceneGraph()
|
||||
{
|
||||
SceneGraphPointer sceneGraph = GetSceneGraph();
|
||||
|
||||
// This is where you add nodes to the scene graph
|
||||
}
|
||||
|
||||
void Graphics2::UpdateSceneGraph()
|
||||
{
|
||||
SceneGraphPointer sceneGraph = GetSceneGraph();
|
||||
|
||||
// This is where you make any changes to the local world transformations to nodes
|
||||
// in the scene graph
|
||||
}
|
11
Graphics2/Graphics2.h
Normal file
11
Graphics2/Graphics2.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "DirectXFramework.h"
|
||||
|
||||
class Graphics2 : public DirectXFramework
|
||||
{
|
||||
public:
|
||||
void CreateSceneGraph();
|
||||
void UpdateSceneGraph();
|
||||
|
||||
};
|
||||
|
BIN
Graphics2/Graphics2.ico
Normal file
BIN
Graphics2/Graphics2.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
Graphics2/Graphics2.rc
Normal file
BIN
Graphics2/Graphics2.rc
Normal file
Binary file not shown.
172
Graphics2/Graphics2.vcxproj
Normal file
172
Graphics2/Graphics2.vcxproj
Normal file
@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{E4F72E0B-F014-43F1-BC2A-EA26230158F9}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Graphics2</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Core.h" />
|
||||
<ClInclude Include="DirectXCore.h" />
|
||||
<ClInclude Include="Framework.h" />
|
||||
<ClInclude Include="DirectXFramework.h" />
|
||||
<ClInclude Include="Graphics2.h" />
|
||||
<ClInclude Include="HelperFunctions.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="SceneGraph.h" />
|
||||
<ClInclude Include="SceneNode.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Graphics2.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Graphics2.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Framework.cpp" />
|
||||
<ClCompile Include="DirectXFramework.cpp" />
|
||||
<ClCompile Include="Graphics2.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
73
Graphics2/Graphics2.vcxproj.filters
Normal file
73
Graphics2/Graphics2.vcxproj.filters
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HelperFunctions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Core.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DirectXCore.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DirectXFramework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SceneGraph.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Graphics2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SceneNode.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Graphics2.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="Graphics2.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Framework.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DirectXFramework.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Graphics2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
13
Graphics2/HelperFunctions.h
Normal file
13
Graphics2/HelperFunctions.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
// Various helper functions
|
||||
|
||||
using namespace std;
|
||||
|
||||
inline void ThrowIfFailed(HRESULT hr)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
throw exception();
|
||||
}
|
||||
}
|
26
Graphics2/SceneGraph.h
Normal file
26
Graphics2/SceneGraph.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "SceneNode.h"
|
||||
|
||||
class SceneGraph : public SceneNode
|
||||
{
|
||||
public:
|
||||
SceneGraph() : SceneNode(L"Root") {};
|
||||
SceneGraph(wstring name) : SceneNode(name) {};
|
||||
~SceneGraph(void) {};
|
||||
|
||||
virtual bool Initialise(void);
|
||||
virtual void Update(FXMMATRIX& currentWorldTransformation);
|
||||
virtual void Render(void);
|
||||
virtual void Shutdown(void);
|
||||
|
||||
void Add(SceneNodePointer node);
|
||||
void Remove(SceneNodePointer node);
|
||||
SceneNodePointer Find(wstring name);
|
||||
|
||||
//private:
|
||||
|
||||
// Here you need to add whatever collection you are going to
|
||||
// use to store the children of this scene graph
|
||||
};
|
||||
|
||||
typedef shared_ptr<SceneGraph> SceneGraphPointer;
|
39
Graphics2/SceneNode.h
Normal file
39
Graphics2/SceneNode.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "core.h"
|
||||
#include "DirectXCore.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Abstract base class for all nodes of the scene graph.
|
||||
// This scene graph implements the Composite Design Pattern
|
||||
|
||||
class SceneNode;
|
||||
|
||||
typedef shared_ptr<SceneNode> SceneNodePointer;
|
||||
|
||||
class SceneNode : public enable_shared_from_this<SceneNode>
|
||||
{
|
||||
public:
|
||||
SceneNode(wstring name) {_name = name; XMStoreFloat4x4(&_worldTransformation, XMMatrixIdentity()); };
|
||||
~SceneNode(void) {};
|
||||
|
||||
// Core methods
|
||||
virtual bool Initialise() = 0;
|
||||
virtual void Update(FXMMATRIX& currentWorldTransformation) { XMStoreFloat4x4(&_combinedWorldTransformation, XMLoadFloat4x4(&_worldTransformation) * currentWorldTransformation); }
|
||||
virtual void Render() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
void SetWorldTransform(FXMMATRIX& worldTransformation) { XMStoreFloat4x4(&_worldTransformation, worldTransformation); }
|
||||
|
||||
// Although only required in the composite class, these are provided
|
||||
// in order to simplify the code base.
|
||||
virtual void Add(SceneNodePointer node) {}
|
||||
virtual void Remove(SceneNodePointer node) {};
|
||||
virtual SceneNodePointer Find(wstring name) { return (_name == name) ? shared_from_this() : nullptr; }
|
||||
|
||||
protected:
|
||||
XMFLOAT4X4 _worldTransformation;
|
||||
XMFLOAT4X4 _combinedWorldTransformation;
|
||||
wstring _name;
|
||||
};
|
||||
|
27
Graphics2/resource.h
Normal file
27
Graphics2/resource.h
Normal file
@ -0,0 +1,27 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by WindowsApp.rc
|
||||
//
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDI_GRAPHICS2 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_GRAPHICS2 109
|
||||
#define IDC_MYICON 2
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NO_MFC 130
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
BIN
Graphics2/small.ico
Normal file
BIN
Graphics2/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
8
Graphics2/targetver.h
Normal file
8
Graphics2/targetver.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||
|
||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||
|
||||
#include <SDKDDKVer.h>
|
Reference in New Issue
Block a user