Hello, Ogre Community!

This tutorial will enable you to build Ogre and get it running in a Windows Store Application. Another member of the community has used these instructions to create a more reader friendly version with pictures and other information, you can view that here:

http://michaelcummings.net/mathoms/getting-started-guide-using-ogre-3d-on-windows-8.1

If you want something more direct and fast, please follow the instructions below:

Building Ogre

1. Install TortoiseHG:

http://mercurial.selenic.com/downloads

Build Dependencies

2. Create a folder D:\Sandbox\OgreDependencies
3. From File Explorer, view this folder location, right click, TortoiseHG -> Clone...
4. Enter in "https://bitbucket.org/eugene_gff/ogre-dependencies-winrt" and click "Clone"
5. Launch "D:\Sandbox\OgreDependencies\src\OgreDependencies.VS2013.WinRT.sln"
6. Select Build -> Batch Build... and click "Select All". Click "Build", everything should build successfully.
7. Libs should be placed under "D:\Sandbox\OgreDependencies\lib", for example "D:\Sandbox\OgreDependencies\lib\x86\Debug\FreeImaged.lib".

Build Ogre

8. Created a folder D:\Sandbox\Ogre. From file exporer, right click, TortoiseHG -> Clone...
9. Enter in "https://bitbucket.org/sinbad/ogre" and click "Clone"
10. Install CMake: http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe. I added CMAKE to system path.
11. Run CMAKE GUI. Set source code location to "D:/Sandbox/Ogre". Set binary output location to "D:/Sandbox/Ogre"
12. Press Configure. Select "Visual Studio 12" from the list.
13. Set OGRE_DEPENDENCIES_DIR to "D:\Sandbox\OgreDependencies" from Name/Value list. Make sure OGRE_STATIC and OGRE_BUILD_PLATFORM_WINRT are set. (checked) Press Configure. Remove Samples, plugins and/or components as necessary and create a minimal list of projects you want to build. Keep pressing Configure until there are no rows outlined in red.
14. Press Generate.
15. Open up "D:\Sandbox\Ogre\OGRE.sln" in Visual Studio 2013
16. From the solution explorer, right click and remove the following projects: ALL_BUILD, INSTALL, PACKAGE
17. Right click OgreMain project and select "Retarget to 8.1". Select all other projects and hit OK.
18. Build the solution. 3 projects failed to build: OgreMain, OgreMeshLodGenerator, RenderSystem_Direct3D11
19. Right click RenderSystem_Direct3D11 project in solution explorer, open up properties. Configuration Properties -> C/C++ -> General -> Consume Windows Runtime Extension: Yes (/ZW)
20. In OgreMain project, open OgreErrorDIalogWinRT.cpp, and add "#include <iostream>" after the includes.
21. Right click OgreMeshLodGenerator project in solution explorer, open up properties. Configuration Properties -> C/C++ -> General -> SDL checks: No (/sdl-)
22. Batch build everything. Everything should be built! (Check Issues below if needed) The libs should be in "D:\Sandbox\Ogre\lib".

Issues?

1. If you're using Visual Studio 2013 express, you might need to additionally install the Windows 8.1 SDK. I found that CMake was acting up because it could not find Gdi32.lib. Link: http://msdn.microsoft.com/en-us/library/windows/desktop/bg162891.aspx
2. D3D11RenderSystem project not getting created? I needed to install the Windows 8.0 SDK and re-generate the solution via CMake: http://msdn.microsoft.com/en-us/library/windows/desktop/hh852363.aspx
3. You might need to add "D:\Sandbox\OgreDependencies\include" to the "Additional Include Directories" for the OgreMain and OgreOverlay projects. These paths can be specified in the project properties.
4. Make sure all projects are not using precompiled headers. Select all projects in the solution explorer,
Right click, than go to "Properties" select "Configuration Properties", than "All Configurations"
and under "Configuration Properties > C/C++ > Precompiled Headers > Precompiled Header" choose "Not Using Precompiled Headers".

Creating your app for the Windows Store

1. Launch Visual Studio 2013
2. File -> New Project...
3. Templates -> Visual C++ -> Store Apps -> Windows Apps -> DirectX App
4. Set name to "SampleOgreApp", location "D:\Sandbox", and check "Create directory for solution". Click OK.
5. Determine whether you will be building in Debug or Release mode. For now lets use Debug mode, and use Debug versions of the Ogre lib. Select "Debug" from the configuration drop down combobox.
6. In solution explorer, Right click SampleOgreApp project, properties. Make sure Configuration is set to "Debug" and Platform set to "Win32".
7. Configuration Properties -> C/C++ -> General -> Additional Include Directories. Add "D:\Sandbox\Ogre\include" and "D:\Sandbox\Ogre\Ogre\OgreMain\include"
8. Configuration Properties -> Linker -> General -> Additional Library Directories. Add "D:\Sandbox\Ogre\lib\Debug"
9. Configuration Properties -> Linker -> Input -> Additional Dependencies. Add OgreMainStatic_d.lib, FreeImaged.lib, freetype2311_d.lib, zlibd.lib, zziplibd.lib
10. In App.h add the following include:

#include "Ogre.h"

Make sure the project builds successfully. This will verify your lib paths and include paths
Make sure the project can run. Find the green arrow toolbar button and select "Simulator" from the drop down menu. Press then green Arrow button. At this point we have a rotating cube rendered using D3D.

Initializing Ogre

11. Replace App.h with the following code:

#pragma once

#include "pch.h"

#include "Ogre.h"
#include "OgreD3D11Plugin.h"
#include "OgreOctreePlugin.h"
#include "OgreRTShaderSystem.h"

#include "ShaderGeneratorTechniqueResolverListener.h"

#include <string>

namespace SampleOgreApp
{
	// 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();
		virtual ~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:
		bool m_windowClosed;
		bool m_windowVisible;

		Ogre::Root* mOgreRoot;
		Ogre::RenderWindow* mOgreRenderWindow;

		Ogre::D3D11Plugin* mD3D11Plugin;
		Ogre::OctreePlugin* mOctreePlugin;

		Ogre::RTShader::ShaderGenerator* mShaderGenerator;                       // The Shader generator instance.
		ShaderGeneratorTechniqueResolverListener* mMaterialMgrListener;          // Shader generator material manager listener.

		void CreateShadersForDefaultMaterialsUsingRTSS();

		std::string ConvertPlatformStringToSTDString(Platform::String^ s);
		Platform::String^ ConvertSTDStringToPlatformString(const std::string& s);
	};
}

ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
	virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
};

12. Replace App.cpp with the following code:

#include "pch.h"
#include "App.h"

#include <ppltasks.h>

using namespace SampleOgreApp;

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),
	mOgreRoot(nullptr)
{
}

App::~App()
{
	delete mOgreRoot;
}

std::string App::ConvertPlatformStringToSTDString(Platform::String^ s)
{
	// need to convert to narrow (OEM or ANSI) codepage so that fstream can use it 
	// properly on international systems.
	char npath[MAX_PATH];

	// Runtime is modern, narrow calls are widened inside CRT using CP_ACP codepage.
	UINT codepage = CP_ACP;

	if (0 == WideCharToMultiByte(codepage, 0 /* Use default flags */, s->Data(), -1, npath, sizeof(npath), NULL, NULL))
	{
		throw ref new Platform::FailureException("Unable to convert Platform string to std::string!");
	}

	// success
	return std::string(npath);
}

Platform::String^ App::ConvertSTDStringToPlatformString(const std::string& s)
{
	std::vector<wchar_t> wpath(s.length() + 1, '\0');

	// Runtime is modern, narrow calls are widened inside CRT using CP_ACP codepage.
	UINT codepage = CP_ACP;

	(void)MultiByteToWideChar(codepage, 0, s.data(), s.length(), &wpath[0], wpath.size());

	return ref new Platform::String(&wpath[0]);
}

void App::CreateShadersForDefaultMaterialsUsingRTSS()
{
	// creates shaders for base material BaseWhite using the RTSS
	Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
	baseWhite->setLightingEnabled(false);
	mShaderGenerator->createShaderBasedTechnique(
		"BaseWhite",
		Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
		Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
	mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
		"BaseWhite");
	if (baseWhite->getNumTechniques() > 1)
	{
		baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
			baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
		baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
			baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
	}

	// creates shaders for base material BaseWhiteNoLighting using the RTSS
	mShaderGenerator->createShaderBasedTechnique(
		"BaseWhiteNoLighting",
		Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
		Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
	mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
		"BaseWhiteNoLighting");
	Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
	if (baseWhite->getNumTechniques() > 1)
	{
		baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
			baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
		baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
			baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
	}
}

// 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);
}

// 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);

	// Disable all pointer visual feedback for better performance when touching.
	auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView();
	pointerVisualizationSettings->IsContactFeedbackEnabled = false; 
	pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;

	// OGRE INTIALIZATION - I've decided to do this here because we need a CoreWindow handle in order to create the Ogre::RenderWindow object.

	if (mOgreRoot == nullptr)
	{

		// The Ogre Root constructor requires 3 directory paths: Plugin path, config path, log path
		//	1. We don't want to have any dll's and have all the libs build staticly, so we can tell Ogre not to look for any plugins by supply a blank string.
		//	2. Similarly, we won't be using an Ogre.cfg file, so we pass in a blank string.
		//  3. We do want logs produced by Ogre, in case there are some issues that need investigation.  For this we'll create a file and pass its path to Ogre.

		Ogre::String emptyString = Ogre::BLANKSTRING;

		// Since we are using the CreateFileAsync method, and we need to make sure the file exists before we instantiate Ogre::Root, we have to use the .then functionality 
		// to make the operations go in order
		Windows::Storage::StorageFolder^ rootApplicationDataFolder = Windows::Storage::ApplicationData::Current->LocalFolder;

		auto createFileTask = create_task(rootApplicationDataFolder->CreateFileAsync(ConvertSTDStringToPlatformString("Ogre.log"), Windows::Storage::CreationCollisionOption::GenerateUniqueName));
		createFileTask.then([=](Windows::Storage::StorageFile^ ogreLog)
		{
			mOgreRoot = new Ogre::Root(emptyString, emptyString, ConvertPlatformStringToSTDString(ogreLog->Path));

			// Let's continue initializing Ogre here, right after instantiating Ogre::Root

			mD3D11Plugin = OGRE_NEW Ogre::D3D11Plugin();
			mOgreRoot->installPlugin(mD3D11Plugin);

			mOctreePlugin = OGRE_NEW Ogre::OctreePlugin();
			mOgreRoot->installPlugin(mOctreePlugin);

			// Lets set the Render System for Ogre to use. (The D3D11Plugin we just loaded)
			mOgreRoot->setRenderSystem(mOgreRoot->getAvailableRenderers()[0]);

			// Initialize Ogre! (NOTE: We cannot create a Render Window until we have a handle to the CoreWindow of our WinRT app)
			mOgreRoot->initialise(false, "OGRE Sample Browser");
						
			// Create our RenderWindow
			Ogre::NameValuePairList miscParams;
			if (window != nullptr)
			{
				miscParams["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)reinterpret_cast<void*>(window));
				mOgreRenderWindow = mOgreRoot->createRenderWindow("SampleOgreApp RenderWindow", static_cast<unsigned int>(window->Bounds.Width), static_cast<unsigned int>(window->Bounds.Height), false, &miscParams);
				
				// With the creation of the RenderWindow, the Material manager is initialized.  If you want materials to be parsed, they need to first be declared using Resource Groups.

				// In this example we want to display an ogre head, which is made of a mesh, material, and textures. Lets tell Ogre to locate these resources for us and associate
				// them with the default Resource Group.  We can do this via the addResourceLocation API.

				// Remember that all assets should be added to the project from inside Visual Studio, in the solution explorer.
				// The location of each asset is defined by its "Relative Path", which can be viewed in the Property window with the asset file selected. (View -> Properties Window)
				// NOTE: Adding filters (folders) to the project and having files in these folders does not indicate their relative path.
				// NOTE: Make sure each file has Content=true for its properties, otherwise it won't be packaged with the application.

				// All of the resources required for the ogre head are stored in our Assets folder. (D:\Sandbox\SampleOgreApp\SampleOgreApp\Assets)
				// Lets add the relative path to the default resource group.
				Ogre::ResourceGroupManager::getSingleton().addResourceLocation(".\\Assets\\", "FileSystem", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

				// Now that we have declared all resource locations we care about, we can initialize our ResourceGroups, and which will parse any scripts such as Materials and programs.
				Ogre::ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups();
				
				// The RTShader system needs to be used for rendering, since the D3D11 device does not have a fixed function pipeline.
				// Initialization of the RTShader must be called after the RenderWindow is created, as the D3D11 RenderSystem creates the D3D11GpuProgramManager at this time.
				Ogre::RTShader::ShaderGenerator::initialize();
				mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
				mShaderGenerator->setTargetLanguage("hlsl", 4.0f);
				
				// By providing the ShaderGenerator with a Cache path, we can re-use shaders. If the required shaders do not exist, they will be built and placed in the cache for future use.
				// If no Cache is specified, the shaders will be built every time they are needed, and stored in a temporary system path.  A good practice would be to set the cache
				// during development, and for submission, bundle the necessary shaders with with the project.
				mShaderGenerator->setShaderCachePath(ConvertPlatformStringToSTDString(rootApplicationDataFolder->Path));

				// Create and register the material manager listener if it doesn't exist yet.
				ShaderGeneratorTechniqueResolverListener* mMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);
				Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);

				// Create a dummy Scene

				// Re-using code from Ogre tutorial: http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+1&structure=Tutorials
				// and from ExampleApplication.h

				Ogre::SceneManager* sm = mOgreRoot->createSceneManager(Ogre::ST_EXTERIOR_CLOSE, "DummyScene");
				sm->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));

				// Add the SceneManager to the ShaderGenerator so that it can listen for Scene rendering events and configure gpu parameters
				mShaderGenerator->addSceneManager(sm);

				CreateShadersForDefaultMaterialsUsingRTSS();
				
				Ogre::Camera* cam = sm->createCamera("DummyCam");
				// Position it at 500 in Z direction
				cam->setPosition(Ogre::Vector3(0, 0, 200));
				cam->setNearClipDistance(5);
				
				Ogre::Viewport* vp = mOgreRenderWindow->addViewport(cam);

				Ogre::Entity* ogreHead = sm->createEntity("Head", "ogrehead.mesh");
				Ogre::SceneNode* headNode = sm->getRootSceneNode()->createChildSceneNode("HeadNode");
				headNode->attachObject(ogreHead);

				Ogre::Light* light = sm->createLight("MainLight");
				light->setPosition(20, 80, 50);
			}
		});
	}
}

// Initializes scene resources, or loads a previously saved app state.
void App::Load(Platform::String^ entryPoint)
{
}

// This method is called after the window becomes active.
void App::Run()
{
	// Let's wait until Ogre has been initialized..
	while (mOgreRoot == nullptr)
		CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);

	while (!m_windowClosed)
	{
		if (m_windowVisible)
		{
			CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
			
			// Perform game-logic update

			// Render
			mOgreRoot->renderOneFrame();
		}
		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]()
	{
		// 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)
{
}

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)
{
}

void App::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
{
}

void App::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args)
{
}


13. Add ShaderGeneratorTechniqueResolverListener.h to the project:

#include "Ogre.h"
#include "OgreRTShaderSystem.h"

/** This class demonstrates basic usage of the RTShader system.
It sub class the material manager listener class and when a target scheme callback
is invoked with the shader generator scheme it tries to create an equivalent shader
based technique based on the default technique of the given material.
*/
class ShaderGeneratorTechniqueResolverListener : public Ogre::MaterialManager::Listener
{
public:

	ShaderGeneratorTechniqueResolverListener(Ogre::RTShader::ShaderGenerator* pShaderGenerator)
	{
		mShaderGenerator = pShaderGenerator;
	}

	/** This is the hook point where shader based technique will be created.
	It will be called whenever the material manager won't find appropriate technique
	that satisfy the target scheme name. If the scheme name is out target RT Shader System
	scheme name we will try to create shader generated technique for it.
	*/
	virtual Ogre::Technique* handleSchemeNotFound(unsigned short schemeIndex,
		const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex,
		const Ogre::Renderable* rend)
	{
		Ogre::Technique* generatedTech = NULL;

		// Case this is the default shader generator scheme.
		if (schemeName == Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)
		{
			bool techniqueCreated;

			// Create shader generated technique for this material.
			techniqueCreated = mShaderGenerator->createShaderBasedTechnique(
				originalMaterial->getName(),
				Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
				schemeName);

			// Case technique registration succeeded.
			if (techniqueCreated)
			{
				// Force creating the shaders for the generated technique.
				mShaderGenerator->validateMaterial(schemeName, originalMaterial->getName());

				// Grab the generated technique.
				Ogre::Material::TechniqueIterator itTech = originalMaterial->getTechniqueIterator();

				while (itTech.hasMoreElements())
				{
					Ogre::Technique* curTech = itTech.getNext();

					if (curTech->getSchemeName() == schemeName)
					{
						generatedTech = curTech;
						break;
					}
				}
			}
		}

		return generatedTech;
	}

protected:
	Ogre::RTShader::ShaderGenerator*        mShaderGenerator;                       // The shader generator instance.
};

14. Configuration Properties -> C/C++ -> General -> Additional Include Directories. Add "D:\Sandbox\Ogre\Plugins\OctreeSceneManager\include", "D:\Sandbox\Ogre\RenderSystems\Direct3D11\include" and "D:\Sandbox\Ogre\Components\RTShaderSystem\include"
15. Configuration Properties -> Linker -> Input -> Additional Dependencies. Add Plugin_OctreeSceneManagerStatic_d.lib, RenderSystem_Direct3D11Static_d.lib, OgreRTShaderSystemStatic_d.lib, dxguid.lib
16. Add the following files to D:\Sandbox\SampleOgreApp\SampleOgreApp\Assets: ogrehead.mesh, ogre.material, greenskin.jpg, tusk.jpg, spheremap.png
17. Add the files from step 15 to the project by right clicking on the "Assets" folder (filter) in the Solution Explorer, Add -> Existing Item...
18. Copy the following hlsl files to your project (D:\Sandbox\SampleOgreApp\SampleOgreApp\Assets) and add them to the "Assets" folder in the Solution Explorer: FFPLib_Common.hlsl, FFPLib_Fog.hlsl, FFPLib_Lighting.hlsl, FFPLib_Texturing.hlsl, FFPLib_Transform.hlsl
19. Make sure to explicitly right click and set properties for all hlsl files, setting Content=yes and "Do not participate in build". (By default they are recognized)

Make sure the project builds successfully.
Make sure the project can run. You should see an Ogre head!!

Issues?

1. Check Ogre.log. Everybody's path will use a different app GUID, here is mine: C:\Users\bkinsey\AppData\Local\Packages\856f2e6b-4a1a-4e76-9b56-535eee39bd3a_4bzmt7j5bjbb6\LocalState