Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
1ea6a35
build setup
FishOfTheNorthStar May 14, 2025
9e9e4d7
support functions
FishOfTheNorthStar May 14, 2025
ffe4e59
basic UI generation
FishOfTheNorthStar May 14, 2025
0c5e3d6
updated readme with additional screenshots and build info
FishOfTheNorthStar May 14, 2025
1a9cc95
GLSL code portions
FishOfTheNorthStar May 14, 2025
ad8fa13
current V1 frag/vertex shader definition
FishOfTheNorthStar May 14, 2025
aedc24b
Full Implmentation and LVGL archived version inclusion
FishOfTheNorthStar May 15, 2025
e24b77b
Added instructions and sample file to make this the default gltf file…
FishOfTheNorthStar May 15, 2025
19303c5
fix: minor corrections to setting up default gltf file viewer
FishOfTheNorthStar May 15, 2025
53fbd62
patch applied to fix crash
FishOfTheNorthStar May 15, 2025
c1fe559
PR adjusts, face culling enabled, better depth precision
FishOfTheNorthStar May 16, 2025
49dd98c
removed b64 and jsmn dependencies
FishOfTheNorthStar May 16, 2025
0bbe067
updated build instructions
FishOfTheNorthStar May 16, 2025
385ed02
Big update with many changes to the work in progress gltf viewer
FishOfTheNorthStar Jun 10, 2025
2f71c89
submodule adjust
FishOfTheNorthStar Jun 10, 2025
86394b6
updated gitmodules to use a custom branch of LVGL for extra mouse sup…
FishOfTheNorthStar Jun 10, 2025
8f94ae2
script adjustment
FishOfTheNorthStar Jun 10, 2025
dd79c70
added spin_degree_ofset parameter to support a yaw platter spin effect
FishOfTheNorthStar Jun 10, 2025
c989cfe
fixed some compiler warnings and added more get/set funcs
FishOfTheNorthStar Jun 10, 2025
30424b0
cleaned up and organized the demo code more
FishOfTheNorthStar Jun 11, 2025
9257b09
style changes and various refactoring
FishOfTheNorthStar Jun 11, 2025
ec518d1
added -sw option to force software rendering
FishOfTheNorthStar Jun 11, 2025
0613926
code style and variable name changes. adjusted material properties o…
FishOfTheNorthStar Jun 11, 2025
7e6ea04
torusknot.gltf material changes and _rebuild.sh default app settings …
FishOfTheNorthStar Jun 11, 2025
36524f0
simplification and renaming
FishOfTheNorthStar Jun 11, 2025
2ed6562
fixed up some compiler warnings and simplified structure more
FishOfTheNorthStar Jun 11, 2025
c6cea84
renamed many files and re-organized them for clarity
FishOfTheNorthStar Jun 11, 2025
18a8136
updated filenames and restored missing source files
FishOfTheNorthStar Jun 11, 2025
ab21b4b
adjusted local function naming convention
FishOfTheNorthStar Jun 12, 2025
b13655f
added better ram temp drive support, stub window mode and a commandli…
FishOfTheNorthStar Jun 12, 2025
fce3619
added notification to the frame rate output when user is in DEBUG bui…
FishOfTheNorthStar Jun 12, 2025
42ec55c
testing resizable windows and removed compilation option that was cre…
FishOfTheNorthStar Jun 13, 2025
0240f49
added file load tab, drag and drop file loading, navigation smoothing…
FishOfTheNorthStar Jun 18, 2025
f94e996
fixed some filenames and relative paths
FishOfTheNorthStar Jun 18, 2025
6610500
organization adjustment
FishOfTheNorthStar Jun 19, 2025
962f5ec
fix gimbal lock on extreme view angles
FishOfTheNorthStar Jun 19, 2025
804777f
stable backup point
FishOfTheNorthStar Jun 19, 2025
7862690
shader cache isolated into it's own class, lv_opengl_shader_cache (to…
FishOfTheNorthStar Jun 19, 2025
51f6dc4
directory structure integration and lv_gltf_data partial isolation
FishOfTheNorthStar Jun 19, 2025
a84a993
lv_gltf_data more fully isolated
FishOfTheNorthStar Jun 19, 2025
af490e9
various code adjustments and optimized inverse bind matrix resolution…
FishOfTheNorthStar Jun 19, 2025
bb54955
documentation
FishOfTheNorthStar Jun 19, 2025
7430eba
more documentation
FishOfTheNorthStar Jun 20, 2025
f822022
improved viewpoint easing and indirect slider adjustment
FishOfTheNorthStar Jun 20, 2025
f64ac24
isolated lv_gltf_override and added small fix to how mouse movement i…
FishOfTheNorthStar Jun 20, 2025
e3cab8d
internalized external dependencies fastgltf, simdjson, and mathc
FishOfTheNorthStar Jun 20, 2025
de0ea6f
Added option LVGL_ENABLE_WEBP_IMAGES to CMakeLists.txt, nonzero value…
FishOfTheNorthStar Jun 21, 2025
1b33cb5
testing internal webp decoder compilation to reduce external dependen…
FishOfTheNorthStar Jun 21, 2025
3589da4
added required notice to the webp_min folder
FishOfTheNorthStar Jun 21, 2025
73a48b6
add: lv_gltf_data_utils_texture_to_image_dsc(), lv_gltf_data_utils_sw…
FishOfTheNorthStar Jun 21, 2025
44409b8
add: documentation in the lv_gltf_data_internal.hpp file
FishOfTheNorthStar Jun 21, 2025
d459bbe
add: support for orthographic projection for non-perspective / isomet…
FishOfTheNorthStar Jun 22, 2025
ebe1950
add: lv_gltf_view_set_bgcolor_red/green/blue and set_bg_opa, also com…
FishOfTheNorthStar Jun 22, 2025
06ab954
add: ability to add more than one override to a nodepath; add: a new …
FishOfTheNorthStar Jun 23, 2025
2c2be93
add: ability to override the default vertex/fragment shaders
FishOfTheNorthStar Jun 23, 2025
fe10e12
fix: changed run.sh so 'always anti-alias' is not specified as the de…
FishOfTheNorthStar Jun 23, 2025
9f1908f
fix: make the application compile
AndreCostaaa Jun 24, 2025
93b57b6
fix: compile lvgl using its cmakelists and set include directories
AndreCostaaa Jun 24, 2025
b2626a2
chore: stop ignoring lvgl and ignore .cache
AndreCostaaa Jun 24, 2025
2c7a6c4
fix: remove a bunch of warnings
AndreCostaaa Jun 24, 2025
6935ca0
fix: webgl compatability
FishOfTheNorthStar Jun 26, 2025
6ed8b6a
improved animation performance, added some function aliases for backg…
FishOfTheNorthStar Jun 27, 2025
210e3cc
clean branch initial commit
FishOfTheNorthStar Jun 27, 2025
88ddd9d
fix: modified webp code to correct some compiler warnings
FishOfTheNorthStar Jun 27, 2025
341df81
fix: string length ISO pedantic warnings from shader code volume, spl…
FishOfTheNorthStar Jun 27, 2025
bf95777
fix: numerous small fixes to resolve compiler warnings
FishOfTheNorthStar Jun 28, 2025
9348022
fix: re-enabled unused-parameter warnings and unknown pragmas
FishOfTheNorthStar Jun 28, 2025
35d8417
rev_ref: mathc -> fix strict shadow warnings & array bound errors
FishOfTheNorthStar Jun 28, 2025
a6babb9
rev_ref: fastgltf -> fix strict shadow warnings
FishOfTheNorthStar Jun 28, 2025
d5bf0a4
fix: CMakeLists.txt -> all warnings re-enabled
FishOfTheNorthStar Jun 28, 2025
3c48479
fix: corrected a couple more minor warnings in fastgltf
FishOfTheNorthStar Jun 28, 2025
d40b03d
fix: completely removed all pragmas and any remaining warning suppres…
FishOfTheNorthStar Jun 28, 2025
3edd7ae
fix: correct a couple final warnings in the stbi_write.h file
FishOfTheNorthStar Jun 28, 2025
a8fb380
remove: mathc requirement
FishOfTheNorthStar Jun 30, 2025
a49aae6
fix(shader_cache): fix segfault caused by calling GetAttachedShaders …
AndreCostaaa Jun 30, 2025
e1e7773
build: configure build system with opengl libs and fastgltf
AndreCostaaa Jun 30, 2025
bbc0d64
chore: remove mathc dependency
AndreCostaaa Jul 1, 2025
1d16538
build: make code compile by fetching dependencies using cmake
AndreCostaaa Jul 1, 2025
ceded1a
chore: remove unused files
AndreCostaaa Jul 1, 2025
349e10c
docs(readme): update getting started section
AndreCostaaa Jul 1, 2025
47cdefb
fix: remove duplicate typedef
AndreCostaaa Jul 1, 2025
b5f09db
build: set correct compiler flags
AndreCostaaa Jul 1, 2025
743ba47
chore: update stb_image to v2.30 removing build warning
AndreCostaaa Jul 1, 2025
497c896
build: use downstream version from fastgltf to avoid build warnings
AndreCostaaa Jul 1, 2025
5292208
chore: move src files to src folder
AndreCostaaa Jul 1, 2025
c109cc1
chore: move desktop example file to env
AndreCostaaa Jul 1, 2025
0f07148
chore: move app resources to src folder
AndreCostaaa Jul 1, 2025
c7fc26e
chore: remove unused file
AndreCostaaa Jul 1, 2025
8806318
chore: move readme images to media folder
AndreCostaaa Jul 1, 2025
0b4556c
chore: move assets to assets folder
AndreCostaaa Jul 1, 2025
3424118
chore: remove unused file
AndreCostaaa Jul 1, 2025
d8a158b
style: format source code using lvgl's format rules
AndreCostaaa Jul 1, 2025
c11da50
build: fix output generated files output path
AndreCostaaa Jul 1, 2025
692c517
chore: simplify gitignore by simply ignoring build and .cache folder
AndreCostaaa Jul 1, 2025
16a8bd2
feat: add a simple 3d texture from gltf demo
AndreCostaaa Jul 1, 2025
8151b26
build: point to correct fixed version of fastgltf
AndreCostaaa Jul 1, 2025
fdb3620
build: use official version of fastgltf as warnings were fixed
AndreCostaaa Jul 3, 2025
078f1ca
build: fetch webp from mirror as official repository isn't working
AndreCostaaa Jul 3, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build/
build
.cache
9 changes: 2 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
[submodule "lib/b64"]
path = lib/b64
url = https://github.com/liamHowatt/b64.git
[submodule "lib/jsmn"]
path = lib/jsmn
url = https://github.com/zserge/jsmn.git
[submodule "lvgl"]
path = lvgl
url = https://github.com/lvgl/lvgl.git
url = https://github.com/FishOfTheNorthStar/lvgl_pr_patch_func.git
branch = pr_3_mouse_ex
188 changes: 159 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,168 @@
cmake_minimum_required(VERSION 3.28)
cmake_minimum_required(VERSION 3.25.1)
project(gltf_view LANGUAGES C CXX)

project(lvgl_workspace LANGUAGES C CXX)
# Set policy to allow to run the target_link_libraries cmd on targets that are
# build in another directory. Currently, the linking is not handled by
# env_support/cmake/os.cmake This means that if a driver is enabled and it
# requires linking an external library it needs to be handled in the top-level
# project.
cmake_policy(SET CMP0079 NEW)

set(CONFIG_LV_BUILD_EXAMPLES 1)
set(CONFIG_LV_BUILD_DEMOS 1)
include(FetchContent)

# LVGL
include(${CMAKE_CURRENT_LIST_DIR}/lvgl/CMakeLists.txt)
include_directories(${CMAKE_CURRENT_LIST_DIR})
find_package(PkgConfig REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
find_package(GLEW REQUIRED)

# find_package(Freetype REQUIRED)
# include_directories(${FREETYPE_INCLUDE_DIRS})
FetchContent_Declare(
fastgltf
GIT_REPOSITORY https://github.com/spnda/fastgltf
GIT_TAG 4e2261350888bae7c35a1f39991f6233d57795f5
GIT_SHALLOW TRUE)

add_executable(lvgl_workspace
main.c
mouse_cursor_icon.c
gltf_loader.c
)
set(FASTGLTF_ENABLE_DEPRECATED_EXT
ON
CACHE BOOL "" FORCE)

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -fsanitize=address -Wno-unused-parameter -Wunused-parameter -Wshadow")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -fsanitize=address -Wno-unused-parameter")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address -Wno-unused-parameter")
FetchContent_MakeAvailable(fastgltf)

target_link_libraries(lvgl_workspace lvgl)
target_link_libraries(lvgl_workspace pthread)
target_link_libraries(lvgl_workspace m)
# target_link_libraries(lvgl_workspace lvgl_thorvg)
# target_link_libraries(lvgl_workspace lvgl_examples)
# target_link_libraries(lvgl_workspace lvgl_demos)
FetchContent_Declare(
webp
GIT_REPOSITORY https://github.com/webmproject/libwebp
GIT_TAG fa6f56496a442eed59b103250021e4b14ebf1427
GIT_SHALLOW TRUE)

target_link_libraries(lvgl_workspace GL)
target_link_libraries(lvgl_workspace GLEW)
target_link_libraries(lvgl_workspace glfw)
FetchContent_MakeAvailable(webp)

# target_link_libraries(lvgl_workspace jpeg)
# target_link_libraries(lvgl_workspace png)
# target_link_libraries(lvgl_workspace ${FREETYPE_LIBRARIES})
# Compiler settings
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -ggdb")
set(CONFIG_LV_BUILD_EXAMPLES
OFF
CACHE BOOL "disable lvgl examples" FORCE)
set(CONFIG_LV_BUILD_DEMOS
OFF
CACHE BOOL "disable lvgl demos" FORCE)
set(CONFIG_LV_USE_THORVG_INTERNAL
OFF
CACHE BOOL "disable thorvg internal" FORCE)

add_subdirectory(lvgl)

# Define common include directories
set(LVGL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/lvgl ${CMAKE_SOURCE_DIR}/lvgl/src)
set(PROTO_INCLUDE_DIRS lib/lv_gltf/data/deps/)

# Create library targets
add_library(lvgl_opengl_shader_cache
lib/lv_opengl_shader_cache/lv_opengl_shader_cache.cpp)
target_include_directories(lvgl_opengl_shader_cache
PRIVATE ${LVGL_INCLUDE_DIRS})

add_library(
lvgl_gltfdata
lib/lv_gltf/data/lv_gltf_override.cpp lib/lv_gltf/data/sup/utils.cpp
lib/lv_gltf/data/sup/injest.cpp lib/lv_gltf/data/sup/reports.cpp
lib/lv_gltf/data/sup/datatypes.cpp)

target_include_directories(lvgl_gltfdata PRIVATE fastgltf ${LVGL_INCLUDE_DIRS}
${PROTO_INCLUDE_DIRS})
target_link_libraries(lvgl_gltfdata PRIVATE lvgl_opengl_shader_cache fastgltf)

target_compile_definitions(lvgl_gltfdata PRIVATE LVGL_ENABLE_WEBP_IMAGES)

add_library(
lvgl_gltfview
lib/lv_gltf/view/lv_gltf_view.cpp
lib/lv_gltf/view/sup/datatypes.cpp
lib/lv_gltf/view/sup/utils.cpp
lib/lv_gltf/view/sup/setup.cpp
lib/lv_gltf/view/sup/animation.cpp
lib/lv_gltf/view/sup/ibl_sampler.cpp
lib/lv_gltf/view/sup/shader_includes.cpp)

target_include_directories(lvgl_gltfview PRIVATE ${LVGL_INCLUDE_DIRS}
${PROTO_INCLUDE_DIRS})
target_link_libraries(lvgl_gltfview PRIVATE lvgl_opengl_shader_cache fastgltf
webp)
target_link_libraries(lvgl_gltfview PRIVATE lvgl_gltfdata fastgltf)

# Main executable
add_executable(
gltf_view
src/demo.cpp
src/demo_ui.c
src/demo_cli.c
src/demo_nav.c
src/demo_os_integrate.c
src/demo_file_load_dialog.c
src/demo_misc_utils.c
src/mouse_cursor_icon.c
src/lvgl_icon_40px_ARGB888.c
src/sprites1_32x32x7.c)

add_executable(demo src/simple_demo.c)

# Build type definitions
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(-DNDEBUG)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
add_definitions(-DNDEBUG)
endif()

# Optional: Enable AddressSanitizer for Debug builds (can be disabled if
# problematic)
option(ENABLE_ASAN "Enable AddressSanitizer in Debug builds" OFF)

if(ENABLE_ASAN AND CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(gltf_view PRIVATE -fsanitize=address)
target_link_options(gltf_view PRIVATE -fsanitize=address)
endif()

# Additional optimization for MinSizeRel
if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
target_link_options(gltf_view PRIVATE -Wl,--gc-sections)
endif()

target_link_libraries(
gltf_view
PRIVATE lvgl
lvgl_gltfview
lvgl_gltfdata
m
OpenGL::GL
GLEW::GLEW
glfw
webp
fastgltf)

target_link_libraries(
demo
PRIVATE lvgl
lvgl_gltfview
lvgl_gltfdata
m
OpenGL::GL
GLEW::GLEW
glfw
webp
fastgltf)

target_include_directories(
gltf_view PRIVATE ./lib/lv_gltf ./lib/lv_gltf/data/deps lvgl lvgl/src)

set_target_properties(gltf_view PROPERTIES COMPILE_DEFINITIONS
"${LVGL_COMPILER_DEFINES}")

set_target_properties(demo PROPERTIES COMPILE_DEFINITIONS
"${LVGL_COMPILER_DEFINES}")

target_include_directories(demo PRIVATE ./lib/lv_gltf ./lib/lv_gltf/data/deps
lvgl lvgl/src)
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
# `lv_example_3dtexture`
# `lv_gltf_viewer`

Example usage of the LVGL `3dtexture` widget.
A simple glTF file viewer, made using the LVGL `3dtexture` widget.

![example running screenclip](readme_image.png)
![example running screenclip one](media/readme/readme_image.png)

Ensure [GLFW is installed](https://docs.lvgl.io/master/details/integration/driver/opengles.html) for this example.

## Getting Started

```shell
git clone <TODO>
git submodule update --init
cmake -B build -S .
make -C build -j$(nproc) lvgl_workspace
./build/lvgl_workspace
cmake -B build
cmake --build build -j$(nproc)
./build/gltf_view -in ./gltfs/logo1.glb
```

---

The STB Image library is included temporarily, just copied from the latest build. Ultimately it should probably be added as a git submodule, but it seems like that will add a few other things that aren't necessary so I'd like to look into a more minimal install for that.

---

To make this the default gltf / glb file viewer on your Raspberry Pi, you can do the following:

(from the root directory of this project)
```bash
cp ./EXAMPLE_gltf-view.desktop ~/.local/share/applications/gltf-view.desktop
xdg-mime default gltf-view.desktop model/gltf-binary
xdg-mime default gltf-view.desktop model/gltf-json
```

For demonstration purposes, there is a very simple
glTF loader implemented in `gltf_loader.c`. It can only
handle very simple glTFs with one mesh described by
a `float` triangle vertex array and a `uint16_t` index array.
Textured meshes are ignored.
Now when you double click a gltf file in your file-manager, it should open glTF-View.

You can confirm the mime-types are setup correctly by viewing
```
~/.config/mimeapps.list
```

---
More Samples:

![example running screenclip two](media/readme/screenshot_image1.png)

![example running screenclip three](media/readme/screenshot_image2.png)
Loading