15 #ifndef SRC_GRAPHICS_APP_H_
16 #define SRC_GRAPHICS_APP_H_
19 #pragma warning ( push, 0 )
20 #include <nanogui/nanogui.h>
21 #pragma warning ( pop )
241 virtual void OnKeyUp(
const char *c,
int modifiers) {}
407 bool cursor_pos_glfw_cb(
double x,
double y);
408 bool mouse_button_glfw_cb(
int button,
int action,
int modifiers);
409 bool key_glfw_cb(
int key,
int scancode,
int action,
int mods);
410 bool char_glfw_cb(
unsigned int codepoint);
411 bool drop_glfw_cb(
int count,
const char **filenames);
412 bool scroll_glfw_cb(
double x,
double y);
413 bool resize_glfw_cb(
int width,
int height);
415 virtual void mouse_move(
const Point2 &pos,
const Vector2 &delta) {
418 virtual void left_mouse_down(
const Point2 &pos) {
421 virtual void left_mouse_drag(
const Point2 &pos,
const Vector2 &delta) {
424 virtual void left_mouse_up(
const Point2 &pos) {
427 virtual void middle_mouse_down(
const Point2 &pos) {
430 virtual void middle_mouse_drag(
const Point2 &pos,
const Vector2 &delta) {
433 virtual void middle_mouse_up(
const Point2 &pos) {
436 virtual void right_mouse_down(
const Point2 &pos) {
439 virtual void right_mouse_drag(
const Point2 &pos,
const Vector2 &delta) {
442 virtual void right_mouse_up(
const Point2 &pos) {
445 virtual void key_down(
const char *c,
int modifiers) {
448 virtual void key_repeat(
const char *c,
int modifiers) {
451 virtual void key_up(
const char *c,
int modifiers) {
454 virtual void special_key_down(
int key,
int scancode,
int modifiers) {
457 virtual void special_key_repeat(
int key,
int scancode,
int modifiers) {
460 virtual void special_key_up(
int key,
int scancode,
int modifiers) {
464 bool graphicsInitialized_;
467 const std::string caption_;
468 nanogui::Screen *screen_;
This is the main application base class for the MinGfx Toolkit.
virtual void OnKeyDown(const char *c, int modifiers)
Transforms a keyboard down event into the actual character typed.
virtual void OnRightMouseDrag(const Point2 &pos, const Vector2 &delta)
If the mouse button is held down and the mouse has moved in the past frame then this function will be...
virtual void InitGraphicsContext()
Users cannot make any graphics calls (e.g., setting the clear color, saving mesh data to the GPU) unt...
virtual void ResizeWindow(int new_width, int new_height)
Cause the graphics windows to resize programmatically rather than by dragging on the corner manually.
virtual void OnSpecialKeyUp(int key, int scancode, int modifiers)
The values for key, scancode, and modifiers are documented here: http://www.glfw.org/docs/latest/grou...
virtual int window_width()
Returns the current width of the client area of the window in pixels.
virtual void OnKeyRepeat(const char *c, int modifiers)
Transforms a keyboard repeat event into the actual character typed.
virtual void OnMouseMove(const Point2 &pos, const Vector2 &delta)
If the mouse has moved in the past frame and no mouse buttons are currently pressed,...
virtual void OnMiddleMouseUp(const Point2 &pos)
If the mouse button was released since the last frame, then this function will be called to notify yo...
virtual Vector2 NormalizedDeviceCoordsToPixels(const Vector2 &pointInNDC)
Transforms a vector in normalized device coordinates (top left = (-1,1) bottom right (1,...
virtual float ReadZValueAtPixel(const Point2 &pointInPixels, unsigned int whichBuffer=GL_BACK)
Returns the z buffer value under the specified pixel. z will be 0 at the near plane and +1 at the far...
virtual bool IsRightMouseDown()
True if the right mouse button is currently held down.
virtual Vector2 PixelsToNormalizedDeviceCoords(const Vector2 &vectorInPixels)
Transforms a vector in viewport coordinates (pixels where top left = (0,0) and bottom right = (window...
virtual void OnLeftMouseUp(const Point2 &pos)
If the mouse button was released since the last frame, then this function will be called to notify yo...
virtual void OnLeftMouseDrag(const Point2 &pos, const Vector2 &delta)
If the mouse button is held down and the mouse has moved in the past frame then this function will be...
virtual void OnMiddleMouseDown(const Point2 &pos)
If the mouse button was pressed down since the last frame, then this function will be called to notif...
virtual void DrawUsingOpenGL()
Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.
virtual bool IsLeftMouseDown()
True if the left mouse button is currently held down.
virtual void Run()
After creating a new GraphicsApp, call this to start the app's mainloop.
virtual bool IsKeyDown(int key)
True if the specified is is currently held down. Uses the GLFW key codes found here: http://www....
virtual Point2 NormalizedDeviceCoordsToPixels(const Point2 &pointInNDC)
Transforms a point in normalized device coordinates (top left = (-1,1) bottom right (1,...
virtual void DrawUsingNanoVG(NVGcontext *ctx)
Override this to draw graphics using the nanovg vector graphics library, which provides an easy way t...
virtual void OnSpecialKeyRepeat(int key, int scancode, int modifiers)
The values for key, scancode, and modifiers are documented here: http://www.glfw.org/docs/latest/grou...
virtual void OnKeyUp(const char *c, int modifiers)
Transforms a keyboard up event into the actual character typed.
virtual void OnRightMouseDown(const Point2 &pos)
If the mouse button was pressed down since the last frame, then this function will be called to notif...
virtual bool IsMiddleMouseDown()
True if the middle mouse button is currently held down.
virtual Point2 PixelsToNormalizedDeviceCoords(const Point2 &pointInPixels)
Transforms a point in viewport coordinates (pixels where top left = (0,0) and bottom right = (window_...
virtual void InitOpenGL()
Override this to initialize the OpenGL context with textures, vertex buffers, etc.
virtual void UpdateSimulation(double dt)
Called once per frame.
virtual ~GraphicsApp()
The destructor will shutdown the graphics system and window.
virtual void OnSpecialKeyDown(int key, int scancode, int modifiers)
The values for key, scancode, and modifiers are documented here: http://www.glfw.org/docs/latest/grou...
virtual GLFWwindow * window()
Access to the underlying GLFWwindow object.
GraphicsApp(int width, int height, const std::string &caption)
Constructs a new app but does not yet run it.
virtual float aspect_ratio()
Returns width/height for the current shape of the window.
virtual void OnMiddleMouseDrag(const Point2 &pos, const Vector2 &delta)
If the mouse button is held down and the mouse has moved in the past frame then this function will be...
virtual int framebuffer_width()
Returns the current width of the framebuffer in pixels.
virtual int window_height()
Returns the current height of the client area of the window in pixels.
virtual void OnRightMouseUp(const Point2 &pos)
If the mouse button was released since the last frame, then this function will be called to notify yo...
virtual void OnWindowResize(int new_width, int new_height)
Override this to respond when the graphics window and/or framebuffer are resized, either by the user ...
virtual nanogui::Screen * screen()
Access to the underlying NanoGUI Screen object.
virtual void InitNanoGUI()
Called at the beginning of the Run() method.
virtual void OnLeftMouseDown(const Point2 &pos)
If the mouse button was pressed down since the last frame, then this function will be called to notif...
virtual int framebuffer_height()
Returns the current height of the framebuffer in pixels.
A 2D Point with floating point coordinates, used for storing 2D texture coordinates,...
A 2D Vector with floating point coordinates, used for storing 2D translations, mouse movements,...
Namespace for the MinGfx Toolkit.