Skip to content
Merged
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
26 changes: 20 additions & 6 deletions thirteen.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ namespace Thirteen
using uint8 = unsigned char;
using uint32 = unsigned int;

#if defined(THIRTEEN_PLATFORM_WINDOWS)
using NativeWindowHandle = HWND;
#elif defined(THIRTEEN_PLATFORM_WEB)
using NativeWindowHandle = void*;
#elif defined(THIRTEEN_PLATFORM_MACOS)
using NativeWindowHandle = void*;
#elif defined(THIRTEEN_PLATFORM_LINUX)
using NativeWindowHandle = int;
#endif

// ========== Function Prototypes ==========

// Initializes window and DX12. Returns a pointer to the pixel buffer on success, or nullptr on failure.
Expand Down Expand Up @@ -121,6 +131,9 @@ namespace Thirteen
// Returns the current height of the rendering surface in pixels.
[[nodiscard]] uint32 GetHeight();

// Returns the platform-specific window handle.
[[nodiscard]] NativeWindowHandle GetWindowHandle();

// Sets the size of the rendering surface. Recreates internal buffers. Returns the new pixel buffer pointer on success, or nullptr on failure. The returned pointer may differ from the one returned by Init().
[[nodiscard]] uint8* SetSize(uint32 width, uint32 height);

Expand Down Expand Up @@ -191,8 +204,6 @@ namespace Thirteen

#if defined(THIRTEEN_PLATFORM_WINDOWS)

using NativeWindowHandle = HWND;

struct PlatformWin32
{
HWND hwnd = nullptr;
Expand Down Expand Up @@ -646,7 +657,7 @@ namespace Thirteen
}
};
#elif defined(__EMSCRIPTEN__)
using NativeWindowHandle = void*;

struct PlatformWeb
{
static constexpr const char* c_canvasSelector = "#canvas";
Expand Down Expand Up @@ -1200,7 +1211,7 @@ namespace Thirteen
}
};
#elif defined(THIRTEEN_PLATFORM_MACOS)
using NativeWindowHandle = void*;

extern "C" void* MTLCreateSystemDefaultDevice(void);

using NSUInteger = unsigned long;
Expand Down Expand Up @@ -1571,8 +1582,6 @@ namespace Thirteen

#elif defined(THIRTEEN_PLATFORM_LINUX)

using NativeWindowHandle = int;

struct PlatformLinuxX11GL
{
void * x11Library = nullptr;
Expand Down Expand Up @@ -2220,6 +2229,11 @@ namespace Thirteen
return Internal::height;
}

NativeWindowHandle GetWindowHandle()
{
return Internal::platform->GetWindowHandle();
}

uint8* SetSize(uint32 width, uint32 height)
{
using namespace Internal;
Expand Down