From 33329c10d04782a30e41c87ade346b8e6a574274 Mon Sep 17 00:00:00 2001 From: Niklas Birk Date: Wed, 1 Apr 2020 22:17:35 +0200 Subject: [PATCH] Finished for Abgabe --- cpuMain.c | 10 +++++----- initOpenGL.c | 2 +- initOpenGL.h | 8 +------- initVulkan.h | 6 ++---- openglMain.c | 1 + particlesystem.c | 4 ++-- particlesystem.h | 2 +- shaders/opengl/ComputeShader.glsl | 2 +- shaders/opengl/FragmentShader.glsl | 5 +---- shaders/opengl/VertexShader.glsl | 4 +--- shaders/vulkan/ComputeShader.comp | 2 +- shaders/vulkan/FragmentShader.frag | 2 +- utils.c | 2 +- vulkanMain.c | 3 +-- 14 files changed, 20 insertions(+), 33 deletions(-) diff --git a/cpuMain.c b/cpuMain.c index 5e628ab..83cff8d 100644 --- a/cpuMain.c +++ b/cpuMain.c @@ -48,12 +48,12 @@ int main() emitter *e; particle *p; vector3f *pos; - for (int j = 0; j < ps->eamount; j++) + for (int y = 0; y < ps->eamount; y++) { - e = (ps->emitters)[j]; - for (int i = 0; i < e->pamount; i++) + e = (ps->emitters)[y]; + for (int x = 0; x < e->pamount; x++) { - p = (e->particles)[i]; + p = (e->particles)[x]; pos = p->position; glColor3f(p->color->x, p->color->y, p->color->z); @@ -86,4 +86,4 @@ void calcCol(particle *p) p->color->x -= 0.00001f; p->color->y -= 0.00001f; p->color->z -= 0.00001f; -} +} \ No newline at end of file diff --git a/initOpenGL.c b/initOpenGL.c index 5a50d99..141cb55 100644 --- a/initOpenGL.c +++ b/initOpenGL.c @@ -112,4 +112,4 @@ void deleteShaders(GLuint *shaders, GLsizei count) { glDeleteShader(shaders[i]); } -} +} \ No newline at end of file diff --git a/initOpenGL.h b/initOpenGL.h index 1086dbb..8c54b2d 100644 --- a/initOpenGL.h +++ b/initOpenGL.h @@ -1,11 +1,7 @@ - #include "glad/glad.h" #include -#ifndef INFORMATIKPROJEKT_INITOPENGL_H -#define INFORMATIKPROJEKT_INITOPENGL_H - void initGlad(); void initGLFW(); @@ -20,6 +16,4 @@ void framebufferSizeCallback(GLFWwindow *window, int width, int height); GLuint compileShader(const GLchar *shaderSource, GLenum shaderType); GLuint linkShaders(GLuint *shaders, GLsizei count); -void deleteShaders(GLuint *shaders, GLsizei count); - -#endif //INFORMATIKPROJEKT_INITOPENGL_H +void deleteShaders(GLuint *shaders, GLsizei count); \ No newline at end of file diff --git a/initVulkan.h b/initVulkan.h index 36a8b99..a5f7778 100644 --- a/initVulkan.h +++ b/initVulkan.h @@ -14,7 +14,7 @@ #define ENGINE_NAME "rwu_particles" #define ENGINE_VERSION VK_MAKE_VERSION(0, 0, 0) -#define PARTICLE_AMOUNT 10000000 +#define PARTICLE_AMOUNT 1000000 #define PARTICLE_SIZE (3 * sizeof(vector3f) + sizeof(float)) #define WORKGROUP_SIZE_Y 1 #define WORKGROUP_SIZE_Z 1 @@ -143,6 +143,4 @@ void createGraphicsCommandBuffers(Graphics *graphics); // Else void mapBufferMemory(Compute *compute, VkDeviceMemory memory, void *inputData, uint32_t dataSize); -void createSemaphore(VkDevice device, VkSemaphore *semaphore); - - +void createSemaphore(VkDevice device, VkSemaphore *semaphore); \ No newline at end of file diff --git a/openglMain.c b/openglMain.c index 5ea7a9d..61c1678 100644 --- a/openglMain.c +++ b/openglMain.c @@ -102,6 +102,7 @@ int main() glfwPollEvents(); } + //END deleteShaders(renderShaders, 2); glDeleteProgram(renderShaderProgram); diff --git a/particlesystem.c b/particlesystem.c index 4767749..e4c4052 100644 --- a/particlesystem.c +++ b/particlesystem.c @@ -42,7 +42,7 @@ particle_system *initParticleSystem(int eamount) /* * Updates particles */ -int updateParticles(float dt, particle_system *ps, CalculatePositionFunction calculatePosition, CalculateColorFunction calculateColor) +void updateParticles(float dt, particle_system *ps, CalculatePositionFunction calculatePosition, CalculateColorFunction calculateColor) { emitter *e; particle *p; @@ -208,4 +208,4 @@ void initRandomParticles(emitter *e) ((float) (rand() % 255)) / 255); (e->particles)[i] = initParticle(pos, dir, color, (float) (rand() % (UPPER_AGE - LOWER_AGE + 1) + LOWER_AGE)); } -} +} \ No newline at end of file diff --git a/particlesystem.h b/particlesystem.h index 3fd3035..87703ad 100644 --- a/particlesystem.h +++ b/particlesystem.h @@ -69,7 +69,7 @@ particle_system *initParticleSystem(int eamount); /* * Updates particle */ -int updateParticles(float dt, particle_system *particleSystem, CalculatePositionFunction calculatePosition, CalculateColorFunction calculateColor); +void updateParticles(float dt, particle_system *particleSystem, CalculatePositionFunction calculatePosition, CalculateColorFunction calculateColor); /* * Resets a particle to seed at emitter's position diff --git a/shaders/opengl/ComputeShader.glsl b/shaders/opengl/ComputeShader.glsl index a95c50a..678f065 100644 --- a/shaders/opengl/ComputeShader.glsl +++ b/shaders/opengl/ComputeShader.glsl @@ -85,4 +85,4 @@ void main() p[gid] = part; } -} +} \ No newline at end of file diff --git a/shaders/opengl/FragmentShader.glsl b/shaders/opengl/FragmentShader.glsl index f843c5d..7942083 100644 --- a/shaders/opengl/FragmentShader.glsl +++ b/shaders/opengl/FragmentShader.glsl @@ -6,7 +6,4 @@ layout(location = 0) out vec4 colOut; void main(void) { colOut = vec4(colV, 1); -} - - - +} \ No newline at end of file diff --git a/shaders/opengl/VertexShader.glsl b/shaders/opengl/VertexShader.glsl index 8e60f0e..2c66e6a 100644 --- a/shaders/opengl/VertexShader.glsl +++ b/shaders/opengl/VertexShader.glsl @@ -9,6 +9,4 @@ void main(void) { colV = colIn; gl_Position = vec4(pos, 1); -} - - +} \ No newline at end of file diff --git a/shaders/vulkan/ComputeShader.comp b/shaders/vulkan/ComputeShader.comp index 16ecadb..4598db5 100644 --- a/shaders/vulkan/ComputeShader.comp +++ b/shaders/vulkan/ComputeShader.comp @@ -93,4 +93,4 @@ void main() p[gid] = part; } -} +} \ No newline at end of file diff --git a/shaders/vulkan/FragmentShader.frag b/shaders/vulkan/FragmentShader.frag index b007fd9..7942083 100644 --- a/shaders/vulkan/FragmentShader.frag +++ b/shaders/vulkan/FragmentShader.frag @@ -6,4 +6,4 @@ layout(location = 0) out vec4 colOut; void main(void) { colOut = vec4(colV, 1); -} +} \ No newline at end of file diff --git a/utils.c b/utils.c index ae779f1..dc26805 100644 --- a/utils.c +++ b/utils.c @@ -33,4 +33,4 @@ char *readFile(char *filename, char *mode, size_t *size) } return buffer; -} +} \ No newline at end of file diff --git a/vulkanMain.c b/vulkanMain.c index 2d7de92..66b91aa 100644 --- a/vulkanMain.c +++ b/vulkanMain.c @@ -142,5 +142,4 @@ int main() shutdownGLFW(window); return SUCCESS; -} - +} \ No newline at end of file