Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwayland-dev libwayland-egl1-mesa libxkbcommon-dev libegl-dev libgl-dev
sudo apt-get install -y libwayland-dev libwayland-egl1-mesa libxkbcommon-dev libegl-dev libgl-dev libasound2-dev

- name: Build
run: make
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Install X11 dependencies
run: |
sudo apt-get update
sudo apt-get install -y libx11-dev libegl-dev libgl-dev
sudo apt-get install -y libx11-dev libegl-dev libgl-dev libasound2-dev

- name: Build
run: make
Expand Down
30 changes: 21 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ TEST_MSG_BIN = /tmp/test_messages
TEST_TIMER_BIN = /tmp/test_timer
TEST_NET_BIN = /tmp/test_net
TEST_FS_BIN = /tmp/test_filesystem
TEST_AUDIO_BIN = /tmp/test_audio

ifdef EMSCRIPTEN
CC = emcc
CFLAGS = -Wall -Wextra -fPIC -I.
LDFLAGS = -sSIDE_MODULE=1 -sUSE_WEBGL2=1 -sMIN_WEBGL_VERSION=1 -sMAX_WEBGL_VERSION=2
LIB_EXT = wasm
FIND_SOURCES = find webgl -name "*.c"
FIND_SOURCES = ( find webgl -name "*.c"; find audio -name "*.c"; )
LANG = c
else ifeq ($(PLATFORM_OS),ios)
IOS_MIN ?= 16.0
Expand All @@ -50,15 +51,15 @@ else ifeq ($(PLATFORM_OS),ios)
MIN_FLAG = $(if $(filter iphoneos,$(SDK)),-miphoneos-version-min,-mios-simulator-version-min)=$(IOS_MIN)
CFLAGS = -Wall -Wextra -I. -arch $(ARCH) -isysroot "$(SDK_PATH)" $(MIN_FLAG) -fobjc-arc -Wno-deprecated-declarations
LIB_EXT = a
FIND_SOURCES = ( find ios -name '*.m'; find unix -name '*.c'; )
FIND_SOURCES = ( find ios -name '*.m'; find unix -name '*.c'; find audio -name '*.c'; )
LANG = objective-c
HAS_WINDOWING := 1
else ifeq ($(PLATFORM_OS),darwin)
CC = clang
CFLAGS = -Wall -Wextra -fPIC -I. -DGL_SILENCE_DEPRECATION -Wno-deprecated-declarations
LDFLAGS = -dynamiclib -framework AppKit -framework Cocoa -framework OpenGL -framework IOSurface -framework Security -framework CoreFoundation -install_name @rpath/$(LIBNAME)
LDFLAGS = -dynamiclib -framework AppKit -framework Cocoa -framework OpenGL -framework IOSurface -framework Security -framework CoreFoundation -framework AudioToolbox -install_name @rpath/$(LIBNAME)
LIB_EXT = dylib
FIND_SOURCES = ( find macos -name "*.m"; find unix -name "*.c"; )
FIND_SOURCES = ( find macos -name "*.m"; find unix -name "*.c"; find audio -name "*.c"; )
LANG = objective-c
TEST_LDFLAGS = -L$(abspath $(OUTDIR)) -lplatform -rpath $(abspath $(OUTDIR))
HAS_WINDOWING := 1
Expand All @@ -72,22 +73,28 @@ else ifeq ($(PLATFORM_OS),linux)
ifneq ($(WAYLAND_LIBS),)
CFLAGS += $(shell pkg-config --cflags wayland-client wayland-egl xkbcommon egl gl 2>/dev/null)
LDFLAGS += $(WAYLAND_LIBS)
FIND_SOURCES = ( find wayland -name "*.c"; find unix -name "*.c"; )
FIND_SOURCES = ( find wayland -name "*.c"; find unix -name "*.c"; find audio -name "*.c"; )
HAS_WINDOWING := 1
else
# Try to detect X11 libraries as fallback
X11_LIBS := $(shell pkg-config --libs x11 egl gl 2>/dev/null)
ifneq ($(X11_LIBS),)
CFLAGS += $(shell pkg-config --cflags x11 egl gl 2>/dev/null)
LDFLAGS += $(X11_LIBS)
FIND_SOURCES = ( find x11 -name "*.c"; find unix -name "*.c"; )
FIND_SOURCES = ( find x11 -name "*.c"; find unix -name "*.c"; find audio -name "*.c"; )
HAS_WINDOWING := 1
else
# Fallback to unix-only (no windowing support)
FIND_SOURCES = find unix -name "*.c"
FIND_SOURCES = ( find unix -name "*.c"; find audio -name "*.c"; )
HAS_WINDOWING := 0
endif
endif
# Optional ALSA playback. Without it, WAV load/mix still build and the device open fails.
ALSA_LIBS := $(shell pkg-config --libs alsa 2>/dev/null)
ifneq ($(ALSA_LIBS),)
CFLAGS += $(shell pkg-config --cflags alsa 2>/dev/null) -DHAVE_ALSA
LDFLAGS += $(ALSA_LIBS)
endif
# Optional OpenSSL support for TLS on Linux
OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null)
ifneq ($(OPENSSL_LIBS),)
Expand All @@ -102,9 +109,9 @@ else ifeq ($(PLATFORM_OS),windows)
LDFLAGS = -shared \
-Wl,--out-implib,$(OUTDIR)/libplatform.dll.a \
-lopengl32 -lgdi32 -luser32 -lcomdlg32 \
-lole32 -lshell32 -ladvapi32 -lws2_32 -lxinput1_4 -lsecur32
-lole32 -lshell32 -ladvapi32 -lws2_32 -lxinput1_4 -lsecur32 -lwinmm
LIB_EXT = dll
FIND_SOURCES = find windows -name "*.c"
FIND_SOURCES = ( find windows -name "*.c"; find audio -name "*.c"; )
LANG = c
# Put the test binary next to the DLL so Windows finds it at runtime
TEST_SRC = $(OUTDIR)/test_platform_api_tmp.c
Expand All @@ -114,6 +121,7 @@ else ifeq ($(PLATFORM_OS),windows)
TEST_TIMER_BIN = $(OUTDIR)/test_timer.exe
TEST_NET_BIN = $(OUTDIR)/test_net.exe
TEST_FS_BIN = $(OUTDIR)/test_filesystem.exe
TEST_AUDIO_BIN = $(OUTDIR)/test_audio.exe
HAS_WINDOWING := 1
else
$(error Unsupported OS: $(PLATFORM_UNAME_S))
Expand Down Expand Up @@ -188,6 +196,10 @@ endif
@$(TEST_FS_BIN)
@rm -f $(TEST_FS_BIN)
@echo "Filesystem tests passed."
@$(CC) -I. tests/test_audio.c $(TEST_LDFLAGS) -o $(TEST_AUDIO_BIN)
@$(TEST_AUDIO_BIN)
@rm -f $(TEST_AUDIO_BIN)
@echo "Audio tests passed."
endif

clean:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ A lightweight, cross-platform C library providing a unified API for window manag
- **Event System**: Unified event handling for mouse, keyboard, and window events
- **Input Processing**: Comprehensive keyboard and mouse input with modifier support
- **Networking**: Portable TCP/UDP sockets, DNS resolution, TLS (Schannel/Secure Transport/OpenSSL), and non-blocking I/O
- **Audio**: SDL-style WAV playback (PCM, float, A-law, mu-law) with a queued or callback device and a software mixer

Load a WAV and queue it to the default device. Devices start paused, as in SDL. ADPCM is not supported.

```c
AXaudiospec spec;
uint8_t *samples = NULL;
uint32_t nbytes = 0;
if (axLoadWAV("jump.wav", &spec, &samples, &nbytes)) {
int dev = axAudioOpen(&spec, NULL);
if (dev) {
axAudioQueue(dev, samples, nbytes);
axAudioPause(dev, FALSE);
}
axFreeWAV(samples);
}
```
- **File Dialogs**: Native file open/save dialogs
- **System Integration**: Theme detection, directory paths, timing utilities
- **Minimal Dependencies**: Simple C API with no bloat
Expand Down
Loading
Loading