Mark Sibly 7 years ago
parent
commit
64262c2025
3 changed files with 82 additions and 2 deletions
  1. 22 0
      modules/mojo/newdocs/audio.md
  2. 54 1
      modules/mojo/newdocs/graphics.md
  3. 6 1
      modules/mojo/newdocs/input.md

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

@@ -2,3 +2,25 @@
 @manpage Audio
 @manpage Audio
 
 
 ### Audio
 ### Audio
+
+A [[Sound]] object contains static audio data that can be play through [[Channel]] objects.
+
+A sound object can be loaded from file using [[Sound.Load]] or constructed from an [[std::std.audio.AudoData|AudioData]] object.
+
+There are several ways to play a sound:
+
+* Using [[Sound.Play]] to play a sound object through a temporary channel object.
+
+* Playing a sound through an existing channel using [[Channel.Play]].
+
+
+#### Music
+
+Music can be streamed from file using [[AudioDevice.PlayMusic|Audio.PlayMusic]].
+
+Music must currently be in ogg format.
+
+
+
+
+

+ 54 - 1
modules/mojo/newdocs/graphics.md

@@ -1,5 +1,58 @@
 
 
 @manpage Graphics
 @manpage Graphics
 
 
-### Graphics
+### Graphics and Rendering
 
 
+@#### Canvases
+
+All rendering in mojo is performed using [[Canvas]] objects.
+
+To render to a canvas you use one of the drawing operations including:
+
+* [[Canvas.DrawImage]] to draw an image to a canvas.
+
+* [[Canvas.DrawPoint]], [[Canvas.DrawLine]], [[Canvas.DrawTriangle]], [[Canvas.DrawPoly]] to draw primitive shapes to a canvas.
+
+You can also clear a canvas to a solid color using [[Canvas.Clear]].
+
+Drawing operations aren't rendered immediately. They are queued so that as many as possible can be rendered at once. You can force any queued drawing operations to be rendered immediately using [[Canvas.Flush]].
+
+A canvas also maintains a number of pieces of rendering state including:
+
+* A viewport and scissor rect. See [[Canvas.Viewport]], [[Canvas.Scissor]].
+
+* A transformation matrix. See: [[Canvas.Matrix]], [[Canvas.Translate]], [[Canvas.Scale]] and [[Canvas.Rotate]].
+
+* A drawing color and alpha level. See: [[Canvas.Color]] and [[Canvas.Alpha]].
+
+* A blend mode. See [[Canvas.BlendMode]].
+
+This canvas state is applied to all drawing operations.
+
+There are 2 ways to obtain a canvas object:
+
+* You get passed a canvas object when a View's [[View.OnRender]] method is invoked. This canvas should be treated as temporary and is only valid until the OnRender method returns. The canvas is automatically flushed when OnRender returns so you don't have to do this yourself.
+
+* You can also create a canvas for rendering directly to an image. In this case, it is important to flush the canvas once you have finished drawing to it.
+
+
+@#### Images
+
+An [[Image]] is a rectangular region of pixels that can be drawn to a canvas.
+
+An image can be loaded from a file using the [[Image.Load]] function or constructed from a [[std:std.graphics.Pixmap|Pixmap]] object.
+
+You can also render to an image using a canvas object.
+
+
+@#### Lighting
+
+A canvas also support 2d lighting with bumpmapping and specular effects.
+
+Light are 'drawn' using the [[Canvas.AddLight]] method, which can only be used when the canvas is in 'lighting mode'.
+
+To put the canvas into lighting mode, use the [[Canvas.BeginLighting]] method. To end lighting mode, use the [[Canvas.EndLighting]] method. EndLighting is what actually renders the lighting, and will add lighting to any graphics rendered between BeginLighting and EndLighting.
+
+You can not change the canvas viewport or scissor rect while the canvas is in lighting mode.
+
+AddLight takes an image parameter and is used in a very similar way to DrawImage. Light images can contain arbitrary colors and can be scaled, rotated etc. when drawn. However, images used for lighting should be loaded using the [[Image.LoadLight]] method.

+ 6 - 1
modules/mojo/newdocs/input.md

@@ -1,5 +1,10 @@
 
 
 @manpage User input
 @manpage User input
 
 
-### User input
+To handle keyboard input, an app can either handle KeyEvent events by overriding the [[View.OnKeyEvent]] method, or poll the [[KeyboardDevice]] directly using the global [[Keyboard]] const.
+
+To handle mouse input, an app can either handle MouseEvent events by overriding the [[View.OnMouseEvent]] method, or poll the [[MouseDevice]] directly using the global [[Mouse]] const.
+
+To handle touch input, an app can either handle TouchEvent events ny overriding the [[View.OnTouchEvent]] method, or poll the [[TouchDevice]] directly using the global [[Touch]] const.
+