-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbulb.cpp
58 lines (40 loc) · 1.19 KB
/
bulb.cpp
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
#include <cppunit/TestCase.h>
#include "Procedural/MandelBulb.h"
#include <thread>
using fractal::MandelBulb;
class MeshTest: public CppUnit::TestCase {
public:
MeshTest(std::string name) :
CppUnit::TestCase(name) {
}
void bulbThreads(int size) {
unsigned threadCount = 16;
unsigned threadSize = size / threadCount;
vector<GLubyte> voxels;
vector<vector<GLubyte>*> voxelParts;
std::vector<std::thread> threads;
for(unsigned i = 0; i < threadCount; i++){
vector<GLubyte> *voxelPart = new vector<GLubyte>();
voxelParts.push_back(voxelPart);
threads.push_back(
std::thread(
MandelBulb::generateVoxels,
threadSize * i, threadSize * (i+1), voxelPart, i+1, size));
}
for(auto& thread : threads){
thread.join();
}
for (unsigned i = 0; i < threadCount; i++) {
foreach (GLubyte voxel, *voxelParts.at(i)) {
voxels.push_back(voxel);
}
}
}
void runTest() {
bulbThreads(128);
}
};
int main() {
MeshTest foo2("bar");
foo2.runTest();
}