-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.h
More file actions
149 lines (125 loc) · 3.87 KB
/
Engine.h
File metadata and controls
149 lines (125 loc) · 3.87 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#pragma once
#include <Windows.h>
#include <WindowsX.h>
#include <D3D11.h>
#include <D3DX11.h>
#include <xnamath.h>
//Texture loading
#include <fstream>
#include <string>
#include <sstream>
#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "d3dx11.lib")
//#pragma comment (lib, "d3dx10.lib")
//copied from the directx sdk
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) {if(p){delete (p); (p)=NULL;}}
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) {if(p){delete[] (p); (p)=NULL;}}
#endif
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) {if(p){(p)->Release(); (p)=NULL;}}
#endif
class Key_Inputs
{
private:
public:
unsigned int MAXBOOLS;
unsigned int ARRAYSIZE;
int *Key_State,*Key_Past;
public:
Key_Inputs();
~Key_Inputs();
bool operator()(char C);
bool Down(char C);
bool Up(char C);
void Update();
};
struct MODELID
{
unsigned int Index_StartPos,Vertex_StartPos;
unsigned int Index_Length,Vertex_Length;
unsigned int VertexBufferOffset; // Offset, in bytes to the first vertex
};
enum TextureID
{
TEX_Albedo = 0,
TEX_Normal,
TEX_Reflectivity,
TEX_Specular,
TEX_Transparency,
TEX_Emission,
TEX_Height,
TEX_MAX_VALUE
};
struct TextureLocationData
{
XMFLOAT4 Low[TEX_MAX_VALUE];
XMFLOAT4 High[TEX_MAX_VALUE];
std::wstring Locations[TEX_MAX_VALUE];
};
struct TextureData
{
XMFLOAT4 Low[TEX_MAX_VALUE];
XMFLOAT4 High[TEX_MAX_VALUE];
ID3D11ShaderResourceView *Textures[TEX_MAX_VALUE];
};
//Engine stage functions
bool Init(ID3D11Device*, ID3D11DeviceContext*, IDXGISwapChain*);
bool Think();
bool Render(bool, MODELID*, MODELID*);
void End();
//engine premade functions
inline void Draw(MODELID Model);
ID3D11ShaderResourceView *LoadTexture(LPCWSTR File);
ID3D11ShaderResourceView *LoadTexture(LPCWSTR File, HRESULT *Err);
ID3D11SamplerState *CreateSampler(D3D11_SAMPLER_DESC *texdesc);
TextureLocationData LoadTextureLocations(LPCWSTR Descriptor);
TextureData LoadTextureSet(TextureLocationData Locs);
TextureData LoadTextureSet(LPCWSTR Descriptor);
//Templated shader loading functions
HRESULT CreateVertexShaderGeneric(const void* BfrPtr, SIZE_T BfrSize, ID3D11ClassLinkage* Linkage, void** Out);
HRESULT CreateHullShaderGeneric(const void* BfrPtr, SIZE_T BfrSize, ID3D11ClassLinkage* Linkage, void** Out);
HRESULT CreateDomainShaderGeneric(const void* BfrPtr, SIZE_T BfrSize, ID3D11ClassLinkage* Linkage, void** Out);
HRESULT CreateGeometryShaderGeneric(const void* BfrPtr, SIZE_T BfrSize, ID3D11ClassLinkage* Linkage, void** Out);
HRESULT CreatePixelShaderGeneric(const void* BfrPtr, SIZE_T BfrSize, ID3D11ClassLinkage* Linkage, void** Out);
ID3D11VertexShader *LoadVertexShader(LPCWSTR File, LPCSTR Function, LPCSTR Format, bool UseConstFormat);
ID3D11HullShader *LoadHullShader(LPCWSTR File, LPCSTR Function, LPCSTR Format, bool UseConstFormat);
ID3D11DomainShader *LoadDomainShader(LPCWSTR File, LPCSTR Function, LPCSTR Format, bool UseConstFormat);
ID3D11GeometryShader *LoadGeometryShader(LPCWSTR File, LPCSTR Function, LPCSTR Format, bool UseConstFormat);
ID3D11PixelShader *LoadPixelShader(LPCWSTR File, LPCSTR Function, LPCSTR Format, bool UseConstFormat);
//utility
unsigned long xorshf96(void);
double xorshfdbl(void);
unsigned long *xorshfdata(void);
unsigned long long GetTimeHns(); // Time in 100 nanoseconds
unsigned int Animate(unsigned long Time,double Interval,unsigned int Frames);
double Wrap(double Input, double Min, double Max);
bool Clamp(int*, int Min, int Max);
bool Clamp(float*, float Min, float Max);
bool Clamp(double*, double Min, double Max);
void TriangleIntersect();
struct Particle
{
/*float Pos[3];
float vel[3];
float StartTime;
float EndTime;*/
unsigned int StartTime;
float Pos[3];
Particle *Next;
};
class ParticleSystem
{
public:
Particle *Data;
Particle **Dead;
unsigned int Alive, Max;
public:
Particle *Root;
ParticleSystem();
void New(Particle *In);
void Remove(Particle** Prev);
~ParticleSystem();
};