PeriDyno 1.2.1
Loading...
Searching...
No Matches
GlfwRenderWindow.h
Go to the documentation of this file.
1#pragma once
2
3#include <Platform.h>
4#include <ImWindow.h>
5
6#include "RenderWindow.h"
7
8struct GLFWwindow;
9namespace dyno {
10
11 class Camera;
12 class Node;
13 struct Picture;
14
16 {
19 };
20
22 {
23 public:
24 GlfwRenderWindow(int argc = 0, char **argv = NULL);
26
27 void initialize(int width, int height) override;
28
29 void mainLoop() override;
30
31 const std::string& name() const;
32
33 void setWindowTitle(const std::string& title);
34
35 void setCursorPos(double x, double y);
36 double getCursorPosX();
37 double getCursorPosY();
38
39 void setButtonType(uint button) { mButtonType = button; }
40 void setButtonMode(uint mode) { mButtonMode = mode; }
41 void setButtonAction(uint action) { mButtonAction = action; }
42 void setButtonState(ButtonState state) { mButtonState = state; }
43
44 void setDefaultAnimationOption(bool op) override { mAnimationToggle = op; }
45
46 uint getButtonType() const { return mButtonType; }
50
51 void turnOnVSync();
52 void turnOffVSync();
53
54 void toggleAnimation();
55
56 int getWidth();
57 int getHeight();
58
59 // ImGui extend function
60 // 全局样式设定
61 void initializeStyle();
62
63 ImWindow* imWindow() { return &mImWindow; }
64
65 protected:
66 void initCallbacks(); //init default callbacks
67
68 void drawScene(void);
69
70 static void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
71 static void keyboardCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
72 static void reshapeCallback(GLFWwindow* window, int w, int h);
73 static void cursorPosCallback(GLFWwindow* window, double x, double y);
74 static void cursorEnterCallback(GLFWwindow* window, int entered);
75 static void scrollCallback(GLFWwindow* window, double offsetX, double OffsetY);
76
77 //save screenshot to file
78 void onSaveScreen(const std::string& filename) override; //save to file with given name
79
80 private:
81 //pointers to callback methods
82 void(*mMouseButtonFunc)(GLFWwindow* window, int button, int action, int mods);
83 void(*mKeyboardFunc)(GLFWwindow* window, int key, int scancode, int action, int mods);
84 void(*mReshapeFunc)(GLFWwindow* window, int w, int h);
85 void(*mCursorPosFunc)(GLFWwindow* window, double x, double y);
86 void(*mCursorEnterFunc)(GLFWwindow* window, int entered);
87 void(*mScrollFunc)(GLFWwindow* window, double offsetX, double OffsetY);
88
89 GLFWwindow* mWindow = nullptr;
90
91 //state of the mouse
96
97 int mPlaneSize = 4;
98
101
102 bool mAnimationToggle = false;
103
104 bool mBackgroundToggle = true;
105 bool mBoundingboxToggle = false;
106
107 double mCursorTempX = -1.0;
108
109 std::string mWindowTitle;
110
111 private:
113 };
114
115}
void(* mCursorPosFunc)(GLFWwindow *window, double x, double y)
void setCursorPos(double x, double y)
void setWindowTitle(const std::string &title)
void setDefaultAnimationOption(bool op) override
void(* mScrollFunc)(GLFWwindow *window, double offsetX, double OffsetY)
void setButtonState(ButtonState state)
void initialize(int width, int height) override
static void scrollCallback(GLFWwindow *window, double offsetX, double OffsetY)
void onSaveScreen(const std::string &filename) override
static void keyboardCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
static void reshapeCallback(GLFWwindow *window, int w, int h)
GlfwRenderWindow(int argc=0, char **argv=NULL)
const std::string & name() const
void setButtonAction(uint action)
void(* mReshapeFunc)(GLFWwindow *window, int w, int h)
ButtonState getButtonState() const
void setButtonType(uint button)
void(* mKeyboardFunc)(GLFWwindow *window, int key, int scancode, int action, int mods)
static void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
static void cursorPosCallback(GLFWwindow *window, double x, double y)
static void cursorEnterCallback(GLFWwindow *window, int entered)
void(* mCursorEnterFunc)(GLFWwindow *window, int entered)
void(* mMouseButtonFunc)(GLFWwindow *window, int button, int action, int mods)
void setButtonMode(uint mode)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
unsigned int uint
Definition VkProgram.h:14