-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolygons.h
More file actions
123 lines (95 loc) · 4.04 KB
/
Copy pathPolygons.h
File metadata and controls
123 lines (95 loc) · 4.04 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
// ===========================================================================
/// <summary>
/// Polygons.cpp
/// DirectXIntroduction
/// created by Mehrdad Soleimanimajd on 31.08.2019
/// </summary>
/// <created>ʆϒʅ, 31.08.2019</created>
/// <changed>ʆϒʅ, 05.07.2023</changed>
// ===========================================================================
#ifndef POLYGONS_H
#define POLYGONS_H
#include <d3d10_1.h>
#include <DirectXMath.h>
#include <string>
#include "ModelFormats.h"
// object models base class
template <class tType>
class Model
{
private:
std::wstring entryPoint;
bool dynamic; // true: dynamic usage + write access for CPU
protected:
ID3D10Device1* device; // pointer to Direct3D device
D3D10_BUFFER_DESC vertexBufferDesc;
// 2D/3D models buffer containers, drawn by invoked shaders that are compiled into vertex/pixel shaders
ID3D10Buffer* vertexBuffer; // models' vertex buffer
D3D10_SUBRESOURCE_DATA subResourceDate; // to interface with the object model vertices as resources
D3D10_BUFFER_DESC indexBufferDesc;
ID3D10Buffer* indexBuffer; // models' index buffer
// Note index buffers purposes: record the location of each vertex introduced in vertex buffer,
// achieving much hider speed, and helps to cache the vertices data in faster locations of video memory.
bool allocate (tType*, unsigned long*, unsigned long&); // object model resources allocation
public:
Model (ID3D10Device1*, std::wstring, bool);
ID3D10Buffer** const getVertexBuffer (void); // vertex buffer
ID3D10Buffer* const getIndexBuffer (void); // index buffer
void release (void); // release the object model
};
void O2DmodelClassLinker (void); // don't call this function: solution for linker error, when using templates.
class Triangles : public Model<Vertex>
{
private:
Vertex verticesData [9]; // object model vertices dataobject model vertices data
unsigned long verticesIndices [9]; // object model vertices dataobject model vertices indices
public:
unsigned long verticesCount; // object model vertices dataobject model vertices count
bool allocated; // true after successful resource allocation
Triangles (ID3D10Device1*);
};
class Line : public Model<Vertex>
{
private:
Vertex verticesData [2]; // object model vertices dataobject model vertices data
unsigned long verticesIndex [2]; // object model vertices dataobject model vertices indices
public:
unsigned long verticesCount; // object model vertices dataobject model vertices count
bool allocated; // true after successful resource allocation
D3D10_MAPPED_TEXTURE2D mappedRes; // updating the resource
// note DirectX 11: D3D11_MAPPED_SUBRESOURCE
Line (ID3D10Device1*);
void update (void);
};
class TexturedTriangles : public Model<VertexT>
{
private:
VertexT verticesData [6]; // object model vertices dataobject model vertices data
unsigned long verticesIndex [6]; // object model vertices dataobject model vertices indices
public:
unsigned long verticesCount; // object model vertices dataobject model vertices count
bool allocated; // true after successful resource allocation
TexturedTriangles (ID3D10Device1*);
};
class LightedTriangle : public Model<VertexL>
{
private:
VertexL verticesData [3]; // object model vertices dataobject model vertices data
unsigned long verticesIndex [3]; // object model vertices dataobject model vertices indices
public:
unsigned long verticesCount; // object model vertices dataobject model vertices count
bool allocated; // true after successful resource allocation
LightedTriangle (ID3D10Device1*);
};
class Cube : public Model<VertexL>
{
private:
VertexL* verticesData; // object model vertices dataobject model vertices data
unsigned long* verticesIndex; // object model vertices dataobject model vertices indices
public:
unsigned long verticesCount; // object model vertices dataobject model vertices count
bool allocated; // true after successful resource allocation
Cube (ID3D10Device1*);
};
#endif // !POLYGONS_H