Blue Brain BioExplorer
FrameBuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  *
4  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
5  * scientific data from visualization
6  *
7  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License version 3.0 as published
11  * by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #pragma once
24 
29 
30 namespace core
31 {
38 class FrameBuffer : public BaseObject
39 {
40 public:
50  PLATFORM_API FrameBuffer(const std::string& name, const Vector2ui& frameSize, FrameBufferFormat frameBufferFormat);
51 
56  PLATFORM_API virtual void map() = 0;
57 
63  PLATFORM_API virtual void unmap() = 0;
64 
70  PLATFORM_API virtual const uint8_t* getColorBuffer() const = 0;
71 
77  PLATFORM_API virtual const float* getFloatBuffer() const = 0;
78 
84  PLATFORM_API virtual void resize(const Vector2ui& frameSize) = 0;
85 
90  PLATFORM_API virtual void clear() { _accumFrames = 0; }
91 
97  PLATFORM_API virtual Vector2ui getSize() const { return _frameSize; }
98 
104  PLATFORM_API virtual void setAccumulation(const bool accumulation) { _accumulation = accumulation; }
105 
111  PLATFORM_API virtual void setFormat(FrameBufferFormat frameBufferFormat) { _frameBufferFormat = frameBufferFormat; }
112 
118  PLATFORM_API virtual void setSubsampling(const size_t) {}
119 
125  PLATFORM_API virtual void createPixelOp(const std::string& /*name*/){};
126 
132  PLATFORM_API virtual void updatePixelOp(const PropertyMap& /*properties*/){};
133 
139  PLATFORM_API size_t getColorDepth() const;
140 
146  PLATFORM_API const Vector2ui& getFrameSize() const { return _frameSize; }
147 
153  PLATFORM_API bool getAccumulation() const { return _accumulation; }
154 
161 
167  PLATFORM_API const std::string& getName() const { return _name; }
168 
174 
180  PLATFORM_API size_t numAccumFrames() const { return _accumFrames; }
181 
188 
194  PLATFORM_API void setAccumulationType(const AccumulationType accumulationType)
195  {
196  _accumulationType = accumulationType;
197  }
198 
205 
206 protected:
207  const std::string _name;
210  bool _accumulation{true};
212  std::atomic_size_t _accumFrames{0};
213 };
214 } // namespace core
#define PLATFORM_API
Definition: Api.h:37
This class represents a frame buffer for an engine specific code. It provides an API for utilizing an...
Definition: FrameBuffer.h:39
PLATFORM_API const std::string & getName() const
Get the Name object.
Definition: FrameBuffer.h:167
Vector2ui _frameSize
Definition: FrameBuffer.h:208
virtual PLATFORM_API void createPixelOp(const std::string &)
Create and set a pixelop (pre/post filter) on the framebuffer.
Definition: FrameBuffer.h:125
AccumulationType _accumulationType
Definition: FrameBuffer.h:211
virtual PLATFORM_API void setSubsampling(const size_t)
Set a new subsampling with a factor from 1 to x of the current size.
Definition: FrameBuffer.h:118
const std::string _name
Definition: FrameBuffer.h:207
PLATFORM_API bool getAccumulation() const
Get the Accumulation object.
Definition: FrameBuffer.h:153
std::atomic_size_t _accumFrames
Definition: FrameBuffer.h:212
virtual PLATFORM_API void setFormat(FrameBufferFormat frameBufferFormat)
Set a new framebuffer format.
Definition: FrameBuffer.h:111
PLATFORM_API const Vector2ui & getFrameSize() const
Get the Frame Size object.
Definition: FrameBuffer.h:146
virtual PLATFORM_API void setAccumulation(const bool accumulation)
Enable/disable accumulation state on the framebuffer.
Definition: FrameBuffer.h:104
PLATFORM_API FrameBufferFormat getFrameBufferFormat() const
Get the Frame Buffer Format object.
Definition: FrameBuffer.h:160
virtual PLATFORM_API const uint8_t * getColorBuffer() const =0
Get the Color Buffer object.
PLATFORM_API FrameBuffer(const std::string &name, const Vector2ui &frameSize, FrameBufferFormat frameBufferFormat)
FrameBuffer constructor.
Definition: FrameBuffer.cpp:27
virtual PLATFORM_API void updatePixelOp(const PropertyMap &)
Update the current pixelop with the given properties.
Definition: FrameBuffer.h:132
virtual PLATFORM_API void clear()
Clear the framebuffer.
Definition: FrameBuffer.h:90
PLATFORM_API void setAccumulationType(const AccumulationType accumulationType)
Set the Accumulation Type object.
Definition: FrameBuffer.h:194
virtual PLATFORM_API void map()=0
Map the buffer for reading with get*Buffer().
FrameBufferFormat _frameBufferFormat
Definition: FrameBuffer.h:209
PLATFORM_API size_t getColorDepth() const
Get the Color Depth object.
Definition: FrameBuffer.cpp:34
PLATFORM_API freeimage::ImagePtr getImage()
Get the Image object.
Definition: FrameBuffer.cpp:49
virtual PLATFORM_API Vector2ui getSize() const
Get the Size object.
Definition: FrameBuffer.h:97
PLATFORM_API size_t numAccumFrames() const
Get the number of accumulation frames.
Definition: FrameBuffer.h:180
virtual PLATFORM_API const float * getFloatBuffer() const =0
Get the Float Buffer object.
PLATFORM_API AccumulationType getAccumulationType() const
Get the Accumulation Type object.
Definition: FrameBuffer.h:204
PLATFORM_API void incrementAccumFrames()
Increment the accumulation frames.
Definition: FrameBuffer.h:173
virtual PLATFORM_API void resize(const Vector2ui &frameSize)=0
Resize the framebuffer to the new size.
virtual PLATFORM_API void unmap()=0
Unmap the buffer for reading with get*Buffer().
std::unique_ptr< FIBITMAP, ImageDeleter > ImagePtr
Definition: ImageUtils.h:49
FrameBufferFormat
Definition: Types.h:205
AccumulationType
Definition: Types.h:215
glm::vec< 2, uint32_t > Vector2ui
Definition: MathTypes.h:133