PeriDyno 1.0.0
Loading...
Searching...
No Matches
GLVisualModule.h
Go to the documentation of this file.
1
16
17#pragma once
18
19#include <chrono>
20#include <mutex>
21#include <Module/VisualModule.h>
22
23#include <Color.h>
24#include <RenderParams.h>
25
26namespace dyno
27{
28 // render pass
30 {
31 const static int COLOR = 0; // common color pass(opacity)
32 const static int SHADOW = 1; // shadow map pass
33 const static int TRANSPARENCY = 2; // transparency pass
34 };
35
37 {
38 public:
40 ~GLVisualModule() override;
41
42 // basic Disney PBR material properties
43 void setColor(const Color& color);
44 void setMetallic(float metallic);
45 void setRoughness(float roughness);
46 void setAlpha(float alpha);
47
48 virtual bool isTransparent() const;
49
50 void draw(const RenderParams& rparams);
51
52 // Attention: that this method should be called within OpenGL context
53 void release();
54
55 public:
56 DEF_VAR(Color, BaseColor, Color(0.8f, 0.8f, 0.8f), "");
57 DEF_VAR(Real, Metallic, 0.0f, "");
58 DEF_VAR(Real, Roughness, 0.5f, "");
59 DEF_VAR(Real, Alpha, 1.0f, "");
60
61 protected:
62 // override methods from Module
63 virtual void updateImpl() override;
64
65 // we use preprocess and postprocess method for update lock and timestamp
66 virtual void preprocess() override final;
67 virtual void postprocess() override final;
68
69 bool validateInputs() override final;
70
71 protected:
72 // methods for create/update/release OpenGL rendering content
73 virtual bool initializeGL() = 0;
74 virtual void releaseGL() = 0;
75 virtual void updateGL() = 0;
76
77 virtual void paintGL(const RenderParams& rparams) = 0;
78
79 private:
80 bool isGLInitialized = false;
81
82 // mutex for sync data
83 std::mutex updateMutex;
84
85 using clock = std::chrono::high_resolution_clock;
86 // the timestamp when graphics context is changed by calling updateGraphicsContext
87 clock::time_point changed;
88 // the timestamp when GL resource is updated by updateGL
89 clock::time_point updated;
90 };
91};
double Real
Definition Typedef.inl:23
virtual bool initializeGL()=0
void setColor(const Color &color)
virtual void updateImpl() override
DEF_VAR(Real, Roughness, 0.5f, "")
void draw(const RenderParams &rparams)
void setAlpha(float alpha)
virtual bool isTransparent() const
bool validateInputs() override final
void setRoughness(float roughness)
virtual void paintGL(const RenderParams &rparams)=0
virtual void postprocess() override final
virtual void preprocess() override final
DEF_VAR(Real, Metallic, 0.0f, "")
virtual void releaseGL()=0
DEF_VAR(Real, Alpha, 1.0f, "")
clock::time_point updated
void setMetallic(float metallic)
virtual void updateGL()=0
DEF_VAR(Color, BaseColor, Color(0.8f, 0.8f, 0.8f), "")
std::chrono::high_resolution_clock clock
clock::time_point changed
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
static const int SHADOW
static const int COLOR
static const int TRANSPARENCY