4.6 KiB
hate-no-d
A Love2D antagonist.
A glorified Makefile, plus a small build.bat for MSVC.
Should work on:
- Linux (x86, x86_64, ARM, ARM64)
- Android (armeabi-v7a, arm64-v8a, x86, x86_64)
- macOS (x86_64, ARM64)
- Windows (x86, x86_64 via MinGW; ARM64 via MSVC)
- FreeBSD, OpenBSD, NetBSD (x86, x86_64) or DragonFly BSD (x86_64)
Quick Start
Once you have the binary, save this as quick-start.lua:
local hnd = require("hate-no-d")
hnd.InitWindow(1280, 720, "hate-no-d")
local text = "Your first hate-no-d application!"
local fontSize = 48
local spacing = fontSize / hnd.GetFontDefault().baseSize
local textSize = hnd.MeasureTextEx(hnd.GetFontDefault(), text, fontSize, spacing)
local posX = (hnd.GetRenderWidth() / 2) - (textSize.x / 2)
local posY = (hnd.GetRenderHeight() / 2) - (textSize.y / 2)
while not hnd.WindowShouldClose() do
hnd.ClearBackground(hnd.SKYBLUE)
hnd.BeginDrawing()
hnd.DrawText(text, posX, posY, fontSize, hnd.DARKBLUE)
hnd.EndDrawing()
end
hnd.CloseWindow()
Then run it:
./hate-no-d quick-start.lua
hate-no-d.lua is the generated raylib/rlgl/raymath binding module. Release
archives include it next to the binary; when building from source, make
generates it automatically.
On Windows, use cmd or PowerShell:
hate-no-d.exe quick-start.lua
Building
You can download precompiled builds from the releases page.
Linux prerequisites
Install a C toolchain, git and the OpenGL/X11 development headers:
Debian/Ubuntu:
sudo apt install build-essential git luajit libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
Fedora:
sudo dnf install gcc make git luajit mesa-libGL-devel libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel
Arch:
sudo pacman -S --needed base-devel git luajit mesa libx11 libxrandr libxinerama libxcursor libxi
Void:
sudo xbps-install -S base-devel git luajit MesaLib-devel libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel
Gentoo:
sudo emerge --ask sys-devel/gcc dev-build/make dev-vcs/git dev-lang/luajit media-libs/mesa x11-libs/libX11 x11-libs/libXrandr x11-libs/libXinerama x11-libs/libXcursor x11-libs/libXi
macOS prerequisites
Install the Xcode Command Line Tools:
xcode-select --install
make and clang come with them. Install the host LuaJIT used by the binding
generator:
brew install luajit
BSD prerequisites
Install GNU Make and the X11 development headers. FreeBSD:
sudo pkg install gmake luajit libX11 libXrandr libXinerama libXi libXcursor
On OpenBSD, NetBSD and DragonFly, install gmake and luajit with the system
package manager (pkg_add gmake luajit, pkgin install gmake luajit or
pkg install gmake luajit); X11 headers are usually in the base X sets, but
install the X11 libraries if they are missing. Use gmake instead of make.
Android prerequisites
Android builds cross-compile from Linux or macOS. Install the Android NDK and
pass its path with ANDROID_NDK, or set ANDROID_NDK_HOME.
Windows prerequisites
For MSVC, install Visual Studio 2022 with the "Desktop development with C++" workload. build.bat locates it automatically and uses the bundled CMake when available; raylib requires CMake 3.22 or newer, so install CMake if your VS2022 copy bundles an older version.
For MinGW, use MSYS2 with the mingw-w64 toolchain and make. A native MSYS2 build is auto-detected; when cross-compiling from another host, pass PLATFORM=Windows (and WIN_ARCH=i686 for 32-bit).
Building from source
To build manually on Linux, macOS or a BSD, run:
git clone --recurse-submodules https://git.pbento.pt/pedro-bento/hate-no-d.git
cd hate-no-d
make
make builds the CLI and regenerates hate-no-d.lua; the generator needs a
host luajit in PATH (override with make LUAJIT=/path/to/luajit). On the
BSDs, use gmake instead of make.
On Windows with MinGW (MSYS2), run make in the MSYS2 MINGW shell. To cross-compile
from another host, run make PLATFORM=Windows (add WIN_ARCH=i686 for 32-bit).
On Windows with MSVC:
git clone --recurse-submodules https://git.pbento.pt/pedro-bento/hate-no-d.git
cd hate-no-d
build.bat
To build for Android from Linux or macOS, pass your NDK path (or set ANDROID_NDK_HOME):
make PLATFORM=Android ANDROID_NDK=/path/to/ndk
ANDROID_ABI defaults to arm64-v8a and ANDROID_API to 21; see make help for the other ABIs. Building armeabi-v7a on a 64-bit host also needs HOST_CC="gcc -m32".