Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TPixelTex2D.h
Go to the documentation of this file.
1#pragma once
2
4#include "Frame/TFrame.h"
5
6#include <Common/assertion.h>
7
8#include <type_traits>
9#include <utility>
10
11namespace ph
12{
13
14template<typename T, std::size_t N>
15class TPixelTex2D : public TAbstractPixelTex2D<T, N>
16{
17public:
18 inline TPixelTex2D() :
19 TPixelTex2D(TFrame<T, N>(1, 1))
20 {}
21
22 explicit inline TPixelTex2D(const TFrame<T, N>& frame) :
23 TAbstractPixelTex2D<T, N>(frame.widthPx(), frame.heightPx()),
24 m_frame(frame)
25 {
26 PH_ASSERT(!m_frame.isEmpty());
27 }
28
29 explicit inline TPixelTex2D(TFrame<T, N>&& frame) :
30 TAbstractPixelTex2D<T, N>(frame.widthPx(), frame.heightPx()),
31 m_frame(std::move(frame))
32 {
33 PH_ASSERT(!m_frame.isEmpty());
34 }
35
36 void sample(
37 const SampleLocation& sampleLocation,
38 TTexPixel<T, N>* out_value) const override = 0;
39
40 inline void getPixel(
41 const uint32 x, const uint32 y,
42 TTexPixel<T, N>* const out_pixel) const
43 {
44 static_assert(std::is_same_v<TTexPixel<T, N>, typename TFrame<T, N>::PixelType>,
45 "require same pixel type");
46
47 PH_ASSERT(out_pixel != nullptr);
48
49 m_frame.getPixel(x, y, out_pixel);
50 }
51
52 inline void setPixels(const TFrame<T, N>& frame)
53 {
54 m_frame = frame;
55 setWidthPx(frame->widthPx());
56 setHeightPx(frame->heightPx());
57
58 PH_ASSERT(!m_frame.isEmpty());
59 }
60
61private:
62 TFrame<T, N> m_frame;
63};
64
65}// end namespace ph
Definition SampleLocation.h:22
Definition TAbstractPixelTex2D.h:21
void setWidthPx(const uint32 widthPx)
Definition TAbstractPixelTex2D.h:79
void setHeightPx(const uint32 heightPx)
Definition TAbstractPixelTex2D.h:87
Definition TFrame.h:21
uint32 heightPx() const
Definition TFrame.ipp:440
uint32 widthPx() const
Definition TFrame.ipp:434
Definition TPixelTex2D.h:16
TPixelTex2D(TFrame< T, N > &&frame)
Definition TPixelTex2D.h:29
void getPixel(const uint32 x, const uint32 y, TTexPixel< T, N > *const out_pixel) const
Definition TPixelTex2D.h:40
TPixelTex2D(const TFrame< T, N > &frame)
Definition TPixelTex2D.h:22
TPixelTex2D()
Definition TPixelTex2D.h:18
void setPixels(const TFrame< T, N > &frame)
Definition TPixelTex2D.h:52
void sample(const SampleLocation &sampleLocation, TTexPixel< T, N > *out_value) const override=0
Definition TArithmeticArray.h:13
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TAABB2D.h:96