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:
</p><p>
<a href="https://github.com/bbguimaraes/college/tree/master/sms">https://github.com/bbguimaraes/college/tree/master/sms</a>
<a href="https://gitlab.bbguimaraes.com/bbguimaraes/college/-/tree/master/sms">
https://gitlab.bbguimaraes.com/bbguimaraes/college/-/tree/master/sms
</a>
</p>
<p>Finally, here is a short demo:</p>
<p>
......
......@@ -59,7 +59,7 @@ an announcement for it.
<p>
And did you know all source code is available under a free software license?
Yes! Run and
<a href="https://gitlab.bbguimaraes.com/bbguimaraes/bbguimaraes.com">get it</a>
<a href="https://gitlab.bbguimaraes.com/bbguimaraes/bbguimaraes.com.git">get it</a>
before more people find out about it.
</p>
<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.
</p>
<a class="src-ref" data-hash="70e07d44a42c3810195c05cc90fc6fd692544f1d" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/demos/repl.lua">demos/repl.lua</a>
<img
src="/files/blog/lua_wasm_demo0.png"
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.
</p>
<p>
<a href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/scripts/emscripten/build.sh">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:
</p>
<a class="src-ref" data-hash="a079068db60c13c975173c7c8c4453534bcf8799" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/scripts/emscripten/build.sh">scripts/emscripten/build.sh</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.
</p>
<p>
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="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/Makefile.am">source</a>):
Lua libraries and scripts (all regular source code text files) are included:
</p>
<a class="src-ref" data-hash="72a7757b61fcc5f4d81137de337ee769ad9bce7f" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/Makefile.am">Makefile.am</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="https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html">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="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/main.cpp">source</a>):
simple C entry point is included in the program:
</p>
<a class="src-ref" data-hash="eb9fcddd4fd6c1c73cd10384fb3f800e0ff6799a" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/main.cpp">src/main.cpp</a>
<pre><code>#ifdef NNGN_PLATFORM_EMSCRIPTEN
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>.
<p>
This function is then exposed as described in the documentation linked above:
</p>
<a class="src-ref" data-hash="72a7757b61fcc5f4d81137de337ee769ad9bce7f" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/Makefile.am">Makefile.am</a>
<pre><code>nngn_js_CXXFLAGS = \
$(AM_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:
</p>
<pre><code>-- src/lua/all.lua
dofile "src/lua/init.lua"
<a class="src-ref" data-hash="40833fe56c2306e2df2a52289bc7ee7678155107" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/lua/all.lua">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>
<p>
Each of these in turn is composed of lower-level pieces:
</p>
<pre><code>-- src/lua/init.lua
dofile "src/lua/path.lua"
<a class="src-ref" data-hash="abed4e12a019e62bd9aa9423b77bf8347af31f34" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/lua/init.lua">src/lua/init.lua</a>
<pre><code>dofile "src/lua/path.lua"
require("nngn.lib.compute").init()
require("nngn.lib.graphics").init()
require("nngn.lib.collision").init()
nngn.socket:init("sock")</code></pre>
<pre><code>-- src/lua/limits.lua
nngn.entities:set_max(1 << 20)
<a class="src-ref" data-hash="cf0b3a65506344cc77a1e1facda3e19dd725d251" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/lua/limits.lua">src/lua/limits.lua</a>
<pre><code>nngn.entities:set_max(1 << 20)
nngn.animations:set_max(1 << 16)
nngn.graphics:resize_textures(16)
nngn.textures:set_max(16)
-- …</code></pre>
<pre><code>-- src/lua/main.lua
local camera = require "nngn.lib.camera"
<a class="src-ref" data-hash="ab5bf80d6445868ec241e4c8418148611454f61b" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/lua/main.lua">src/lua/main.lua</a>
<pre><code>local camera = require "nngn.lib.camera"
local entity = require "nngn.lib.entity"
local font = require "nngn.lib.font"
local map = require "nngn.lib.map"
......@@ -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:
</p>
<pre><code>-- demos/demo.lua
dofile "src/lua/init.lua"
<a class="src-ref" data-hash="5d48b238abaf1199562d6ca443b6b06059a46ae7" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/demos/demo1.lua">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:
</p>
<pre><code>-- demos/colliders.lua
dofile "src/lua/path.lua"
<a class="src-ref" data-hash="61ffd3ae17460d5a86acb66b874eb2800d69d015" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/demos/colliders.lua">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:
</p>
<pre><code>-- demos/cl/vector.lua
dofile "src/lua/path.lua"
<a class="src-ref" data-hash="0f59333d712f00d2a80554ed1e2c5f24129deafa" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/demos/cl/vector.lua">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:
</p>
<pre><code>-- src/lson/crono.lua
return {
<a class="src-ref" data-hash="252e3b7b9381cf2520181d6d1952231b2b623518" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/src/lson/crono.lua">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:
</p>
<pre><code>-- maps/zelda.lua
-- …
<a class="src-ref" data-hash="5b3f64156cc41a6402b270291ce55242d63d60ee" href="https://gitlab.bbguimaraes.com/bbguimaraes/nngn/-/blob/master/maps/zelda.lua">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