10 #include "agl/renderer.h"
11 #include "agl/camera.h"
125 virtual void scroll(
float dx,
float dy) {}
138 virtual void keyUp(
int key,
int mods) {}
273 void lookAt(
const glm::vec3& camPos,
274 const glm::vec3& camLook,
275 const glm::vec3& up = glm::vec3(0, 1, 0));
282 void perspective(
float fovRadians,
float aspect,
float near,
float far);
289 void ortho(
float minx,
float maxx,
290 float miny,
float maxy,
float minz,
float maxz);
308 static void onScrollCb(GLFWwindow* w,
double xoffset,
double yoffset);
309 static void onMouseMotionCb(GLFWwindow* w,
double x,
double y);
310 static void onMouseButtonCb(GLFWwindow* w,
int button,
int action,
int mods);
311 static void onResizeCb(GLFWwindow* w,
int width,
int height);
312 static void onKeyboardCb(GLFWwindow* w,
313 int key,
int code,
int action,
int mods);
315 void onMouseMotion(
int x,
int y);
316 void onMouseButton(
int button,
int action,
int mods);
317 void onKeyboard(
int key,
int scancode,
int action,
int mods);
319 void onScroll(
float xoffset,
float yoffset);
326 int _windowWidth, _windowHeight;
329 float _lastx, _lasty;
331 glm::vec3 _backgroundColor;
332 struct GLFWwindow* _window = 0;
336 #endif // AGL_WINDOW_H_
bool screenshot(const std::string &filename)
Save the current screen image to a file.
Definition: window.cpp:137
virtual void keyDown(int key, int mods)
Override this method to respond to key presses (button down)
Definition: window.h:149
void perspective(float fovRadians, float aspect, float near, float far)
Set the current projection to a perspective view.
Definition: window.cpp:102
void run()
Opens the window and starts the main application loop.
Definition: window.cpp:113
virtual void resize(int width, int height)
Override this method to respond to window resizing.
Definition: window.h:158
void setWindowSize(int w, int h)
Set the size of the window in pixels.
Definition: window.cpp:198
bool keyIsDown(int key) const
Query whether the given key is down @key The key to test.
Definition: window.cpp:188
virtual void scroll(float dx, float dy)
Override this method to respond to scrolling the middle mouse button.
Definition: window.h:125
void ortho(float minx, float maxx, float miny, float maxy, float minz, float maxz)
Set the current projection to an orthographic view.
Definition: window.cpp:97
virtual void setup()
Override this method to perform setup before the main application loop.
Definition: window.h:77
bool cameraEnabled() const
Returns true if the camera controls are active; false otherwise.
Definition: window.h:296
void background(const glm::vec3 &color)
Set the background color.
Definition: window.cpp:39
void noLoop()
Stop the main application loop.
Definition: window.cpp:45
virtual void draw()
Override this method to draw.
Definition: window.h:84
void setupOrthoScene(const glm::vec3 ¢er, const glm::vec3 &dim)
Initialize the projection and camera to fit the given dimensions and center using an orthographic pro...
Definition: window.cpp:49
Manages the window and user input.
Definition: window.h:21
Window()
Constructor.
Definition: window.cpp:23
bool mouseIsDown(int button) const
Query whether the given mouse button is down.
Definition: window.cpp:193
void lookAt(const glm::vec3 &camPos, const glm::vec3 &camLook, const glm::vec3 &up=glm::vec3(0, 1, 0))
Definition: window.cpp:107
void setCameraEnabled(bool on)
Set whether the window's camera controls are active.
Definition: window.h:302
virtual void mouseUp(int button, int mods)
Override this method to respond to mouse press (button up)
Definition: window.h:115
Implements orbit and pan camera movement.
Definition: camera.h:19
float elapsedTime() const
Return the amount of time since the setup() was called (in seconds)
Definition: window.cpp:178
The Renderer class draws meshes to the screen using shaders.
Definition: renderer.h:37
virtual void keyUp(int key, int mods)
Override this method to respond to key presses (button up)
Definition: window.h:138
float height() const
Return the window height in pixels.
Definition: window.cpp:166
Global utilities and common third party includes.
void setupPerspectiveScene(const glm::vec3 ¢er, const glm::vec3 &dim)
Initialize the projection and camera to fit the given dimensions and center using a perspective proje...
Definition: window.cpp:60
virtual void mouseMotion(int x, int y, int dx, int dy)
Override this method to respond to mouse movement.
Definition: window.h:96
float width() const
Return the window width in pixels.
Definition: window.cpp:170
float dt() const
Return the amount of time since the previous frame (in seconds)
Definition: window.cpp:174
virtual void mouseDown(int button, int mods)
Override this method to respond to mouse press (button down)
Definition: window.h:107
glm::vec2 mousePosition() const
Return the current mouse position (in screen coordinates)
Definition: window.cpp:182