-
Notifications
You must be signed in to change notification settings - Fork 0
01 hello window
Copyright (c) 2024-2026 Jack Waechter. MIT licensed.
Open a window, clear it, swap. That is the whole AP2 loop.
#include <AP2/AP2.h>
int main(void) {
if (!AP_Init(AP_INIT_VIDEO)) {
return 1;
}
if (!AP_CreateWindow("Hello AP2", 1280, 720,
AP_WINDOW_RESIZABLE | AP_WINDOW_VSYNC)) {
AP_Quit();
return 1;
}
while (AP_IsRunning()) {
AP_PumpEvents();
if (AP_IsKeyPressed(AP_KEY_ESCAPE)) {
AP_RequestClose();
}
AP_SetDrawColor(0.08f, 0.09f, 0.11f, 1.0f);
AP_Clear();
AP_Present();
}
AP_DestroyWindow(NULL);
AP_Quit();
return 0;
}| Call | Role |
|---|---|
AP_Init(AP_INIT_VIDEO) |
Starts windowing and the graphics device |
AP_CreateWindow |
One window. Later draw/input calls use it |
AP_IsRunning |
False after the user hits the close button or AP_RequestClose
|
AP_PumpEvents |
OS events, input, audio tick |
AP_Tick |
Optional. Caps FPS (AP_SetTargetFPS) and returns dt in seconds |
AP_SetDrawColor |
RGBA 0–1. AP_Clear uses this color |
AP_Clear |
Fill the color buffer |
AP_Present |
Swap (and run post-process if enabled) |
AP_DestroyWindow(NULL) |
Destroy the active window |
AP_Quit |
Shut down subsystems |
AP_INIT_VIDEO already includes windowing. Add | AP_INIT_AUDIO when you need sound.
AP_WINDOW_RESIZABLE | AP_WINDOW_HIGH_PIXEL_DENSITY | AP_WINDOW_MSAA | AP_WINDOW_VSYNCAP_WINDOW_FULLSCREEN is exclusive fullscreen. Size is logical pixels; AP_GetWindowSizeInPixels is the framebuffer size on HiDPI displays.
Caption chrome (decorated windows):
AP_WINDOW_NO_TITLE | AP_WINDOW_NO_MINIMIZE | AP_WINDOW_NO_MAXIMIZE | AP_WINDOW_NO_CLOSEOr at runtime: AP_SetWindowTitleVisible, AP_SetWindowMinimizeButton, AP_SetWindowMaximizeButton, AP_SetWindowCloseButton. AP_WINDOW_NO_BUTTONS hides all three. Close disabled still lets AP_RequestClose work.
Failed init or window creation leaves a message in AP_GetErrorMessage(). Log it if you are wiring a real app:
if (!AP_Init(AP_INIT_VIDEO)) {
AP_ERROR("init: %s", AP_GetErrorMessage());
return 1;
}AP2 — Application Primitives. MIT licensed. Copyright (c) 2024-2026 Jack Waechter. Generated from docs/ in the repository.
- Home
- Guides
- Tutorials
- Tutorial 01 — Hello window
- Tutorial 02 — Drawing in 2D
- Tutorial 03 — Textures and sprites
- Tutorial 04 — Input
- Tutorial 05 — Audio
- Tutorial 06 — Text and fonts
- Tutorial 07 — Immediate GUI
- Tutorial 08 — 3D
- Tutorial 09 — Shaders and post-processing
- Tutorial 10 — Breakout
- Tutorial 11 — Top-down walker
- Tutorial 12 — Desktop tool
- Tutorial 13 — Tilemaps
- Tutorial 14 — Advanced 3D: A PBR Product Scene
- Tutorial 15 — Advanced GUI: A Retained-Mode Desktop App
- Tutorial 16 — Camera Rigs and Cinematic Post-Processing
- Tutorial 17 — Capstone: A Complete Application