瀏覽代碼

rm fenced codeblocks;

Not all markdown converters support them...
bjorn 2 年之前
父節點
當前提交
22ec2d6639

+ 1 - 1
api/init.lua

@@ -8602,7 +8602,7 @@ return {
         },
         {
           name = "BufferLayout",
-          description = "The different ways to pack Buffer fields into memory.\n\nThe default is `packed`, which is suitable for vertex buffers and index buffers.  It doesn't add any padding between elements, and so it doesn't waste any space.  However, this layout won't necessarily work for uniform buffers and storage buffers.\n\nThe `std140` layout corresponds to the std140 layout used for uniform buffers in GLSL.  It adds the most padding between fields, and requires the stride to be a multiple of 16.  Example:\n\n``` layout(std140) uniform ObjectScales { float scales[64]; }; ```\n\nThe `std430` layout corresponds to the std430 layout used for storage buffers in GLSL.  It adds some padding between certain types, and may round up the stride.  Example:\n\n``` layout(std430) buffer TileSizes { vec2 sizes[]; } ```",
+          description = "The different ways to pack Buffer fields into memory.\n\nThe default is `packed`, which is suitable for vertex buffers and index buffers.  It doesn't add any padding between elements, and so it doesn't waste any space.  However, this layout won't necessarily work for uniform buffers and storage buffers.\n\nThe `std140` layout corresponds to the std140 layout used for uniform buffers in GLSL.  It adds the most padding between fields, and requires the stride to be a multiple of 16.  Example:\n\n    layout(std140) uniform ObjectScales { float scales[64]; };\n\nThe `std430` layout corresponds to the std430 layout used for storage buffers in GLSL.  It adds some padding between certain types, and may round up the stride.  Example:\n\n    layout(std430) buffer TileSizes { vec2 sizes[]; }",
           key = "BufferLayout",
           module = "lovr.graphics",
           values = {

+ 2 - 6
api/lovr/graphics/BufferLayout.lua

@@ -9,16 +9,12 @@ return {
     The `std140` layout corresponds to the std140 layout used for uniform buffers in GLSL.  It adds
     the most padding between fields, and requires the stride to be a multiple of 16.  Example:
 
-    ```
-    layout(std140) uniform ObjectScales { float scales[64]; };
-    ```
+        layout(std140) uniform ObjectScales { float scales[64]; };
 
     The `std430` layout corresponds to the std430 layout used for storage buffers in GLSL.  It adds
     some padding between certain types, and may round up the stride.  Example:
 
-    ```
-    layout(std430) buffer TileSizes { vec2 sizes[]; }
-    ```
+        layout(std430) buffer TileSizes { vec2 sizes[]; }
   ]],
   values = {
     {

+ 89 - 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(pass)
-  -- This is called once every frame.
-  --
-  -- You can call functions on the pass to render graphics.
+    function lovr.draw(pass)
+      -- This is called once every frame.
+      --
+      -- You can call functions on the pass to render graphics.
 
-  print('rendering')
-end
-```
+      print('rendering')
+    end
 
 By filling in the different callbacks you can start to define the behavior of an app.
 
@@ -100,25 +98,23 @@ play area, so the origin is on the ground in the middle of the play space.
 
 You've already seen `Pass:text`, but here's another example:
 
-```
-function lovr.load()
-  -- Load a 3D model
-  model = lovr.graphics.newModel('monkey.obj')
+    function lovr.load()
+      -- Load a 3D model
+      model = lovr.graphics.newModel('monkey.obj')
 
-  -- Use a dark grey background
-  lovr.graphics.setBackgroundColor(.2, .2, .2)
-end
+      -- Use a dark grey background
+      lovr.graphics.setBackgroundColor(.2, .2, .2)
+    end
 
-function lovr.draw(pass)
-  -- Draw the model
-  pass:setColor(1, 1, 1)
-  pass:draw(model, -.5, 1, -3)
+    function lovr.draw(pass)
+      -- Draw the model
+      pass:setColor(1, 1, 1)
+      pass:draw(model, -.5, 1, -3)
 
-  -- Draw a red cube using the "cube" primitive
-  pass:setColor(1, 0, 0)
-  pass:cube(.5, 1, -3, .5, lovr.timer.getTime())
-end
-```
+      -- Draw a red cube using the "cube" primitive
+      pass:setColor(1, 0, 0)
+      pass:cube(.5, 1, -3, .5, lovr.timer.getTime())
+    end
 
 lovr.headset
 ---
@@ -140,12 +136,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(pass)
-  local x, y, z = lovr.headset.getPosition()
-  pass:sphere(-x, y, -z, .1)
-end
-```
+    function lovr.draw(pass)
+      local x, y, z = lovr.headset.getPosition()
+      pass:sphere(-x, y, -z, .1)
+    end
 
 lovr.audio
 ---
@@ -156,13 +150,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.
 
@@ -182,59 +174,57 @@ 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)
+      -- 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
+
+      -- 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)
+        end
+        controllerBoxes[i]:setPosition(lovr.headset.getPosition(hand))
+        controllerBoxes[i]:setOrientation(lovr.headset.getOrientation(hand))
+      end
+
+      -- Update the physics simulation
+      world:update(dt)
     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)
+
+    -- 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
+
+    function lovr.draw(pass)
+      pass:setColor(1.0, 0, 0)
+      for i, box in ipairs(boxes) do
+        drawBox(pass, box)
+      end
+
+      pass:setColor(0, 0, 1.0)
+      for i, box in ipairs(controllerBoxes) do
+        drawBox(pass, 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(pass, box)
-  local x, y, z = box:getPosition()
-  pass:cube(x, y, z, .25, quat(box:getOrientation()), 'line')
-end
-
-function lovr.draw(pass)
-  pass:setColor(1.0, 0, 0)
-  for i, box in ipairs(boxes) do
-    drawBox(pass, box)
-  end
-
-  pass:setColor(0, 0, 1.0)
-  for i, box in ipairs(controllerBoxes) do
-    drawBox(pass, box)
-  end
-end
-```
 
 Next Steps
 ---

+ 30 - 50
guides/Compiling.md

@@ -39,12 +39,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
@@ -55,48 +53,38 @@ macOS
 
 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/bin` 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
 
 Linux
 ---
 
 Install a C compiler and CMake, then run:
 
-```
-$ 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:
 
-```
-$ ~/.local/share/Steam/ubuntu12_32/steam-runtime/run.sh lovr
-```
+    $ ~/.local/share/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
 
 Android
 ---
@@ -160,34 +148,28 @@ the command line:
 
 The usual CMake incantation with all of the above variables set up should produce `lovr.apk`:
 
-```
-$ mkdir build
-$ cd build
-$ cmake \
-    -D CMAKE_TOOLCHAIN_FILE=/path/to/ndk/build/cmake/android.toolchain.cmake \
-    -D ANDROID_SDK=/path/to/android \
-    -D ANDROID_ABI=arm64-v8a \
-    -D ANDROID_NATIVE_API_LEVEL=26 \
-    -D ANDROID_BUILD_TOOLS_VERSION=29.0.3 \
-    -D ANDROID_KEYSTORE=/path/to/test.keystore \
-    -D ANDROID_KEYSTORE_PASS=PASS:hunter2 \
-    ..
-$ cmake --build .
-```
+    $ mkdir build
+    $ cd build
+    $ cmake \
+        -D CMAKE_TOOLCHAIN_FILE=/path/to/ndk/build/cmake/android.toolchain.cmake \
+        -D ANDROID_SDK=/path/to/android \
+        -D ANDROID_ABI=arm64-v8a \
+        -D ANDROID_NATIVE_API_LEVEL=26 \
+        -D ANDROID_BUILD_TOOLS_VERSION=29.0.3 \
+        -D ANDROID_KEYSTORE=/path/to/test.keystore \
+        -D ANDROID_KEYSTORE_PASS=PASS:hunter2 \
+        ..
+    $ 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.
 
@@ -213,9 +195,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.
 

+ 3 - 5
guides/Getting_Started.md

@@ -34,11 +34,9 @@ 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(pass)
-  pass:text('hello world', 0, 1.7, -3, .5)
-end
-```
+    function lovr.draw(pass)
+      pass:text('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

+ 6 - 12
guides/Getting_Started_(Quest).md

@@ -36,17 +36,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(pass)
-  pass:text('hello world', 0, 1.7, -3, .5)
-end
-```
+    function lovr.draw(pass)
+      pass:text('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.
 
@@ -57,10 +53,8 @@ Tips
 
 - It is possible to restart the app from the command line by running:
 
-```
-adb shell am force-stop org.lovr.app
-adb shell am start org.lovr.app/org.lovr.app.Activity
-```
+    adb shell am force-stop org.lovr.app
+    adb shell am start org.lovr.app/org.lovr.app.Activity
 
 - 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

+ 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
 
 Also see the <a data-key="Plugins">Plugins</a> page for a list of useful plugins.
 

+ 10 - 14
guides/Plugins.md

@@ -11,14 +11,12 @@ Using Plugins
 
 To use a plugin, place its library file next to the lovr executable and `require` it from Lua:
 
-```
--- myplugin.dll is next to lovr.exe
-local myplugin = require 'myplugin'
+    -- myplugin.dll is next to lovr.exe
+    local myplugin = require 'myplugin'
 
-function lovr.load()
-  myplugin.dothething()
-end
-```
+    function lovr.load()
+      myplugin.dothething()
+    end
 
 > On Unix systems, some plugin files might be prefixed with `lib` (e.g. `liblovr-plugin.so`).
 > In this case, be sure to require the plugin with the lib prefix: `require 'liblovr-plugin'`.
@@ -91,13 +89,11 @@ Creating Plugins
 Internally, a plugin is no different from a regular native Lua library.  A plugin library only needs
 to have a Lua C function with a symbol named after the plugin:
 
-```
-int luaopen_supermegaplugin(lua_State* L) {
-  // This code gets run when the plugin is required,
-  // and anything it returns on the stack is used
-  // as the require's return value.
-}
-```
+    int luaopen_supermegaplugin(lua_State* L) {
+      // This code gets run when the plugin is required,
+      // and anything it returns on the stack is used
+      // as the require's return value.
+    }
 
 All of [Lua's rules](https://www.lua.org/manual/5.1/manual.html#pdf-package.loaders) for native
 plugin loading, including processing of dots and hyphens and all-in-one loading, apply to LÖVR

+ 1 - 3
guides/Standard_Shader.md

@@ -28,9 +28,7 @@ Skybox
 
 TODO
 
-```
-$ ./bin/cmgen --type=cubemap --format=png -x out env.hdr
-```
+    $ ./bin/cmgen --type=cubemap --format=png -x out env.hdr
 
 Shader Setup
 ---