From 9b83919815f6a6ce5d73da1c28483970d0ca5589 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 14:22:28 -0600 Subject: added dev/MinGfx/ --- .../docs/html/classmingfx_1_1_graphics_app.html | 1837 ++++++++++++++++++++ 1 file changed, 1837 insertions(+) create mode 100644 dev/MinGfx/docs/html/classmingfx_1_1_graphics_app.html (limited to 'dev/MinGfx/docs/html/classmingfx_1_1_graphics_app.html') diff --git a/dev/MinGfx/docs/html/classmingfx_1_1_graphics_app.html b/dev/MinGfx/docs/html/classmingfx_1_1_graphics_app.html new file mode 100644 index 0000000..15fe349 --- /dev/null +++ b/dev/MinGfx/docs/html/classmingfx_1_1_graphics_app.html @@ -0,0 +1,1837 @@ + + + + + + + +MinGfx Toolkit: mingfx::GraphicsApp Class Reference + + + + + + + + + + + + +
+
+ + + + + + +
+
MinGfx Toolkit +  1.0 +
+
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+ +
+
mingfx::GraphicsApp Class Reference
+
+
+

Detailed Description

+

This is the main application base class for the MinGfx Toolkit.

+


+

+

Create a Subclass:

+

To create your own graphics application, you should create a subclass of GraphicsApp and then override some key functions:

+
    +
  1. User Input: To get input from the keyboard and mouse, override OnMouseMove() and/or the other On...() functions.
  2. +
  3. Drawing Graphics: To draw graphics override one or more of the Draw*() functions.
      +
    • DrawUsingNanoVG() is the right place to make 2D drawing calls using the nanovg library.
    • +
    • DrawUsingOpenGL() is the right place to make 2D or 3D drawing calls using OpenGL. This includes drawing using the Mesh, QuickShapes, DefaultShader, ShaderProgram, and all other MinGfx classes since these are all based on OpenGL.
    • +
    • InitNanoGUI() is the right place to create nanogui windows to add a 2D user interface to your app.
    • +
    • InitOpenGL() is the right place to load textures, meshes, shaders, and other graphics objects that can only be created after the OpenGL context exists.
    • +
    +
  4. +
  5. Physics, Animation, AI, etc.: Override the UpdateSimulation() function to do other non-graphics calculations required by your program. This is called automatically once per frame.
  6. +
+

Keep in mind that internally the app uses a rendering loop that looks something like this:

InitNanoGUI(); // your hook for initializing NanoGUI widgets
+
InitOpenGL(); // your hook for initializing OpenGL graphics
+
while (!program_ready_to_close) {
+
// user input
+
internal_get_input_events_from_operating_system();
+
OnMouseMove(); // your hook for processing input
+
On*(); // all other event callbacks -- your hook for processing input
+
+
// phyics, etc.
+
UpdateSimulation(); // your hook for physics, animation, AI, etc.
+
+
// draw graphics
+
internal_render_gui_elements_using_nanogui();
+
DrawUsingNanoVG(); // your hook for drawing 2D vector graphics
+
DrawUsingOpenGL(); // your hook for 2D/3D rendering with OpenGL
+
}
+
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,...
Definition: graphics_app.h:165
+
virtual void DrawUsingOpenGL()
Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.
Definition: graphics_app.h:317
+
virtual void DrawUsingNanoVG(NVGcontext *ctx)
Override this to draw graphics using the nanovg vector graphics library, which provides an easy way t...
Definition: graphics_app.h:311
+
virtual void InitOpenGL()
Override this to initialize the OpenGL context with textures, vertex buffers, etc.
Definition: graphics_app.h:297
+
virtual void UpdateSimulation(double dt)
Called once per frame.
Definition: graphics_app.h:306
+
virtual void InitNanoGUI()
Called at the beginning of the Run() method.
Definition: graphics_app.h:284
+

A Complete Example with GUI Widgets

+

If you wish to add some buttons, sliders, etc. in your application, you can do this inside GraphicsApp by accessing the NanoGUI library. You will need to pass NanoGUI a nanogui::screen object, which you can get from the screen() function. NanoGui setup should be done in the constructor, like this:

#include <mingfx.h>
+
using namespace mingfx;
+
+
class MyApp : public GraphcisApp {
+
public:
+
MyApp() : GraphicsApp(1024,768, "My Amazing App") {
+
}
+
+
virtual ~MyApp() {}
+
+
void InitNanoGUI() {
+
// Setup the GUI window
+
nanogui::Window *window = new nanogui::Window(screen(), "My GUI Panel");
+
window->setPosition(Eigen::Vector2i(10, 10));
+
window->setSize(Eigen::Vector2i(400,200));
+
window->setLayout(new nanogui::GroupLayout());
+
+
nanogui::Button pause_btn = new nanogui::Button(window, "Pause");
+
pause_btn->setCallback(std::bind(&MyApp::OnPauseBtnPressed, this));
+
pause_btn->setTooltip("Toggle playback.");
+
+
screen()->performLayout();
+
}
+
+
void InitOpenGL() {
+
glClearColor(0.0, 0.0, 0.0, 1);
+
}
+
+
// this callback is for the nanogui pause_btn defined above
+
void OnPauseBtnPressed() {
+
std::cout << "Pause pressed." << std::endl;
+
}
+
+
// this callback is built into the base GraphicsApp class
+
void OnMouseMove(const Point2 &pos, const Vector2 &delta) {
+
std::cout << "Mouse moved to " << pos << std::endl;
+
}
+
+
void DrawUsingOpenGL() {
+
Matrix4 model = Matrix4::Translation(Vector3(-1,0,0)) * Matrix4::Scale(Vector3(0.5, 0.5, 0.5));
+
Matrix4 view = Matrix4::LookAt(Point3(0,0,3), Point3(0,0,0), Vector3(0,1,0));
+
Matrix4 proj = Matrix4::Perspective(60.0, aspect_ratio(), 0.1, 10.0);
+
quick_shapes_.DrawCube(model, view, proj, Color(1,1,1));
+
}
+
+
private:
+
QuickShapes quick_shapes_;
+
};
+
+
+
int main(int argc, const char *argv[]) {
+
MyApp app;
+
app.Run();
+
return 0;
+
}
+
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 nanogui::Screen * screen()
Access to the underlying NanoGUI Screen object.
+
static Matrix4 Scale(const Vector3 &v)
Returns the scale matrix described by the vector.
+
static Matrix4 Perspective(float fov_y_in_degrees, float aspect_ratio, float near_plane_dist, float far_plane_dist)
Returns a perspective projection matrix equivalent to the one gluPerspective creates.
+
static Matrix4 LookAt(Point3 eye, Point3 target, Vector3 up)
Returns a view matrix that centers the camera at the 'eye' position and orients it to look at the des...
+
static Matrix4 Translation(const Vector3 &v)
Returns the translation matrix described by the vector.
+
Includes the entire MinGfx library and calls using namespace mingfx.
+
Namespace for the MinGfx Toolkit.
Definition: aabb.h:21
+
+

Definition at line 135 of file graphics_app.h.

+
+

#include <graphics_app.h>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

 GraphicsApp (int width, int height, const std::string &caption)
 Constructs a new app but does not yet run it. More...
 
virtual ~GraphicsApp ()
 The destructor will shutdown the graphics system and window. More...
 
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, then this callback function will be called to report the new position of the mouse to you. More...
 
virtual void OnLeftMouseDown (const Point2 &pos)
 If the mouse button was pressed down since the last frame, then this function will be called to notify you. More...
 
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 called to tell you that a "dragging" operation is happening. More...
 
virtual void OnLeftMouseUp (const Point2 &pos)
 If the mouse button was released since the last frame, then this function will be called to notify you. More...
 
virtual void OnMiddleMouseDown (const Point2 &pos)
 If the mouse button was pressed down since the last frame, then this function will be called to notify you. More...
 
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 called to tell you that a "dragging" operation is happening. More...
 
virtual void OnMiddleMouseUp (const Point2 &pos)
 If the mouse button was released since the last frame, then this function will be called to notify you. More...
 
virtual void OnRightMouseDown (const Point2 &pos)
 If the mouse button was pressed down since the last frame, then this function will be called to notify you. More...
 
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 called to tell you that a "dragging" operation is happening. More...
 
virtual void OnRightMouseUp (const Point2 &pos)
 If the mouse button was released since the last frame, then this function will be called to notify you. More...
 
virtual void OnKeyDown (const char *c, int modifiers)
 Transforms a keyboard down event into the actual character typed. More...
 
virtual void OnKeyRepeat (const char *c, int modifiers)
 Transforms a keyboard repeat event into the actual character typed. More...
 
virtual void OnKeyUp (const char *c, int modifiers)
 Transforms a keyboard up event into the actual character typed. More...
 
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/group__keys.html. More...
 
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/group__keys.html. More...
 
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/group__keys.html. More...
 
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 dragging the window or through a call to ResizeWindow(). More...
 
virtual void Run ()
 After creating a new GraphicsApp, call this to start the app's mainloop. More...
 
virtual void InitNanoGUI ()
 Called at the beginning of the Run() method. More...
 
virtual void InitOpenGL ()
 Override this to initialize the OpenGL context with textures, vertex buffers, etc. More...
 
virtual void UpdateSimulation (double dt)
 Called once per frame. More...
 
virtual void DrawUsingNanoVG (NVGcontext *ctx)
 Override this to draw graphics using the nanovg vector graphics library, which provides an easy way to draw 2D shapes to the screen. More...
 
virtual void DrawUsingOpenGL ()
 Override this to draw graphics using raw OpenGL 2D or 3D graphics calls. More...
 
virtual bool IsKeyDown (int key)
 True if the specified is is currently held down. Uses the GLFW key codes found here: http://www.glfw.org/docs/latest/group__keys.html. More...
 
virtual bool IsLeftMouseDown ()
 True if the left mouse button is currently held down. More...
 
virtual bool IsMiddleMouseDown ()
 True if the middle mouse button is currently held down. More...
 
virtual bool IsRightMouseDown ()
 True if the right mouse button is currently held down. More...
 
virtual int window_width ()
 Returns the current width of the client area of the window in pixels. More...
 
virtual int window_height ()
 Returns the current height of the client area of the window in pixels. More...
 
virtual int framebuffer_width ()
 Returns the current width of the framebuffer in pixels. More...
 
virtual int framebuffer_height ()
 Returns the current height of the framebuffer in pixels. More...
 
virtual float aspect_ratio ()
 Returns width/height for the current shape of the window. More...
 
virtual Point2 PixelsToNormalizedDeviceCoords (const Point2 &pointInPixels)
 Transforms a point in viewport coordinates (pixels where top left = (0,0) and bottom right = (window_width()-1, window_height()-1)) to normalized device coordinates, (top left = (-1,1) bottom right (1,-1)). More...
 
virtual Point2 NormalizedDeviceCoordsToPixels (const Point2 &pointInNDC)
 Transforms a point in normalized device coordinates (top left = (-1,1) bottom right (1,-1)) to pixels (top left = (0,0), bottom right = (window width-1, window height-1)) More...
 
virtual Vector2 PixelsToNormalizedDeviceCoords (const Vector2 &vectorInPixels)
 Transforms a vector in viewport coordinates (pixels where top left = (0,0) and bottom right = (window width-1, window height-1)) to normalized device coordinates, (top left = (-1,1) bottom right (1,-1)). More...
 
virtual Vector2 NormalizedDeviceCoordsToPixels (const Vector2 &pointInNDC)
 Transforms a vector in normalized device coordinates (top left = (-1,1) bottom right (1,-1)) to pixels (top left = (0,0), bottom right = (window width-1, window height-1)) More...
 
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 plane. More...
 
virtual nanogui::Screen * screen ()
 Access to the underlying NanoGUI Screen object. More...
 
virtual GLFWwindow * window ()
 Access to the underlying GLFWwindow object. More...
 
virtual void ResizeWindow (int new_width, int new_height)
 Cause the graphics windows to resize programmatically rather than by dragging on the corner manually. More...
 
virtual void InitGraphicsContext ()
 Users cannot make any graphics calls (e.g., setting the clear color, saving mesh data to the GPU) until the graphics context is initialized by calling this method. More...
 
+

Constructor & Destructor Documentation

+ +

◆ GraphicsApp()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
mingfx::GraphicsApp::GraphicsApp (int width,
int height,
const std::string & caption 
)
+
+ +

Constructs a new app but does not yet run it.

+
Parameters
+ + + + +
widthThe width of the client area of the window in pixels.
heightThe height of the client area of the window in pixels.
captionThe caption for the window's title bar.
+
+
+ +
+
+ +

◆ ~GraphicsApp()

+ +
+
+ + + + + +
+ + + + + + + +
virtual mingfx::GraphicsApp::~GraphicsApp ()
+
+virtual
+
+ +

The destructor will shutdown the graphics system and window.

+ +
+
+

Member Function Documentation

+ +

◆ aspect_ratio()

+ +
+
+ + + + + +
+ + + + + + + +
virtual float mingfx::GraphicsApp::aspect_ratio ()
+
+virtual
+
+ +

Returns width/height for the current shape of the window.

+ +
+
+ +

◆ DrawUsingNanoVG()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::DrawUsingNanoVG (NVGcontext * ctx)
+
+inlinevirtual
+
+ +

Override this to draw graphics using the nanovg vector graphics library, which provides an easy way to draw 2D shapes to the screen.

+ +

Definition at line 311 of file graphics_app.h.

+ +
+
+ +

◆ DrawUsingOpenGL()

+ +
+
+ + + + + +
+ + + + + + + +
virtual void mingfx::GraphicsApp::DrawUsingOpenGL ()
+
+inlinevirtual
+
+ +

Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.

+ +

Definition at line 317 of file graphics_app.h.

+ +
+
+ +

◆ framebuffer_height()

+ +
+
+ + + + + +
+ + + + + + + +
virtual int mingfx::GraphicsApp::framebuffer_height ()
+
+virtual
+
+ +

Returns the current height of the framebuffer in pixels.

+

Note that on some displays (e.g., Mac Retina) the framebuffer is larger than the window.

+ +
+
+ +

◆ framebuffer_width()

+ +
+
+ + + + + +
+ + + + + + + +
virtual int mingfx::GraphicsApp::framebuffer_width ()
+
+virtual
+
+ +

Returns the current width of the framebuffer in pixels.

+

Note that on some displays (e.g., Mac Retina) the framebuffer is larger than the window.

+ +
+
+ +

◆ InitGraphicsContext()

+ +
+
+ + + + + +
+ + + + + + + +
virtual void mingfx::GraphicsApp::InitGraphicsContext ()
+
+virtual
+
+ +

Users cannot make any graphics calls (e.g., setting the clear color, saving mesh data to the GPU) until the graphics context is initialized by calling this method.

+

It is called automatically by the Run() method before calling the InitNanoGUI() and InitOpenGL() methods. So, users should place all of their graphics initialization code inside one of those two methods.

+ +
+
+ +

◆ InitNanoGUI()

+ +
+
+ + + + + +
+ + + + + + + +
virtual void mingfx::GraphicsApp::InitNanoGUI ()
+
+inlinevirtual
+
+ +

Called at the beginning of the Run() method.

+

Override this to initialize any NanoGUI graphics related properties including 2D windows, buttons, sliders, etc...

+

IMPORTANT: Put any NanoGUI initialization code here, NOT in the constructors of the classes that you create, or, create your classes from within this function. The graphics calls will fail if the OpenGL context has not yet been initialized, and it is not guaranteed to be initialized until this function has been called.

+ +

Definition at line 284 of file graphics_app.h.

+ +
+
+ +

◆ InitOpenGL()

+ +
+
+ + + + + +
+ + + + + + + +
virtual void mingfx::GraphicsApp::InitOpenGL ()
+
+inlinevirtual
+
+ +

Override this to initialize the OpenGL context with textures, vertex buffers, etc.

+

that you will use later inside DrawUsingOpenGL(). This InitOpenGL() function is called once on program startup just after the OpenGL drawing context is created.

+

IMPORTANT: Put any OpenGL initialization code here, NOT in the constructors of the classes that you create, or, create your classes from within this function. The graphics calls will fail if the OpenGL context has not yet been initialized, and it is not guaranteed to be initialized until this function has been called.

+ +

Definition at line 297 of file graphics_app.h.

+ +
+
+ +

◆ IsKeyDown()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual bool mingfx::GraphicsApp::IsKeyDown (int key)
+
+virtual
+
+ +

True if the specified is is currently held down. Uses the GLFW key codes found here: http://www.glfw.org/docs/latest/group__keys.html.

+ +
+
+ +

◆ IsLeftMouseDown()

+ +
+
+ + + + + +
+ + + + + + + +
virtual bool mingfx::GraphicsApp::IsLeftMouseDown ()
+
+virtual
+
+ +

True if the left mouse button is currently held down.

+ +
+
+ +

◆ IsMiddleMouseDown()

+ +
+
+ + + + + +
+ + + + + + + +
virtual bool mingfx::GraphicsApp::IsMiddleMouseDown ()
+
+virtual
+
+ +

True if the middle mouse button is currently held down.

+ +
+
+ +

◆ IsRightMouseDown()

+ +
+
+ + + + + +
+ + + + + + + +
virtual bool mingfx::GraphicsApp::IsRightMouseDown ()
+
+virtual
+
+ +

True if the right mouse button is currently held down.

+ +
+
+ +

◆ NormalizedDeviceCoordsToPixels() [1/2]

+ +
+
+ + + + + +
+ + + + + + + + +
virtual Point2 mingfx::GraphicsApp::NormalizedDeviceCoordsToPixels (const Point2pointInNDC)
+
+virtual
+
+ +

Transforms a point in normalized device coordinates (top left = (-1,1) bottom right (1,-1)) to pixels (top left = (0,0), bottom right = (window width-1, window height-1))

+ +
+
+ +

◆ NormalizedDeviceCoordsToPixels() [2/2]

+ +
+
+ + + + + +
+ + + + + + + + +
virtual Vector2 mingfx::GraphicsApp::NormalizedDeviceCoordsToPixels (const Vector2pointInNDC)
+
+virtual
+
+ +

Transforms a vector in normalized device coordinates (top left = (-1,1) bottom right (1,-1)) to pixels (top left = (0,0), bottom right = (window width-1, window height-1))

+ +
+
+ +

◆ OnKeyDown()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnKeyDown (const char * c,
int modifiers 
)
+
+inlinevirtual
+
+ +

Transforms a keyboard down event into the actual character typed.

+
Parameters
+ + + +
cThe character for the key that was pressed.
modifiersIf any modifiers (Alt, Ctrl, Shift, etc.) were held at the same time, then these are encoded in this int. See the detailed description here: http://www.glfw.org/docs/latest/group__mods.html
+
+
+ +

Definition at line 225 of file graphics_app.h.

+ +
+
+ +

◆ OnKeyRepeat()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnKeyRepeat (const char * c,
int modifiers 
)
+
+inlinevirtual
+
+ +

Transforms a keyboard repeat event into the actual character typed.

+
Parameters
+ + + +
cThe character for the key that was pressed.
modifiersIf any modifiers (Alt, Ctrl, Shift, etc.) were held at the same time, then these are encoded in this int. See the detailed description here: http://www.glfw.org/docs/latest/group__mods.html
+
+
+ +

Definition at line 233 of file graphics_app.h.

+ +
+
+ +

◆ OnKeyUp()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnKeyUp (const char * c,
int modifiers 
)
+
+inlinevirtual
+
+ +

Transforms a keyboard up event into the actual character typed.

+
Parameters
+ + + +
cThe character for the key that was pressed.
modifiersIf any modifiers (Alt, Ctrl, Shift, etc.) were held at the same time, then these are encoded in this int. See the detailed description here: http://www.glfw.org/docs/latest/group__mods.html
+
+
+ +

Definition at line 241 of file graphics_app.h.

+ +
+
+ +

◆ OnLeftMouseDown()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::OnLeftMouseDown (const Point2pos)
+
+inlinevirtual
+
+ +

If the mouse button was pressed down since the last frame, then this function will be called to notify you.

+
Parameters
+ + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
+
+
+ +

Definition at line 174 of file graphics_app.h.

+ +
+
+ +

◆ OnLeftMouseDrag()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnLeftMouseDrag (const Point2pos,
const Vector2delta 
)
+
+inlinevirtual
+
+ +

If the mouse button is held down and the mouse has moved in the past frame then this function will be called to tell you that a "dragging" operation is happening.

+
Parameters
+ + + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
deltaThis is the change in the position of the mouse in pixels since the last frame.
+
+
+ +

Definition at line 187 of file graphics_app.h.

+ +
+
+ +

◆ OnLeftMouseUp()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::OnLeftMouseUp (const Point2pos)
+
+inlinevirtual
+
+ +

If the mouse button was released since the last frame, then this function will be called to notify you.

+
Parameters
+ + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width()-1, window_height()-1) is the bottom right corner.
+
+
+ +

Definition at line 196 of file graphics_app.h.

+ +
+
+ +

◆ OnMiddleMouseDown()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::OnMiddleMouseDown (const Point2pos)
+
+inlinevirtual
+
+ +

If the mouse button was pressed down since the last frame, then this function will be called to notify you.

+
Parameters
+ + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
+
+
+ +

Definition at line 200 of file graphics_app.h.

+ +
+
+ +

◆ OnMiddleMouseDrag()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnMiddleMouseDrag (const Point2pos,
const Vector2delta 
)
+
+inlinevirtual
+
+ +

If the mouse button is held down and the mouse has moved in the past frame then this function will be called to tell you that a "dragging" operation is happening.

+
Parameters
+ + + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
deltaThis is the change in the position of the mouse in pixels since the last frame.
+
+
+ +

Definition at line 203 of file graphics_app.h.

+ +
+
+ +

◆ OnMiddleMouseUp()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::OnMiddleMouseUp (const Point2pos)
+
+inlinevirtual
+
+ +

If the mouse button was released since the last frame, then this function will be called to notify you.

+
Parameters
+ + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width()-1, window_height()-1) is the bottom right corner.
+
+
+ +

Definition at line 206 of file graphics_app.h.

+ +
+
+ +

◆ OnMouseMove()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnMouseMove (const Point2pos,
const Vector2delta 
)
+
+inlinevirtual
+
+ +

If the mouse has moved in the past frame and no mouse buttons are currently pressed, then this callback function will be called to report the new position of the mouse to you.

+
Parameters
+ + + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
deltaThis is the change in the position of the mouse in pixels since the last frame.
+
+
+ +

Definition at line 165 of file graphics_app.h.

+ +
+
+ +

◆ OnRightMouseDown()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::OnRightMouseDown (const Point2pos)
+
+inlinevirtual
+
+ +

If the mouse button was pressed down since the last frame, then this function will be called to notify you.

+
Parameters
+ + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
+
+
+ +

Definition at line 210 of file graphics_app.h.

+ +
+
+ +

◆ OnRightMouseDrag()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnRightMouseDrag (const Point2pos,
const Vector2delta 
)
+
+inlinevirtual
+
+ +

If the mouse button is held down and the mouse has moved in the past frame then this function will be called to tell you that a "dragging" operation is happening.

+
Parameters
+ + + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width(), window_height()) is the bottom right corner.
deltaThis is the change in the position of the mouse in pixels since the last frame.
+
+
+ +

Definition at line 213 of file graphics_app.h.

+ +
+
+ +

◆ OnRightMouseUp()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::OnRightMouseUp (const Point2pos)
+
+inlinevirtual
+
+ +

If the mouse button was released since the last frame, then this function will be called to notify you.

+
Parameters
+ + +
posThis is the current position of the mouse in pixels, where (0,0) is at the top left corner of the screen and (window_width()-1, window_height()-1) is the bottom right corner.
+
+
+ +

Definition at line 216 of file graphics_app.h.

+ +
+
+ +

◆ OnSpecialKeyDown()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnSpecialKeyDown (int key,
int scancode,
int modifiers 
)
+
+inlinevirtual
+
+ +

The values for key, scancode, and modifiers are documented here: http://www.glfw.org/docs/latest/group__keys.html.

+ +

Definition at line 247 of file graphics_app.h.

+ +
+
+ +

◆ OnSpecialKeyRepeat()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnSpecialKeyRepeat (int key,
int scancode,
int modifiers 
)
+
+inlinevirtual
+
+ +

The values for key, scancode, and modifiers are documented here: http://www.glfw.org/docs/latest/group__keys.html.

+ +

Definition at line 251 of file graphics_app.h.

+ +
+
+ +

◆ OnSpecialKeyUp()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnSpecialKeyUp (int key,
int scancode,
int modifiers 
)
+
+inlinevirtual
+
+ +

The values for key, scancode, and modifiers are documented here: http://www.glfw.org/docs/latest/group__keys.html.

+ +

Definition at line 255 of file graphics_app.h.

+ +
+
+ +

◆ OnWindowResize()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::OnWindowResize (int new_width,
int new_height 
)
+
+inlinevirtual
+
+ +

Override this to respond when the graphics window and/or framebuffer are resized, either by the user dragging the window or through a call to ResizeWindow().

+ +

Definition at line 261 of file graphics_app.h.

+ +
+
+ +

◆ PixelsToNormalizedDeviceCoords() [1/2]

+ +
+
+ + + + + +
+ + + + + + + + +
virtual Point2 mingfx::GraphicsApp::PixelsToNormalizedDeviceCoords (const Point2pointInPixels)
+
+virtual
+
+ +

Transforms a point in viewport coordinates (pixels where top left = (0,0) and bottom right = (window_width()-1, window_height()-1)) to normalized device coordinates, (top left = (-1,1) bottom right (1,-1)).

+ +
+
+ +

◆ PixelsToNormalizedDeviceCoords() [2/2]

+ +
+
+ + + + + +
+ + + + + + + + +
virtual Vector2 mingfx::GraphicsApp::PixelsToNormalizedDeviceCoords (const Vector2vectorInPixels)
+
+virtual
+
+ +

Transforms a vector in viewport coordinates (pixels where top left = (0,0) and bottom right = (window width-1, window height-1)) to normalized device coordinates, (top left = (-1,1) bottom right (1,-1)).

+ +
+
+ +

◆ ReadZValueAtPixel()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual float mingfx::GraphicsApp::ReadZValueAtPixel (const Point2pointInPixels,
unsigned int whichBuffer = GL_BACK 
)
+
+virtual
+
+ +

Returns the z buffer value under the specified pixel. z will be 0 at the near plane and +1 at the far plane.

+ +
+
+ +

◆ ResizeWindow()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
virtual void mingfx::GraphicsApp::ResizeWindow (int new_width,
int new_height 
)
+
+virtual
+
+ +

Cause the graphics windows to resize programmatically rather than by dragging on the corner manually.

+ +
+
+ +

◆ Run()

+ +
+
+ + + + + +
+ + + + + + + +
virtual void mingfx::GraphicsApp::Run ()
+
+virtual
+
+ +

After creating a new GraphicsApp, call this to start the app's mainloop.

+

Each time through the mainloop the app will: 1. respond any user input events by calling the On*() callback methods, 2. call UpdateSimulation(), and 3. call the two Draw*() methods. Note that Run() does not return until the user closes the app and the program is ready to shutdown.

+ +
+
+ +

◆ screen()

+ +
+
+ + + + + +
+ + + + + + + +
virtual nanogui::Screen* mingfx::GraphicsApp::screen ()
+
+virtual
+
+ +

Access to the underlying NanoGUI Screen object.

+ +
+
+ +

◆ UpdateSimulation()

+ +
+
+ + + + + +
+ + + + + + + + +
virtual void mingfx::GraphicsApp::UpdateSimulation (double dt)
+
+inlinevirtual
+
+ +

Called once per frame.

+

Override this and fill it in to update your simulation code or any other updates you need to make to your model that are timed rather than in response to user input.

+
Parameters
+ + +
dtis the elapsed time since the last call.
+
+
+ +

Definition at line 306 of file graphics_app.h.

+ +
+
+ +

◆ window()

+ +
+
+ + + + + +
+ + + + + + + +
virtual GLFWwindow* mingfx::GraphicsApp::window ()
+
+virtual
+
+ +

Access to the underlying GLFWwindow object.

+ +
+
+ +

◆ window_height()

+ +
+
+ + + + + +
+ + + + + + + +
virtual int mingfx::GraphicsApp::window_height ()
+
+virtual
+
+ +

Returns the current height of the client area of the window in pixels.

+ +
+
+ +

◆ window_width()

+ +
+
+ + + + + +
+ + + + + + + +
virtual int mingfx::GraphicsApp::window_width ()
+
+virtual
+
+ +

Returns the current width of the client area of the window in pixels.

+ +
+
+
The documentation for this class was generated from the following file: +
+ + + + + -- cgit v1.2.3