Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,14 @@ include(Modules)
include(Shaders)

# Subdirectories for engine libs
add_subdirectory(engine/native)
add_subdirectory(engine)

# Main Executable
add_executable(draconic engine/native/main/main.cpp)

target_link_libraries(draconic
PRIVATE
core
math
io
memory
platform
input
rendering
scene
native
bgfx
bx
bimg
Expand Down
2 changes: 2 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_modules_library(native)
target_link_libraries(native PUBLIC platform core input scene rendering)
9 changes: 5 additions & 4 deletions engine/native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
add_subdirectory(thirdparty SYSTEM)

add_modules_library(platform)
add_modules_library(core SHARED)
add_modules_library(input)
add_modules_library(rendering)
add_modules_library(scene)

add_subdirectory(thirdparty SYSTEM)
add_subdirectory(platform)

target_link_libraries(platform PUBLIC platform_impl)
target_link_libraries(core PUBLIC definitions math io memory)
target_link_libraries(input PRIVATE SDL3::SDL3-static core)
target_link_libraries(input PRIVATE SDL3::SDL3-static platform core)
target_link_libraries(rendering PUBLIC rhi rendergraph mesh material quad_renderer renderer)
target_link_libraries(scene PUBLIC renderable transform_component camera)
7 changes: 7 additions & 0 deletions engine/native/draconic.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export module draconic;

export import platform;
export import core;
export import input;
export import scene;
export import rendering;
6 changes: 1 addition & 5 deletions engine/native/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
#include <bgfx/bgfx.h>
#include <bx/math.h>

import core;
import input;
import platform;
import scene;
import rendering;
import draconic;

int main(int argc, char* argv[])
{
Expand Down
37 changes: 1 addition & 36 deletions engine/native/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1 @@
# Platform-specific source selection
if(WIN32)
set(PLATFORM_SRC "win32/win32.cpp")
set(PLATFORM_DEPS "")
elseif(APPLE)
set(PLATFORM_SRC "mac/mac.mm")
set(PLATFORM_DEPS "-framework Cocoa -framework Metal -framework QuartzCore")
else()
set(PLATFORM_SRC "linux/linux.cpp")
find_package(PkgConfig REQUIRED)
pkg_check_modules(X11_LIBS REQUIRED IMPORTED_TARGET x11 xext xcursor xrandr xrender xi xfixes)
pkg_check_modules(WAYLAND_LIBS IMPORTED_TARGET wayland-client wayland-egl wayland-cursor egl)
set(PLATFORM_DEPS PkgConfig::X11_LIBS)
if(WAYLAND_LIBS_FOUND)
list(APPEND PLATFORM_DEPS PkgConfig::WAYLAND_LIBS)
endif()
endif()

add_library(platform STATIC)

target_sources(platform
PUBLIC FILE_SET CXX_MODULES
BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}"
FILES platform.cppm

PRIVATE
${PLATFORM_SRC}
)

target_include_directories(platform INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

target_link_libraries(platform PRIVATE SDL3::SDL3-static ${PLATFORM_DEPS} core)

if(DRACO_HAS_WAYLAND)
target_compile_definitions(platform PRIVATE DRACO_HAS_WAYLAND=1)
endif()
add_subdirectory(impl)
29 changes: 29 additions & 0 deletions engine/native/platform/impl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Platform-specific source selection
if(WIN32)
set(PLATFORM_SRC "win32/win32.cpp")
set(PLATFORM_DEPS "")
elseif(APPLE)
set(PLATFORM_SRC "mac/mac.mm")
set(PLATFORM_DEPS "-framework Cocoa -framework Metal -framework QuartzCore")
else()
set(PLATFORM_SRC "linux/linux.cpp")
find_package(PkgConfig REQUIRED)
pkg_check_modules(X11_LIBS REQUIRED IMPORTED_TARGET x11 xext xcursor xrandr xrender xi xfixes)
pkg_check_modules(WAYLAND_LIBS IMPORTED_TARGET wayland-client wayland-egl wayland-cursor egl)
set(PLATFORM_DEPS PkgConfig::X11_LIBS)
if(WAYLAND_LIBS_FOUND)
list(APPEND PLATFORM_DEPS PkgConfig::WAYLAND_LIBS)
endif()
endif()

add_library(platform_impl STATIC
${PLATFORM_SRC}
)
target_include_directories(platform_impl
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)
target_link_libraries(platform_impl PUBLIC SDL3::SDL3-static PRIVATE ${PLATFORM_DEPS})
if(DRACO_HAS_WAYLAND)
target_compile_definitions(platform_impl PRIVATE DRACO_HAS_WAYLAND=1)
endif()
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module;
#include "platform_impl.h"

#include <print>
#include <string_view>

#include <SDL3/SDL.h>

module platform;
#include <cstdint>

import core.stdtypes;

namespace draco::platform {
namespace draco::platform::impl {
NativeWindowFrame get_native_handles(void* sdl_window_ptr) {
SDL_Window* window = static_cast<SDL_Window*>(sdl_window_ptr);
NativeWindowFrame frame;
Expand All @@ -19,7 +17,7 @@ namespace draco::platform {

if (std::string_view(driver) == "x11") {
frame.ndt = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, nullptr);
frame.nwh = (void*)(uintptr)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
frame.nwh = (void*)(std::uintptr_t)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
frame.type = NativeWindowType::X11;
} else if (std::string_view(driver) == "wayland") {
frame.ndt = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nullptr);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module;

#include <cstdint>
#include "platform_impl.h"

#include <SDL3/SDL.h>

module platform;

namespace draco::platform {
namespace draco::platform::impl {
NativeWindowFrame get_native_handles(void* sdl_window_ptr) {
SDL_Window* window = static_cast<SDL_Window*>(sdl_window_ptr);
NativeWindowFrame frame;
Expand Down
29 changes: 29 additions & 0 deletions engine/native/platform/impl/platform_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

namespace draco::platform::impl {

enum class NativeWindowType
{
None,
Default,
Win32,
Wayland,
X11,
Cocoa
};

struct NativeWindowFrame
{
void* nwh = nullptr; // Native Window Handle
void* ndt = nullptr; // Native Display Type

int width = 0;
int height = 0;

bool valid = false;

NativeWindowType type = NativeWindowType::None; // Track the type of the native window
};

NativeWindowFrame get_native_handles(void* sdl_window_ptr);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module;

#include <cstdint>
#include "platform_impl.h"

#include <SDL3/SDL.h>

module platform;

namespace draco::platform {
namespace draco::platform::impl {
NativeWindowFrame get_native_handles(void* sdl_window_ptr) {
SDL_Window* window = static_cast<SDL_Window*>(sdl_window_ptr);
NativeWindowFrame frame;
Expand Down
29 changes: 6 additions & 23 deletions engine/native/platform/platform.cppm
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
module;

#include <cstdint>
#include "impl/platform_impl.h"

export module platform;

export namespace draco::platform {
enum class NativeWindowType
{
None,
Default,
Win32,
Wayland,
X11,
Cocoa
};

struct NativeWindowFrame
{
void* nwh = nullptr; // Native Window Handle
void* ndt = nullptr; // Native Display Type
using NativeWindowType = impl::NativeWindowType;
using NativeWindowFrame = impl::NativeWindowFrame;

int width = 0;
int height = 0;

bool valid = false;

NativeWindowType type = NativeWindowType::None; // Track the type of the native window
};

NativeWindowFrame get_native_handles(void* sdl_window_ptr);
NativeWindowFrame get_native_handles(void* sdl_window_ptr) {
return impl::get_native_handles(sdl_window_ptr);
}
}
Loading