OpenStructure
scene_fx.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_SCENE_FX_HH
20 #define OST_SCENE_FX_HH
21 
22 #include <ost/gfx/gl_helper.hh>
23 #include <ost/geom/geom.hh>
24 
25 /*
26  low level code for scene shading effects
27 
28  Author: Ansgar Philippsen
29 */
30 
31 namespace ost { namespace gfx {
32 
33 class Scene;
34 
35 namespace impl {
36 
37 struct Beacon {
38  float wx, wy;
41 };
42 
43 class SceneFX {
44  friend class ::ost::gfx::Scene;
45 public:
47  static SceneFX& Instance();
48 
49  void Setup();
50 
51  void Resize(unsigned int w, unsigned int h);
52 
53  void Preprocess();
54  // assumes scene has been drawn in the active framebuffer
55  void Postprocess();
56 
57  // returns true if the post-processing will run
58  bool WillPostprocess() const;
59 
60  void DrawTex(unsigned int w, unsigned int h, GLuint texid);
61 
72  bool use_beacon;
74 
75 private:
76  SceneFX();
77  SceneFX(const SceneFX&) {}
78  SceneFX& operator=(const SceneFX&) {return *this;}
79 
80  void screenblur4();
81  void prep_shadow_map();
82  void prep_depth_darkening();
83  void prep_amb_occlusion();
84  void draw_screen_quad(uint w, uint h);
85  void prep_beacon();
86  void draw_beacon();
87 
88  GLuint scene_tex_id_;
89  GLuint depth_tex_id_;
90  GLuint shadow_tex_id_;
91  geom::Mat4 shadow_tex_mat_;
92  GLuint occl_tex_id_;
93  GLuint dark_tex_id_;
94  GLuint norm_tex_id_;
95  GLuint kernel_tex_id_;
96  uint kernel_size_;
97  GLuint kernel2_tex_id_;
98  uint kernel2_size_;
99 
100  GLuint scene_tex2_id_;
101  GLuint norm_tex2_id_;
102  GLuint scene_fb_;
103  GLuint scene_rb_;
104  GLuint depth_rb_;
105 
106  bool use_fb_;
107 };
108 
109 }}} // ns
110 
111 #endif
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
void Resize(unsigned int w, unsigned int h)
void DrawTex(unsigned int w, unsigned int h, GLuint texid)
static SceneFX & Instance()
bool WillPostprocess() const
unsigned int uint
Definition: base.hh:29
Definition: base.dox:1