From 2c57248d828f31589d34504c48eee27deb810d06 Mon Sep 17 00:00:00 2001 From: ktyl Date: Fri, 29 Oct 2021 13:30:45 +0100 Subject: [PATCH] dynamically allocate memory when generating noise texture --- src/gfx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gfx.c b/src/gfx.c index 7f12c0e..7483a0b 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -214,7 +214,7 @@ GLuint createNoiseTexture(int width, int height) int length = width*height*channels; 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++) { @@ -225,6 +225,8 @@ GLuint createNoiseTexture(int width, int height) glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F); glGenerateMipmap(GL_TEXTURE_2D); + free(data); + return texture; }