Commit b8d8eb1d authored by bbguimaraes's avatar bbguimaraes
Browse files

Track source code references

parent 7dfb1ea9
......@@ -61,7 +61,9 @@ I have wasted too much time playing with it.  It's really addictive.  Anyway,
the entire code base is under a copy-left license (GPLv2), so you can take a
look, experiment, do whatever you want with it:
<a href=""></a>
<a href="">
<p>Finally, here is a short demo:</p>
......@@ -59,7 +59,7 @@ an announcement for it.
And did you know all source code is available under a free software license?
Yes! Run and
<a href="">get it</a>
<a href="">get it</a>
before more people find out about it.
<h2 id="a-dark-interlude">
......@@ -64,6 +64,7 @@ text box with the result (I heard you like interpreters…). It is similar in
function to the command-line <code>lua</code> interpreter that might be found in
your operating system.
<a class="src-ref" data-hash="70e07d44a42c3810195c05cc90fc6fd692544f1d" href="">demos/repl.lua</a>
title="Lua Wasm demo - write some lua code and press enter"
......@@ -130,11 +131,11 @@ to its tool chain, so the
in the repository can be used almost unmodified.
<a href="">Here</a>
is the script that is used in my builds, which is executed once, before the
final <code>make</code> call. Other than downloading and extracting the source
code, its only significant actions are:
A script is used in my builds, which is executed once, before the final
<code>make</code> call. Other than downloading and extracting the source code,
its only significant actions are:
<a class="src-ref" data-hash="a079068db60c13c975173c7c8c4453534bcf8799" href="">scripts/emscripten/</a>
<pre><code>patch -Np0 < "$PATCHES_DIR/lua.patch"
pushd src/
emmake make generic ALL=liblua.a</code></pre>
......@@ -168,9 +169,9 @@ analogous for any other build system.
Because of how <code>emscripten</code> builds work, this is also the step where
Lua libraries and scripts (all regular source code text files) are included
(<a href="">source</a>):
Lua libraries and scripts (all regular source code text files) are included:
<a class="src-ref" data-hash="72a7757b61fcc5f4d81137de337ee769ad9bce7f" href=""></a>
<pre><code>nngn_js_LDFLAGS= \
$(nngn_js_CXXFLAGS) -O3 --source-map-base / \
--embed-file $(srcdir)/src/lua/@src/lua \
......@@ -192,9 +193,9 @@ exposed to Javascript and, by extension, the browser console:
<a href="">communication</a>
between Javascript and the application. The simplest form is via
<code>ccall</code> and <code>cwrap</code>, which directly expose C functions. A
simple C entry point is included in the program
(<a href="">source</a>):
simple C entry point is included in the program:
<a class="src-ref" data-hash="eb9fcddd4fd6c1c73cd10384fb3f800e0ff6799a" href="">src/main.cpp</a>
extern "C" {
void lua(const char *s) { NNGN_LOG_CONTEXT_F(); p_nngn->lua.dostring(s); }
......@@ -221,6 +222,7 @@ member is the object that wraps the <code>lua_State*</code>.
This function is then exposed as described in the documentation linked above:
<a class="src-ref" data-hash="72a7757b61fcc5f4d81137de337ee769ad9bce7f" href=""></a>
<pre><code>nngn_js_CXXFLAGS = \
… \
......@@ -87,28 +87,28 @@ map is a script (it is the default value for <code>argv</code>). Its only
statements are <code>dofile</code>s (Lua's version of <code>#include</code> or
<code>import</code>) which load and execute separate, specialized scripts:
<pre><code>-- src/lua/all.lua
dofile "src/lua/init.lua"
<a class="src-ref" data-hash="40833fe56c2306e2df2a52289bc7ee7678155107" href="">src/lua/all.lua</a>
<pre><code>dofile "src/lua/init.lua"
dofile "src/lua/limits.lua"
dofile "src/lua/main.lua"
dofile "maps/main.lua"</code></pre>
Each of these in turn is composed of lower-level pieces:
<pre><code>-- src/lua/init.lua
dofile "src/lua/path.lua"
<a class="src-ref" data-hash="abed4e12a019e62bd9aa9423b77bf8347af31f34" href="">src/lua/init.lua</a>
<pre><code>dofile "src/lua/path.lua"
<pre><code>-- src/lua/limits.lua
nngn.entities:set_max(1 << 20)
<a class="src-ref" data-hash="cf0b3a65506344cc77a1e1facda3e19dd725d251" href="">src/lua/limits.lua</a>
<pre><code>nngn.entities:set_max(1 << 20)
nngn.animations:set_max(1 << 16)
-- …</code></pre>
<pre><code>-- src/lua/main.lua
local camera = require ""
<a class="src-ref" data-hash="ab5bf80d6445868ec241e4c8418148611454f61b" href="">src/lua/main.lua</a>
<pre><code>local camera = require ""
local entity = require "nngn.lib.entity"
local font = require "nngn.lib.font"
local map = require ""
......@@ -131,8 +131,8 @@ default configuration for separate parts of the engine (keyboard bindings,
camera placement, default parameters for the various sub-systems, etc.) by
loading the appropriate script:
<pre><code>-- demos/demo.lua
dofile "src/lua/init.lua"
<a class="src-ref" data-hash="5d48b238abaf1199562d6ca443b6b06059a46ae7" href="">demos/demo1.lua</a>
<pre><code>dofile "src/lua/init.lua"
dofile "src/lua/limits.lua"
dofile "src/lua/main.lua"
-- …
......@@ -169,8 +169,8 @@ input.input:add(
Benchmarks are scripts that set up the engine in a similar manner and either
leave the test running or run it for a while and dump the results:
<pre><code>-- demos/colliders.lua
dofile "src/lua/path.lua"
<a class="src-ref" data-hash="61ffd3ae17460d5a86acb66b874eb2800d69d015" href="">demos/colliders.lua</a>
<pre><code>dofile "src/lua/path.lua"
local entity = require "nngn.lib.entity"
local player = require "nngn.lib.player"
require "src/lua/input"
......@@ -194,8 +194,8 @@ end
Integration tests are scripts that set up the engine, exercise some part of it
via the Lua interface, and check the results:
<pre><code>-- demos/cl/vector.lua
dofile "src/lua/path.lua"
<a class="src-ref" data-hash="0f59333d712f00d2a80554ed1e2c5f24129deafa" href="">demos/cl/vector.lua</a>
<pre><code>dofile "src/lua/path.lua"
local common = require "demos/cl/common"
nngn:set_compute(Compute.OPENCL_BACKEND, Compute.opencl_params{debug = true})
......@@ -333,8 +333,8 @@ These are simply scripts that contain only static data, mostly in the form of
tables (Lua's primary data structure). All these scripts do is
<code>return</code> the data:
<pre><code>-- src/lson/crono.lua
return {
<a class="src-ref" data-hash="252e3b7b9381cf2520181d6d1952231b2b623518" href="">src/lson/crono.lua</a>
<pre><code>return {
name = "crono",
collider = {type = Collider.AABB, bb = {-8, -16, 8, -8}},
renderer = {
......@@ -390,8 +390,8 @@ While the manner in which the file is processed is necessarily imperative (it
is simply loaded and executed), several utility functions make the contents
mostly declarative:
<pre><code>-- maps/zelda.lua
-- …
<a class="src-ref" data-hash="5b3f64156cc41a6402b270291ce55242d63d60ee" href="">maps/zelda.lua</a>
<pre><code>-- …
local entities, animations = {}, {}
-- …
local function init() -- …
......@@ -143,11 +143,15 @@ pre {
margin-right: 8em;
.blog pre {
.blog pre, .blog .src-ref {
margin-left: 2em;
margin-right: 2em;
.blog .src-ref {
font-style: italic;
.blog :not(pre) code {
font-weight: bold;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment