#include #include #include using namespace ReWindow; std::ostream& operator<<(std::ostream& os, const std::pair& v) { return os << "{" << v.first << ", " << v.second << "}"; } class MyWindow : public OpenGLWindow { public: MyWindow(const std::string& title, int w, int h) : OpenGLWindow(title, w, h, 2, 1) {} void OnMouseMove(const MouseMoveEvent& e) override {} void OnKeyDown(const KeyDownEvent& e) override { if (e.key == Keys::F11) SetFullscreen(!IsFullscreen()); } bool OnResizeRequest(const WindowResizeRequestEvent& e) override { return true; } void OnMouseButtonDown(const MouseButtonDownEvent& e) override { RWindow::OnMouseButtonDown(e); } void OnMouseButtonUp(const MouseButtonUpEvent& e) override { RWindow::OnMouseButtonUp(e); } void OnRefresh(float elapsed) override { if (IsMouseButtonDown(MouseButtons::Left)) std::cout << "Left Mouse Button" << std::endl; if (IsMouseButtonDown(MouseButtons::Right)) std::cout << "Right Mouse Button" << std::endl; if (IsMouseButtonDown(MouseButtons::Middle)) std::cout << "Middle Mouse Button" << std::endl; if (IsMouseButtonDown(MouseButtons::Mouse4)) std::cout << "Mouse4 Mouse Button" << std::endl; if (IsMouseButtonDown(MouseButtons::Mouse5)) std::cout << "Mouse5 Mouse Button" << std::endl; SwapBuffers(); } }; int main() { auto* window = new MyWindow("Test Window", 600, 480); Logger::Debug(std::format("New window '{}' created. width={} height={}", window->GetTitle(), window->GetWidth(), window->GetHeight())); window->Notify("Hello", "Test notification."); if (window->Open()) Logger::Debug(std::format("Opened window '{}'", window->GetTitle())); Logger::Debug("TODO: Cannot set flags until after window is open"); window->SetVsyncEnabled(true); window->DisableResizing(); window->SetKeyRepeatEnabled(false); Logger::Debug(std::format ( "Window '{}' flags: IN_FOCUS={} FULLSCREEN={} RESIZEABLE={} VSYNC={} KEY_REPEAT={} QUIT={}", window->GetTitle(), window->IsFocused(), window->IsFullscreen(), window->IsResizable(), window->IsVsyncEnabled(), window->IsKeyRepeat(), window->IsClosing()) ); window->OnKeyDownEvent += [&] (KeyDownEvent e) { jlog::Debug(e.key.Mnemonic); }; window->OnMouseButtonDownEvent += [&] (MouseButtonDownEvent e) { jlog::Debug(e.Button.Mnemonic + std::to_string(e.Button.ButtonIndex)); }; window->OnMouseWheelEvent += [&, window] (MouseWheelEvent e) { std::cout << window->GetMouseWheelPersistent() << std::endl; }; while (!window->IsClosing()) { window->ManagedRefresh(); if (window->IsFocused()) window->SetCursorCenter(); } delete window; }