Browse Source

rm fenced codeblocks;

bjorn 2 years ago
parent
commit
d8a99210bd

+ 2 - 7
api/init.lua

@@ -47,11 +47,6 @@ return {
                   type = "table",
                   description = "Configuration for the math module.",
                   table = {
-                    {
-                      name = "ffi",
-                      type = "boolean",
-                      description = "Whether vector objects should use an optimized LuaJIT FFI codepath."
-                    },
                     {
                       name = "globals",
                       type = "boolean",
@@ -4608,7 +4603,7 @@ return {
       description = "The `lovr.filesystem` module provides access to the filesystem.",
       key = "lovr.filesystem",
       enums = {},
-      notes = "LÖVR programs can only write to a single directory, called the save directory.  The location of the save directory is platform-specific:\n\n<table>\n  <tr>\n    <td>Windows</td>\n    <td><code>C:\\Users\\&lt;user&gt;\\AppData\\Roaming\\LOVR\\&lt;identity&gt;</code></td>\n  </tr>\n  <tr>\n    <td>macOS</td>\n    <td><code>/Users/&lt;user&gt;/Library/Application Support/LOVR/&lt;identity&gt;</code></td>\n  </tr> </table>\n\n`<identity>` should be a unique identifier for your app.  It can be set either in `lovr.conf` or by using `lovr.filesystem.setIdentity`.\n\nAll filenames are relative to either the save directory or the directory containing the project source.  Files in the save directory take precedence over files in the project.",
+      notes = "LÖVR programs can only write to a single directory, called the save directory.  The location of the save directory is platform-specific:\n\n<table>\n  <tr>\n    <td>Windows</td>\n    <td><code>C:\\Users\\&lt;user&gt;\\AppData\\Roaming\\LOVR\\&lt;identity&gt;</code></td>\n  </tr>\n  <tr>\n    <td>macOS</td>\n    <td><code>/Users/&lt;user&gt;/Library/Application Support/LOVR/&lt;identity&gt;</code></td>\n  </tr>\n  <tr>\n    <td>Linux</td>\n    <td><code>/home/&lt;user&gt;/.local/share/LOVR/&lt;identity&gt;</code></td>\n  </tr>\n  <tr>\n    <td>Android</td>\n    <td><code>/sdcard/Android/data/&lt;identity&gt;/files</code></td>\n  </tr> </table>\n\n`<identity>` should be a unique identifier for your app.  It can be set either in `lovr.conf` or by using `lovr.filesystem.setIdentity`.\n\nAll filenames are relative to either the save directory or the directory containing the project source.  Files in the save directory take precedence over files in the project.",
       functions = {
         {
           name = "append",
@@ -4846,7 +4841,7 @@ return {
               }
             }
           },
-          notes = "The save directory takes the following form:\n\n``` <appdata>/LOVR/<identity> ```\n\nWhere `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`."
+          notes = "The save directory takes the following form:\n\n    <appdata>/LOVR/<identity>\n\nWhere `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`."
         },
         {
           name = "getSize",

+ 1 - 3
api/lovr/filesystem/getSaveDirectory.lua

@@ -12,9 +12,7 @@ return {
   notes = [[
     The save directory takes the following form:
 
-    ```
-    <appdata>/LOVR/<identity>
-    ```
+        <appdata>/LOVR/<identity>
 
     Where `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is
     `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`.

+ 8 - 0
api/lovr/filesystem/init.lua

@@ -15,6 +15,14 @@ return {
         <td>macOS</td>
         <td><code>/Users/&lt;user&gt;/Library/Application Support/LOVR/&lt;identity&gt;</code></td>
       </tr>
+      <tr>
+        <td>Linux</td>
+        <td><code>/home/&lt;user&gt;/.local/share/LOVR/&lt;identity&gt;</code></td>
+      </tr>
+      <tr>
+        <td>Android</td>
+        <td><code>/sdcard/Android/data/&lt;identity&gt;/files</code></td>
+      </tr>
     </table>
 
     `<identity>` should be a unique identifier for your app.  It can be set either in `lovr.conf` or

+ 95 - 99
guides/Callbacks_and_Modules.md

@@ -20,32 +20,30 @@ Callbacks
 There are various callbacks that can be used for interesting things.  Three of the most used ones
 are `lovr.load`, `lovr.update`, and `lovr.draw`.  A simple project skeleton might look like this:
 
-```
-function lovr.load()
-  -- This is called once on load.
-  --
-  -- You can use it to load assets and set everything up.
+    function lovr.load()
+      -- This is called once on load.
+      --
+      -- You can use it to load assets and set everything up.
 
-  print('loaded!')
-end
+      print('loaded!')
+    end
 
-function lovr.update(dt)
-  -- This is called continuously and is passed the "delta time" as dt, which
-  -- is the number of seconds elapsed since the last update.
-  --
-  -- You can use it to simulate physics or update game logic.
+    function lovr.update(dt)
+      -- This is called continuously and is passed the "delta time" as dt, which
+      -- is the number of seconds elapsed since the last update.
+      --
+      -- You can use it to simulate physics or update game logic.
 
-  print('updating', dt)
-end
+      print('updating', dt)
+    end
 
-function lovr.draw()
-  -- This is called once every frame.
-  --
-  -- You can use it to render the scene.
+    function lovr.draw()
+      -- This is called once every frame.
+      --
+      -- You can use it to render the scene.
 
-  print('rendering')
-end
-```
+      print('rendering')
+    end
 
 By filling in the different callbacks you can start to define the behavior of an app.
 
@@ -99,25 +97,23 @@ play area, so the origin is on the ground in the middle of the play space.
 
 You've already seen `lovr.graphics.print`, but here's another example:
 
-```
-function lovr.load()
-  -- Load a 3D model
-  model = lovr.graphics.newModel('monkey.obj')
-end
+    function lovr.load()
+      -- Load a 3D model
+      model = lovr.graphics.newModel('monkey.obj')
+    end
 
-function lovr.draw()
-  -- Use a dark grey background
-  lovr.graphics.setBackgroundColor(.2, .2, .2)
+    function lovr.draw()
+      -- Use a dark grey background
+      lovr.graphics.setBackgroundColor(.2, .2, .2)
 
-  -- Draw the model
-  lovr.graphics.setColor(1.0, 1.0, 1.0)
-  model:draw(-.5, 1, -3)
+      -- Draw the model
+      lovr.graphics.setColor(1.0, 1.0, 1.0)
+      model:draw(-.5, 1, -3)
 
-  -- Draw a red cube using the "cube" primitive
-  lovr.graphics.setColor(1.0, 0, 0)
-  lovr.graphics.cube('fill', .5, 1, -3, .5, lovr.timer.getTime())
-end
-```
+      -- Draw a red cube using the "cube" primitive
+      lovr.graphics.setColor(1.0, 0, 0)
+      lovr.graphics.cube('fill', .5, 1, -3, .5, lovr.timer.getTime())
+    end
 
 lovr.headset
 ---
@@ -139,12 +135,10 @@ functions can be used to figure out the state of buttons and other controls on t
 
 Here's a simple example that draws a sphere in the "opposite" position of the headset:
 
-```
-function lovr.draw()
-  local x, y, z = lovr.headset.getPosition()
-  lovr.graphics.sphere(-x, y, -z, .1)
-end
-```
+    function lovr.draw()
+      local x, y, z = lovr.headset.getPosition()
+      lovr.graphics.sphere(-x, y, -z, .1)
+    end
 
 lovr.audio
 ---
@@ -155,13 +149,11 @@ directions, which are used to make things sound realistic as the headset moves a
 Each instance of a sound is called a `Source`.  To create a sources, use `lovr.audio.newSource` and
 pass it an ogg file.  You can then call `play` on the source to play it.
 
-```
-function lovr.load()
-  ambience = lovr.audio.newSource('background.ogg')
-  ambience:setLooping(true)
-  ambience:play()
-end
-```
+    function lovr.load()
+      ambience = lovr.audio.newSource('background.ogg')
+      ambience:setLooping(true)
+      ambience:play()
+    end
 
 See the `Source` page for more information.
 
@@ -181,59 +173,63 @@ forces applied it.  The world should be updated in `lovr.update` using the `dt`
 
 Here's an example that makes a tower of boxes that you can knock down with controllers:
 
-```
-function lovr.load()
-  world = lovr.physics.newWorld()
+    function lovr.load()
+      world = lovr.physics.newWorld()
+
+      -- Create the ground
+      world:newBoxCollider(0, 0, 0, 5, .01, 5):setKinematic(true)
 
-  -- Create the ground
-  world:newBoxCollider(0, 0, 0, 5, .01, 5):setKinematic(true)
+      -- Create boxes!
+      boxes = {}
+      for x = -1, 1, .25 do
+        for y = .125, 2, .25 do
+          local box = world:newBoxCollider(x, y, -1, .25)
+          table.insert(boxes, box)
+        end
+      end
 
-  -- Create boxes!
-  boxes = {}
-  for x = -1, 1, .25 do
-    for y = .125, 2, .25 do
-      local box = world:newBoxCollider(x, y, -1, .25)
-      table.insert(boxes, box)
+      -- Each controller is going to have a collider attached to it
+      controllerBoxes = {}
     end
-  end
-
-  -- Each controller is going to have a collider attached to it
-  controllerBoxes = {}
-end
-
-function lovr.update(dt)
-  -- Synchronize controllerBoxes with the active controllers
-  for i, hand in ipairs(lovr.headset.getHands()) do
-    if not controllerBoxes[i] then
-      controllerBoxes[i] = world:newBoxCollider(0, 0, 0, .25)
-      controllerBoxes[i]:setKinematic(true)
+
+    function lovr.update(dt)
+      -- Synchronize controllerBoxes with the active controllers
+      for i, hand in ipairs(lovr.headset.getHands()) do
+        if not controllerBoxes[i] then
+          controllerBoxes[i] = world:newBoxCollider(0, 0, 0, .25)
+          controllerBoxes[i]:setKinematic(true)
+        end
+        controllerBoxes[i]:setPosition(lovr.headset.getPosition(hand))
+        controllerBoxes[i]:setOrientation(lovr.headset.getOrientation(hand))
+      end
+
+      -- Update the physics simulation
+      world:update(dt)
+    end
+
+    -- A helper function for drawing boxes
+    function drawBox(pass, box)
+      local x, y, z = box:getPosition()
+      pass:cube(x, y, z, .25, quat(box:getOrientation()), 'line')
+    end
+
+    -- A helper function for drawing boxes
+    function drawBox(box)
+      local x, y, z = box:getPosition()
+      lovr.graphics.cube('line', x, y, z, .25, box:getOrientation())
+    end
+
+    function lovr.draw()
+      lovr.graphics.setColor(1.0, 0, 0)
+      for i, box in ipairs(boxes) do
+        drawBox(box)
+      end
+
+      lovr.graphics.setColor(0, 0, 1.0)
+      for i, box in ipairs(controllerBoxes) do
+        drawBox(box)
+      end
     end
-    controllerBoxes[i]:setPosition(lovr.headset.getPosition(hand))
-    controllerBoxes[i]:setOrientation(lovr.headset.getOrientation(hand))
-  end
-
-  -- Update the physics simulation
-  world:update(dt)
-end
-
--- A helper function for drawing boxes
-function drawBox(box)
-  local x, y, z = box:getPosition()
-  lovr.graphics.cube('line', x, y, z, .25, box:getOrientation())
-end
-
-function lovr.draw()
-  lovr.graphics.setColor(1.0, 0, 0)
-  for i, box in ipairs(boxes) do
-    drawBox(box)
-  end
-
-  lovr.graphics.setColor(0, 0, 1.0)
-  for i, box in ipairs(controllerBoxes) do
-    drawBox(box)
-  end
-end
-```
 
 Next Steps
 ---

+ 39 - 75
guides/Compiling.md

@@ -29,12 +29,10 @@ Windows
 From the lovr folder, run these commands to create a build folder and compile the project using
 CMake:
 
-```
-$ mkdir build
-$ cd build
-$ cmake ..
-$ cmake --build .
-```
+    $ mkdir build
+    $ cd build
+    $ cmake ..
+    $ cmake --build .
 
 The executable will then exist at `/path/to/lovr/build/Debug/lovr.exe`.  A LÖVR project (a folder
 containing a `main.lua` script) can then be dropped onto `lovr.exe` to run it, or it can be run
@@ -45,26 +43,20 @@ macOS
 
 Install the dependencies using your package manager of choice:
 
-```
-$ brew install glfw3 luajit physfs openal-soft ode libccd
-```
+    $ brew install glfw3 luajit physfs openal-soft ode libccd
 
 Next, build using CMake, as above:
 
-```
-$ mkdir build
-$ cd build
-$ cmake ..
-$ cmake --build .
-```
+    $ mkdir build
+    $ cd build
+    $ cmake ..
+    $ cmake --build .
 
 The lovr executable should exist in `lovr/build` now.  It's recommended to set up an alias or
 symlink so that this executable can be found in your PATH environment variable.  Once that's done,
 you can run a project like this:
 
-```
-$ lovr /path/to/myGame
-```
+    $ lovr /path/to/myGame
 
 > You may need to set the `PKG_CONFIG_PATH` environment variable for OpenAL to be located properly.
 > If you run into this, see [Troubleshooting](#troubleshooting) below for more info.
@@ -76,40 +68,30 @@ First, install the dependencies using your package manager of choice.
 
 #### Arch Linux
 
-```
-$ pacman -S glfw-x11 luajit physfs openal ode
-```
+    $ pacman -S glfw-x11 luajit physfs openal ode
 
 #### Debian/Ubuntu
 
-```
-$ sudo apt install build-essential cmake xorg-dev libglfw3-dev libluajit-5.1-dev libphysfs-dev libopenal-dev libode-dev libccd-dev libenet-dev
-```
+    $ sudo apt install build-essential cmake xorg-dev libglfw3-dev libluajit-5.1-dev libphysfs-dev libopenal-dev libode-dev libccd-dev libenet-dev
 
 Then, build with CMake:
 
-```
-$ mkdir build
-$ cd build
-$ cmake ..
-$ cmake --build .
-```
+    $ mkdir build
+    $ cd build
+    $ cmake ..
+    $ cmake --build .
 
 On Linux, LÖVR needs to run within the Steam Runtime.  To do this, first [install
 Steam](https://wiki.archlinux.org/index.php/Steam#Installation).  Next, [install the Steam udev
 rules](https://github.com/ValveSoftware/SteamVR-for-Linux#usb-device-requirements).  Then, run LÖVR
 within the Steam runtime:
 
-```
-$ ~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr
-```
+    $ ~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr
 
 If you receive errors related to `libstdc++`, set the `LD_PRELOAD` environment variable when running
 the command:
 
-```
-$ LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1' ~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr
-```
+    $ LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1' ~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr
 
 WebXR
 ---
@@ -118,41 +100,33 @@ First, [install the Emscripten SDK](https://emscripten.org/docs/getting_started/
 
 Unix:
 
-```
-$ mkdir build
-$ cd build
-$ emcmake cmake ..
-$ emmake make -j2
-```
+    $ mkdir build
+    $ cd build
+    $ emcmake cmake ..
+    $ emmake make -j2
 
 Windows (from a Visual Studio Command Prompt, make sure the Emscripten SDK is on PATH):
 
-```
-$ mkdir build
-$ cd build
-$ emcmake cmake -G "NMake Makefiles" ..
-$ emmake nmake
-```
+    $ mkdir build
+    $ cd build
+    $ emcmake cmake -G "NMake Makefiles" ..
+    $ emmake nmake
 
 The above commands will output `lovr.js`, `lovr.wasm`, and `lovr.html`.  The easiest way to run LÖVR
 from here is to use `emrun`:
 
-```
-$ emrun --browser firefox lovr.html
-```
+    $ emrun --browser firefox lovr.html
 
 To add a project, create a .zip of its contents and serve it alongside the HTML and JS files.  The
 following JS can be added to the page to download the zip file, add it to the emscripten virtual
 filesystem, and add it as a command line argument:
 
-```
-var filename = 'game.zip';
-var url = '/game.zip';
-Module.arguments.push(filename);
-Module.preRun.push(function() {
-  Module.FS_createPreloadedFile('/', filename, url, true, false);
-});
-```
+    var filename = 'game.zip';
+    var url = '/game.zip';
+    Module.arguments.push(filename);
+    Module.preRun.push(function() {
+      Module.FS_createPreloadedFile('/', filename, url, true, false);
+    });
 
 See `lovr.html` (or `src/resources/lovr.html`) for a full example page, including a button that
 can be used to enter/exit immersive mode.
@@ -211,9 +185,7 @@ found at `config/default`.  Some android-specific configuration needs to be fill
 
 Once all of this is set up, run `tup init` if tup hasn't been initialized yet.  Then run
 
-```
-$ tup
-```
+    $ tup
 
 to build the apk.
 
@@ -237,24 +209,18 @@ the command line:
 
 The usual CMake incantation with all of the above variables set up should produce `lovr.apk`:
 
-```
-$ cmake ..
-$ cmake --build .
-```
+    $ cmake ..
+    $ cmake --build .
 
 ### Installing the APK
 
 To install the APK, an Android device needs to be connected.  Run
 
-```
-$ adb devices
-```
+    $ adb devices
 
 to ensure that a device is connected, then run
 
-```
-$ adb install lovr.apk
-```
+    $ adb install lovr.apk
 
 To install the apk.  The `-r` flag can be used to overwrite an existing apk.
 
@@ -278,9 +244,7 @@ A keystore file needs to be generated, which is used to sign the APK after it's
 
 To generate a keystore, use Java's `keytool` tool:
 
-```
-$ keytool -genkey -keystore <name>.keystore -alias <name> -keyalg RSA -keysize 2048 -validity 10000
-```
+    $ keytool -genkey -keystore <name>.keystore -alias <name> -keyalg RSA -keysize 2048 -validity 10000
 
 When specifying the password for the keystore, it can be done in multiple ways:
 

+ 2 - 6
guides/Distribution.md

@@ -12,9 +12,7 @@ contents.  On Windows you can select all the files in a project (**not** the pro
 click them, and choose "Send to" -> "Compressed (zip) folder".  On Unix systems, the `zip` utility
 can be used:
 
-```
-$ zip -9qr .
-```
+    $ zip -9qr .
 
 A zip archive can be run with LÖVR but isn't a standalone executable yet.
 
@@ -24,9 +22,7 @@ Creating an Executable
 Once you have a project archive, it can be appended to the LÖVR binary to create a standalone
 executable.  On Windows, this can be done using the command prompt:
 
-```
-$ copy /b lovr.exe+MyProject.zip MyProject.exe
-```
+    $ copy /b lovr.exe+MyProject.zip MyProject.exe
 
 On Unix systems, the `cat` utility can be used to concatenate the two files.
 

+ 5 - 7
guides/Getting_Started.md

@@ -36,15 +36,13 @@ file in your project folder, LÖVR will run the code in there when the project s
 
 Create a file called `main.lua` in a project folder and type the following Lua code in it:
 
-```
-function lovr.draw()
-  lovr.graphics.print('hello world', 0, 1.7, -3, .5)
-end
-```
+    function lovr.draw()
+      lovr.graphics.print('hello world', 0, 1.7, -3, .5)
+    end
 
 Don't worry if you're confused about the code, it's not important to understand it all right now.
-In short, we declared the `lovr.draw` callback and used `lovr.graphics.print` in there to render
-some text in the world.  We'll learn more about how this works in the next guide.
+In short, we declared the `lovr.draw` callback and used `Pass:text` in there to render some text in
+the world.  We'll learn more about how this works in the next guide.
 
 Running a Project
 ---

+ 8 - 15
guides/Getting_Started_(Android).md

@@ -24,9 +24,7 @@ Download the latest Android APK from the [Downloads page](https://lovr.org/downl
 
 Install it to the device:
 
-```
-$ adb install lovr.apk
-```
+    $ adb install lovr.apk
 
 Try running it by navigating to the "Library" -> "Unknown Sources" menu of the headset and running
 the `org.lovr.app` app.  You should see the no game screen.
@@ -37,17 +35,13 @@ Running a Project
 Now we can create a LÖVR project, which is a folder with some code and assets in it.  Create a
 folder called `hello-world` and add this code to a file named `main.lua` in there:
 
-```
-function lovr.draw()
-  lovr.graphics.print('hello world', 0, 1.7, -3, .5)
-end
-```
+    function lovr.draw()
+      lovr.graphics.print('hello world', 0, 1.7, -3, .5)
+    end
 
 Then use `adb` to sync it to the device:
 
-```
-$ adb push --sync /path/to/hello-world/. /sdcard/Android/data/org.lovr.app/files
-```
+    $ adb push --sync /path/to/hello-world/. /sdcard/Android/data/org.lovr.app/files
 
 Note the trailing `.` in the path to the project, it's important.
 
@@ -58,11 +52,10 @@ Tips
 
 - It is possible to restart the app from the command line by running:
 
-```
-adb shell am force-stop org.lovr.app
+<pre><code>adb shell am force-stop org.lovr.app
 adb shell am start org.lovr.app/org.lovr.app.Activity
-```
+</code></pre>
 
-- For even faster restarts, use [`lodr`](https://github.com/mcclure/lodr) for live reloading.
+- For even faster restarts, use [lodr](https://github.com/mcclure/lodr) for live reloading.
 - If you need to use `print` in Lua for debug messages, you can see those in a terminal by running
   `adb logcat -s LOVR`.

+ 5 - 7
guides/Libraries.md

@@ -6,14 +6,12 @@ the capabilities of LÖVR and others just make it easier to get stuff done.  Lib
 distributed as a single Lua file.  You can copy the Lua file into your project and `require` it to
 use the library:
 
-```
--- library.lua is sitting next to our main.lua here
-local lib = require('library')
+    -- library.lua is sitting next to our main.lua here
+    local lib = require('library')
 
-function lovr.load()
-  lib.doStuff()
-end
-```
+    function lovr.load()
+      lib.doStuff()
+    end
 
 Below is a catalog of useful libraries.  All of them can be used with LÖVR, although some of them
 only depend on Lua and aren't specific to LÖVR.