Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TMipmap.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/assertion.h>
6
7#include <vector>
8#include <memory>
9
10namespace ph
11{
12
13template<typename T, std::size_t N>
14class TMipmap : public TAbstractPixelTex2D<T, N>
15{
16public:
17 inline TMipmap() :
18 TMipmap(1)
19 {}
20
21 explicit inline TMipmap(const std::size_t numLevels) :
22 TAbstractPixelTex2D<T, N>(),
23 m_levels(numLevels, nullptr)
24 {
25 PH_ASSERT(numLevels >= 1);
26 }
27
28 virtual ~TMipmap() override = default;
29
30 virtual void sample(
31 const SampleLocation& sampleLocation,
32 TTexPixel<T, N>* const out_value) const = 0;
33
34 inline const TAbstractPixelTex2D<T, N>* getLevel(const std::size_t level) const
35 {
36 PH_ASSERT(level < m_levels.size());
37
38 return m_levels[level].get();
39 }
40
41 inline std::size_t numLevels() const
42 {
43 return m_levels.size();
44 }
45
46protected:
47 inline void setLevel(const std::size_t level,
48 std::unique_ptr<TAbstractPixelTex2D<T, N>> texture)
49 {
50 PH_ASSERT(level < m_levels.size());
51
52 m_levels[level] = std::move(texture);
53 }
54
55private:
56 std::vector<std::unique_ptr<TAbstractPixelTex2D<T, N>>> m_levels;
57};
58
59}// end namespace ph
Definition SampleLocation.h:22
Definition TAbstractPixelTex2D.h:21
Definition TMipmap.h:15
void setLevel(const std::size_t level, std::unique_ptr< TAbstractPixelTex2D< T, N > > texture)
Definition TMipmap.h:47
std::size_t numLevels() const
Definition TMipmap.h:41
const TAbstractPixelTex2D< T, N > * getLevel(const std::size_t level) const
Definition TMipmap.h:34
TMipmap(const std::size_t numLevels)
Definition TMipmap.h:21
virtual void sample(const SampleLocation &sampleLocation, TTexPixel< T, N > *const out_value) const =0
TMipmap()
Definition TMipmap.h:17
virtual ~TMipmap() override=default
Definition TArithmeticArray.h:13
The root for all renderer implementations.
Definition EEngineProject.h:6