diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-09-20 18:15:14 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-09-20 18:15:14 -0500 |
commit | 342403a02f8063903d0f38327430721d4d0ae331 (patch) | |
tree | 29d020a27bc16939c568dd4b29166566d1c0e658 /dev/MinGfx/example/CircleViewer.cpp | |
parent | Fix parenthesis (diff) | |
download | csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.gz csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.bz2 csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.lz csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.xz csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.tar.zst csci4611-5a8b6d8538618b144e39618350ad06a4d9e232fa.zip |
do ass1submission-p1.0
Diffstat (limited to 'dev/MinGfx/example/CircleViewer.cpp')
-rw-r--r-- | dev/MinGfx/example/CircleViewer.cpp | 244 |
1 files changed, 122 insertions, 122 deletions
diff --git a/dev/MinGfx/example/CircleViewer.cpp b/dev/MinGfx/example/CircleViewer.cpp index 9bf50b9..e051551 100644 --- a/dev/MinGfx/example/CircleViewer.cpp +++ b/dev/MinGfx/example/CircleViewer.cpp @@ -1,122 +1,122 @@ - -#include "CircleViewer.h" - -#include <nanogui/nanogui.h> -#include <iostream> - - -CircleViewer::CircleViewer() : GraphicsApp(1024,768, "Circle Simulation") { - simTime_ = 0.0; - paused_ = false; - - //InitGraphicsContext(); -} - - -CircleViewer::~CircleViewer() { - -} - -void CircleViewer::InitNanoGUI() { - nanogui::FormHelper *gui = new nanogui::FormHelper(screen()); - nanogui::ref<nanogui::Window> window = gui->addWindow(Eigen::Vector2i(10, 10), "Simulation Controls"); - pauseBtn_ = gui->addButton("Pause", std::bind(&CircleViewer::OnPauseBtnPressed, this)); - gui->addButton("Restart", std::bind(&CircleViewer::OnRestartBtnPressed, this)); - - screen()->performLayout(); -} - -void CircleViewer::UpdateSimulation(double dt) { - if (!paused_) { - simTime_ += dt; - std::cout << "Update Simulation " << simTime_ << std::endl; - } -} - - -void CircleViewer::OnRestartBtnPressed() { - simTime_ = 0.0; -} - -void CircleViewer::OnPauseBtnPressed() { - paused_ = !paused_; - if (paused_) { - pauseBtn_->setCaption("Play"); - } - else { - pauseBtn_->setCaption("Pause"); - } -} - - -void CircleViewer::OnMouseMove(const Point2 &pos, const Vector2 &delta) { - std::cout << "Mouse moved by " << delta << " to reach " << pos << std::endl; -} - - -void CircleViewer::OnLeftMouseDown(const Point2 &pos) { - std::cout << "Left mouse button DOWN at " << pos << std::endl; -} - -void CircleViewer::OnLeftMouseDrag(const Point2 &pos, const Vector2 &delta) { - std::cout << "Mouse dragged (left button) by " << delta << " to reach " << pos << std::endl; -} - -void CircleViewer::OnLeftMouseUp(const Point2 &pos) { - std::cout << "Left mouse button UP at " << pos << std::endl; -} - - -void CircleViewer::OnRightMouseDown(const Point2 &pos) { - std::cout << "Right mouse button DOWN at " << pos << std::endl; -} - -void CircleViewer::OnRightMouseDrag(const Point2 &pos, const Vector2 &delta) { - std::cout << "Mouse dragged (right button) by " << delta << " to reach " << pos << std::endl; -} - -void CircleViewer::OnRightMouseUp(const Point2 &pos) { - std::cout << "Right mouse button UP at " << pos << std::endl; -} - - -void CircleViewer::OnKeyDown(const char *c, int modifiers) { - std::cout << "Key DOWN (" << c << ") modifiers=" << modifiers << std::endl; -} - -void CircleViewer::OnKeyUp(const char *c, int modifiers) { - std::cout << "Key UP (" << c << ") modifiers=" << modifiers << std::endl; -} - - -void CircleViewer::OnSpecialKeyDown(int key, int scancode, int modifiers) { - std::cout << "Special Key DOWN key=" << key << " scancode=" << scancode << " modifiers=" << modifiers << std::endl; -} - -void CircleViewer::OnSpecialKeyUp(int key, int scancode, int modifiers) { - std::cout << "Special Key UP key=" << key << " scancode=" << scancode << " modifiers=" << modifiers << std::endl; -} - - -void CircleViewer::DrawUsingNanoVG(NVGcontext *ctx) { - // example of drawing some circles - - nvgBeginPath(ctx); - nvgCircle(ctx, 512+50.0*cos(simTime_), 350+200.0*sin(simTime_), 50); - nvgFillColor(ctx, nvgRGBA(100,100,255,200)); - nvgFill(ctx); - nvgStrokeColor(ctx, nvgRGBA(0,0,0,255)); - nvgStroke(ctx); - - nvgBeginPath(ctx); - nvgCircle(ctx, 512+200.0*cos(simTime_), 350+50.0*sin(simTime_), 50); - nvgFillColor(ctx, nvgRGBA(255,100,100,200)); - nvgFill(ctx); - nvgStrokeColor(ctx, nvgRGBA(0,0,0,255)); - nvgStroke(ctx); -} - -void CircleViewer::DrawUsingOpenGL() { - -} - +
+#include "CircleViewer.h"
+
+#include <nanogui/nanogui.h>
+#include <iostream>
+
+
+CircleViewer::CircleViewer() : GraphicsApp(1024,768, "Circle Simulation") {
+ simTime_ = 0.0;
+ paused_ = false;
+
+ //InitGraphicsContext();
+}
+
+
+CircleViewer::~CircleViewer() {
+
+}
+
+void CircleViewer::InitNanoGUI() {
+ nanogui::FormHelper *gui = new nanogui::FormHelper(screen());
+ nanogui::ref<nanogui::Window> window = gui->addWindow(Eigen::Vector2i(10, 10), "Simulation Controls");
+ pauseBtn_ = gui->addButton("Pause", std::bind(&CircleViewer::OnPauseBtnPressed, this));
+ gui->addButton("Restart", std::bind(&CircleViewer::OnRestartBtnPressed, this));
+
+ screen()->performLayout();
+}
+
+void CircleViewer::UpdateSimulation(double dt) {
+ if (!paused_) {
+ simTime_ += dt;
+ std::cout << "Update Simulation " << simTime_ << std::endl;
+ }
+}
+
+
+void CircleViewer::OnRestartBtnPressed() {
+ simTime_ = 0.0;
+}
+
+void CircleViewer::OnPauseBtnPressed() {
+ paused_ = !paused_;
+ if (paused_) {
+ pauseBtn_->setCaption("Play");
+ }
+ else {
+ pauseBtn_->setCaption("Pause");
+ }
+}
+
+
+void CircleViewer::OnMouseMove(const Point2 &pos, const Vector2 &delta) {
+ std::cout << "Mouse moved by " << delta << " to reach " << pos << std::endl;
+}
+
+
+void CircleViewer::OnLeftMouseDown(const Point2 &pos) {
+ std::cout << "Left mouse button DOWN at " << pos << std::endl;
+}
+
+void CircleViewer::OnLeftMouseDrag(const Point2 &pos, const Vector2 &delta) {
+ std::cout << "Mouse dragged (left button) by " << delta << " to reach " << pos << std::endl;
+}
+
+void CircleViewer::OnLeftMouseUp(const Point2 &pos) {
+ std::cout << "Left mouse button UP at " << pos << std::endl;
+}
+
+
+void CircleViewer::OnRightMouseDown(const Point2 &pos) {
+ std::cout << "Right mouse button DOWN at " << pos << std::endl;
+}
+
+void CircleViewer::OnRightMouseDrag(const Point2 &pos, const Vector2 &delta) {
+ std::cout << "Mouse dragged (right button) by " << delta << " to reach " << pos << std::endl;
+}
+
+void CircleViewer::OnRightMouseUp(const Point2 &pos) {
+ std::cout << "Right mouse button UP at " << pos << std::endl;
+}
+
+
+void CircleViewer::OnKeyDown(const char *c, int modifiers) {
+ std::cout << "Key DOWN (" << c << ") modifiers=" << modifiers << std::endl;
+}
+
+void CircleViewer::OnKeyUp(const char *c, int modifiers) {
+ std::cout << "Key UP (" << c << ") modifiers=" << modifiers << std::endl;
+}
+
+
+void CircleViewer::OnSpecialKeyDown(int key, int scancode, int modifiers) {
+ std::cout << "Special Key DOWN key=" << key << " scancode=" << scancode << " modifiers=" << modifiers << std::endl;
+}
+
+void CircleViewer::OnSpecialKeyUp(int key, int scancode, int modifiers) {
+ std::cout << "Special Key UP key=" << key << " scancode=" << scancode << " modifiers=" << modifiers << std::endl;
+}
+
+
+void CircleViewer::DrawUsingNanoVG(NVGcontext *ctx) {
+ // example of drawing some circles
+
+ nvgBeginPath(ctx);
+ nvgCircle(ctx, 512+50.0*cos(simTime_), 350+200.0*sin(simTime_), 50);
+ nvgFillColor(ctx, nvgRGBA(100,100,255,200));
+ nvgFill(ctx);
+ nvgStrokeColor(ctx, nvgRGBA(0,0,0,255));
+ nvgStroke(ctx);
+
+ nvgBeginPath(ctx);
+ nvgCircle(ctx, 512+200.0*cos(simTime_), 350+50.0*sin(simTime_), 50);
+ nvgFillColor(ctx, nvgRGBA(255,100,100,200));
+ nvgFill(ctx);
+ nvgStrokeColor(ctx, nvgRGBA(0,0,0,255));
+ nvgStroke(ctx);
+}
+
+void CircleViewer::DrawUsingOpenGL() {
+
+}
+
|