boo/lib/win/WindowWin32.cpp

179 lines
2.7 KiB
C++
Raw Normal View History

2015-08-31 03:40:58 +00:00
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <Windows.h>
#include "boo/IWindow.hpp"
#include "boo/IGraphicsContext.hpp"
2015-05-06 00:50:57 +00:00
namespace boo
{
2015-08-31 03:40:58 +00:00
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()
{
}
};
2015-05-06 00:50:57 +00:00
2015-08-31 03:40:58 +00:00
class WindowWin32 : public IWindow
2015-05-06 00:50:57 +00:00
{
HWND m_hwnd;
public:
2015-08-31 03:40:58 +00:00
WindowWin32(const SystemString& title)
2015-05-06 00:50:57 +00:00
{
2015-08-31 03:40:58 +00:00
m_hwnd = CreateWindowW(L"BooWindow", title.c_str(), WS_OVERLAPPEDWINDOW,
2015-05-06 00:50:57 +00:00
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
2015-08-31 03:40:58 +00:00
NULL, NULL, NULL, NULL);
2015-05-06 00:50:57 +00:00
}
2015-08-31 03:40:58 +00:00
~WindowWin32()
2015-05-06 00:50:57 +00:00
{
}
void setCallback(IWindowCallback* cb)
{
}
void showWindow()
{
}
void hideWindow()
{
}
2015-08-31 03:40:58 +00:00
SystemString getTitle()
2015-05-06 00:50:57 +00:00
{
2015-08-31 03:40:58 +00:00
wchar_t title[256];
int c = GetWindowTextW(m_hwnd, title, 256);
return SystemString(title, c);
2015-05-06 00:50:57 +00:00
}
2015-08-31 03:40:58 +00:00
void setTitle(const SystemString& title)
2015-05-06 00:50:57 +00:00
{
2015-08-31 03:40:58 +00:00
SetWindowTextW(m_hwnd, title.c_str());
2015-05-06 00:50:57 +00:00
}
void setWindowFrameDefault()
{
}
void getWindowFrame(float& xOut, float& yOut, float& wOut, float& hOut) const
{
}
void setWindowFrame(float x, float y, float w, float h)
{
}
float getVirtualPixelFactor() const
{
2015-08-31 03:40:58 +00:00
return 1.0;
2015-05-06 00:50:57 +00:00
}
bool isFullscreen() const
{
2015-08-31 03:40:58 +00:00
return false;
2015-05-06 00:50:57 +00:00
}
void setFullscreen(bool fs)
{
}
2015-08-31 03:40:58 +00:00
void waitForRetrace()
{
}
uintptr_t getPlatformHandle() const
{
return uintptr_t(m_hwnd);
}
2015-05-06 00:50:57 +00:00
ETouchType getTouchType() const
{
2015-08-31 03:40:58 +00:00
return TOUCH_NONE;
2015-05-06 00:50:57 +00:00
}
};
2015-08-31 03:40:58 +00:00
IWindow* _WindowWin32New(const SystemString& title)
2015-05-06 00:50:57 +00:00
{
2015-08-31 03:40:58 +00:00
return new WindowWin32(title);
2015-05-06 00:50:57 +00:00
}
}