Fillwave  10.0.0
Debugger.h
1 #pragma once
2 
3 /*
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2018 Filip Wasil and Fillwave community members
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
12  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <flw/flc/buffers/mVertexBufferDebug.h>
25 #include <flw/flf/models/base/IReloadable.h>
26 #include <flw/cmn/scene/ICamera.h>
27 
28 namespace flw {
29 namespace flc {
30 class FramebufferGeometry;
31 }
32 
33 enum class EDebuggerState {
34  lightsSpot
35  , lightsSpotColor
36  , lightsSpotDepth
37  , lightsPoint
38  , lightsPointDepth
39  , lightsPointColor
40  , pickingMap
41  , off
42  , toggleState
43 };
44 
45 class Engine;
46 
47 namespace flf {
48 class Camera;
49 
60 class Debugger : public IReloadable {
61 public:
62  Debugger(Engine* engine, GLsizei howManyDebugWindows = 6);
63  ~Debugger() override;
64 
65  /* State */
66  void setState(EDebuggerState state);
67  EDebuggerState getState();
68 
69  /* Render */
70  void prepareDebugWindow(GLint id = 0);
71  void renderFromCamera(ICamera &c, GLint id = 0);
72  void renderDepthPerspective(GLint id = 0);
73  void renderDepthOrthographic(GLint id = 0);
74  void renderPickingMap();
75  void renderGeometryBuffer(GLuint width, GLuint height, GLuint attachments, flc::FramebufferGeometry *buffer);
76 
77 private:
78  struct DebugWindowInfo {
79  glm::ivec2 size;
80  glm::ivec2 offset;
81  };
82 
83  std::vector<DebugWindowInfo> mDebugWindows;
84 
85  EDebuggerState mState;
86  flc::Program* mProgram;
87  Engine* mEngine;
88 
90 
91  GLuint mDebugWindowsSize;
92  GLuint mMiniwindowsOccupied;
93 
94  GLint mULCTextureUnit, mULCNearPlane, mULCFarPlane;
95 
96  void initBuffers() override;
97 
98  void initPipeline() override;
99 
100  void initVBO() override;
101 
102  void initVAO() override;
103 
104  void initUniformsCache() override;
105 };
106 
107 } /* flf */
108 } /* flw */
Definition: Aliases.h:30
Encapsulates reloadable objects.
Definition: IReloadable.h:35
Framebuffer with multiple color and depth attachments.
Definition: FramebufferGeometry.h:39
Fillwave engine core.
Definition: Engine.h:85
Vertex buffer specialized with VertexDebug data structure.
Definition: mVertexBufferDebug.h:42
Single GLSL program object.
Definition: Program.h:37
Fillwave debugger.
Definition: Debugger.h:60
Stores camera view parameters.
Definition: ICamera.h:32