-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture2D.h
50 lines (38 loc) · 903 Bytes
/
Texture2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "Image.h"
#include <glm/glm.hpp>
#include <memory>
#include <vector>
class Texture2D
{
std::shared_ptr<Image> texture; // ͬһÕÅÎÆÀí¾Í±ð¿½±´ÁË
float invW;
float invH;
bool is_mipmap_enable{ false }; //! TEST
void GenMipmap(void);
public:
std::vector<std::shared_ptr<Image>> mips;
enum class WrapMode {
Repeat,
ClampToEdge
};
enum class SampleMode {
Nearst,
Bilinear,
// trilinear if enable Mipmap
};
WrapMode wmode;
SampleMode smode;
bool EnableMipmap(void);
public:
Texture2D();
Texture2D(const Texture2D&) = default;
Texture2D& operator=(const Texture2D&) = default;
Texture2D(const char* file);
const int GetWidth() const noexcept;
const int GetHeight() const noexcept;
// sample function
glm::vec4 Sample(float x, float y, float level = 0.0f);
private:
glm::vec4 BilinearSampling(std::shared_ptr<Image> src, float x, float y);
};