Join Pablo Colapinto for an in-depth discussion in this video Handling GLFW callbacks, part of Learning OpenGL.
In this lesson, I'd like to show you how we've bound GLFW's event handling to our application. So on line 39 of our GLFW app.hpp file, we call window create passing this to it. If we look at our GLFW window, it create method takes a pointer to some unknown application type. That's what this is when we create our window here.
This is used to generate callback functions for when a key is struck or when the mouse is moved. We pass in the GLFW window context, and tell it to call the interface onKeyDown function. Which is also templated on the application. Up here in interface, the onKeyDown function templated on the application calls the application's onKeyDown function.
We do the same with mouse movements. So when our application creates a window on line 39, it binds our application's onMouseMove, onMouseDown and onKeyDown methods to GLFW's event handling. This is useful because it enables us to actually decide what to do in the case of mouse movement or keystrokes later on in our cpp files.
- What is OpenGL?
- Setting up an OpenGL workflow
- Creating a window with GLFW
- Working with geometric primitives
- Rotating, translating, and scaling
- Understanding matrix transformations
- Creating mesh data structures
- Buffering mesh data
- Getting mouse and keyboard input
Skill Level Intermediate
Q: Why am I getting errors saying I don’t have GLEW installed when I try to create the Xcode projects with Cmake?
1) Download, Install, and Run Xcode
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install glew
./bootstrap && make && make install
brew install cmake
cd Exercise Filesmkdir xcodecd xcodecmake -G "Xcode" ..