#include #include #include class Window : public ReWindow::OpenGLWindow { private: Vector2 box_pos = Vector2::Zero; public: Window(const std::string& title, unsigned int width, unsigned int height) : OpenGLWindow(title, width, height, 2, 1) {} ~Window() override = default; void InitGL() { if (!JGL::Init({ GetSize().x, GetSize().y}, 75, 100)) throw std::runtime_error("We encountered an error while initializing JGL."); glClearColor(0.f, 0.f, 0.f, 0.f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glDepthMask(GL_TRUE); } void Display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); JGL::Update({ GetSize().x, GetSize().y }); // Rendering goes here. J2D::Begin(nullptr, true); J2D::FillRect(Colors::Red, box_pos, {32, 32}); J2D::End(); } void OnRefresh(float elapsed) override { // Code that runs every frame (that is not rendering) goes here. if (IsKeyDown(Keys::W)) box_pos.y -= 240 * GetDeltaTime(); if (IsKeyDown(Keys::S)) box_pos.y += 240 * GetDeltaTime(); if (IsKeyDown(Keys::A)) box_pos.x -= 240 * GetDeltaTime(); if (IsKeyDown(Keys::D)) box_pos.x += 240 * GetDeltaTime(); Display(); ReWindow::OpenGLWindow::SwapBuffers(); } }; int main() { auto* window = new Window("title", 1152, 864); if (!window->Open()) throw std::runtime_error("We encountered an error while opening the window."); ReWindow::Logger::Debug.EnableConsole(false); window->SetVsyncEnabled(true); window->SetResizable(false); window->InitGL(); while (!window->IsClosing()) window->ManagedRefresh(); }