Files
Dejvino 0f22c6afca Add raylib-esp32 lib and FloorPlan3D demo (3D floor plan via rlsw)
Vendor raylib-esp32 v1.0.3 (63db94b) under lib/ — raylib 6.x core with
the rlsw software renderer plus the ESP32-S3 port layer (SPI display
drivers, async double-buffered flush). raylib/examples, projects, tools
and logo are trimmed (~80 MB of content nothing here compiles); see
lib/raylib-esp32/VENDOR.md for provenance.

New floorplan3d-demo (emulator-template base) renders the NetDeck demo
map (nd_demomap.h) as a 3D floor plan — bulkhead walls, blast door,
cover crates, airlock pad, terminal — through the real on-device 3D
stack on the desktop:

- rcore_emu.c: desktop PLATFORM_CUSTOM layer mirroring rcore_esp32.c,
  flushing the RGB565 sw-renderer buffer into emuGfx::fb instead of SPI
- raylib_emu_config.h: same module/limit defines as the device build
- HUD via 3x5 bitmap font into fb: rlsw's 2D textured-quad path
  (DrawText/DrawRectangle) misplaces/flips quads and samples wrong
  atlas texels in this build; the 3D path is pixel-accurate

Verified: dual build (make netdeck) green, demo smoke test clean at
~59 FPS, 600-frame stability run OK.
2026-11-16 21:46:31 +01:00

143 lines
5.2 KiB
C

#ifndef RAYLIB_ESP32_CONFIG_H
#define RAYLIB_ESP32_CONFIG_H
#ifndef EXTERNAL_CONFIG_FLAGS
#define EXTERNAL_CONFIG_FLAGS
#endif
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "sdkconfig.h"
// Route all raylib allocations through PSRAM.
// rlgl.h maps SW_MALLOC -> RL_MALLOC, so this also covers the SW renderer.
#define RL_MALLOC(sz) heap_caps_malloc(sz, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#define RL_CALLOC(n, sz) \
heap_caps_calloc(n, sz, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#define RL_REALLOC(ptr, sz) \
heap_caps_realloc(ptr, sz, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#define RL_FREE(ptr) heap_caps_free(ptr)
// Software renderer framebuffer
#define SW_FRAMEBUFFER_COLOR_TYPE R5G6B5
#define SW_FRAMEBUFFER_DEPTH_TYPE D16
#define SW_FRAMEBUFFER_OUTPUT_BGRA false
// ---------------------------------------------------------------------------
// Framebuffer placement: internal SRAM on ESP32-S3
// ---------------------------------------------------------------------------
// The rasterizer inner loop hammers the color/depth buffers every pixel.
// Internal SRAM has ~10x lower latency than PSRAM for random access.
// 240x240 R5G6B5+D16 = ~225 KB — fits in the S3's 512 KB SRAM.
// Falls back to PSRAM automatically if internal memory is insufficient.
#if CONFIG_IDF_TARGET_ESP32S3
static inline void *_sw_fb_alloc_prefer_internal(void *old, size_t sz) {
void *p = heap_caps_malloc(sz, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
printf("allocated in internal SRAM: %p\n", p);
if (!p)
p = heap_caps_malloc(sz, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
if (old)
heap_caps_free(old);
return p;
}
#define SW_FB_REALLOC(ptr, sz) _sw_fb_alloc_prefer_internal(ptr, sz)
#define SW_FB_FREE(ptr) heap_caps_free(ptr)
#endif
// ---------------------------------------------------------------------------
// Module selection
// ---------------------------------------------------------------------------
#define SUPPORT_MODULE_RSHAPES 1
#define SUPPORT_MODULE_RTEXTURES 1
#define SUPPORT_MODULE_RTEXT 1
#define SUPPORT_MODULE_RMODELS 1
#define SUPPORT_MODULE_RAUDIO 0
// ---------------------------------------------------------------------------
// rcore
// ---------------------------------------------------------------------------
#define SUPPORT_CAMERA_SYSTEM 1
#define SUPPORT_GESTURES_SYSTEM 1
#define SUPPORT_RPRAND_GENERATOR 1
#define SUPPORT_MOUSE_GESTURES 0
#define SUPPORT_SSH_KEYBOARD_RPI 0
#define SUPPORT_WINMM_HIGHRES_TIMER 0
#define SUPPORT_PARTIALBUSY_WAIT_LOOP 0
#define SUPPORT_SCREEN_CAPTURE 0
#define SUPPORT_GIF_RECORDING 0
#define SUPPORT_COMPRESSION_API 0
#define SUPPORT_AUTOMATION_EVENTS 0
#define SUPPORT_CLIPBOARD_IMAGE 0
#define MAX_FILEPATH_CAPACITY 512
#define MAX_FILEPATH_LENGTH 256
#define MAX_KEYBOARD_KEYS 128
#define MAX_MOUSE_BUTTONS 4
#define MAX_GAMEPADS 1
#define MAX_GAMEPAD_AXES 4
#define MAX_GAMEPAD_BUTTONS 16
#define MAX_GAMEPAD_VIBRATION_TIME 2.0f
#define MAX_TOUCH_POINTS 4
#define MAX_KEY_PRESSED_QUEUE 8
#define MAX_CHAR_PRESSED_QUEUE 8
#define MAX_DECOMPRESSION_SIZE 16
// ---------------------------------------------------------------------------
// rlgl (embedded-friendly batch sizes)
// ---------------------------------------------------------------------------
#define RL_SUPPORT_MESH_GPU_SKINNING 0
#define RL_DEFAULT_BATCH_BUFFERS 1
#define RL_DEFAULT_BATCH_DRAWCALLS 128
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 2
#define RL_MAX_MATRIX_STACK_SIZE 16
#define RL_MAX_SHADER_LOCATIONS 16
#define RL_CULL_DISTANCE_NEAR 0.05
#define RL_CULL_DISTANCE_FAR 1000.0
// ---------------------------------------------------------------------------
// rshapes
// ---------------------------------------------------------------------------
#define SUPPORT_QUADS_DRAW_MODE 1
#define SPLINE_SEGMENT_DIVISIONS 16
// ---------------------------------------------------------------------------
// rtextures — image file formats
// ---------------------------------------------------------------------------
#define SUPPORT_FILEFORMAT_PNG 1
#define SUPPORT_FILEFORMAT_BMP 0
#define SUPPORT_FILEFORMAT_TGA 0
#define SUPPORT_FILEFORMAT_JPG 0
#define SUPPORT_FILEFORMAT_GIF 0
#define SUPPORT_FILEFORMAT_QOI 1
#define SUPPORT_FILEFORMAT_PSD 0
#define SUPPORT_FILEFORMAT_DDS 0
#define SUPPORT_FILEFORMAT_HDR 0
#define SUPPORT_FILEFORMAT_PIC 0
#define SUPPORT_FILEFORMAT_KTX 0
#define SUPPORT_FILEFORMAT_ASTC 0
#define MAX_IMAGE_FLIP_QUEUE 2
// ---------------------------------------------------------------------------
// rtext — font file formats
// ---------------------------------------------------------------------------
#define SUPPORT_FILEFORMAT_FNT 1
#define SUPPORT_FILEFORMAT_TTF 0
#define SUPPORT_FILEFORMAT_BMF 0
#define MAX_TEXT_BUFFER_LENGTH 512
#define MAX_TEXTSPLIT_COUNT 64
// ---------------------------------------------------------------------------
// rmodels — 3D model file formats
// ---------------------------------------------------------------------------
#define SUPPORT_FILEFORMAT_OBJ 1
#define SUPPORT_FILEFORMAT_MTL 1
#define SUPPORT_FILEFORMAT_GLTF 1
#define SUPPORT_FILEFORMAT_M3D 1
#define SUPPORT_FILEFORMAT_VOX 0
#define SUPPORT_FILEFORMAT_IQM 0
#define SUPPORT_MESH_GENERATION 1
#endif // RAYLIB_ESP32_CONFIG_H