Marko Pintera 13 лет назад
Родитель
Сommit
ed85a56ea6

+ 5 - 15
CamelotRenderer/TODO.txt

@@ -18,6 +18,7 @@ HardwareBuffer - Base class for all buffers
 DefaultHardwareBufferManager - Provides emulation of hardware buffers
 DefaultHardwareBufferManager - Provides emulation of hardware buffers
  - I think this class is okay to stay, although I'm not sure where its used, but its simple enough
  - I think this class is okay to stay, although I'm not sure where its used, but its simple enough
 Texture - PARSED!
 Texture - PARSED!
+HardwareOcclusionQuery - OK, but I might consider a more generic interface for queries (I'll need profiling queries too for example)
 
 
 TODO FILES:
 TODO FILES:
 
 
@@ -31,8 +32,6 @@ Frustum
 GpuProgramParams - Holds all parameters used in a shader program and allows us to set them by index or name
 GpuProgramParams - Holds all parameters used in a shader program and allows us to set them by index or name
  - Explore if we can remove GpuSharedParameters. I'm not exactly sure what they're used for
  - Explore if we can remove GpuSharedParameters. I'm not exactly sure what they're used for
 
 
-HardwareOcclusionQuery - OK, but I might consider a more generic interface for queries (I'll need profiling queries too for example)
-
 HardwarePixelBuffer 
 HardwarePixelBuffer 
  - I might consider giving PixelBox a better name. Also rename PixelFormat.h to PixelUtil.h or similar. Makes more sense.
  - I might consider giving PixelBox a better name. Also rename PixelFormat.h to PixelUtil.h or similar. Makes more sense.
  - _clearSliceRTT method I'm not sure what is it used for, but I might want to remove it
  - _clearSliceRTT method I'm not sure what is it used for, but I might want to remove it
@@ -45,27 +44,19 @@ TODO:
  - Make sure to parse D3D9 implementations of above classes and see what needs removing there as well
  - Make sure to parse D3D9 implementations of above classes and see what needs removing there as well
  - OpenGL too
  - OpenGL too
 
 
-IMPORTANT: I think I should strive to make the renderer one unique CmRenderSystem.dll (Log manager, exceptions, math can go in a separate CmUtility library?)
-   - Later separate out OpenGL and D3D9 dlls as well, since I want to support D3D11. And I want to keep the framework separate from implementation
-     - AND because I need to have it separated since I can't expect DirectX to compile on OSX or Linux
-
 TOMORROW:
 TOMORROW:
- - Incorporate CamelotUtility library into CamelotRenderer
-   - Move remaining Utility files to CamelotUtility (files like StringUtil, PixelUtil and similar)
-     - Port exceptions
-	 - Add log
-   - Remove remaining not-needed headers
+ - Add precompiled headers to all projects
+ - Make sure they include Exception & Log classes
 
 
 Other notes:
 Other notes:
  - Search for all remaining "TODO PORT" comments and fix them
  - Search for all remaining "TODO PORT" comments and fix them
- - Rename all macros and other OGRE references to CM
  - How am I notified on device reset? (When I need to reload my resources)
  - How am I notified on device reset? (When I need to reload my resources)
  - If possible, make sure GLSL uses EntryPoint and Profile fields I have added to GpuProgram
  - If possible, make sure GLSL uses EntryPoint and Profile fields I have added to GpuProgram
  - Remove all fixed pipeline methods from D3D9 and OpenGL renderers
  - Remove all fixed pipeline methods from D3D9 and OpenGL renderers
+ - Make CamelotRenderer a project on its own?
 
 
  At one point rebuild everything and make sure all warnings are gone
  At one point rebuild everything and make sure all warnings are gone
-Figure out how to ignore those warnings in NVparse
-String stuff should go to a single StringUtil file
+  - Also scan everything for "Ogre" and remove any references to it
 
 
 After everything is polished:
 After everything is polished:
  - Make sure the renderer can run on a separate thread
  - Make sure the renderer can run on a separate thread
@@ -74,7 +65,6 @@ After everything is polished:
     - Maybe just add support for Cg and force everyone to use that? - I'd like to be able to just switch out renderer in a single location and that everything keeps on working without 
     - Maybe just add support for Cg and force everyone to use that? - I'd like to be able to just switch out renderer in a single location and that everything keeps on working without 
 	  further modifications.
 	  further modifications.
  - Port boost threads to std threads (CmThreadDefines.h)
  - Port boost threads to std threads (CmThreadDefines.h)
- - I should move boost so it resides in CamelotUtility
  - Also, create all file format parsers and also make them reside in CamelotUtility
  - Also, create all file format parsers and also make them reside in CamelotUtility
    (Actual importers will still be implemented in Editor, but parsing capabilities should be available for camelotutility)
    (Actual importers will still be implemented in Editor, but parsing capabilities should be available for camelotutility)
  
  

+ 2 - 0
CamelotUtility/CamelotUtility.vcxproj

@@ -76,6 +76,7 @@
     <ClInclude Include="Include\CmColor.h" />
     <ClInclude Include="Include\CmColor.h" />
     <ClInclude Include="Include\CmDynLibManager.h" />
     <ClInclude Include="Include\CmDynLibManager.h" />
     <ClInclude Include="Include\CmException.h" />
     <ClInclude Include="Include\CmException.h" />
+    <ClInclude Include="Include\CmLog.h" />
     <ClInclude Include="Include\CmMathAsm.h" />
     <ClInclude Include="Include\CmMathAsm.h" />
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmModule.h" />
     <ClInclude Include="Include\CmPixelUtil.h" />
     <ClInclude Include="Include\CmPixelUtil.h" />
@@ -104,6 +105,7 @@
     <ClCompile Include="Source\CmColor.cpp" />
     <ClCompile Include="Source\CmColor.cpp" />
     <ClCompile Include="Source\CmDynLibManager.cpp" />
     <ClCompile Include="Source\CmDynLibManager.cpp" />
     <ClCompile Include="Source\CmException.cpp" />
     <ClCompile Include="Source\CmException.cpp" />
+    <ClCompile Include="Source\CmLog.cpp" />
     <ClCompile Include="Source\CmMath.cpp" />
     <ClCompile Include="Source\CmMath.cpp" />
     <ClCompile Include="Source\CmMatrix3.cpp" />
     <ClCompile Include="Source\CmMatrix3.cpp" />
     <ClCompile Include="Source\CmMatrix4.cpp" />
     <ClCompile Include="Source\CmMatrix4.cpp" />

+ 6 - 0
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -108,6 +108,9 @@
     <ClInclude Include="Include\CmModule.h">
     <ClInclude Include="Include\CmModule.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\CmLog.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Include\CmAxisAlignedBox.cpp">
     <ClCompile Include="Include\CmAxisAlignedBox.cpp">
@@ -155,5 +158,8 @@
     <ClCompile Include="Source\CmDynLibManager.cpp">
     <ClCompile Include="Source\CmDynLibManager.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\CmLog.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 97 - 0
CamelotUtility/Include/CmLog.h

@@ -0,0 +1,97 @@
+#pragma once
+
+#include "CmPrerequisitesUtil.h"
+#include "boost/signal.hpp"
+
+namespace CamelotEngine
+{
+	/**	   
+	* @brief	Different log levels that log entries may be assigned.
+	 */
+	enum LogLevel
+	{
+		LL_DEBUG = 0x1,
+		LL_INFO = 0x2,
+		LL_WARNING = 0x4,
+		LL_ERROR = 0x8
+	};
+
+	/**
+	 * @brief	A single log entry, usually used in QtLogModel as
+	 * 			a representation of a log entry in the Console window.
+	 */
+	class CM_EXPORT LogEntry
+	{
+	public:
+		LogEntry(const String& msg, LogLevel level);
+
+		LogLevel getLevel(void) { return mLevel; }
+		const String& getMessage(void) { return mMsg; }
+
+	private:
+		String mMsg;
+		LogLevel mLevel;
+	};
+
+	/**
+	 * @brief	Used for logging messages to a file. Can also send out callbacks to
+	 * 			registered classes when a message is received, so they can do with it as they wish.
+	 */
+	class CM_EXPORT Log
+	{
+	public:
+		/**
+		 * @brief	Constructor.
+		 *
+		 * @param	logFilePath		  	Full pathname of the log file. Should have a .html extension.
+		 * @param	autoSave		  	(optional) Whether to save the log to disk whenever a new message
+		 * 								is added. (Useful when you want to make sure your log is up to
+		 * 								date after a crash). The log file will only be saved on exit, or
+		 * 								if you call save manually.
+		 * @param	suppressFileOutput	(optional) If true, log won't be saved to a file, even if you
+		 * 								call save manually.
+		 */
+		Log(const String& logFilePath, bool autoSave = true, bool suppressFileOutput = false);
+		~Log();
+
+		/**
+		 * @brief	Logs a new message. If autoSave is enabled it will automatically save the message to
+		 * 			disk.
+		 *
+		 * @param	message	The message describing the log entry.
+		 * @param	level  	Severity of the log entry.
+		 */
+		void logMsg(const String& message, LogLevel level);
+
+		/**
+		 * @brief	Removes all log entries. If autoSave is enabled the file on disk will be cleared too.
+		 */
+		void clear();
+
+		/**
+		 * @brief	Saves the log file to disk.
+		 */
+		void save();
+
+	private:
+		std::vector<LogEntry*> mEntries;
+
+		bool mAutoSave;
+		bool mSuppressFileOutput;
+		String mSaveFilePath;
+
+		/**
+		 * @brief	Called whenever a new entry is added.
+		 */
+		void doOnEntryAdded(const LogEntry& entry);
+
+		/************************************************************************/
+		/* 								SIGNALS		                     		*/
+		/************************************************************************/
+	public:
+		/**
+		 * @brief	Triggered when a new entry in the log is added.
+		 */
+		boost::signal<void(const LogEntry&)> onEntryAdded;
+	};
+}

+ 60 - 0
CamelotUtility/Source/CmLog.cpp

@@ -0,0 +1,60 @@
+#include "CmLog.h"
+
+namespace CamelotEngine
+{
+	LogEntry::LogEntry(const String& msg, LogLevel level)
+		:mMsg(msg), mLevel(level)
+	{ }
+
+	Log::Log(const String& logFilePath, bool autoSave, bool suppressFileOutput)
+		:mAutoSave(autoSave), mSuppressFileOutput(suppressFileOutput), mSaveFilePath(logFilePath)
+	{
+	}
+
+	Log::~Log()
+	{
+		save();
+
+		for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
+			delete *iter;
+	}
+
+	void Log::logMsg(const String& message, LogLevel level)
+	{
+		LogEntry* newEntry = new LogEntry(message, level);
+		mEntries.push_back(newEntry);
+
+		doOnEntryAdded(*newEntry);
+
+		if(mAutoSave)
+			save();
+	}
+
+	void Log::clear()
+	{
+		for(auto iter = mEntries.begin(); iter != mEntries.end(); ++iter)
+			delete *iter;
+
+		mEntries.clear();
+
+		if(mAutoSave)
+			save();
+	}
+
+	void Log::save()
+	{
+		if(mSuppressFileOutput)
+			return;
+
+		// TODO - Write to disk and throw exception if it can't
+		
+		//OGRE_EXCEPT(::Ogre::Exception::ERR_INTERNAL_ERROR, 
+		//	"Cannot create log file at " + mSaveFilePath,
+		//	"Log::save()");
+	}
+
+	void Log::doOnEntryAdded(const LogEntry& entry)
+	{
+		onEntryAdded(entry);
+	}
+}