-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstantBufferClass.hpp
90 lines (65 loc) · 1.78 KB
/
ConstantBufferClass.hpp
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
#ifndef CONSTANTBUFFERCLASS_HPP
#define CONSTANTBUFFERCLASS_HPP
#include <d3d11.h>
#include <DirectXMath.h>
#include "Globals.hpp" // PI,SCREENWIDTH/HEIGHT in InitializeConstantMatrices
#include "objLoader.hpp"
struct MatrixBufferLoaded
{
DirectX::XMMATRIX world;
DirectX::XMMATRIX view;
DirectX::XMMATRIX projection;
};
struct MatrixBufferStored
{
DirectX::XMFLOAT4X4 world;
DirectX::XMFLOAT4X4 view;
DirectX::XMFLOAT4X4 projection;
DirectX::XMFLOAT4 Kd;
DirectX::XMFLOAT4 ColorID;
};
class ConstantBufferClass {
private:
MatrixBufferLoaded UnformattedMatrixData;
MatrixBufferStored FormattedMatrixData;
ID3D11Buffer* ConstantBuffer;
void InitializeConstantMatrices();
void CreateSetConstantBuffers(
ID3D11Device* *Device,
ID3D11DeviceContext* *DeviceContext
);
public:
ConstantBufferClass();
~ConstantBufferClass();
/* ------------- COMMENTS -------------
Releases internal [ID3D11*Buffer ConstantBuffer]
*/
void ReleaseAll();
MatrixBufferStored *GetFormattedMatrixData();
ID3D11Buffer* *GetConstantBuffer();
/* ------------- COMMENTS -------------
Initializes UnformattedMatrixData,
Reformats to FormattedMatrixData,
Creates & sets constantbuffer to register (0).
*/
void Initialize(
ID3D11Device* *Device,
ID3D11DeviceContext* *DeviceContext
);
/* ------------- COMMENTS -------------
Adds the Kd-values from the objectData parameter to the
FormattedMatrixData.
*/
void AddMaterialDataToFormattedStruct(ObjectDataClass objectData);
/*
Reformats the internal UnformattedDataStruct to the internal FormattedDataStruct.
*/
void MatrixToFloat4X4Reformat();
};
// -------------- NON-CLASS FUNCTIONS --------------
void AlterConstantBuffers(
ID3D11Buffer* TargetBuffer,
MatrixBufferStored TargetStruct,
ID3D11DeviceContext* *DeviceContext
);
#endif