2
0
Mark Sibly 8 жил өмнө
parent
commit
fb3cfbb378

+ 1 - 1
modules/mojo/app/app.monkey2

@@ -456,7 +456,7 @@ Class AppInstance
 	#end
 	Method MainLoop()
 		
-		If (Not _requestRender Or Not Renderable) And Idle=Null
+		If Not _requestRender Or Not Renderable
 
 			SDL_WaitEvent( Null )
 

+ 73 - 0
modules/mojo/newdocs/app.md

@@ -0,0 +1,73 @@
+
+@manpage Application framework
+
+### Application framework
+
+@#### Initialization and the event loop
+
+To initialize mojo, you need to do at least 3 things:
+
+* Create an [[AppInstance]] using 'New AppInstance'. This will automatically initialize the [[App]] global variable.
+* Create a [[Window]]. You will generally create a subclass of window you have defined yourself, eg: 'New MyWindow'.
+* Start the app using [[AppInstance.Run|App.Run]].
+
+This can all be done inside Main().
+
+Once the app is running, mojo runs a simple event loop that looks like this:
+
+* Get OS events and dispatch corresponding mojo events if necessary.
+* Once there are no OS events left to process, any custom [[AppInstance.Idle|App.Idle]] handlers are called.
+* If the application has called [[AppInstance.RequestRender|App.RequestRender]], the app is then rendered.
+
+The app will continue executing the event loop until [[AppInstance.Terminate|App.Terminate]] is called.
+
+@#### Subclassing Window
+
+Subclassing the app Window class is easy - just extend the [[Window]] class.
+
+To render to the window, you will also need to override the [[Window.OnRender]] method. 
+
+The OnRender method is called when the app needs to be rendered, and is passed a [[Canvas|Canvas]] instance for window rendering code to use.
+
+In addition, you may also want to override the [[Window.OnWindowEvent]] method to handle window close, resize etc events.
+
+@#### Handling user input
+
+There are 2 main ways to handle user input, via the [[View.OnKeyEvent]] and [[View.OnMouseEvent]] event handlers or using the
+[[input.Keyboard]] and [[input.Mouse]] devices.
+
+Key and mouse events are sent to your app as soon they are processed by the event loop, while the keyboard and mouse devices may be 'polled' at
+any time.
+
+
+@#### A minimal mojo app.
+
+Ok, time to put it all together!
+
+@example
+
+#Import "<std>"
+#Import "<mojo>"
+
+Using std..
+Using mojo..
+
+Class MyWindow Extends Windows
+
+	Method OnRender( canvas:Canvas ) Override
+
+		canvas.DrawText( "Hello World",Width/2,Height/2,.5,.5 )
+	End
+	
+End
+
+Function Main()
+
+	New AppInstance
+	
+	New MyWindow
+	
+	App.Run()
+End
+
+@end

+ 4 - 0
modules/mojo/newdocs/audio.md

@@ -0,0 +1,4 @@
+
+@manpage Audio
+
+### Audio

+ 5 - 0
modules/mojo/newdocs/graphics.md

@@ -0,0 +1,5 @@
+
+@manpage Graphics
+
+### Graphics
+

+ 5 - 0
modules/mojo/newdocs/input.md

@@ -0,0 +1,5 @@
+
+@manpage User input
+
+### User input
+

+ 20 - 0
modules/mojo/newdocs/manual.md

@@ -0,0 +1,20 @@
+
+@manpage The mojo module
+
+# The mojo module
+
+Mojo is a simple, lightweight, application framework optimized for realtime applications such as games.
+
+Mojo includes the folloing namespaces:
+
+| Namespace				| Description
+|:----------------------|:-----------
+| [[mojo.app]]			| Core application framework.
+| [[mojo.graphics]]		| Drawing and rendering.
+| [[mojo.input]]		| Reading user input.
+| [[mojo.audio]]		| Pplaying sounds.
+
+@import app.md
+@import graphics.md
+@import audio.md
+@import input.md