Skip to content

Commit e33cf1a

Browse files
peak3dMischa Spiegelmock
authored andcommitted
Allocate PerlinNoise dynamically / Fix thread detach after join (#170)
1 parent 299fd58 commit e33cf1a

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/libprojectM/Renderer/TextureManager.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <algorithm>
22
#include <vector>
3+
#include <memory>
34

45
#include "projectM-opengl.h"
56

@@ -84,52 +85,52 @@ TextureManager::TextureManager(const std::string _presetsURL, const int texsizeX
8485
blurTextures.push_back(textureBlur);
8586
}
8687

87-
PerlinNoise noise;
88+
std::unique_ptr<PerlinNoise> noise(new PerlinNoise());
8889

8990
GLuint noise_texture_lq_lite;
9091
glGenTextures(1, &noise_texture_lq_lite);
9192
glBindTexture(GL_TEXTURE_2D, noise_texture_lq_lite);
92-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGB, GL_FLOAT, noise.noise_lq_lite);
93+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGB, GL_FLOAT, noise->noise_lq_lite);
9394
Texture * textureNoise_lq_lite = new Texture("noise_lq_lite", noise_texture_lq_lite, GL_TEXTURE_2D, 32, 32, false);
9495
textureNoise_lq_lite->getSampler(GL_REPEAT, GL_LINEAR);
9596
textures["noise_lq_lite"] = textureNoise_lq_lite;
9697

9798
GLuint noise_texture_lq;
9899
glGenTextures(1, &noise_texture_lq);
99100
glBindTexture(GL_TEXTURE_2D, noise_texture_lq);
100-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_lq);
101+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise->noise_lq);
101102
Texture * textureNoise_lq = new Texture("noise_lq", noise_texture_lq, GL_TEXTURE_2D, 256, 256, false);
102103
textureNoise_lq->getSampler(GL_REPEAT, GL_LINEAR);
103104
textures["noise_lq"] = textureNoise_lq;
104105

105106
GLuint noise_texture_mq;
106107
glGenTextures(1, &noise_texture_mq);
107108
glBindTexture(GL_TEXTURE_2D, noise_texture_mq);
108-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_mq);
109+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise->noise_mq);
109110
Texture * textureNoise_mq = new Texture("noise_mq", noise_texture_mq, GL_TEXTURE_2D, 256, 256, false);
110111
textureNoise_mq->getSampler(GL_REPEAT, GL_LINEAR);
111112
textures["noise_mq"] = textureNoise_mq;
112113

113114
GLuint noise_texture_hq;
114115
glGenTextures(1, &noise_texture_hq);
115116
glBindTexture(GL_TEXTURE_2D, noise_texture_hq);
116-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise.noise_hq);
117+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_FLOAT, noise->noise_hq);
117118
Texture * textureNoise_hq = new Texture("noise_hq", noise_texture_hq, GL_TEXTURE_2D, 256, 256, false);
118119
textureNoise_hq->getSampler(GL_REPEAT, GL_LINEAR);
119120
textures["noise_hq"] = textureNoise_hq;
120121

121122
GLuint noise_texture_lq_vol;
122123
glGenTextures( 1, &noise_texture_lq_vol );
123124
glBindTexture( GL_TEXTURE_3D, noise_texture_lq_vol );
124-
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32 ,32 ,32 ,0 ,GL_RGB ,GL_FLOAT ,noise.noise_lq_vol);
125+
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32 ,32 ,32 ,0 ,GL_RGB ,GL_FLOAT ,noise->noise_lq_vol);
125126
Texture * textureNoise_lq_vol = new Texture("noisevol_lq", noise_texture_lq_vol, GL_TEXTURE_3D, 32, 32, false);
126127
textureNoise_lq_vol->getSampler(GL_REPEAT, GL_LINEAR);
127128
textures["noisevol_lq"] = textureNoise_lq_vol;
128129

129130
GLuint noise_texture_hq_vol;
130131
glGenTextures( 1, &noise_texture_hq_vol );
131132
glBindTexture( GL_TEXTURE_3D, noise_texture_hq_vol );
132-
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32, 32, 32, 0, GL_RGB, GL_FLOAT, noise.noise_hq_vol);
133+
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 32, 32, 32, 0, GL_RGB, GL_FLOAT, noise->noise_hq_vol);
133134
Texture * textureNoise_hq_vol = new Texture("noisevol_hq", noise_texture_hq_vol, GL_TEXTURE_3D, 32, 32, false);
134135
textureNoise_hq_vol->getSampler(GL_REPEAT, GL_LINEAR);
135136
textures["noisevol_hq"] = textureNoise_hq_vol;

src/libprojectM/projectM.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ projectM::~projectM()
7676
worker_sync.finish_up();
7777
printf("e");
7878
pthread_join(thread, &status);
79-
printf("a");
80-
pthread_detach(thread);
8179
printf("n");
8280
#ifdef SYNC_PRESET_SWITCHES
8381
pthread_mutex_destroy( &preset_mutex );

0 commit comments

Comments
 (0)