-
Notifications
You must be signed in to change notification settings - Fork 0
/
Skybox.h
53 lines (45 loc) · 1.17 KB
/
Skybox.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
#ifndef SKYBOX_H_
#define SKYBOX_H_
#include "entity/FixedGeometry.h"
#include "assets/AssetManager.h"
using namespace anengine;
class Skybox : public FixedGeometry
{
static StaticAsset<VertexBuffer> myVertexBuffer;
AssetRef<Texture> myTextureRef;
Asset<Texture> myTexture;
protected:
virtual AssetRef<VertexBuffer> GetGeometry(AssetManager *manager)
{
return myVertexBuffer.Get(manager);
}
virtual void OnDraw(FrameTime elapsed)
{
glDrawArrays(GL_TRIANGLES, 0, 36);
}
virtual void OnCreate()
{
myTexture = myTextureRef;
FixedGeometry::OnCreate();
}
virtual void OnDestroy()
{
myTexture.Release();
FixedGeometry::OnDestroy();
}
virtual void OnNewProgram()
{
ProgramState().SetUniform("Texture", myTexture);
//ProgramState().SetUniform("Projection", MatrixF4::Orthogonal(-0.2, 0.2, -0.2, 0.2, 0.1, 5));
FixedGeometry::OnNewProgram();
}
public:
Skybox(AssetRef<Texture> tex)
: myTextureRef(tex) { }
virtual ~Skybox() { }
void SetTexture(AssetRef<Texture> texture)
{
myTextureRef = texture;
}
};
#endif