-
Notifications
You must be signed in to change notification settings - Fork 0
/
Playground.hpp
140 lines (109 loc) · 2.52 KB
/
Playground.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
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
#ifndef PLAYGROUND_HPP
#define PLAYGROUND_HPP
#include <string>
#include <QVector2D>
#include <QVector3D>
#include <QMatrix4x4>
#include <qopengl.h>
#include <queue>
#include <condition_variable>
#include <mutex>
using namespace std;
static condition_variable g_jobs_ready;
static condition_variable g_jobs_done;
static mutex g_mtx;
static bool jobs_available = false;
static bool jobs_done = false;
static mutex l_mtx;
static void logFunc(QString text) {
std::lock_guard<std::mutex> lock(l_mtx);
qDebug() << text;
}
enum RenderJob
{
LoadMesh,
DrawMesh,
DrawMeshIndexed,
CreateProgram,
CreateShader
};
struct Transform
{
};
enum class VA_Index { POS, NRM, TEX };
struct Vertex {
QVector3D position;
// QVector3D normal;
// QVector2D texCoord;
};
struct Texture2D {
GLuint textureID;
std::string type;
// aiString path;
};
/* encompass all mesh types into one */
struct RawMesh
{
std::vector<Vertex> vertices;
std::vector<GLuint> indices;
// std::vector<Texture2D> textures;
};
struct Mesh
{
unsigned vertex_array = 0;
unsigned vertex_buffer;
unsigned index_buffer;
RawMesh rawMesh;
};
struct Material
{
};
struct Model
{
Mesh mesh;
Material material;
Transform transform;
Transform aabb_transform;
};
namespace RenderCommands
{
struct CommandDrawIndexed {
int command_id;
uint32_t index_count;
uint32_t vertex_count;
Model model;
unsigned program_id;
struct attribs {
};
};
struct CommandCreateProgram {
uint32_t command_id;
unsigned program_id;
};
struct CommandCreateShader {
uint32_t command_id;
unsigned shader_id;
};
}
struct Swapper
{
Swapper() {
UpdateDrawCommands = new std::vector<RenderCommands::CommandDrawIndexed>();
RenderDrawCommands = new std::vector<RenderCommands::CommandDrawIndexed>();
// UpdateDrawCommands->reserve(1);
// RenderDrawCommands->reserve(1);
}
void swap() {
auto commands = UpdateDrawCommands;
RenderDrawCommands = commands;
UpdateDrawCommands = RenderDrawCommands;
}
std::vector<RenderCommands::CommandDrawIndexed> *UpdateDrawCommands;
std::vector<RenderCommands::CommandDrawIndexed> *RenderDrawCommands;
};
//class Playground
//{
//public:
// Playground();
//};
#endif // PLAYGROUND_HPP