[WIP] SDL Window wrap
This commit is contained in:
parent
599f1e4ffe
commit
5e4eabc582
|
@ -121,7 +121,6 @@ powershell -Command "& {Expand-Archive -LiteralPath Dependencies/SDL/SDL.zip -De
|
||||||
robocopy "Dependencies/SDL/tmp/SDL2-2.24.0/lib/x64" "Dependencies/SDL/lib/" /ns /nfl /ndl /nc /njh
|
robocopy "Dependencies/SDL/tmp/SDL2-2.24.0/lib/x64" "Dependencies/SDL/lib/" /ns /nfl /ndl /nc /njh
|
||||||
robocopy "Dependencies/SDL/tmp/SDL2-2.24.0/include/" "Dependencies/SDL/include/" /ns /nfl /ndl /nc /njh
|
robocopy "Dependencies/SDL/tmp/SDL2-2.24.0/include/" "Dependencies/SDL/include/" /ns /nfl /ndl /nc /njh
|
||||||
rmdir "Dependencies/SDL/tmp/" /s /q
|
rmdir "Dependencies/SDL/tmp/" /s /q
|
||||||
del "Dependencies/SDL/SDL.zip"
|
|
||||||
powershell -Command "& {Remove-Item "Dependencies/SDL/SDL.zip"}"
|
powershell -Command "& {Remove-Item "Dependencies/SDL/SDL.zip"}"
|
||||||
|
|
||||||
:done
|
:done
|
||||||
|
|
|
@ -23,9 +23,10 @@ namespace Sandbox
|
||||||
_In_ INT nCmdShow
|
_In_ INT nCmdShow
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
SHLOG_TITLE("Initialising SBApplication")
|
//SHLOG_TITLE("Initialising SBApplication")
|
||||||
|
SHADE::SHSDLWindow::InitPlatform();
|
||||||
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||||
|
sdlWindow.CreateSDLWindow(window.GetHWND());
|
||||||
|
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef SB_APPLICATION_H
|
#ifndef SB_APPLICATION_H
|
||||||
#define SB_APPLICATION_H
|
#define SB_APPLICATION_H
|
||||||
#include <Graphics/Windowing/SHWindow.h>
|
#include <Graphics/Windowing/SDL/SHSDLWindow.h>
|
||||||
|
#include "Graphics/Windowing/SHWindow.h"
|
||||||
//using namespace SHADE;
|
//using namespace SHADE;
|
||||||
|
|
||||||
namespace Sandbox
|
namespace Sandbox
|
||||||
|
@ -9,6 +10,7 @@ namespace Sandbox
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SHADE::SHWindow window;
|
SHADE::SHWindow window;
|
||||||
|
SHADE::SHSDLWindow sdlWindow;
|
||||||
//SHAppConfig config;
|
//SHAppConfig config;
|
||||||
public:
|
public:
|
||||||
SBApplication() = default;
|
SBApplication() = default;
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
|
||||||
|
#include "SHSDLWindow.h"
|
||||||
|
|
||||||
|
#include "Tools/SHLogger.h"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
SHSDLWindow::~SHSDLWindow()
|
||||||
|
{
|
||||||
|
SDL_DestroyWindow(sdlWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHSDLWindow::InitPlatform(void) noexcept
|
||||||
|
{
|
||||||
|
SDL_Init(SDL_INIT_EVERYTHING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHSDLWindow::CreateSDLWindow(const char* title, int x, int y, int width, int height) noexcept
|
||||||
|
{
|
||||||
|
sdlWindow = SDL_CreateWindow(title, x, y, width, height, 0);
|
||||||
|
if (sdlWindow == nullptr)
|
||||||
|
{
|
||||||
|
SHLOG_ERROR("Failed to create window")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHSDLWindow::CreateSDLWindow(HWND hwnd) noexcept
|
||||||
|
{
|
||||||
|
sdlWindow = SDL_CreateWindowFrom(hwnd);
|
||||||
|
if (sdlWindow == nullptr)
|
||||||
|
{
|
||||||
|
SHLOG_ERROR("Failed to create window from existing native Win32 Window")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN 0
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
class SHSDLWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SHSDLWindow() = default;
|
||||||
|
~SHSDLWindow();
|
||||||
|
|
||||||
|
static void InitPlatform(void) noexcept;
|
||||||
|
void CreateSDLWindow(const char* title, int x, int y, int width, int height) noexcept;
|
||||||
|
void CreateSDLWindow(HWND hwnd) noexcept;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SDL_Window* sdlWindow = nullptr;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue