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.
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* @brief ESP LCD: GC9A01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_idf_version.h"
|
||||
|
||||
#ifndef ESP_LCD_GC9A01_VER_MAJOR
|
||||
#define ESP_LCD_GC9A01_VER_MAJOR 1
|
||||
#define ESP_LCD_GC9A01_VER_MINOR 0
|
||||
#define ESP_LCD_GC9A01_VER_PATCH 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LCD panel initialization commands.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int cmd; /*<! The specific LCD command */
|
||||
const void *data; /*<! Buffer that holds the command specific data */
|
||||
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
|
||||
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
|
||||
} gc9a01_lcd_init_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief LCD panel vendor configuration.
|
||||
*
|
||||
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
const gc9a01_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
|
||||
* The array should be declared as `static const` and positioned outside the function.
|
||||
* Please refer to `vendor_specific_init_default` in source file.
|
||||
*/
|
||||
uint16_t init_cmds_size; /*<! Number of commands in above array */
|
||||
} gc9a01_vendor_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel for model GC9A01
|
||||
*
|
||||
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config general panel device configuration
|
||||
* @param[out] ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_gc9a01(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
/**
|
||||
* @brief LCD panel bus configuration structure
|
||||
*
|
||||
* @param[in] sclk SPI clock pin number
|
||||
* @param[in] mosi SPI MOSI pin number
|
||||
* @param[in] max_trans_sz Maximum transfer size in bytes
|
||||
*
|
||||
*/
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
#define GC9A01_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
|
||||
{ \
|
||||
.mosi_io_num = mosi, \
|
||||
.miso_io_num = -1, \
|
||||
.sclk_io_num = sclk, \
|
||||
.quadwp_io_num = -1, \
|
||||
.quadhd_io_num = -1, \
|
||||
.data4_io_num = -1, \
|
||||
.data5_io_num = -1, \
|
||||
.data6_io_num = -1, \
|
||||
.data7_io_num = -1, \
|
||||
.max_transfer_sz = max_trans_sz, \
|
||||
}
|
||||
#else
|
||||
#define GC9A01_PANEL_BUS_SPI_CONFIG(sclk, mosi, max_trans_sz) \
|
||||
{ \
|
||||
.mosi_io_num = mosi, \
|
||||
.miso_io_num = -1, \
|
||||
.sclk_io_num = sclk, \
|
||||
.quadwp_io_num = -1, \
|
||||
.quadhd_io_num = -1, \
|
||||
.max_transfer_sz = max_trans_sz, \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief LCD panel IO configuration structure
|
||||
*
|
||||
* @param[in] cs SPI chip select pin number
|
||||
* @param[in] dc SPI data/command pin number
|
||||
* @param[in] cb Callback function when SPI transfer is done
|
||||
* @param[in] cb_ctx Callback function context
|
||||
*
|
||||
*/
|
||||
#define GC9A01_PANEL_IO_SPI_CONFIG(cs, dc, callback, callback_ctx) \
|
||||
{ \
|
||||
.cs_gpio_num = cs, \
|
||||
.dc_gpio_num = dc, \
|
||||
.spi_mode = 0, \
|
||||
.pclk_hz = 80 * 1000 * 1000, \
|
||||
.trans_queue_depth = 10, \
|
||||
.on_color_trans_done = callback, \
|
||||
.user_ctx = callback_ctx, \
|
||||
.lcd_cmd_bits = 8, \
|
||||
.lcd_param_bits = 8, \
|
||||
.flags = {} \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @file
|
||||
* @brief ESP LCD: ST7796
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/lcd_types.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_idf_version.h"
|
||||
#if SOC_MIPI_DSI_SUPPORTED
|
||||
#include "esp_lcd_mipi_dsi.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LCD panel initialization commands.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int cmd; /*<! The specific LCD command */
|
||||
const void *data; /*<! Buffer that holds the command specific data */
|
||||
size_t data_bytes; /*<! Size of `data` in memory, in bytes */
|
||||
unsigned int delay_ms; /*<! Delay in milliseconds after this command */
|
||||
} st7796_lcd_init_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief LCD panel vendor configuration.
|
||||
*
|
||||
* @note This structure needs to be passed to the `vendor_config` field in `esp_lcd_panel_dev_config_t`.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
const st7796_lcd_init_cmd_t *init_cmds; /*!< Pointer to initialization commands array. Set to NULL if using default commands.
|
||||
* The array should be declared as `static const` and positioned outside the function.
|
||||
* Please refer to `vendor_specific_init_default` in source file.
|
||||
*/
|
||||
uint16_t init_cmds_size; /*<! Number of commands in above array */
|
||||
#if SOC_MIPI_DSI_SUPPORTED
|
||||
struct {
|
||||
esp_lcd_dsi_bus_handle_t dsi_bus; /*!< MIPI-DSI bus configuration */
|
||||
const esp_lcd_dpi_panel_config_t *dpi_config; /*!< MIPI-DPI panel configuration */
|
||||
} mipi_config;
|
||||
#endif
|
||||
struct {
|
||||
unsigned int use_mipi_interface: 1; /*<! Set to 1 if using MIPI interface, default is SPI/I80 interface */
|
||||
} flags;
|
||||
} st7796_vendor_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel for model ST7796
|
||||
*
|
||||
* @note Vendor specific initialization can be different between manufacturers, should consult the LCD supplier for initialization sequence code.
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config general panel device configuration
|
||||
* @param[out] ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_st7796(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////// Default Configuration Macros for I80 Interface /////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief LCD panel bus configuration structure
|
||||
*
|
||||
* @param[in] max_trans_bytes Maximum bytes of data to be transferred in one transaction. Normally set to the size of one frame bytes.
|
||||
* @param[in] data_width Data bus width
|
||||
* @param[in] dc I80 data/command pin number
|
||||
* @param[in] wr I80 write clock pin number
|
||||
* @param[in] d[0:15] I80 data pin number 0 ~ 15. Set to -1 if not used.
|
||||
*
|
||||
*/
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 4, 1)
|
||||
#define ST7796_PANEL_BUS_I80_CONFIG(max_trans_bytes, data_width, dc, wr, d0, d1, d2, d3, d4, \
|
||||
d5, d6, d7, d8 , d9, d10, d11, d12, d13, d14, d15) \
|
||||
{ \
|
||||
.clk_src = LCD_CLK_SRC_PLL160M, \
|
||||
.dc_gpio_num = dc, \
|
||||
.wr_gpio_num = wr, \
|
||||
.data_gpio_nums = { \
|
||||
d0, d1, d2, d3, d4, d5, d6, d7, d8 , d9, d10, d11, d12, d13, d14, d15 \
|
||||
}, \
|
||||
.bus_width = data_width, \
|
||||
.max_transfer_bytes = max_trans_bytes, \
|
||||
}
|
||||
#elif ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
|
||||
#define ST7796_PANEL_BUS_I80_CONFIG(max_trans_bytes, data_width, dc, wr, d0, d1, d2, d3, d4, \
|
||||
d5, d6, d7, d8 , d9, d10, d11, d12, d13, d14, d15) \
|
||||
{ \
|
||||
.clk_src = LCD_CLK_SRC_PLL160M, \
|
||||
.dc_gpio_num = dc, \
|
||||
.wr_gpio_num = wr, \
|
||||
.data_gpio_nums = { \
|
||||
d0, d1, d2, d3, d4, d5, d6, d7, d8 , d9, d10, d11, d12, d13, d14, d15 \
|
||||
}, \
|
||||
.bus_width = data_width, \
|
||||
.max_transfer_bytes = max_trans_bytes, \
|
||||
.psram_trans_align = 64, \
|
||||
.sram_trans_align = 4, \
|
||||
}
|
||||
#else
|
||||
#define ST7796_PANEL_BUS_I80_CONFIG(max_trans_bytes, data_width, dc, wr, d0, d1, d2, d3, d4, \
|
||||
d5, d6, d7, d8 , d9, d10, d11, d12, d13, d14, d15) \
|
||||
{ \
|
||||
.clk_src = LCD_CLK_SRC_PLL160M, \
|
||||
.dc_gpio_num = dc, \
|
||||
.wr_gpio_num = wr, \
|
||||
.data_gpio_nums = { \
|
||||
d0, d1, d2, d3, d4, d5, d6, d7, d8 , d9, d10, d11, d12, d13, d14, d15 \
|
||||
}, \
|
||||
.bus_width = data_width, \
|
||||
.max_transfer_bytes = max_trans_bytes, \
|
||||
.dma_burst_size = 64, \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LCD panel IO configuration structure
|
||||
*
|
||||
* @param[in] cs I80 chip select pin number
|
||||
* @param[in] cb Callback function when data transfer is done
|
||||
* @param[in] cb_ctx Callback function context
|
||||
*
|
||||
*/
|
||||
#define ST7796_PANEL_IO_I80_CONFIG(cs, cb, cb_ctx) \
|
||||
{ \
|
||||
.cs_gpio_num = cs, \
|
||||
.pclk_hz = 10 * 1000 * 1000, \
|
||||
.trans_queue_depth = 10, \
|
||||
.dc_levels = { \
|
||||
.dc_idle_level = 0, \
|
||||
.dc_cmd_level = 0, \
|
||||
.dc_dummy_level = 0, \
|
||||
.dc_data_level = 1, \
|
||||
}, \
|
||||
.flags = { \
|
||||
.swap_color_bytes = 1, \
|
||||
}, \
|
||||
.on_color_trans_done = cb, \
|
||||
.user_ctx = cb_ctx, \
|
||||
.lcd_cmd_bits = 8, \
|
||||
.lcd_param_bits = 8, \
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// Default Configuration Macros for MIPI-DSI Interface //////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief MIPI-DSI bus configuration structure
|
||||
*
|
||||
* @param[in] lane_num Number of data lanes
|
||||
* @param[in] lane_mbps Lane bit rate in Mbps
|
||||
*
|
||||
*/
|
||||
#define ST7796_PANEL_BUS_DSI_1CH_CONFIG() \
|
||||
{ \
|
||||
.bus_id = 0, \
|
||||
.num_data_lanes = 1, \
|
||||
.phy_clk_src = 0, \
|
||||
.lane_bit_rate_mbps = 480, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MIPI-DBI panel IO configuration structure
|
||||
*
|
||||
*/
|
||||
#define ST7796_PANEL_IO_DBI_CONFIG() \
|
||||
{ \
|
||||
.virtual_channel = 0, \
|
||||
.lcd_cmd_bits = 8, \
|
||||
.lcd_param_bits = 8, \
|
||||
}
|
||||
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
|
||||
/**
|
||||
* @brief MIPI DPI configuration structure
|
||||
*
|
||||
* @note refresh_rate = (dpi_clock_freq_mhz * 1000000) / (h_res + hsync_pulse_width + hsync_back_porch + hsync_front_porch)
|
||||
* / (v_res + vsync_pulse_width + vsync_back_porch + vsync_front_porch)
|
||||
*
|
||||
* @param[in] px_format Pixel format of the panel
|
||||
*
|
||||
*/
|
||||
#define ST7796_320_480_PANEL_60HZ_DPI_CONFIG(px_format) \
|
||||
{ \
|
||||
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, \
|
||||
.dpi_clock_freq_mhz = 10, \
|
||||
.virtual_channel = 0, \
|
||||
.pixel_format = px_format, \
|
||||
.num_fbs = 1, \
|
||||
.video_timing = { \
|
||||
.h_size = 320, \
|
||||
.v_size = 480, \
|
||||
.hsync_back_porch = 10, \
|
||||
.hsync_pulse_width = 10, \
|
||||
.hsync_front_porch = 20, \
|
||||
.vsync_back_porch = 10, \
|
||||
.vsync_pulse_width = 10, \
|
||||
.vsync_front_porch = 10, \
|
||||
}, \
|
||||
.flags.use_dma2d = true, \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief MIPI DPI configuration structure
|
||||
*
|
||||
* @note refresh_rate = (dpi_clock_freq_mhz * 1000000) / (h_res + hsync_pulse_width + hsync_back_porch + hsync_front_porch)
|
||||
* / (v_res + vsync_pulse_width + vsync_back_porch + vsync_front_porch)
|
||||
*
|
||||
* @param[in] color_format Input color format of the panel
|
||||
*
|
||||
*/
|
||||
#define ST7796_320_480_PANEL_60HZ_DPI_CONFIG_CF(color_format) \
|
||||
{ \
|
||||
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT, \
|
||||
.dpi_clock_freq_mhz = 10, \
|
||||
.virtual_channel = 0, \
|
||||
.in_color_format = color_format, \
|
||||
.num_fbs = 1, \
|
||||
.video_timing = { \
|
||||
.h_size = 320, \
|
||||
.v_size = 480, \
|
||||
.hsync_back_porch = 10, \
|
||||
.hsync_pulse_width = 10, \
|
||||
.hsync_front_porch = 20, \
|
||||
.vsync_back_porch = 10, \
|
||||
.vsync_pulse_width = 10, \
|
||||
.vsync_front_porch = 10, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_types.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* @brief Initialize ST7796 LCD panel with SPI/I80 interface
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config LCD panel device configuration
|
||||
* @param[out] ret_panel LCD panel handle
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Otherwise: Fail
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_st7796_general(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
#if SOC_MIPI_DSI_SUPPORTED
|
||||
/**
|
||||
* @brief Initialize ST7796 LCD panel with MIPI interface
|
||||
*
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @param[in] panel_dev_config LCD panel device configuration
|
||||
* @param[out] ret_panel LCD panel handle
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Otherwise: Fail
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_st7796_mipi(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||
esp_lcd_panel_handle_t *ret_panel);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Forwarding header — lets users write #include <raylib.h> */
|
||||
#include "../raylib/src/raylib.h"
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef RAYLIB_ESP32_H
|
||||
#define RAYLIB_ESP32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "raylib_esp32_displays.h"
|
||||
|
||||
typedef struct {
|
||||
raylib_display_driver_e driver;
|
||||
spi_host_device_t spi_host;
|
||||
int pin_sclk;
|
||||
int pin_mosi;
|
||||
int pin_cs;
|
||||
int pin_dc;
|
||||
int pin_rst;
|
||||
int pin_bl;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint32_t spi_freq_hz; /* 0 → use driver default */
|
||||
} raylib_esp32_display_config_t;
|
||||
|
||||
/**
|
||||
* Initialize display hardware and the raylib port layer.
|
||||
* Must be called before InitWindow().
|
||||
*
|
||||
* Sets up: SPI bus → panel driver → port layer (DMA flush, semaphores).
|
||||
* Also turns on the backlight via pin_bl (active-high).
|
||||
*/
|
||||
esp_err_t raylib_esp32_init(const raylib_esp32_display_config_t *config);
|
||||
|
||||
/**
|
||||
* Mount a LittleFS partition so that raylib's LoadModel / LoadTexture /
|
||||
* LoadFont can read from it via standard fopen().
|
||||
*
|
||||
* @param mount_point VFS path, e.g. "/data"
|
||||
* @param partition Partition label in the partition table (usually "spiffs")
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t raylib_esp32_mount_fs(const char *mount_point,
|
||||
const char *partition_label);
|
||||
|
||||
/**
|
||||
* Tear down the port layer and free the display framebuffer.
|
||||
*/
|
||||
void raylib_esp32_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RAYLIB_ESP32_H */
|
||||
@@ -0,0 +1,142 @@
|
||||
#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
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef RAYLIB_ESP32_DISPLAYS_H
|
||||
#define RAYLIB_ESP32_DISPLAYS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_idf_version.h"
|
||||
// #include "esp_lcd_panel_io.h"
|
||||
|
||||
#include "esp_lcd_io_spi.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
|
||||
#include "driver/spi_master.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* IDF 4.4 uses void* for the SPI bus handle; IDF 5.x takes spi_host_device_t directly */
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
#define RAYLIB_LCD_SPI_HOST(h) ((esp_lcd_spi_bus_handle_t)(h))
|
||||
#else
|
||||
#define RAYLIB_LCD_SPI_HOST(h) (h)
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
RAYLIB_DRIVER_GC9A01,
|
||||
RAYLIB_DRIVER_ST7789,
|
||||
RAYLIB_DRIVER_ST7796S,
|
||||
RAYLIB_DRIVER_ILI9341,
|
||||
RAYLIB_DRIVER_CUSTOM,
|
||||
} raylib_display_driver_e;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
esp_err_t (*init_panel)(spi_host_device_t spi_host,
|
||||
int pin_cs, int pin_dc, int pin_rst,
|
||||
uint16_t width, uint16_t height,
|
||||
uint32_t spi_freq_hz,
|
||||
esp_lcd_panel_handle_t *out_panel,
|
||||
esp_lcd_panel_io_handle_t *out_io);
|
||||
bool needs_invert_color;
|
||||
bool needs_byte_swap;
|
||||
uint32_t default_spi_freq_hz;
|
||||
} raylib_display_driver_t;
|
||||
|
||||
const raylib_display_driver_t *raylib_esp32_get_driver(raylib_display_driver_e id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_ESP32_DISPLAYS_H
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef RAYLIB_ESP32_PORT_H
|
||||
#define RAYLIB_ESP32_PORT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_handle_t panel;
|
||||
esp_lcd_panel_io_handle_t io;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
bool swap_bytes;
|
||||
size_t chunk_height;
|
||||
} raylib_port_config_t;
|
||||
|
||||
esp_err_t raylib_port_init(const raylib_port_config_t *config);
|
||||
esp_err_t raylib_port_flush_rgb565(const uint16_t *buf, int x, int y, int w, int h);
|
||||
esp_err_t raylib_port_flush_rgb565_vflip(const uint16_t *src, int w, int h);
|
||||
esp_err_t raylib_port_flush_async(const uint16_t *src, int w, int h);
|
||||
esp_err_t raylib_port_wait_flush(void);
|
||||
void raylib_port_get_dimensions(uint16_t *w, uint16_t *h);
|
||||
void raylib_port_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_ESP32_PORT_H
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Forwarding header — lets users write #include <raymath.h> */
|
||||
#include "../raylib/src/raymath.h"
|
||||
@@ -0,0 +1,2 @@
|
||||
/* Forwarding header — lets users write #include <rlgl.h> */
|
||||
#include "../raylib/src/rlgl.h"
|
||||
Reference in New Issue
Block a user