Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Window::Window(std::string title, int32_t width, int32_t height) {
- // TODO: add support for monitor and share for GLFW
- m_window = std::unique_ptr<GLFWwindow, GLFWdeleter>(glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr));
- glfwSetWindowUserPointer(m_window.get(), this);
- glfwSetCursorPosCallback(m_window.get(), Window::callback);
- }
- void Window::mouse_callback(double xpos, double ypos) {
- std::cout << "x: " << xpos << " y: " << ypos << std::endl;
- }
- void Window::callback(GLFWwindow* window, double xpos, double ypos)
- {
- auto win = static_cast<Window*>(glfwGetWindowUserPointer(window));
- win->mouse_callback(xpos, ypos);
- }
- auto window = std::make_unique<Window>("Hello World!", 640, 480);
- window->make_current();
- g_engine.registerWindow(std::move(window));
- g_engine.run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement