Overte C++ Documentation
FramebufferCache.h
1 //
2 // Created by Bradley Austin Davis on 2015/07/20
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #ifndef hifi_FramebufferCache_h
10 #define hifi_FramebufferCache_h
11 
12 #include <QSize>
13 
14 #include <mutex>
15 #include <gpu/Forward.h>
16 #include <DependencyManager.h>
17 
19 class FramebufferCache : public Dependency {
20  SINGLETON_DEPENDENCY
21 
22 public:
23  // Shadow map size is static
24  static const int SHADOW_MAP_SIZE = 2048;
25 
27  void setFrameBufferSize(QSize frameBufferSize);
28  const QSize& getFrameBufferSize() const { return _frameBufferSize; }
29 
31  gpu::FramebufferPointer getFramebuffer();
32 
33  // TODO add sync functionality to the release, so we don't reuse a framebuffer being read from
35  void releaseFramebuffer(const gpu::FramebufferPointer& framebuffer);
36 
37 private:
38  void createPrimaryFramebuffer();
39 
40  gpu::FramebufferPointer _shadowFramebuffer;
41 
42  QSize _frameBufferSize{ 100, 100 };
43 
44  std::mutex _mutex;
45  std::list<gpu::FramebufferPointer> _cachedFramebuffers;
46 };
47 
48 #endif // hifi_FramebufferCache_h
Stores cached textures, including render-to-texture targets.
Definition: FramebufferCache.h:19
void releaseFramebuffer(const gpu::FramebufferPointer &framebuffer)
Releases a free framebuffer back for reuse.
Definition: FramebufferCache.cpp:48
gpu::FramebufferPointer getFramebuffer()
Returns a free framebuffer with a single color attachment for temp or intra-frame operations.
Definition: FramebufferCache.cpp:38
void setFrameBufferSize(QSize frameBufferSize)
Sets the desired texture resolution for the framebuffer objects.
Definition: FramebufferCache.cpp:20