Răsfoiți Sursa

More work on user manuals

BearishSun 9 ani în urmă
părinte
comite
ef59933827

+ 26 - 0
Documentation/Manuals/Native/User/logging.md

@@ -0,0 +1,26 @@
+Logging	messages								{#logging}
+===============
+
+Logging can be a useful way to debug issues during development, or notify the user that an error occurred. In Banshee it is handled though the @ref bs::Debug "Debug" class. Use @ref bs::gDebug "gDebug()" for an easy way to access the **Debug** instance.
+
+Use any of these methods to log a new message:
+ - @ref bs::Debug::logDebug "Debug::logDebug" - Logs an informative message.
+ - @ref bs::Debug::logWarning "Debug::logWarning" - Log a message that an issue happened, but it's non critical.
+ - @ref bs::Debug::logError "Debug::logError" - Log a message that an issue happened, and it's critical.
+ 
+~~~~~~~~~~~~~{.cpp}
+UINT32 x = 5;
+
+gDebug().logDebug("Value of x is: " + toString(x));
+
+if(x != 5)
+	gDebug().logError("X must equal 5!");
+~~~~~~~~~~~~~
+
+All logged messages will be output to the standard console output, as well as the attached debugger output (if any).
+
+Messages are also saved internally, and can be output to a .html file by calling @ref bs::Debug::saveLog "Debug::saveLog()".
+
+~~~~~~~~~~~~~{.cpp}
+gDebug().saveLog("C:\myLog.html");
+~~~~~~~~~~~~~

+ 67 - 0
Documentation/Manuals/Native/User/time.md

@@ -0,0 +1,67 @@
+Measuring time								{#time}
+===============
+
+Being able to tell the current time, as well as being able to tell elapsed time since the last frame is important for any real-time application. Use the @ref bs::Time "Time" class, accessible through @ref bs::gTime "gTime()" to retrieve global information about the time in Banshee.
+
+# Current time
+
+Use @ref bs::Time::getTime() "Time::getTime()" to get the current time (since application start) in seconds.
+
+~~~~~~~~~~~~~{.cpp}
+float curTime = gTime().getTime();
+gDebug().logDebug("Application was started " + toString(curTime) + " seconds ago.");
+~~~~~~~~~~~~~
+
+It's important to note this value is only updated once per frame (i.e. it stays constant throughout a frame). If you need more precise time that can be used for inter-frame measurements, use @ref bs::Time::getTimePrecise "Time::getTimePrecise()", which returns the current time in microseconds.
+
+~~~~~~~~~~~~~{.cpp}
+UINT64 preciseTimeStart = gTime().getTimePrecise();
+
+UINT64 counter = 0;
+for(int i = 0; i < 1000000; i++)
+	counter += i % 10;
+
+UINT64 preciseTimeEnd = gTime().getTimePrecise();
+UINT64 timeElapsed = preciseTimeEnd - preciseTimeStart;
+
+float secondsElapsed = timeElapsed * Time::MICROSEC_TO_SEC;
+gDebug().logDebug("Operation took " + toString(secondsElapsed) + " seconds.");
+~~~~~~~~~~~~~
+
+> @ref bs::Time::MICROSEC_TO_SEC "Time::MICROSEC_TO_SEC" is a constant to convert between microseconds and seconds.
+
+You should use **Time::getTime()** for most gameplay purposes, while **Time::getTimePrecise()** can be used for profiling and other similar situations.
+
+# Elapsed time
+Often it is useful to know know how much has passed since the last frame. Use @ref bs::Time::getFrameDelta() "Time::getFrameDelta()" to get the elapsed time from the previous frame.
+
+~~~~~~~~~~~~~{.cpp}
+float elapsedTime = gTime().getFrameDelta();
+gDebug().logDebug("Last frame was " + toString(elapsedTime) + " seconds ago.");
+~~~~~~~~~~~~~
+
+# Frame index
+Sometimes, often for debugging purposes, it is useful to know the index of the current frame. Use @ref bs::Time::getFrameIdx() "Time::getFrameIdx()". Each frame the index gets incremented by one.
+
+~~~~~~~~~~~~~{.cpp}
+UINT64 frameIdx = gTime().getFrameIdx();
+gDebug().logDebug("This is frame #" + toString(frameIdx));
+~~~~~~~~~~~~~
+
+# Intervals
+Sometimes it is useful to measure a time interval, like we did with **Time::getTimePrecise()** with the example above. You can also use the @ref bs::Timer "Timer" class for the same purpose, but with a slightly simpler interface.
+
+~~~~~~~~~~~~~{.cpp}
+Timer timer; // Starts counting
+
+UINT64 counter = 0;
+for(int i = 0; i < 1000000; i++)
+	counter += i % 10;
+
+float secondsElapsed = timer.getMicroseconds() * Time::MICROSEC_TO_SEC;
+gDebug().logDebug("Operation took " + toString(secondsElapsed) + " seconds.");
+~~~~~~~~~~~~~
+
+Timer starts counting as soon as its constructed, and you can use @ref bs::Timer::getMicroseconds "Timer::getMicroseconds()" to retrieve the time elapsed.
+
+Optionally you can also reset the timer by calling @ref bs::Timer::reset "Timer::reset()". This will set the time elapsed to 0, and any elapsed time will be reported from the last reset call.

+ 3 - 3
Source/BansheeCore/Include/BsInputFwd.h

@@ -16,9 +16,9 @@ namespace bs
 	 *
 	 *
 	 * @note
 	 * @note
 	 * These codes are only keyboard scan codes. This means that exact scan code identifier might not correspond to that 
 	 * These codes are only keyboard scan codes. This means that exact scan code identifier might not correspond to that 
-	 * exact character on users keyboard, depending on users input locale. Only for US locale will these scan code names 
-	 * will match the actual keyboard input. Think of the US key code names as only a convenience for more easily 
-	 * identifying which location on the keyboard a scan code represents.
+	 * exact character on user's keyboard, depending on user's input locale. Only for US locale will these scan code names 
+	 * match the actual keyboard input. Think of the US key code names as only a convenience for more easily identifying
+	 * which location on the keyboard a scan code represents.
 	 * @note
 	 * @note
 	 * When storing these sequentially make sure to only reference the low order 2 bytes. Two high order bytes are used for 
 	 * When storing these sequentially make sure to only reference the low order 2 bytes. Two high order bytes are used for 
 	 * various flags.
 	 * various flags.

+ 1 - 5
Source/BansheeUtility/Include/BsTimer.h

@@ -10,11 +10,7 @@ namespace bs
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	/**
-	 * Timer class used for querying high precision timers.
-	 *
-	 * @note	Not thread safe.
-	 */
+	/** Timer class used for querying high precision timers. */
 	class BS_UTILITY_EXPORT Timer
 	class BS_UTILITY_EXPORT Timer
     {
     {
     public:
     public: