-
Notifications
You must be signed in to change notification settings - Fork 12
Add rendering stuff, cross-platform support, camera controller & SDL input logic #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mcdubhghlas
merged 48 commits into
Redot-Engine:master
from
AR-DEV-1:rendering-hardware-abstraction
May 28, 2026
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
6458806
Start workin' on RHI
AR-DEV-1 b58cba3
Idk how I missed these, they coulda been major security vulnerabilities
AR-DEV-1 7b92c6b
Do what CodeRabbit said & add Wayland support (still doesn't work)
AR-DEV-1 64c0d2f
Fix includes
AR-DEV-1 c955c7d
Add uniform management
AR-DEV-1 eebea86
Add texture loadin' support
AR-DEV-1 b433315
Add framebuffer handles, render targets & dynamic/transient buffers s…
AR-DEV-1 436c405
Add depth & stencil testing, Alpha blending modes, dedicated sampler …
AR-DEV-1 d1694ef
Draco is 3D!
AR-DEV-1 64615cd
Add camera controller & remove all std imports (replaced by the tradi…
AR-DEV-1 27f83bc
Apply suggestions
AR-DEV-1 80af026
Fix issues
AR-DEV-1 43141d2
Minor improvements & fixes
AR-DEV-1 b448c46
Add mesh abstraction + compilation of shaders when building
AR-DEV-1 97d97ee
Add transform system
AR-DEV-1 c2c80b5
Upgrade render pipeline architecture (material + RenderGraph refactor)
AR-DEV-1 2f2f08c
Start working on Quad/Sprite renderer
AR-DEV-1 e43bcea
Merge branch 'master' of https://github.com/Redot-Engine/DraconicEngi…
AR-DEV-1 b117660
Work on QuadRenderer
AR-DEV-1 463ab5e
QuadRenderer finally works!
AR-DEV-1 e148291
Merge branch 'Redot-Engine:master' into rendering-hardware-abstraction
AR-DEV-1 6dcdc0f
Small stuff
AR-DEV-1 1046f1d
Apply some suggestions
AR-DEV-1 833d9a8
Forgot these
AR-DEV-1 d28e09f
Minor fixes
AR-DEV-1 62db8b7
Minor fixes
AR-DEV-1 7183e07
Fix incorrect declaration
AR-DEV-1 1065b03
Fix Wayland
AR-DEV-1 570b52a
Wayland works!
AR-DEV-1 05c8310
Compile shaderc
AR-DEV-1 cb36c8f
Remove sync window SDL loop so Draco may run on Windows [skip ci]
AR-DEV-1 4540c3a
PR cleanup
AR-DEV-1 c40f59c
Update CMake version
AR-DEV-1 abad3ef
Add missing include
AR-DEV-1 e94b9de
Add caching to CI
AR-DEV-1 dd90c75
Merge branch 'master' into rendering-hardware-abstraction
AR-DEV-1 ff5480f
Fix compiler error
AR-DEV-1 f8c737c
Apply suggestions
AR-DEV-1 5862d99
Merge branch 'master' into rendering-hardware-abstraction
AR-DEV-1 9b61dd6
Use our own types & constants
AR-DEV-1 3b6f166
Merge branch 'master' into rendering-hardware-abstraction
AR-DEV-1 c6007b8
Cleanup + improvements
AR-DEV-1 5373a78
Merge branch 'Redot-Engine:master' into rendering-hardware-abstraction
AR-DEV-1 e79fa0b
Fix errors
AR-DEV-1 de86d2c
Apply some suggestions
AR-DEV-1 e720027
Code cleanup
AR-DEV-1 b0e9cd2
Address some of Jon's concerns
AR-DEV-1 4abe47d
Merge branch 'master' into rendering-hardware-abstraction
AR-DEV-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| include_guard(GLOBAL) | ||
|
|
||
| set(SHADER_SRC_DIR "${CMAKE_SOURCE_DIR}/engine/native/rendering/shaders") | ||
| set(SHADER_BIN_DIR "${CMAKE_BINARY_DIR}") | ||
| set(BGFX_INCLUDE "${CMAKE_SOURCE_DIR}/engine/native/thirdparty/bgfx/src") | ||
|
|
||
| function(compile_shaders TARGET_NAME) | ||
| file(MAKE_DIRECTORY ${SHADER_BIN_DIR}) | ||
|
|
||
| if(APPLE) | ||
| set(VERTEX_PROFILE "metal") | ||
| set(FRAGMENT_PROFILE "metal") | ||
| set(SHADER_PLATFORM "osx") | ||
| elseif(WIN32) | ||
| set(VERTEX_PROFILE "s_5_0") | ||
| set(FRAGMENT_PROFILE "s_5_0") | ||
| set(SHADER_PLATFORM "windows") | ||
| else() | ||
| set(VERTEX_PROFILE "spirv") | ||
| set(FRAGMENT_PROFILE "spirv") | ||
| set(SHADER_PLATFORM "linux") | ||
| endif() | ||
|
|
||
| set(VERTEX_INPUT "${SHADER_SRC_DIR}/vs.sc") | ||
| set(VERTEX_OUTPUT "${SHADER_BIN_DIR}/vs.bin") | ||
|
|
||
| set(FRAGMENT_INPUT "${SHADER_SRC_DIR}/fs.sc") | ||
| set(FRAGMENT_OUTPUT "${SHADER_BIN_DIR}/fs.bin") | ||
|
|
||
| set(QUAD_VERTEX_INPUT "${SHADER_SRC_DIR}/vs_quad.sc") | ||
| set(QUAD_VERTEX_OUTPUT "${SHADER_BIN_DIR}/vs_quad.bin") | ||
|
|
||
| set(QUAD_FRAGMENT_INPUT "${SHADER_SRC_DIR}/fs_quad.sc") | ||
| set(QUAD_FRAGMENT_OUTPUT "${SHADER_BIN_DIR}/fs_quad.bin") | ||
|
|
||
| set(VARYING_DEF "${SHADER_SRC_DIR}/varying.def.sc") | ||
| set(QUAD_VARYING_DEF "${SHADER_SRC_DIR}/varying_quad.def.sc") | ||
|
|
||
| add_custom_command( | ||
| TARGET draconic POST_BUILD | ||
| COMMENT "Compiling asset pipelines and core engine shaders via native tools..." | ||
|
|
||
| COMMAND $<TARGET_FILE:shaderc> | ||
| -f ${VERTEX_INPUT} | ||
| -o ${VERTEX_OUTPUT} | ||
| --type vertex | ||
| --platform ${SHADER_PLATFORM} | ||
| -p ${VERTEX_PROFILE} | ||
| --varyingdef ${VARYING_DEF} | ||
| -i ${BGFX_INCLUDE} | ||
|
|
||
| COMMAND $<TARGET_FILE:shaderc> | ||
| -f ${FRAGMENT_INPUT} | ||
| -o ${FRAGMENT_OUTPUT} | ||
| --type fragment | ||
| --platform ${SHADER_PLATFORM} | ||
| -p ${FRAGMENT_PROFILE} | ||
| --varyingdef ${VARYING_DEF} | ||
| -i ${BGFX_INCLUDE} | ||
|
|
||
| COMMAND $<TARGET_FILE:shaderc> | ||
| -f ${QUAD_VERTEX_INPUT} | ||
| -o ${QUAD_VERTEX_OUTPUT} | ||
| --type vertex | ||
| --platform ${SHADER_PLATFORM} | ||
| -p ${VERTEX_PROFILE} | ||
| --varyingdef ${QUAD_VARYING_DEF} | ||
| -i ${BGFX_INCLUDE} | ||
|
|
||
| COMMAND $<TARGET_FILE:shaderc> | ||
| -f ${QUAD_FRAGMENT_INPUT} | ||
| -o ${QUAD_FRAGMENT_OUTPUT} | ||
| --type fragment | ||
| --platform ${SHADER_PLATFORM} | ||
| -p ${FRAGMENT_PROFILE} | ||
| --varyingdef ${QUAD_VARYING_DEF} | ||
| -i ${BGFX_INCLUDE} | ||
|
|
||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VERTEX_OUTPUT} $<TARGET_FILE_DIR:draconic> | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FRAGMENT_OUTPUT} $<TARGET_FILE_DIR:draconic> | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QUAD_VERTEX_OUTPUT} $<TARGET_FILE_DIR:draconic> | ||
| COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QUAD_FRAGMENT_OUTPUT} $<TARGET_FILE_DIR:draconic> | ||
| ) | ||
| endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,12 @@ | ||
| add_modules_library(core SHARED) | ||
| add_modules_library(input) | ||
| add_modules_library(rendering) | ||
| add_modules_library(scene) | ||
|
|
||
| add_subdirectory(thirdparty SYSTEM) | ||
| add_subdirectory(platform) | ||
|
|
||
| add_modules_library(core SHARED) | ||
| target_link_libraries(core PUBLIC definitions math memory) | ||
| target_link_libraries(core PUBLIC definitions math io memory) | ||
| target_link_libraries(input PRIVATE SDL3::SDL3-static core) | ||
| target_link_libraries(rendering PUBLIC rhi rendergraph mesh material quad_renderer renderer) | ||
| target_link_libraries(scene PUBLIC renderable transform_component camera) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| add_modules_library(definitions PIC) | ||
| add_modules_library(math) | ||
| add_modules_library(io) | ||
| add_modules_library(memory) | ||
| target_link_libraries(math PUBLIC definitions) | ||
| target_link_libraries(memory PUBLIC definitions) | ||
|
|
||
| target_link_libraries(math PUBLIC definitions bx) | ||
| target_link_libraries(io PUBLIC definitions stb_image) | ||
| target_link_libraries(memory PUBLIC definitions math) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| module; | ||
|
|
||
| #include <vector> | ||
| #include <string> | ||
| #include <fstream> | ||
| #include <print> | ||
|
|
||
| module core.io.filesystem; | ||
|
|
||
| import core.stdtypes; | ||
|
|
||
| namespace draco::core::io::filesystem | ||
| { | ||
| std::vector<u8> load_binary(const std::string& path) | ||
| { | ||
| // Open at the end (ate) to get size and in binary mode | ||
| std::ifstream file(path, std::ios::binary | std::ios::ate); | ||
|
|
||
| if (!file.is_open()) { | ||
| std::println("Error: Could not open file at: {}", path); | ||
| // Return an empty vector | ||
| return {}; | ||
| } | ||
|
|
||
| std::streamsize size = file.tellg(); | ||
| if (size < 0) { | ||
| std::println("Error: File is empty or unreadable: {}", path); | ||
| return {}; | ||
| } | ||
|
|
||
| if (size == 0) { | ||
| return {}; | ||
| } | ||
|
|
||
| file.seekg(0, std::ios::beg); | ||
|
|
||
| std::vector<u8> buffer(static_cast<std::size_t>(size)); | ||
| if (file.read(reinterpret_cast<char*>(buffer.data()), size)) { | ||
| return buffer; | ||
| } | ||
|
|
||
| std::println("Error: Failed to read file contents: {}", path); | ||
| return {}; | ||
|
AR-DEV-1 marked this conversation as resolved.
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module; | ||
|
|
||
| #include <vector> | ||
| #include <string> | ||
| #include <fstream> | ||
|
|
||
| export module core.io.filesystem; | ||
|
|
||
| import core.stdtypes; | ||
|
|
||
| export namespace draco::core::io::filesystem | ||
| { | ||
| // Returns a buffer of the file data | ||
| std::vector<u8> load_binary(const std::string& path); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| module; | ||
|
|
||
| #include <vector> | ||
| #include <filesystem> | ||
| #include <limits> | ||
| #include <print> | ||
|
|
||
| #define STB_IMAGE_IMPLEMENTATION | ||
| #include <stb_image.h> | ||
|
|
||
| module core.io.image_loader; | ||
|
|
||
| import core.stdtypes; | ||
|
|
||
| // TODO: I'm too lazy to write code so we need somethin' better | ||
|
|
||
| namespace draco::core::io::image_loader | ||
| { | ||
| ImageData load_image(const std::filesystem::path& path) | ||
| { | ||
| ImageData result; | ||
|
|
||
| std::error_code ec; | ||
| if (!std::filesystem::exists(path, ec) || ec) { | ||
| std::println("Error: Image path does not exist: {}", path.string()); | ||
| return result; | ||
| } | ||
|
|
||
| int width, height, channels; | ||
| // STBI_rgb_alpha forces the output to be 4 bytes per pixel (RGBA) | ||
| unsigned char* data = stbi_load(path.string().c_str(), &width, &height, &channels, STBI_rgb_alpha); | ||
|
|
||
| if (!data) { | ||
| std::println("Error: Failed to decode image: {}", path.string()); | ||
| return result; | ||
| } | ||
|
|
||
| if (width <= 0 || height <= 0) { | ||
| stbi_image_free(data); | ||
| return result; | ||
| } | ||
|
|
||
| const usize w = static_cast<usize>(width); | ||
| const usize h = static_cast<usize>(height); | ||
| if (w > (std::numeric_limits<usize>::max() / 4) / h) { | ||
| stbi_image_free(data); | ||
| return result; | ||
| } | ||
|
|
||
| usize size = w * h * 4; | ||
|
|
||
| result.pixels.assign(data, data + size); | ||
| result.width = static_cast<u16>(width); | ||
| result.height = static_cast<u16>(height); | ||
| result.channels = 4; | ||
| result.is_valid = true; | ||
|
|
||
| // Free the memory allocated by stb | ||
| stbi_image_free(data); | ||
|
|
||
| return result; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| module; | ||
|
|
||
| #include <vector> | ||
| #include <cstdint> | ||
| #include <filesystem> | ||
|
|
||
| export module core.io.image_loader; | ||
|
|
||
| import core.stdtypes; | ||
|
|
||
| export namespace draco::core::io::image_loader | ||
| { | ||
| struct ImageData | ||
| { | ||
| std::vector<u8> pixels; | ||
| u32 width = 0; | ||
| u32 height = 0; | ||
| u8 channels = 0; | ||
| bool is_valid = false; | ||
| }; | ||
|
|
||
| // Load an image file (PNG, JPG, etc) & decode it to raw RGBA8 | ||
| ImageData load_image(const std::filesystem::path& path); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export module core.io; | ||
|
|
||
| export import core.io.filesystem; | ||
| export import core.io.image_loader; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure of the best spot to put it, but Windows headers need
_{Architecture}_defined to compile properly. Something like this will do:Add this and #27, then Windows will compile fine.