GlobeEngine
DebugMapProvider.h
Go to the documentation of this file.
1 //This class should only be used in ExoEngine.cpp (provides the debug map funcitonalities for this class)
2 #ifndef GlobeEngine_DebugMapProvider_h
3 #define GlobeEngine_DebugMapProvider_h
4 
5 #include "DebugMap.h"
6 #include "Shader.h"
7 #include "ArcBallCamera.h"
8 #include "FrameBufferObject.h"
9 
10 namespace geUtil {
12  {
13  public:
15 
16  void clear(){
17  debugmap_orbitColor.clear();
18  debugmap_orbitColor.isVisible(false);
19  debugmap_orbitDepth.clear();
20  debugmap_orbitIDs.clear();
21  debugmap_bodiesColor.clear();
22  debugmap_bodiesDepth.clear();
23  debugmap_bodiesIDs.clear();
24  debugmap_bodiesNormals.clear();
25  }
26 
27  void setUpMaps(std::string shaderPath, std::shared_ptr<ge::ArcBallCamera> camera){
28  std::shared_ptr<ge::Shader> programForDebug = std::make_shared<ge::Shader>();
29  programForDebug->load(shaderPath, "debug/debug", ge::Shader::VERTEX_FRAGMENT);
30 
31  bool vis = debugmap_orbitColor.isVisible();
32 
33  clear();
34 
35  int margin = 6;
36 
37  //vmml::Vector2d map_size = vmml::Vector2d((camera->getViewport().x() / 3.0) - (1.0 / 2.0)*margin, (int)(camera->getViewport().y() / 3.0) - (1.0 / 2.0)*margin);
38  vmml::Vector2d map_size = vmml::Vector2d((camera->getViewport().x() / 2.0) - (1.0 / 2.0)*margin, (int)(camera->getViewport().y() / 2.0) - (1.0 / 2.0)*margin);
39 
40  //debugmap_orbitColor.create(programForDebug, vmml::Vector2f(0.0f, 0.0f));
41  //debugmap_orbitColor.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
42  //debugmap_orbitColor.setViewport(map_size);
43  //debugmap_orbitColor.setLayer(0);
44  //debugmap_orbitColor.isVisible(vis); //set debug map to visible
45 
46  //debugmap_orbitDepth.create(programForDebug, vmml::Vector2f(camera->getViewport().x() / 3.0 + margin, 0.0f));
47  //debugmap_orbitDepth.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
48  //debugmap_orbitDepth.setViewport(map_size);
49  //debugmap_orbitDepth.setLayer(1);
50  //debugmap_orbitDepth.isVisible(vis); //set debug map to visible
51 
52  //debugmap_orbitIDs.create(programForDebug, vmml::Vector2f((camera->getViewport().x() / 3.0) * 2 + margin, 0.0f));
53  debugmap_orbitIDs.create(programForDebug, vmml::Vector2f(0.0f, 0.0f));
54  debugmap_orbitIDs.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
55  debugmap_orbitIDs.setViewport(map_size);
56  debugmap_orbitIDs.isVisible(vis); //set debug map to visible
57 
58  //debugmap_bodiesColor.create(programForDebug, vmml::Vector2f(0.0f, camera->getViewport().y() / 3.0 + margin));
59  debugmap_bodiesColor.create(programForDebug, vmml::Vector2f(0.0f, camera->getViewport().y() / 2.0 + margin));
60  debugmap_bodiesColor.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
61  debugmap_bodiesColor.setViewport(map_size);
62  debugmap_bodiesColor.isVisible(vis); //set debug map to visible
63 
64  //debugmap_bodiesDepth.create(programForDebug, vmml::Vector2f(camera->getViewport().x() / 3.0 + margin, camera->getViewport().y() / 3.0 + margin));
65  //debugmap_bodiesDepth.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
66  //debugmap_bodiesDepth.setViewport(map_size);
67  //debugmap_bodiesDepth.setLayer(1);
68  //debugmap_bodiesDepth.isVisible(vis); //set debug map to visible
69 
70  //debugmap_bodiesIDs.create(programForDebug, vmml::Vector2f((camera->getViewport().x() / 3.0) * 2 + margin, camera->getViewport().y() / 3.0 + margin));
71  debugmap_bodiesIDs.create(programForDebug, vmml::Vector2f((camera->getViewport().x() / 2.0) + margin, camera->getViewport().y() / 2.0 + margin));
72  debugmap_bodiesIDs.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
73  debugmap_bodiesIDs.setViewport(map_size);
74  debugmap_bodiesIDs.isVisible(vis); //set debug map to visible
75 
76  //debugmap_bodiesNormals.create(programForDebug, vmml::Vector2f(0.0f, (camera->getViewport().y() / 3.0) * 2 + margin));
77  debugmap_bodiesNormals.create(programForDebug, vmml::Vector2f((camera->getViewport().x() / 2.0) + margin, 0.0f));
78  debugmap_bodiesNormals.setProjectionMatrix(camera->createOrthoProjectionMatrix(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
79  debugmap_bodiesNormals.setViewport(map_size);
80  debugmap_bodiesNormals.isVisible(vis); //set debug map to visible
81  }
82 
83  //void draw(std::shared_ptr<ge::ArcBallCamera> camera, ge::FrameBufferObject* orbitsFbo, ge::FrameBufferObject* bodiesFbo, ge::FrameBufferObject* habZonesFbo){
84  // if (debugmap_orbitColor.isVisible()){
85  // //debugmap_orbitColor.draw(camera, orbitsFbo->getColorHandle(0), 0);
86  // //debugmap_orbitDepth.draw(camera, orbitsFbo->getDepthHandle(), 0);
87  // debugmap_orbitIDs.draw(camera, orbitsFbo->getColorTexture(2)->getHandle(), 0);
88  // debugmap_bodiesColor.draw(camera, bodiesFbo->getColorTexture(0)->getHandle(), 0);
89  // //debugmap_bodiesDepth.draw(camera, bodiesFbo->getDepthHandle(), 0);
90  // debugmap_bodiesIDs.draw(camera, bodiesFbo->getColorTexture(2)->getHandle(), 0);
91  // debugmap_bodiesNormals.draw(camera, bodiesFbo->getColorTexture(3)->getHandle(), 0); //other buffer than in name
92  // }
93  //}
94 
95  void draw(std::shared_ptr<ge::ArcBallCamera> camera, ge::FrameBufferObject* fbo1, ge::FrameBufferObject* fbo2, ge::FrameBufferObject* fbo3){
96  if (debugmap_orbitColor.isVisible()){
97  //debugmap_orbitColor.draw(camera, orbitsFbo->getColorHandle(0), 0);
98  //debugmap_orbitDepth.draw(camera, orbitsFbo->getDepthHandle(), 0);
99  debugmap_orbitIDs.draw(camera, fbo1->getColorTexture(0)->getHandle(), 0);
100  debugmap_bodiesColor.draw(camera, fbo1->getColorTexture(3)->getHandle(), 0);
101  //debugmap_bodiesDepth.draw(camera, bodiesFbo->getDepthHandle(), 0);
102  debugmap_bodiesIDs.draw(camera, fbo3->getColorTexture(0)->getHandle(), 0);
103  debugmap_bodiesNormals.draw(camera, fbo3->getColorTexture(1)->getHandle(), 0); //other buffer than in name
104  }
105  }
106 
108  debugmap_orbitColor.isVisible(!debugmap_orbitColor.isVisible());
109  }
110 
111  //void reloadShader(std::shared_ptr<ge::Shader> programForDebug, std::string shaderPath){
112  // std::shared_ptr<ge::Shader> ring = std::make_shared<ge::Shader>();
113  // programForDebug->load(shaderPath, "debug/debug", ge::Shader::VERTEX_FRAGMENT);
114  //}
115 
116  private:
117  DebugMap debugmap_orbitDepth;
118  DebugMap debugmap_bodiesDepth;
119  DebugMap debugmap_orbitColor;
120  DebugMap debugmap_bodiesColor;
121  DebugMap debugmap_orbitIDs;
122  DebugMap debugmap_bodiesIDs;
123  DebugMap debugmap_bodiesNormals;
124 
125  GLuint testHandle;
126 
127  };
128 }
129 #endif
void create()
Definition: DebugMap.h:22
bool isVisible() const
Definition: DrawableComponent.cpp:143
void setUpMaps(std::string shaderPath, std::shared_ptr< ge::ArcBallCamera > camera)
Definition: DebugMapProvider.h:27
typedef int(CALL_CONVENTION *func_type_com_asprise_ocr_setup)(bool)
void setProjectionMatrix(vmml::Matrix4d _mat)
Definition: DebugMap.cpp:98
Definition: DebugMap.h:18
DebugMapProvider()
Definition: DebugMapProvider.h:14
Definition: FrameBufferObject.h:20
void clear()
Definition: DebugMapProvider.h:16
void toggleVisibility()
Definition: DebugMapProvider.h:107
void draw(std::shared_ptr< ge::Camera > _cam, GLint _unit)
Definition: DebugMap.cpp:56
const std::shared_ptr< TextureHandle > getColorTexture(GLint _index) const
Definition: FrameBufferObject.cpp:205
void draw(std::shared_ptr< ge::ArcBallCamera > camera, ge::FrameBufferObject *fbo1, ge::FrameBufferObject *fbo2, ge::FrameBufferObject *fbo3)
Definition: DebugMapProvider.h:95
Definition: Shader.h:28
void setViewport(vmml::Vector2d _viewport)
Definition: DebugMap.cpp:103
Definition: DebugLogger.h:14
Definition: DebugMapProvider.h:11
void clear()
Definition: DebugMap.cpp:4