MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Platform_Windows

Class Platform_Windows

olcPixelGameEngine.h:6686–6986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6684namespace olc
6685{
6686 class Platform_Windows : public olc::Platform
6687 {
6688 private:
6689 HWND olc_hWnd = nullptr;
6690 std::wstring wsAppName;
6691 inline static olc::vi2d vWinPos;
6692 inline static olc::vi2d vWinSize;
6693
6694 std::wstring ConvertS2W(std::string s)
6695 {
6696#ifdef __MINGW32__
6697 wchar_t* buffer = new wchar_t[s.length() + 1];
6698 mbstowcs(buffer, s.c_str(), s.length());
6699 buffer[s.length()] = L'\0';
6700#else
6701 int count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, NULL, 0);
6702 wchar_t* buffer = new wchar_t[count];
6703 MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, buffer, count);
6704#endif
6705 std::wstring w(buffer);
6706 delete[] buffer;
6707 return w;
6708 }
6709
6710
6711
6712 public:
6713 virtual olc::rcode ApplicationStartUp() override { return olc::rcode::OK; }
6714 virtual olc::rcode ApplicationCleanUp() override { return olc::rcode::OK; }
6715 virtual olc::rcode ThreadStartUp() override { return olc::rcode::OK; }
6716
6717 virtual olc::rcode ThreadCleanUp() override
6718 {
6719 renderer->DestroyDevice();
6720 PostMessage(olc_hWnd, WM_DESTROY, 0, 0);
6721 return olc::OK;
6722 }
6723
6724 virtual olc::rcode CreateGraphics(bool bFullScreen, bool bEnableVSYNC, const olc::vi2d& vViewPos, const olc::vi2d& vViewSize) override
6725 {
6726 if (renderer->CreateDevice({ olc_hWnd }, bFullScreen, bEnableVSYNC) == olc::rcode::OK)
6727 {
6728 renderer->UpdateViewport(vViewPos, vViewSize);
6729 return olc::rcode::OK;
6730 }
6731 else
6732 return olc::rcode::FAIL;
6733 }
6734
6735 virtual olc::rcode CreateWindowPane(const olc::vi2d& vWindowPos, olc::vi2d& vWindowSize, bool bFullScreen) override
6736 {
6737 WNDCLASS wc;
6738 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
6739 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
6740 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
6741 wc.hInstance = GetModuleHandle(nullptr);
6742 wc.lpfnWndProc = olc_WindowEvent;
6743 wc.cbClsExtra = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected