mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-17 17:05:24 +00:00
Windows refactors
This commit is contained in:
@@ -1,27 +1,98 @@
|
||||
#include "windowsys/IWindow.hpp"
|
||||
#include "windowsys/IGraphicsContext.hpp"
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <Windows.h>
|
||||
#include "boo/IWindow.hpp"
|
||||
#include "boo/IGraphicsContext.hpp"
|
||||
|
||||
namespace boo
|
||||
{
|
||||
|
||||
IGraphicsContext* _CGraphicsContextWin32New(IGraphicsContext::EGraphicsAPI api,
|
||||
IWindow* parentWindow);
|
||||
struct GraphicsContextWin32 : IGraphicsContext
|
||||
{
|
||||
|
||||
EGraphicsAPI m_api;
|
||||
EPixelFormat m_pf;
|
||||
IWindow* m_parentWindow;
|
||||
|
||||
public:
|
||||
IWindowCallback* m_callback;
|
||||
|
||||
GraphicsContextWin32(EGraphicsAPI api, IWindow* parentWindow)
|
||||
: m_api(api),
|
||||
m_pf(PF_RGBA8),
|
||||
m_parentWindow(parentWindow)
|
||||
{}
|
||||
|
||||
~GraphicsContextWin32()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void _setCallback(IWindowCallback* cb)
|
||||
{
|
||||
m_callback = cb;
|
||||
}
|
||||
|
||||
EGraphicsAPI getAPI() const
|
||||
{
|
||||
return m_api;
|
||||
}
|
||||
|
||||
EPixelFormat getPixelFormat() const
|
||||
{
|
||||
return m_pf;
|
||||
}
|
||||
|
||||
void setPixelFormat(EPixelFormat pf)
|
||||
{
|
||||
if (pf > PF_RGBAF32_Z24)
|
||||
return;
|
||||
m_pf = pf;
|
||||
}
|
||||
|
||||
void initializeContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IGraphicsContext* makeShareContext() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void makeCurrent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void clearCurrent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void swapBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CWindowWin32 final : public IWindow
|
||||
class WindowWin32 : public IWindow
|
||||
{
|
||||
|
||||
HWND m_hwnd;
|
||||
|
||||
public:
|
||||
|
||||
CWindowWin32(const std::string& title)
|
||||
WindowWin32(const SystemString& title)
|
||||
{
|
||||
m_hwnd = CreateWindowW(L"BooWindow", L"BooTest", WS_OVERLAPPEDWINDOW,
|
||||
m_hwnd = CreateWindowW(L"BooWindow", title.c_str(), WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
~CWindowWin32()
|
||||
~WindowWin32()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -41,14 +112,16 @@ public:
|
||||
|
||||
}
|
||||
|
||||
std::string getTitle()
|
||||
SystemString getTitle()
|
||||
{
|
||||
|
||||
wchar_t title[256];
|
||||
int c = GetWindowTextW(m_hwnd, title, 256);
|
||||
return SystemString(title, c);
|
||||
}
|
||||
|
||||
void setTitle(const std::string& title)
|
||||
void setTitle(const SystemString& title)
|
||||
{
|
||||
|
||||
SetWindowTextW(m_hwnd, title.c_str());
|
||||
}
|
||||
|
||||
void setWindowFrameDefault()
|
||||
@@ -68,29 +141,38 @@ public:
|
||||
|
||||
float getVirtualPixelFactor() const
|
||||
{
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
bool isFullscreen() const
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setFullscreen(bool fs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void waitForRetrace()
|
||||
{
|
||||
}
|
||||
|
||||
uintptr_t getPlatformHandle() const
|
||||
{
|
||||
return uintptr_t(m_hwnd);
|
||||
}
|
||||
|
||||
ETouchType getTouchType() const
|
||||
{
|
||||
|
||||
return TOUCH_NONE;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IWindow* _CWindowWin32New(const std::string& title)
|
||||
IWindow* _WindowWin32New(const SystemString& title)
|
||||
{
|
||||
return new CWindowWin32(title);
|
||||
return new WindowWin32(title);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user