Pārlūkot izejas kodu

Added EditorApplication that more neatly wraps editor start up stuff

Marko Pintera 12 gadi atpakaļ
vecāks
revīzija
d59a9aeec6

+ 12 - 8
CSharpWrap.txt

@@ -70,14 +70,6 @@ to call a Main function in the assembly
 
 
  -----------------
  -----------------
 
 
- VERY IMPORTANT:
-  - Attempt to compile mono runtime as 64bit
-
-Make sure to add /etc and /lib folders in CamelotDependencies. Plus all of the x64 files.
- - lib/bin files only exist in x86 Debug. And projects are only set up for that single configuration as well
-
- -----------------
-
  add BansheeEditor class
  add BansheeEditor class
  Add C++ EditorApplication and have it start up Application and create a main window
  Add C++ EditorApplication and have it start up Application and create a main window
 Then in C# class just call EditorApplication to create a main window
 Then in C# class just call EditorApplication to create a main window
@@ -94,6 +86,18 @@ For EditorWindow, add a new class in BansheeEditor, which pretty much does the j
 
 
  -----------------
  -----------------
 
 
+ Implementation steps:
+ - Get EditorApplication finished and make the main window open from C#
+   - (Will possibly need to make new CamelotClient.cpp? since that one is full of junk)
+ - Add support for Resources
+   - Importer - Likely invisible for outside world
+   - Resources.Save/Load - Will likely need some kind of an AssetManager for all imported assets
+   - Texture, Mesh, Font, Shader, Material
+     - Before this I will also probably require all the basic classes like Vector3, etc.
+ - Emulate current CamelotClient tests in C#
+
+ -----------------
+
  But which ones will I need initially?
  But which ones will I need initially?
   - [EditorApplication] - Entry point. Creates a MainEditorWindow
   - [EditorApplication] - Entry point. Creates a MainEditorWindow
   - [EditorWindow] (Scene, Project, Hierarchy, etc.)
   - [EditorWindow] (Scene, Project, Hierarchy, etc.)

+ 4 - 322
CamelotClient/CamelotClient.cpp

@@ -1,53 +1,12 @@
 #include "stdafx.h"
 #include "stdafx.h"
 #include <windows.h>
 #include <windows.h>
 
 
-#include "BsApplication.h"
-#include "CmApplication.h"
-#include "CmDynLibManager.h"
-
-#include "CmSceneObject.h"
-#include "BsCamera.h"
-#include "CmHighLevelGpuProgramManager.h"
-#include "CmRenderSystem.h"
-#include "CmRenderWindow.h"
-#include "CmResources.h"
-#include "BsRenderable.h"
-#include "CmMaterial.h"
-#include "CmShader.h"
-#include "CmTechnique.h"
-#include "CmPass.h"
-#include "CmImporter.h"
-#include "CmMesh.h"
-#include "CmGpuProgInclude.h" // DEBUG ONLY
-#include "CmGpuProgramImportOptions.h"
-#include "CmFontImportOptions.h"
-#include "CmCommandQueue.h"
-#include "CmBlendState.h"
-
-// Editor includes
-#include "BsEditorWindowManager.h"
-#include "BsMainEditorWindow.h"
-// End editor includes
-
-#include "CmDebugCamera.h"
-#include "DbgEditorWidget1.h"
-#include "DbgEditorWidget2.h"
-#include "CmRTTIType.h"
-#include "CmPlatform.h"
-
-#define DX11
-//#define DX9
-//#define GL
+#include "BsEditorApplication.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 using namespace BansheeEditor;
 using namespace BansheeEditor;
 using namespace BansheeEngine;
 using namespace BansheeEngine;
 
 
-void editorUpdate()
-{
-	EditorWindowManager::instance().update();	
-}
-
 int CALLBACK WinMain(
 int CALLBACK WinMain(
 	_In_  HINSTANCE hInstance,
 	_In_  HINSTANCE hInstance,
 	_In_  HINSTANCE hPrevInstance,
 	_In_  HINSTANCE hPrevInstance,
@@ -55,286 +14,9 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	_In_  int nCmdShow
 	)
 	)
 {
 {
-	RENDER_WINDOW_DESC renderWindowDesc;
-	renderWindowDesc.width = 1280;
-	renderWindowDesc.height = 720;
-	renderWindowDesc.title = "Banshee";
-	renderWindowDesc.fullscreen = false;
-	renderWindowDesc.border = WindowBorder::None;
-
-#ifdef DX11
-	gBansheeApp().startUp(renderWindowDesc, "CamelotD3D11RenderSystem", "BansheeForwardRenderer", "D:\\CamelotResourceMetas");
-#elif defined DX9
-	gBansheeApp().startUp(renderWindowDesc, "CamelotD3D9RenderSystem", "BansheeForwardRenderer", "D:\\CamelotResourceMetas");
-#else
-	gBansheeApp().startUp(renderWindowDesc, "CamelotGLRenderSystem", "BansheeForwardRenderer", "D:\\CamelotResourceMetas");
-#endif
-
-	RenderSystem* renderSystem = RenderSystem::instancePtr();
-	RenderWindowPtr renderWindow = gApplication().getPrimaryWindow();
-
-	HSceneObject testModelGO = SceneObject::create("TestMesh");
-	HRenderable testRenderable = testModelGO->addComponent<Renderable>();
-
-#if defined DX9
-	///////////////// HLSL 9 SHADERS //////////////////////////
-	String dx9psLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl9_ps.gpuprog";
-	String dx9vsLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl9_vs.gpuprog";
-
-	ImportOptionsPtr gpuProgImportOptions = Importer::instance().createImportOptions(dx9psLoc);
-	if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
-	{
-		GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
-
-		importOptions->setEntryPoint("ps_main");
-		importOptions->setLanguage("hlsl");
-		importOptions->setProfile(GPP_PS_2_0);
-		importOptions->setType(GPT_FRAGMENT_PROGRAM);
-	}
-
-	HHighLevelGpuProgram fragProgRef = Importer::instance().import(dx9psLoc, gpuProgImportOptions);
-
-	gpuProgImportOptions = Importer::instance().createImportOptions(dx9vsLoc);
-	if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
-	{
-		GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
-
-		importOptions->setEntryPoint("vs_main");
-		importOptions->setLanguage("hlsl");
-		importOptions->setProfile(GPP_VS_2_0);
-		importOptions->setType(GPT_VERTEX_PROGRAM);
-	}
-
-	HHighLevelGpuProgram vertProgRef = Importer::instance().import(dx9vsLoc, gpuProgImportOptions);
-
-#elif defined DX11
-
-	HGpuProgInclude gpuProgInclude = Importer::instance().import("C:\\testInclude.gpuproginc");
-	const String& debugString = gpuProgInclude->getString();
-	
-	/////////////////// HLSL 11 SHADERS //////////////////////////
-	String dx11psLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl11_ps.gpuprog";
-	String dx11vsLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl11_vs.gpuprog";
-
-	ImportOptionsPtr gpuProgImportOptions = Importer::instance().createImportOptions(dx11psLoc);
-	if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
-	{
-		GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
-
-		importOptions->setEntryPoint("ps_main");
-		importOptions->setLanguage("hlsl");
-		importOptions->setProfile(GPP_PS_4_0);
-		importOptions->setType(GPT_FRAGMENT_PROGRAM);
-	}
-
-	HHighLevelGpuProgram fragProgRef = Importer::instance().import(dx11psLoc, gpuProgImportOptions);
-
-	gpuProgImportOptions = Importer::instance().createImportOptions(dx11vsLoc);
-	if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
-	{
-		GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
-
-		importOptions->setEntryPoint("vs_main");
-		importOptions->setLanguage("hlsl");
-		importOptions->setProfile(GPP_VS_4_0);
-		importOptions->setType(GPT_VERTEX_PROGRAM);
-	}
-
-	HHighLevelGpuProgram vertProgRef = Importer::instance().import(dx11vsLoc, gpuProgImportOptions);
-	
-#else
-	///////////////// GLSL SHADERS ////////////////////////////
-	String glslpsLoc = "C:\\Projects\\BansheeEngine\\Data\\glsl_ps.gpuprog";
-	String glslvsLoc = "C:\\Projects\\BansheeEngine\\Data\\glsl_vs.gpuprog";
-
-	ImportOptionsPtr gpuProgImportOptions = Importer::instance().createImportOptions(glslpsLoc);
-	if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
-	{
-		GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
-
-		importOptions->setEntryPoint("main");
-		importOptions->setLanguage("glsl");
-		importOptions->setProfile(GPP_PS_2_0);
-		importOptions->setType(GPT_FRAGMENT_PROGRAM);
-	}
-
-	HHighLevelGpuProgram fragProgRef = Importer::instance().import(glslpsLoc, gpuProgImportOptions);
-
-	gpuProgImportOptions = Importer::instance().createImportOptions(glslvsLoc);
-	if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
-	{
-		GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
-
-		importOptions->setEntryPoint("main");
-		importOptions->setLanguage("glsl");
-		importOptions->setProfile(GPP_VS_2_0);
-		importOptions->setType(GPT_VERTEX_PROGRAM);
-	}
-
-	HHighLevelGpuProgram vertProgRef = Importer::instance().import(glslvsLoc, gpuProgImportOptions);
-#endif
-
-	gResources().create(vertProgRef, "C:\\vertProgCg.vprog", true);
-	gResources().unload(vertProgRef);
-	vertProgRef = gResources().load("C:\\vertProgCg.vprog");
-
-	gResources().create(fragProgRef, "C:\\fragProgCg.vprog", true);
-	gResources().unload(fragProgRef);
-	fragProgRef = gResources().load("C:\\fragProgCg.vprog");
-
-	ShaderPtr testShader = Shader::create("TestShader");
-
-	testShader->addParameter("matViewProjection", "matViewProjection", GPDT_MATRIX_4X4);
-
-#if defined DX11
-	testShader->addParameter("input", "input", GPDT_STRUCT, 2, 8);
-#endif
-
-	testShader->addParameter("samp", "samp", GPOT_SAMPLER2D);
-	testShader->addParameter("tex", "tex", GPOT_TEXTURE2D);
-	TechniquePtr newTechniqueGL = testShader->addTechnique("GLRenderSystem", "ForwardRenderer");
-	PassPtr newPassGL = newTechniqueGL->addPass();
-	newPassGL->setVertexProgram(vertProgRef);
-	newPassGL->setFragmentProgram(fragProgRef);
-
-	// TODO - I need to create different techniques for different render systems (and renderers, if there were any),
-	// which is redundant as some techniques can be reused. I should add a functionality that supports multiple
-	// render systems/renderers per technique
-	TechniquePtr newTechniqueDX = testShader->addTechnique("D3D9RenderSystem", "ForwardRenderer");
-	PassPtr newPassDX = newTechniqueDX->addPass();
-	newPassDX->setVertexProgram(vertProgRef);
-	newPassDX->setFragmentProgram(fragProgRef);
-
-	TechniquePtr newTechniqueDX11 = testShader->addTechnique("D3D11RenderSystem", "ForwardRenderer");
-	PassPtr newPassDX11 = newTechniqueDX11->addPass();
-	newPassDX11->setVertexProgram(vertProgRef);
-	newPassDX11->setFragmentProgram(fragProgRef);
-
-	HMaterial testMaterial = Material::create();
-	testMaterial->setShader(testShader);
-
-	testMaterial->setMat4("matViewProjection", Matrix4::IDENTITY);
-
-#if defined DX11
-	float dbgMultipliers1[2];
-	dbgMultipliers1[0] = 0.0f;
-	dbgMultipliers1[1] = 0.0f;
-
-	float dbgMultipliers2[2];
-	dbgMultipliers2[0] = 1.0f;
-	dbgMultipliers2[1] = 1.0f;
-
-	testMaterial->setStructData("input", dbgMultipliers1, sizeof(dbgMultipliers1), 0);
-	testMaterial->setStructData("input", dbgMultipliers2, sizeof(dbgMultipliers2), 1);
-#endif
-
-	//testMaterialRef = gResources().load("C:\\testMaterial.mat");
-	//testMaterialRef.waitUntilLoaded();
-
-	/*TextureRef testTex = static_resource_cast<Texture>(Importer::instance().import("C:\\ImportTest.tga"));*/
-	HTexture testTexRef = static_resource_cast<Texture>(Importer::instance().import("C:\\ArenaTowerDFS.psd"));
-	HMesh dbgMeshRef = static_resource_cast<Mesh>(Importer::instance().import("C:\\X_Arena_Tower.FBX"));
-
-	//int tmpFlag = _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_DELAY_FREE_MEM_DF);
-
-	gResources().create(testTexRef, "C:\\ExportTest.tex", true);
-	gResources().create(dbgMeshRef, "C:\\ExportMesh.mesh", true);
-
-	gResources().unload(testTexRef);
-	gResources().unload(dbgMeshRef);
-
-	testTexRef = static_resource_cast<Texture>(gResources().loadAsync("C:\\ExportTest.tex"));
-	dbgMeshRef = static_resource_cast<Mesh>(gResources().loadAsync("C:\\ExportMesh.mesh"));
-	
-	dbgMeshRef.synchronize();
-	testTexRef.synchronize();
-
-	testMaterial->setTexture("tex", testTexRef);
-	gResources().create(testMaterial, "C:\\ExportMaterial.mat", true);
-
-	gResources().unload(testMaterial);
-
-	testMaterial = gResources().load("C:\\ExportMaterial.mat");
-
-	//_ASSERT(_CrtCheckMemory());
-
-	testRenderable->setMesh(dbgMeshRef);
-	testRenderable->setMaterial(0, testMaterial);
-
-	//// Set the new state for the flag
-	//_CrtSetDbgFlag( tmpFlag );
-
-	HTexture dbgCursor = static_resource_cast<Texture>(Importer::instance().import("C:\\CursorDbg.psd"));
-	PixelDataPtr cursorPixelData = dbgCursor->allocateSubresourceBuffer(0);
-
-	gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
-	gMainSyncedCA().submitToCoreThread(true);
-
-	//Cursor::setCustomCursor(*cursorPixelData, Int2(0, 0));
-
-	dbgCursor = nullptr;
-
-	/************************************************************************/
-	/* 								EDITOR INIT                      		*/
-	/************************************************************************/
-
-	EditorWindowManager::startUp(cm_new<EditorWindowManager>());
-	MainEditorWindow* mainWindow = MainEditorWindow::create(gApplication().getPrimaryWindow());
-	
-	CM::gApplication().mainLoopCallback.connect(&editorUpdate);
-
-	/************************************************************************/
-	/* 							  EDITOR INIT END                    		*/
-	/************************************************************************/
-
-	DbgEditorWidget1::open();
-	DbgEditorWidget2::open();
-
-	gBansheeApp().runMainLoop();
-
-	/************************************************************************/
-	/* 							EDITOR SHUTDOWN                      		*/
-	/************************************************************************/
-
-	EditorWindowManager::shutDown();
-
-	/************************************************************************/
-	/* 							EDITOR SHUTDOWN END                    		*/
-	/************************************************************************/
-
-	//testMaterial->destroy();
-#ifdef DX11
-	gpuProgInclude = nullptr;
-#endif
-
-	gResources().unload(testTexRef);
-	gResources().unload(dbgMeshRef);
-	gResources().unload(fragProgRef);
-	gResources().unload(vertProgRef);
-	gResources().unload(testMaterial);
-
-	testMaterial = nullptr;
-	testTexRef = nullptr;
-	dbgMeshRef = nullptr;
-	fragProgRef = nullptr;
-	vertProgRef = nullptr;
-
-	testModelGO->destroy();
-
-	newPassGL = nullptr;
-	newTechniqueGL = nullptr;
-
-	newPassDX = nullptr;
-	newTechniqueDX = nullptr;
-
-	newPassDX11 = nullptr;
-	newTechniqueDX11 = nullptr;
-
-	testShader = nullptr;
-	
-	renderWindow = nullptr;
-	
-	gBansheeApp().shutDown();
+	EditorApplication::startUp(cm_new<EditorApplication>(RenderSystemPlugin::DX11));
+	EditorApplication::instance().runMainLoop();
+	EditorApplication::shutDown();
 
 
 	return 0;
 	return 0;
 }
 }

+ 2 - 0
CamelotClient/CamelotClient.vcxproj

@@ -256,6 +256,7 @@
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsDockManager.h" />
     <ClInclude Include="Include\BsDockManager.h" />
+    <ClInclude Include="Include\BsEditorApplication.h" />
     <ClInclude Include="Include\BsEditorPrerequisites.h" />
     <ClInclude Include="Include\BsEditorPrerequisites.h" />
     <ClInclude Include="Include\BsEditorWidget.h" />
     <ClInclude Include="Include\BsEditorWidget.h" />
     <ClInclude Include="Include\BsEditorWidgetContainer.h" />
     <ClInclude Include="Include\BsEditorWidgetContainer.h" />
@@ -292,6 +293,7 @@
     <ClCompile Include="Source\BsGUIWindowDropArea.cpp" />
     <ClCompile Include="Source\BsGUIWindowDropArea.cpp" />
     <ClCompile Include="Source\BsMainEditorWindow.cpp" />
     <ClCompile Include="Source\BsMainEditorWindow.cpp" />
     <ClCompile Include="Source\CmDebugCamera.cpp" />
     <ClCompile Include="Source\CmDebugCamera.cpp" />
+    <ClCompile Include="Source\BsEditorApplication.cpp" />
     <ClCompile Include="Source\CmTestTextSprite.cpp" />
     <ClCompile Include="Source\CmTestTextSprite.cpp" />
     <ClCompile Include="Source\DbgEditorWidget1.cpp" />
     <ClCompile Include="Source\DbgEditorWidget1.cpp" />
     <ClCompile Include="Source\DbgEditorWidget2.cpp" />
     <ClCompile Include="Source\DbgEditorWidget2.cpp" />

+ 6 - 0
CamelotClient/CamelotClient.vcxproj.filters

@@ -84,6 +84,9 @@
     <ClInclude Include="Include\BsGUIMenuBar.h">
     <ClInclude Include="Include\BsGUIMenuBar.h">
       <Filter>Header Files\Editor</Filter>
       <Filter>Header Files\Editor</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsEditorApplication.h">
+      <Filter>Header Files\Editor</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="stdafx.cpp">
     <ClCompile Include="stdafx.cpp">
@@ -143,5 +146,8 @@
     <ClCompile Include="Source\BsGUIMenuBar.cpp">
     <ClCompile Include="Source\BsGUIMenuBar.cpp">
       <Filter>Source Files\Editor</Filter>
       <Filter>Source Files\Editor</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsEditorApplication.cpp">
+      <Filter>Source Files\Editor</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 30 - 0
CamelotClient/Include/BsEditorApplication.h

@@ -0,0 +1,30 @@
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "CmModule.h"
+
+namespace BansheeEditor
+{
+	enum class RenderSystemPlugin
+	{
+		DX11,
+		DX9,
+		OpenGL
+	};
+
+	class EditorApplication : public CM::Module<EditorApplication>
+	{
+	public:
+		EditorApplication(RenderSystemPlugin renderSystemPlugin);
+		~EditorApplication();
+
+		void runMainLoop();
+
+	private:
+		RenderSystemPlugin mActiveRSPlugin;
+
+		static const CM::String& getLibraryNameForRenderSystem(RenderSystemPlugin plugin);
+
+		void update();
+	};
+}

+ 300 - 0
CamelotClient/Source/BsEditorApplication.cpp

@@ -0,0 +1,300 @@
+#include "BsEditorApplication.h"
+#include "BsEditorWindowManager.h"
+#include "BsMainEditorWindow.h"
+#include "BsApplication.h"
+#include "CmApplication.h"
+#include "CmRenderWindow.h"
+
+// DEBUG ONLY
+#include "DbgEditorWidget1.h"
+#include "DbgEditorWidget2.h"
+#include "CmResources.h"
+#include "CmSceneObject.h"
+#include "CmImporter.h"
+#include "CmGpuProgram.h"
+#include "CmGpuProgramImportOptions.h"
+#include "CmShader.h"
+#include "CmTexture.h"
+#include "CmMaterial.h"
+#include "CmTechnique.h"
+#include "CmPass.h"
+#include "BsRenderable.h"
+
+using namespace CamelotFramework;
+using namespace BansheeEngine;
+
+namespace BansheeEditor
+{
+	EditorApplication::EditorApplication(RenderSystemPlugin renderSystemPlugin)
+		:mActiveRSPlugin(renderSystemPlugin)
+	{
+		RENDER_WINDOW_DESC renderWindowDesc;
+		renderWindowDesc.width = 1280;
+		renderWindowDesc.height = 720;
+		renderWindowDesc.title = "BansheeEditor";
+		renderWindowDesc.fullscreen = false;
+		renderWindowDesc.border = WindowBorder::None;
+
+		const String& renderSystemLibraryName = getLibraryNameForRenderSystem(renderSystemPlugin);
+		gBansheeApp().startUp(renderWindowDesc, renderSystemLibraryName, "BansheeForwardRenderer", "D:\\CamelotResourceMetas"); // TODO - Make renderer and resource cache dir customizable
+
+		/************************************************************************/
+		/* 								DEBUG CODE                      		*/
+		/************************************************************************/
+
+		RenderSystem* renderSystem = RenderSystem::instancePtr();
+		RenderWindowPtr renderWindow = gApplication().getPrimaryWindow();
+
+		HSceneObject testModelGO = SceneObject::create("TestMesh");
+		HRenderable testRenderable = testModelGO->addComponent<Renderable>();
+
+		String psLoc;
+		String vsLoc;
+
+		GpuProgramProfile psProfile;
+		GpuProgramProfile vsProfile;
+
+		String psEntry;
+		String vsEntry;
+
+		String language;
+
+		switch (renderSystemPlugin)
+		{
+		case RenderSystemPlugin::DX11:
+			{
+				psLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl11_ps.gpuprog";
+				vsLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl11_vs.gpuprog";
+				language = "hlsl";
+				psProfile = GPP_PS_4_0;
+				vsProfile = GPP_VS_4_0;
+				psEntry = "ps_main";
+				vsEntry = "vs_main";
+				break;
+			}
+		case RenderSystemPlugin::DX9:
+			{
+				psLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl9_ps.gpuprog";
+				vsLoc = "C:\\Projects\\BansheeEngine\\Data\\hlsl9_vs.gpuprog";
+				language = "hlsl";
+				psProfile = GPP_PS_2_0;
+				vsProfile = GPP_VS_2_0;
+				psEntry = "ps_main";
+				vsEntry = "vs_main";
+				break;
+			}
+		case RenderSystemPlugin::OpenGL:
+			{
+				psLoc = "C:\\Projects\\BansheeEngine\\Data\\glsl_ps.gpuprog";
+				vsLoc = "C:\\Projects\\BansheeEngine\\Data\\glsl_vs.gpuprog";
+				language = "glsl";
+				psProfile = GPP_PS_2_0;
+				vsProfile = GPP_VS_2_0;
+				psEntry = "main";
+				vsEntry = "main";
+				break;
+			}
+		}
+
+		ImportOptionsPtr gpuProgImportOptions = Importer::instance().createImportOptions(psLoc);
+		if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
+		{
+			GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
+
+			importOptions->setEntryPoint(psEntry);
+			importOptions->setLanguage(language);
+			importOptions->setProfile(psProfile);
+			importOptions->setType(GPT_FRAGMENT_PROGRAM);
+		}
+
+		HHighLevelGpuProgram fragProgRef = Importer::instance().import(psLoc, gpuProgImportOptions);
+
+		gpuProgImportOptions = Importer::instance().createImportOptions(vsLoc);
+		if(rtti_is_of_type<GpuProgramImportOptions>(gpuProgImportOptions))
+		{
+			GpuProgramImportOptions* importOptions = static_cast<GpuProgramImportOptions*>(gpuProgImportOptions.get());
+
+			importOptions->setEntryPoint(vsEntry);
+			importOptions->setLanguage(language);
+			importOptions->setProfile(vsProfile);
+			importOptions->setType(GPT_VERTEX_PROGRAM);
+		}
+
+		HHighLevelGpuProgram vertProgRef = Importer::instance().import(vsLoc, gpuProgImportOptions);
+
+		gResources().create(vertProgRef, "C:\\vertProgCg.vprog", true);
+		gResources().unload(vertProgRef);
+		vertProgRef = gResources().load("C:\\vertProgCg.vprog");
+
+		gResources().create(fragProgRef, "C:\\fragProgCg.vprog", true);
+		gResources().unload(fragProgRef);
+		fragProgRef = gResources().load("C:\\fragProgCg.vprog");
+
+		ShaderPtr testShader = Shader::create("TestShader");
+
+		testShader->addParameter("matViewProjection", "matViewProjection", GPDT_MATRIX_4X4);
+
+		if(renderSystemPlugin == RenderSystemPlugin::DX11)
+				testShader->addParameter("input", "input", GPDT_STRUCT, 2, 8);
+
+		testShader->addParameter("samp", "samp", GPOT_SAMPLER2D);
+		testShader->addParameter("tex", "tex", GPOT_TEXTURE2D);
+		TechniquePtr newTechniqueGL = testShader->addTechnique("GLRenderSystem", "ForwardRenderer");
+		PassPtr newPassGL = newTechniqueGL->addPass();
+		newPassGL->setVertexProgram(vertProgRef);
+		newPassGL->setFragmentProgram(fragProgRef);
+
+		// TODO - I need to create different techniques for different render systems (and renderers, if there were any),
+		// which is redundant as some techniques can be reused. I should add a functionality that supports multiple
+		// render systems/renderers per technique
+		TechniquePtr newTechniqueDX = testShader->addTechnique("D3D9RenderSystem", "ForwardRenderer");
+		PassPtr newPassDX = newTechniqueDX->addPass();
+		newPassDX->setVertexProgram(vertProgRef);
+		newPassDX->setFragmentProgram(fragProgRef);
+
+		TechniquePtr newTechniqueDX11 = testShader->addTechnique("D3D11RenderSystem", "ForwardRenderer");
+		PassPtr newPassDX11 = newTechniqueDX11->addPass();
+		newPassDX11->setVertexProgram(vertProgRef);
+		newPassDX11->setFragmentProgram(fragProgRef);
+
+		HMaterial testMaterial = Material::create();
+		testMaterial->setShader(testShader);
+
+		testMaterial->setMat4("matViewProjection", Matrix4::IDENTITY);
+
+		if(renderSystemPlugin == RenderSystemPlugin::DX11)
+		{
+			float dbgMultipliers1[2];
+			dbgMultipliers1[0] = 0.0f;
+			dbgMultipliers1[1] = 0.0f;
+
+			float dbgMultipliers2[2];
+			dbgMultipliers2[0] = 1.0f;
+			dbgMultipliers2[1] = 1.0f;
+
+			testMaterial->setStructData("input", dbgMultipliers1, sizeof(dbgMultipliers1), 0);
+			testMaterial->setStructData("input", dbgMultipliers2, sizeof(dbgMultipliers2), 1);
+		}
+
+		HTexture testTexRef = static_resource_cast<Texture>(Importer::instance().import("C:\\ArenaTowerDFS.psd"));
+		HMesh dbgMeshRef = static_resource_cast<Mesh>(Importer::instance().import("C:\\X_Arena_Tower.FBX"));
+
+		gResources().create(testTexRef, "C:\\ExportTest.tex", true);
+		gResources().create(dbgMeshRef, "C:\\ExportMesh.mesh", true);
+
+		gResources().unload(testTexRef);
+		gResources().unload(dbgMeshRef);
+
+		testTexRef = static_resource_cast<Texture>(gResources().loadAsync("C:\\ExportTest.tex"));
+		dbgMeshRef = static_resource_cast<Mesh>(gResources().loadAsync("C:\\ExportMesh.mesh"));
+
+		dbgMeshRef.synchronize();
+		testTexRef.synchronize();
+
+		testMaterial->setTexture("tex", testTexRef);
+		gResources().create(testMaterial, "C:\\ExportMaterial.mat", true);
+
+		gResources().unload(testMaterial);
+
+		testMaterial = gResources().load("C:\\ExportMaterial.mat");
+
+		testRenderable->setMesh(dbgMeshRef);
+		testRenderable->setMaterial(0, testMaterial);
+
+		HTexture dbgCursor = static_resource_cast<Texture>(Importer::instance().import("C:\\CursorDbg.psd"));
+		PixelDataPtr cursorPixelData = dbgCursor->allocateSubresourceBuffer(0);
+
+		gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
+		gMainSyncedCA().submitToCoreThread(true);
+
+		/************************************************************************/
+		/* 							END DEBUG CODE                      		*/
+		/************************************************************************/
+
+		EditorWindowManager::startUp(cm_new<EditorWindowManager>());
+		MainEditorWindow* mainWindow = MainEditorWindow::create(gApplication().getPrimaryWindow());
+
+		gApplication().mainLoopCallback.connect(boost::bind(&EditorApplication::update, this));
+
+		DbgEditorWidget1::open(); // DEBUG ONLY
+		DbgEditorWidget2::open(); // DEBUG ONLY
+
+		gBansheeApp().runMainLoop();
+
+		EditorWindowManager::shutDown();
+
+		/************************************************************************/
+		/* 								DEBUG CODE                      		*/
+		/************************************************************************/
+
+		gResources().unload(testTexRef);
+		gResources().unload(dbgMeshRef);
+		gResources().unload(fragProgRef);
+		gResources().unload(vertProgRef);
+		gResources().unload(testMaterial);
+
+		testMaterial = nullptr;
+		testTexRef = nullptr;
+		dbgMeshRef = nullptr;
+		fragProgRef = nullptr;
+		vertProgRef = nullptr;
+
+		testModelGO->destroy();
+
+		newPassGL = nullptr;
+		newTechniqueGL = nullptr;
+
+		newPassDX = nullptr;
+		newTechniqueDX = nullptr;
+
+		newPassDX11 = nullptr;
+		newTechniqueDX11 = nullptr;
+
+		testShader = nullptr;
+
+		renderWindow = nullptr;
+
+		/************************************************************************/
+		/* 							END DEBUG CODE                      		*/
+		/************************************************************************/
+
+		gBansheeApp().shutDown();
+
+	}
+
+	EditorApplication::~EditorApplication()
+	{
+		// TODO - Move shutdown code from constructor to here. Right now I don't care because cleanup 
+		// isn't working as intended and if I move stuff I will probably break it even more
+	}
+
+	void EditorApplication::runMainLoop()
+	{
+		// TODO - Move "runMainLoop" code from constructor to here. Right now I don't care because cleanup 
+		// isn't working as intended and if I move stuff I will probably break it even more
+	}
+
+	void EditorApplication::update()
+	{
+		EditorWindowManager::instance().update();	
+	}
+
+	const String& EditorApplication::getLibraryNameForRenderSystem(RenderSystemPlugin plugin)
+	{
+		static String DX11Name = "CamelotD3D11RenderSystem";
+		static String DX9Name = "CamelotD3D9RenderSystem";
+		static String OpenGLName = "CamelotGLRenderSystem";
+
+		switch(plugin)
+		{
+		case RenderSystemPlugin::DX11:
+			return DX11Name;
+		case RenderSystemPlugin::DX9:
+			return DX9Name;
+		case RenderSystemPlugin::OpenGL:
+			return OpenGLName;
+		}
+
+		return StringUtil::BLANK;
+	}
+}

+ 25 - 0
MBansheeEditor/Program.cs

@@ -7,7 +7,32 @@ namespace MBansheeEditor
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
+            // Starts main editor window with the specified width/height and render system
+            // (Window position and sizes are stored internally. Restored upon StartUp and saved upon ShutDown)
+            //EditorApplication.StartUp(RenderSystem.DX11, 1024, 800);
+
+            // TODO - A class to manipulate menu items
 
 
         }
         }
     }
     }
+
+    //class SceneView : EditorWindow
+    //{
+       // SceneView()
+    //    {
+            // GUI is a GUILayout that is initialized internally by EditorWindow
+            //GUI.AddButton("Some text");
+            //GUI.AddXLayout();
+            //GUI.CreateAreaFixed(100, 100, 400, 400); // GUIArea creating another GUIArea
+
+            // Add support for GUIContent
+            // Add support for GUILayoutOptions
+            // Add support for GUIElementStyle and GUISkin - For now ignore this as I need to deal with Fonts, Textures, SpriteTextures, etc.
+     //   }
+    //}
+
+    //class MyGUI : //GUIWidget // GUIWidget is automatically initialized with Game render window. Editor GUIWidgets are specially initialized 
+    //{
+        
+    //}
 }
 }