diff --git a/initVulkan.c b/initVulkan.c index 927e990..d2b54fa 100644 --- a/initVulkan.c +++ b/initVulkan.c @@ -336,7 +336,7 @@ void createComputeDescriptorSets(Compute *compute) void createShaderModule(VkDevice device, char *filename, VkShaderModule *shaderModule) { - long shaderSourceSize; + size_t shaderSourceSize; char *shaderSource = readFile(filename, "rb", &shaderSourceSize); VkShaderModuleCreateInfo shaderModuleInfo; diff --git a/initVulkan.h b/initVulkan.h index 5acff37..36a8b99 100644 --- a/initVulkan.h +++ b/initVulkan.h @@ -20,7 +20,7 @@ #define WORKGROUP_SIZE_Z 1 #define SUCCESS 0 -#define FAILURE -1 +#define FAILURE (-1) #define ASSERT_VK(f) { \ VkResult res = (f); \ if (res != VK_SUCCESS) { \ @@ -28,7 +28,7 @@ assert(res == VK_SUCCESS); \ } \ } -#define ASSERT_GLFW_SUCCESS(res) { if (res != GLFW_TRUE) { printf("Error-Code: %d", res); return FAILURE; } } +#define ASSERT_GLFW_SUCCESS(res) { if ((res) != GLFW_TRUE) { printf("Error-Code: %d", res); return FAILURE; } } typedef struct dt { float dt; diff --git a/openglMain.c b/openglMain.c index 16f8fdb..5ea7a9d 100644 --- a/openglMain.c +++ b/openglMain.c @@ -70,10 +70,10 @@ int main() glBindBuffer(GL_ARRAY_BUFFER, particleBuffer); // position glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeOfParticle, (GLvoid *)0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, (GLsizei) sizeOfParticle, (GLvoid *)0); // color glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeOfParticle, (GLvoid *)24); + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, (GLsizei) sizeOfParticle, (GLvoid *)24); glBindVertexArray(0); /************* RENDER LOOP *************/ @@ -94,7 +94,7 @@ int main() /*** UPDATE ***/ glUseProgram(computeShaderProgram); - glUniform1f(dtUniformLocation, tFrame); + glUniform1f(dtUniformLocation, (GLfloat) tFrame); glDispatchCompute(PARTICLE_AMOUNT / WORKGROUP_SIZE_X, 1, 1); glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT); diff --git a/particlesystem.c b/particlesystem.c index a7ae7fb..4767749 100644 --- a/particlesystem.c +++ b/particlesystem.c @@ -1,6 +1,5 @@ #include #include -#include #include "particlesystem.h" @@ -74,9 +73,9 @@ void resetParticle(emitter *e, particle *p) p->position->y = e->position->y; p->position->z = e->position->z; - p->velocity->x = ((float) (rand() % 2 ? -1 : 1) * rand()) / RAND_MAX; - p->velocity->y = ((float) (rand() % 2 ? -1 : 1) * rand()) / RAND_MAX; - p->velocity->z = ((float) (rand() % 2 ? -1 : 1) * rand()) / RAND_MAX; + p->velocity->x = ((float) ((rand() % 2 ? -1 : 1) * rand())) / RAND_MAX; + p->velocity->y = ((float) ((rand() % 2 ? -1 : 1) * rand())) / RAND_MAX; + p->velocity->z = ((float) ((rand() % 2 ? -1 : 1) * rand())) / RAND_MAX; p->age = rand() / 10; } @@ -86,7 +85,7 @@ void resetParticle(emitter *e, particle *p) */ int drawParticles(particle_system *particleSystem) { - + return 0; } /* diff --git a/utils.c b/utils.c index ec90d17..ae779f1 100644 --- a/utils.c +++ b/utils.c @@ -4,11 +4,11 @@ #include #include "utils.h" -char *readFile(char *filename, char *mode, long *size) +char *readFile(char *filename, char *mode, size_t *size) { FILE *file; char *buffer; - long bytes; + size_t bytes; if((file = fopen(filename, mode)) == NULL) { @@ -16,7 +16,7 @@ char *readFile(char *filename, char *mode, long *size) } fseek(file, 0L, SEEK_END); - bytes = ftell(file); + bytes = (size_t) ftell(file); fseek(file, 0L, SEEK_SET); if((buffer = calloc(bytes, sizeof(char))) == NULL) diff --git a/utils.h b/utils.h index 046f3ec..8048ec2 100644 --- a/utils.h +++ b/utils.h @@ -6,4 +6,4 @@ #define WORKGROUP_SIZE_X 1024 -char *readFile(char *filename, char *mode, long *size); \ No newline at end of file +char *readFile(char *filename, char *mode, size_t *size); \ No newline at end of file diff --git a/vulkanMain.c b/vulkanMain.c index 39d78b3..2d7de92 100644 --- a/vulkanMain.c +++ b/vulkanMain.c @@ -23,7 +23,7 @@ int main() freeParticleSystem(ps); /************* INIT GLFW *************/ - ASSERT_GLFW_SUCCESS(glfwInit()); + ASSERT_GLFW_SUCCESS(glfwInit()) glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "Informatikprojekt - Vulkan", NULL, NULL); @@ -54,8 +54,8 @@ int main() submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &compute.semaphore; - ASSERT_VK(vkQueueSubmit(compute.queue, 1, &submitInfo, VK_NULL_HANDLE)); - ASSERT_VK(vkQueueWaitIdle(compute.queue)); + ASSERT_VK(vkQueueSubmit(compute.queue, 1, &submitInfo, VK_NULL_HANDLE)) + ASSERT_VK(vkQueueWaitIdle(compute.queue)) createComputeCommandBuffer(&compute);