dynamically allocate memory when generating noise texture
This commit is contained in:
parent
7f84ffd551
commit
2c57248d82
|
@ -214,7 +214,7 @@ GLuint createNoiseTexture(int width, int height)
|
||||||
int length = width*height*channels;
|
int length = width*height*channels;
|
||||||
printf("generating %d random floats\n", length);
|
printf("generating %d random floats\n", length);
|
||||||
|
|
||||||
float data[width*height*channels];
|
float* data = (float*)malloc(length*sizeof(float));
|
||||||
|
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
|
@ -225,6 +225,8 @@ GLuint createNoiseTexture(int width, int height)
|
||||||
glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
|
glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue