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

<HR>
Creative Commons Copyright -- Some rights reserved.


THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

  • "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
  • "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
  • "Licensor" means the individual or entity that offers the Work under the terms of this License.
  • "Original Author" means the individual or entity who created the Work.
  • "Work" means the copyrightable work of authorship offered under the terms of this License.
  • "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
  • "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.

2. Fair Use Rights

Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant

Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

  • to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
  • to create and reproduce Derivative Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
  • to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
  • For the avoidance of doubt, where the work is a musical composition:
    • Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
    • Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
    • Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).


The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions

The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

  • You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
  • You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
  • If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability.

EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

  • This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
  • Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

  • Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
  • Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
  • If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
  • No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
  • This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.