-
Notifications
You must be signed in to change notification settings - Fork 0
/
gutils.h
57 lines (48 loc) · 1.27 KB
/
gutils.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
50
51
52
53
54
55
56
57
#ifndef GUTILS_H
#define GUTILS_H
#include<string>
#include "gmath.h"
#include "gbuffer.h"
#include "tgaimage.h"
enum GTextureWrapMode
{
kTWMRepeat,
kTWMClamp
};
enum GDebugType
{
kNone,
kDiffuseTex,
kNormalTex,
kWorldNormal,
kWorldTangent,
};
class GUtils
{
public:
static int screenWidth;
static int screenHeight;
static float screenAspectRatio();
static float worldSize;
static GDebugType debugType;
static std::string GetProjRootPath();
static std::string GetAbsPath(const std::string& relativePath);
static bool IsFileExist(const std::string filepath);
// sample image
static GColor SampleImage(const TGAImage* img, GMath::vec2 uv, GTextureWrapMode wrapMode=GTextureWrapMode::kTWMClamp, GColor defaultColor=GColor::black);
static GColor SampleImage(const std::vector<TGAImage>* mipmaps, GMath::vec2 uv, int mipmapLevel, GTextureWrapMode wrapMode=GTextureWrapMode::kTWMClamp, GColor defaultColor=GColor::black);
// vector
template<typename T>
static void ReleaseVector(std::vector<T*>& v)
{
for(size_t i=0; i<v.size(); i++)
{
if(v[i]!=nullptr)
{
delete v[i];
v[i] = nullptr;
}
}
}
};
#endif // GUTILS_H