mirror of
https://github.com/nicbarker/clay.git
synced 2025-12-23 09:41:04 +00:00
- **Initialize Window**: - Successfully created a GLFW window with dimensions 1280x720. - Set up window hints for OpenGL version and core profile, enabling multisampling, and enabling depth testing. - **Setup Renderer**: - Initialized the Clay rendering context with a memory arena and dimensions. - Set up the measure text and render text functions using stb_image.h and stb_truetype.h. - Initialized the GLES3 renderer with 4096 texture units. - Loaded a Roboto-Regular font atlas and set it as the default font for rendering. - **Main Loop**: - Called `Clay_UpdateScrollContainers` to handle scroll events. - Set the layout dimensions and cleared the color buffer and depth buffer. - Render the Clay video demo layout. - Swapped the window buffers to display the rendered video. - **Cleanup**: - Cleaned up the GLFW window and renderer resources when the application is closed. This setup provides a basic framework for rendering videos in GLES3 with GLFW, leveraging stb_image.h for asset loading and Clay for the rendering engine. - Configure GLFW and SDL2 in the main files - Fix the video bugs in the main file 🪝 Stb dependency to be managed with cmake in examples 💀 Allow clients to configure headers, also expose Gles3_Renderer through header-only mode 🧹 Quality of life: automatically set screen dimensions to renderer Before users had to set them manually 📚 **🎨 Renderers/GLES3:** Improve round-rectangle clipping with uniform border thickness Implemented improvements to the renderer for GLES3, ensuring better handling of rounded rectangles with borders, making the layout more visually appealing. - Added two new functions `RenderHeaderButton1`, `RenderHeaderButton2`, and `RenderHeaderButton3` for creating header buttons with different styles. - Updated the `CreateLayout` function to include these new buttons in the right panel. - Added a TODO note for handling the outer radius calculation, as it seems to be incorrect in the current implementation. - Replace `bl_i + B` and `br_i + B` with `bl` and `br` respectively to simplify the code. - Simplify the logic for checking pixel inside the inner rounded rect by directly using `innerLocal`. 📥 Change borders to be inset - Fixed incorrect border calculation in the shader. - Added support for inset borders by adjusting the boundary calculations based on `CLAY_BORDERS_ARE_INSET`. This change also gives the renderer more choice in handling different border styles. 🏗️ CMake builds for GLES3 renderer examples
99 lines
2.7 KiB
CMake
99 lines
2.7 KiB
CMake
cmake_minimum_required(VERSION 3.27)
|
|
project(GLES3_GLFW_video_demo C)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
# -------------------------------------------------
|
|
# FetchContent
|
|
# -------------------------------------------------
|
|
include(FetchContent)
|
|
set(FETCHCONTENT_QUIET FALSE)
|
|
|
|
# -------------------------------------------------
|
|
# STB (header-only)
|
|
# -------------------------------------------------
|
|
FetchContent_Declare(
|
|
stb
|
|
GIT_REPOSITORY https://github.com/nothings/stb.git
|
|
GIT_TAG master
|
|
)
|
|
FetchContent_MakeAvailable(stb)
|
|
|
|
# -------------------------------------------------
|
|
# GLFW
|
|
# -------------------------------------------------
|
|
FetchContent_Declare(
|
|
glfw
|
|
GIT_REPOSITORY https://github.com/glfw/glfw.git
|
|
GIT_TAG 3.4
|
|
GIT_SHALLOW TRUE
|
|
)
|
|
FetchContent_MakeAvailable(glfw)
|
|
|
|
# Disable examples/tests/docs (important)
|
|
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
|
|
|
# -------------------------------------------------
|
|
# Executable
|
|
# -------------------------------------------------
|
|
add_executable(GLES3_GLFW_video_demo
|
|
main.c
|
|
)
|
|
|
|
target_include_directories(GLES3_GLFW_video_demo
|
|
PUBLIC
|
|
.
|
|
../..
|
|
${stb_SOURCE_DIR}
|
|
)
|
|
|
|
# -------------------------------------------------
|
|
# Link libraries
|
|
# -------------------------------------------------
|
|
target_link_libraries(GLES3_GLFW_video_demo
|
|
PRIVATE
|
|
glfw
|
|
)
|
|
|
|
# -------------------------------------------------
|
|
# Platform-specific OpenGL / GLES
|
|
# -------------------------------------------------
|
|
if(APPLE)
|
|
find_library(OPENGL_FRAMEWORK OpenGL)
|
|
target_link_libraries(GLES3_GLFW_video_demo PRIVATE ${OPENGL_FRAMEWORK})
|
|
|
|
# Needed for GLFW on macOS
|
|
target_link_libraries(GLES3_GLFW_video_demo
|
|
PRIVATE
|
|
"-framework Cocoa"
|
|
"-framework IOKit"
|
|
"-framework CoreVideo"
|
|
)
|
|
elseif(WIN32)
|
|
target_link_libraries(GLES3_GLFW_video_demo PRIVATE opengl32)
|
|
elseif(UNIX)
|
|
target_link_libraries(GLES3_GLFW_video_demo PRIVATE GL)
|
|
endif()
|
|
|
|
# -------------------------------------------------
|
|
# Build flags (kept minimal)
|
|
# -------------------------------------------------
|
|
if(MSVC)
|
|
target_compile_options(GLES3_GLFW_video_demo PRIVATE /W3)
|
|
else()
|
|
target_compile_options(GLES3_GLFW_video_demo PRIVATE -Wall -Wextra)
|
|
endif()
|
|
|
|
# -------------------------------------------------
|
|
# Copy resources
|
|
# -------------------------------------------------
|
|
add_custom_command(
|
|
TARGET GLES3_GLFW_video_demo POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/resources
|
|
${CMAKE_CURRENT_BINARY_DIR}/resources
|
|
)
|