Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return olc::rcode::OK;
- }
- olc::rcode SaveImageResource(olc::Sprite* spr, const std::string& sImageFile) override
- {
- return olc::rcode::OK;
- }
- };
- }
- #endif
- // O------------------------------------------------------------------------------O
- // | START IMAGE LOADER: stb_image.h |
- // O------------------------------------------------------------------------------O
- // O------------------------------------------------------------------------------O
- // | START PLATFORM: MICROSOFT WINDOWS XP, VISTA, 7, 8, 10 |
- // O------------------------------------------------------------------------------O
- #if defined(OLC_PLATFORM_WINAPI)
- #if defined(_WIN32) && !defined(__MINGW32__)
- #pragma comment(lib, "user32.lib") // Visual Studio Only
- #pragma comment(lib, "gdi32.lib") // For other Windows Compilers please add
- #pragma comment(lib, "opengl32.lib") // these libs to your linker input
- #endif
- namespace olc
- {
- class Platform_Windows : public olc::Platform
- {
- private:
- HWND olc_hWnd = nullptr;
- std::wstring wsAppName;
- std::wstring ConvertS2W(std::string s)
- {
- #ifdef __MINGW32__
- wchar_t* buffer = new wchar_t[s.length() + 1];
- mbstowcs(buffer, s.c_str(), s.length());
- buffer[s.length()] = L'\0';
- #else
- int count = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, NULL, 0);
- wchar_t* buffer = new wchar_t[count];
- MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, buffer, count);
- #endif
- std::wstring w(buffer);
- delete[] buffer;
- return w;
- }
- public:
- virtual olc::rcode ApplicationStartUp() override { return olc::rcode::OK; }
- virtual olc::rcode ApplicationCleanUp() override { return olc::rcode::OK; }
- virtual olc::rcode ThreadStartUp() override { return olc::rcode::OK; }
- virtual olc::rcode ThreadCleanUp() override
- {
- renderer->DestroyDevice();
- PostMessage(olc_hWnd, WM_DESTROY, 0, 0);
- return olc::OK;
- }
- virtual olc::rcode CreateGraphics(bool bFullScreen, bool bEnableVSYNC, const olc::vi2d& vViewPos, const olc::vi2d& vViewSize) override
- {
- if (renderer->CreateDevice({ olc_hWnd }, bFullScreen, bEnableVSYNC) == olc::rcode::OK)
- {
- renderer->UpdateViewport(vViewPos, vViewSize);
- return olc::rcode::OK;
- }
- else
- return olc::rcode::FAIL;
- }
- virtual olc::rcode CreateWindowPane(const olc::vi2d& vWindowPos, olc::vi2d& vWindowSize, bool bFullScreen) override
- {
- WNDCLASS wc;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- wc.hInstance = GetModuleHandle(nullptr);
- wc.lpfnWndProc = olc_WindowEvent;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.lpszMenuName = nullptr;
- wc.hbrBackground = nullptr;
- wc.lpszClassName = olcT("OLC_PIXEL_GAME_ENGINE");
- RegisterClass(&wc);
- // Define window furniture
- DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
- DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME;
- olc::vi2d vTopLeft = vWindowPos;
- // Handle Fullscreen
- if (bFullScreen)
- {
- dwExStyle = 0;
- dwStyle = WS_VISIBLE | WS_POPUP;
Advertisement
Add Comment
Please, Sign In to add comment