Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Window::Window(std::string title, int32_t width, int32_t height) {
  2. // TODO: add support for monitor and share for GLFW
  3. m_window = std::unique_ptr<GLFWwindow, GLFWdeleter>(glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr));
  4.  
  5. glfwSetWindowUserPointer(m_window.get(), this);
  6. glfwSetCursorPosCallback(m_window.get(), Window::callback);
  7. }
  8.  
  9. void Window::mouse_callback(double xpos, double ypos) {
  10. std::cout << "x: " << xpos << " y: " << ypos << std::endl;
  11. }
  12.  
  13. void Window::callback(GLFWwindow* window, double xpos, double ypos)
  14. {
  15. auto win = static_cast<Window*>(glfwGetWindowUserPointer(window));
  16. win->mouse_callback(xpos, ypos);
  17. }
  18.  
  19. auto window = std::make_unique<Window>("Hello World!", 640, 480);
  20. window->make_current();
  21. g_engine.registerWindow(std::move(window));
  22. g_engine.run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement