Bubba-3D  0.9.0
Awesome game engine!
Renderer.h
1 /*
2  * This file is part of Bubba-3D.
3  *
4  * Bubba-3D is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Bubba-3D is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with Bubba-3D. If not, see http://www.gnu.org/licenses/.
16  */
17 #ifndef __RENDERER_H__
18 #define __RENDERER_H__
19 
20 #ifdef WIN32
21 #include <windows.h>
22 #endif
23 
24 #include "linmath/float4x4.h"
25 #include "Utils.h"
26 #include "Effects.h"
27 
28 #define CUBE_MAP_RESOLUTION 512
29 #define SHADOW_MAP_RESOLUTION 2048
30 
31 
32 class Camera;
33 class Scene;
34 class IDrawable;
35 
36 class Renderer {
37 public:
38  Renderer();
39  ~Renderer();
40 
41  void initGL();
42 
43  void drawScene(Camera *camera, Scene* scene, float currentTime);
44 
45  void swapBuffer();
46 
47  void resize(unsigned int width, unsigned int height);
48 
49  void initRenderer(int width, int height);
50 
51  Effects effects;
52 private:
53  float currentTime;
54 
55  Fbo createPostProcessFbo(int width, int height);
56  void drawShadowMap(Fbo sbo, chag::float4x4 viewProjectionMatrix, Scene *scene);
57  void drawShadowCasters(ShaderProgram* shaderProgram, Scene *scene);
58  void drawTransparent(ShaderProgram* shaderProgram, Scene *scene);
59  void setFog(ShaderProgram* shaderProgram);
60  void setLights(ShaderProgram* shaderProgram, Scene *scene);
61 
62  ShaderProgram* shaderProgram;
63 
64  Fbo sbo;
65  Camera *cubeMapCameras[6];
66 
67  // Drawing
68  void drawModel(IDrawable &model, ShaderProgram* shaderProgram);
69  void drawFullScreenQuad();
70  void renderPostProcess();
71  void blurImage();
72 
73  // Postprocess
74  ShaderProgram* postFxShader;
75  ShaderProgram* horizontalBlurShader;
76  ShaderProgram* verticalBlurShader;
77  ShaderProgram* cutoffShader;
78  Fbo postProcessFbo, horizontalBlurFbo, verticalBlurFbo, cutOffFbo;
79 };
80 
81 
82 #endif // __RENDERER_H__
Definition: Utils.h:29
Class for maintaining OpenGL shader programs.
Definition: ShaderProgram.h:39
Definition: Scene.h:29
Definition: Camera.h:26