Commit a935a12d authored by Philip Trettner's avatar Philip Trettner

Added basic camera handling to GlfwApp

parent c9a48655
......@@ -11,6 +11,7 @@ target_link_libraries(glow-extras-glfw PUBLIC
aion
AntTweakBar
fmt
glfw
glow-extras-timing
glow-extras-material
glow-extras-pipeline
......
This diff is collapsed.
......@@ -58,6 +58,7 @@ enum class CursorMode
*
* Notes:
* - if you use primitive/occlusion queries, use setQueryStats(false);
* - overwrite onResetView if you want a different default view
*
* Usage:
* int main(int argc, char *argv[])
......@@ -77,8 +78,8 @@ private:
GLFWwindow* mWindow = nullptr; ///< current GLFW window
TwBar* mTweakbar = nullptr; ///< main tweakbar window
int mWindowWidth = 640; ///< window width, only set before run!
int mWindowHeight = 480; ///< window height, only set before run!
int mWindowWidth = 1280; ///< window width, only set before run!
int mWindowHeight = 720; ///< window height, only set before run!
bool mDumpTimingsOnShutdown = true; ///< if true, dumps AION timings on shutdown
......@@ -94,7 +95,8 @@ private:
double mOutputStatsInterval = 5.0; ///< number of seconds between stats output (0.0 for never)
bool mQueryStats = true; ///< if true, queries stats (vertices, fragments, ...)
bool mUseDefaultRendering = true; ///< if true, uses default rendering pipeline setup
bool mUseDefaultRendering = true; ///< if true, uses default rendering pipeline setup
bool mUseDefaultCameraHandling = true; ///< if true, implements default cam handling
double mCurrentTime = 0.0; ///< current frame time (starts with 0)
......@@ -105,8 +107,21 @@ private:
SharedPrimitiveQuery mPrimitiveQuery; ///< nr of primitives per frame
SharedOcclusionQuery mOcclusionQuery; ///< nr of pixels per frame
SharedTimerQuery mRenderStartQuery; ///< start timestamp
SharedTimerQuery mRenderEndQuery; ///< end timestamp
SharedTimerQuery mRenderStartQuery; ///< start timestamp
SharedTimerQuery mRenderEndQuery; ///< end timestamp
// Camera handling
private:
bool mMouseLeft = false;
bool mMouseRight = false;
float mCameraMoveSpeed = 15.0f; ///< in units/s
float mCameraMoveSpeedFactor = 5.0f; ///< factor of move speed if shift is pressed
float mCameraTurnSpeed = 5.0f; ///< in radians/total screen
float mCameraScrollSpeed = 5.0f; ///< in % per scroll
double mMouseLastX = -1.0;
double mMouseLastY = -1.0;
public:
GLOW_PROPERTY(UpdateRate);
......@@ -126,14 +141,20 @@ public:
GLOW_GETTER(Camera);
GLOW_GETTER(Pipeline);
GLOW_PROPERTY(UseDefaultCameraHandling);
GLOW_PROPERTY(CameraMoveSpeed);
GLOW_PROPERTY(CameraTurnSpeed);
GLOW_PROPERTY(CameraScrollSpeed);
void setTitle(std::string const& title);
glm::vec2 getMousePosition() const { return {mMouseX, mMouseY}; }
GLFWwindow* window() const { return mWindow; }
TwBar* tweakbar() const { return mTweakbar; }
public:
/// sets the current clipboard content
void setClipboardString(std::string const& s);
void setClipboardString(std::string const& s) const;
/// gets the current clipboard content
std::string getClipboardString() const;
......@@ -172,6 +193,9 @@ protected:
/// Called whenever files are dropped (drag'n'drop), parameters is file paths
virtual bool onFileDrop(std::vector<std::string> const& files);
/// Called when view should be reset
virtual void onResetView();
public:
/// Initializes GLFW and GLOW, and runs until window is closed
int run(int argc, char* argv[]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment