PeriDyno 1.2.1
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
22#include <Field/Color.h>
23#include <Module/VisualModule.h>
24
25#include <RenderParams.h>
26
27namespace dyno
28{
29 // render pass
31 {
32 const static int COLOR = 0; // common color pass(opacity)
33 const static int SHADOW = 1; // shadow map pass
34 const static int TRANSPARENCY = 2; // transparency pass
35 };
36
38 {
39 public:
41 ~GLVisualModule() override;
42
43 // basic Disney PBR material properties
44 void setColor(const Color& color);
45 void setMetallic(float metallic);
46 void setRoughness(float roughness);
47 void setAlpha(float alpha);
48
49 virtual bool isTransparent() const;
50
51 void draw(const RenderParams& rparams);
52
53 // Attention: that this method should be called within OpenGL context
54 void release();
55
56 public:
57 DEF_VAR(Color, BaseColor, Color(0.8f, 0.8f, 0.8f), "");
58 DEF_VAR(Real, Metallic, 0.0f, "");
59 DEF_VAR(Real, Roughness, 0.5f, "");
60 DEF_VAR(Real, Alpha, 1.0f, "");
61
62 protected:
63 // override methods from Module
64 virtual void updateImpl() override;
65
66 // we use preprocess and postprocess method for update lock and timestamp
67 virtual void preprocess() override final;
68 virtual void postprocess() override final;
69
70 bool validateInputs() override final;
71
72 protected:
73 // methods for create/update/release OpenGL rendering content
74 virtual bool initializeGL() = 0;
75 virtual void releaseGL() = 0;
76 virtual void updateGL() = 0;
77
78 virtual void paintGL(const RenderParams& rparams) = 0;
79
80 private:
81 bool isGLInitialized = false;
82
83 // mutex for sync data
85
86 using clock = std::chrono::high_resolution_clock;
87 // the timestamp when graphics context is changed by calling updateGraphicsContext
88 clock::time_point changed;
89 // the timestamp when GL resource is updated by updateGL
90 clock::time_point updated;
91 };
92};
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
Definition guid.cpp:136
static const int SHADOW
static const int COLOR
static const int TRANSPARENCY