Ocular Engine
GraphicsDriver.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_GRAPHICS_DRIVER__H__
19 #define __H__OCULAR_GRAPHICS_DRIVER__H__
20 
21 #include "Graphics/Texture/RenderTexture.hpp"
22 #include "Graphics/Texture/DepthTexture.hpp"
23 
24 #include "Graphics/Shader/VertexShader.hpp"
25 #include "Graphics/Shader/GeometryShader.hpp"
26 #include "Graphics/Shader/FragmentShader.hpp"
27 #include "Graphics/Shader/PreTessellationShader.hpp"
28 #include "Graphics/Shader/PostTessellationShader.hpp"
29 #include "Graphics/Shader/Buffer/GPUBuffer.hpp"
30 
31 #include "Graphics/RenderState/RenderState.hpp"
32 
33 #include "Graphics/Material/Material.hpp"
34 #include "Graphics/Mesh/Mesh.hpp"
35 #include "Graphics/Viewport.hpp"
36 
37 #include "Graphics/FrameStats.hpp"
38 #include "Graphics/DebugGraphics/DebugGraphics.hpp"
39 
40 #include "Scene/SceneObject.hpp"
41 
42 //------------------------------------------------------------------------------------------
43 
48 namespace Ocular
49 {
54  namespace Graphics
55  {
60  {
61  public:
62 
64  virtual ~GraphicsDriver();
65 
70  virtual bool initialize();
71 
81  virtual void clearBuffers(Core::Color const& clearColor = Core::Color::DefaultClearGray());
82 
87  virtual void clearDepthBuffer(float value = 1.0f);
88 
93  virtual void clearStencilBuffer(uint32_t value = 0);
94 
98  virtual void swapBuffers();
99 
106  virtual RenderState* getRenderState();
107 
112  virtual void setRenderTexture(RenderTexture* texture);
113 
118  virtual void setDepthTexture(DepthTexture* texture);
119 
120  //------------------------------------------------------------------------------
121  // Creation Methods
122  //------------------------------------------------------------------------------
123 
131  virtual Material* createMaterial() const;
132 
136  virtual Viewport* createViewport(float x, float y, float width, float height, float minDepth = 0.0f, float maxDepth = 1.0f) const;
137 
138  //------------------------------------------------------------------------------
139  // Textures
140 
149  virtual Texture* createTexture(TextureDescriptor const& descriptor) const;
150 
159  virtual Texture2D* createTexture2D(TextureDescriptor const& descriptor) const;
160 
170  virtual RenderTexture* createRenderTexture(TextureDescriptor const& descriptor) const;
171 
180  virtual DepthTexture* createDepthTexture(TextureDescriptor const& descriptor) const;
181 
187  virtual uint32_t getMaxBoundTextures() const;
188 
189  //------------------------------------------------------------------------------
190  // Shaders
191 
199  virtual VertexShader* createVertexShader() const;
200 
208  virtual GeometryShader* createGeometryShader() const;
209 
217  virtual FragmentShader* createFragmentShader() const;
218 
227 
236 
244  virtual UniformBuffer* createUniformBuffer(UniformBufferType type) const;
245 
246  //------------------------------------------------------------------------------
247  // Meshes
248 
256  virtual IndexBuffer* createIndexBuffer() const;
257 
265  virtual VertexBuffer* createVertexBuffer() const;
266 
267  //------------------------------------------------------------------------------
268  // Buffers
269 
278  virtual GPUBuffer* createGPUBuffer(GPUBufferDescriptor const& descriptor) const;
279 
280  //------------------------------------------------------------------------------
281  // Debug Draw Methods
282  //------------------------------------------------------------------------------
283 
292  virtual void drawDebugLine(Math::Vector3f const& start, Math::Vector3f const& stop, Core::Color const& color, uint64_t lifetime = 30000);
293 
304  virtual void drawDebugCircle(Math::Vector3f const& center, float radius, Math::Vector3f const& normal, Core::Color const& color, uint32_t segments = 64, uint64_t lifetime = 30000);
305 
309  virtual void renderDebug();
310 
319  virtual bool renderMesh(Mesh* mesh, uint32_t submesh = 0);
320 
327  virtual bool renderBounds(Core::SceneObject* object, Math::BoundsType type);
328 
329  //------------------------------------------------------------------------------
330  // Frame Info
331  //------------------------------------------------------------------------------
332 
336  void clearFrameStats();
337 
342 
343  protected:
344 
348  void addDrawCall(uint32_t numIndices);
349 
350  //------------------------------------------------------------
351 
352  FrameStats m_LastFrameStats;
353  FrameStats m_CurrFrameStats;
354 
355  Debug m_Debug;
356 
357  RenderState* m_RenderState;
358 
359  private:
360  };
361  }
365 }
370 //------------------------------------------------------------------------------------------
371 
372 #endif
virtual Material * createMaterial() const
Definition: GraphicsDriver.cpp:89
virtual FragmentShader * createFragmentShader() const
Definition: GraphicsDriver.cpp:163
Definition: VertexBuffer.hpp:78
virtual VertexBuffer * createVertexBuffer() const
Definition: GraphicsDriver.cpp:192
virtual void clearBuffers(Core::Color const &clearColor=Core::Color::DefaultClearGray())
Definition: GraphicsDriver.cpp:54
Definition: Texture2D.hpp:45
Definition: FragmentShader.hpp:40
Definition: VertexShader.hpp:40
virtual void drawDebugCircle(Math::Vector3f const &center, float radius, Math::Vector3f const &normal, Core::Color const &color, uint32_t segments=64, uint64_t lifetime=30000)
Definition: GraphicsDriver.cpp:211
A special texture that stores high precision depth information for each pixel.
Definition: DepthTexture.hpp:41
virtual bool initialize()
Definition: GraphicsDriver.cpp:49
A special texture that can be rendered directly to.
Definition: RenderTexture.hpp:41
virtual void setDepthTexture(DepthTexture *texture)
Definition: GraphicsDriver.cpp:84
virtual VertexShader * createVertexShader() const
Definition: GraphicsDriver.cpp:153
FrameStats getLastFrameStats() const
Definition: GraphicsDriver.cpp:247
virtual GeometryShader * createGeometryShader() const
Definition: GraphicsDriver.cpp:158
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: PreTessellationShader.hpp:40
virtual DepthTexture * createDepthTexture(TextureDescriptor const &descriptor) const
Definition: GraphicsDriver.cpp:139
Definition: Color.hpp:40
virtual void swapBuffers()
Definition: GraphicsDriver.cpp:69
virtual bool renderBounds(Core::SceneObject *object, Math::BoundsType type)
Definition: GraphicsDriver.cpp:230
Combination of a VertexBuffer and IndexBuffer.
Definition: Mesh.hpp:49
Definition: RenderState.hpp:42
Definition: TextureDescriptor.hpp:45
Draws debug graphics such as lines, points, bounding volumes, axis, etc.
Definition: DebugGraphics.hpp:61
virtual void drawDebugLine(Math::Vector3f const &start, Math::Vector3f const &stop, Core::Color const &color, uint64_t lifetime=30000)
Definition: GraphicsDriver.cpp:206
void addDrawCall(uint32_t numIndices)
Definition: GraphicsDriver.cpp:256
static Color const & DefaultClearGray()
Definition: Color.cpp:173
virtual PostTessellationShader * createPostTessellationShader() const
Definition: GraphicsDriver.cpp:173
virtual void clearDepthBuffer(float value=1.0f)
Definition: GraphicsDriver.cpp:59
virtual GPUBuffer * createGPUBuffer(GPUBufferDescriptor const &descriptor) const
Definition: GraphicsDriver.cpp:197
A generic buffer that can be uploaded to the GPU.
Definition: GPUBuffer.hpp:81
Definition: SceneObject.hpp:93
virtual RenderTexture * createRenderTexture(TextureDescriptor const &descriptor) const
Definition: GraphicsDriver.cpp:134
Definition: GPUBuffer.hpp:62
virtual IndexBuffer * createIndexBuffer() const
Definition: GraphicsDriver.cpp:187
virtual uint32_t getMaxBoundTextures() const
Definition: GraphicsDriver.cpp:144
Definition: IndexBuffer.hpp:77
Definition: PostTessellationShader.hpp:40
void clearFrameStats()
Definition: GraphicsDriver.cpp:239
virtual void clearStencilBuffer(uint32_t value=0)
Definition: GraphicsDriver.cpp:64
Definition: FrameStats.hpp:37
Definition: Viewport.hpp:40
virtual void setRenderTexture(RenderTexture *texture)
Definition: GraphicsDriver.cpp:79
virtual Texture * createTexture(TextureDescriptor const &descriptor) const
Definition: GraphicsDriver.cpp:103
virtual bool renderMesh(Mesh *mesh, uint32_t submesh=0)
Definition: GraphicsDriver.cpp:225
Generic buffer for storing and binding of shader uniforms.
Definition: UniformBuffer.hpp:73
virtual PreTessellationShader * createPreTessellationShader() const
Definition: GraphicsDriver.cpp:168
virtual Texture2D * createTexture2D(TextureDescriptor const &descriptor) const
Definition: GraphicsDriver.cpp:129
virtual RenderState * getRenderState()
Definition: GraphicsDriver.cpp:74
Definition: GeometryShader.hpp:40
virtual void renderDebug()
Definition: GraphicsDriver.cpp:216
Definition: Material.hpp:62
Base class for all texture objects.
Definition: Texture.hpp:45
virtual UniformBuffer * createUniformBuffer(UniformBufferType type) const
Definition: GraphicsDriver.cpp:178
Definition: GraphicsDriver.hpp:59