diff --git a/src/inputHandler.c b/src/inputHandler.c index 32de687..7b529c5 100644 --- a/src/inputHandler.c +++ b/src/inputHandler.c @@ -1,5 +1,8 @@ #include "inputHandler.h" +/** + * Moves the camera in a somewhat smooth motion. + */ void handleCameraTravel() { if (cameraTraveling) @@ -16,6 +19,9 @@ void handleCameraTravel() } } +/** + * Sets the position of the camera while moving. + */ void travelCamera(vec3 newPosition) { cameraTravelPosition = newPosition; @@ -54,10 +60,6 @@ void handleInputs(double deltaTime) { travelCamera((vec3){3.574698f, 0.966039f, 3.852249f}); } - if (glfwGetKey(window, GLFW_KEY_7) == GLFW_PRESS) - { - travelCamera((vec3){0.324839f, 1.325346f, 3.798471f}); - } if (!cameraTraveling) { if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) @@ -178,7 +180,9 @@ void handleInputs(double deltaTime) } } -// input handler to quit with ESC +/** + * Function for if you wanna escape the program. + */ void keyboardHandler(GLFWwindow *window, int key, int scancode, int action, int mods) { assert(window != NULL); diff --git a/src/matrixMath.c b/src/matrixMath.c index b8debd1..62568cb 100644 --- a/src/matrixMath.c +++ b/src/matrixMath.c @@ -1,10 +1,4 @@ -#include -#include -#include -#include -#include -#include #include "matrixMath.h" // MATRICES IN COLUMN MAJOR @@ -90,10 +84,9 @@ void vec3Normalise(vec3* out, vec3* a) { } /* - mat4 functions + mat4 functions (tested) */ -//tested // CREATE 4x4 IDENTITY MATRIX void identity(mat4* out) { assert(out != NULL); @@ -103,7 +96,6 @@ void identity(mat4* out) { } } -//tested // CREATE 4x4 TRANSLATION MATRIX void translation(mat4* out, vec3* v) { assert(out != NULL); @@ -114,7 +106,6 @@ void translation(mat4* out, vec3* v) { out->m23 = v->z; } -//tested // CREATE 4x4 SCALING MATRIX void scaling(mat4* out, vec3* v) { assert(out != NULL); @@ -186,7 +177,6 @@ void multiplyAny(GLfloat* out, GLfloat* A, GLfloat* B, int wA, int hA, int wB) { result = NULL; } -//tested // MULTIPLY TWO 4x4 MATRICES void multiply(mat4* out, mat4* A, mat4* B) { assert(out != NULL); @@ -196,7 +186,6 @@ void multiply(mat4* out, mat4* A, mat4* B) { multiplyAny((GLfloat*)out, (GLfloat*)A, (GLfloat*)B, 4, 4, 4); } -//! // MULTIPLY in WITH TRANSLATION MATRIX OF v void translate(mat4* out, mat4* in, vec3* v) { assert(out != NULL); @@ -208,7 +197,6 @@ void translate(mat4* out, mat4* in, vec3* v) { multiply(out, &translationMatrix, in); } -//! // MULTIPLY in WITH SCALING MATRIX OF v void scale(mat4* out, mat4* in, vec3* v) { assert(out != NULL); @@ -220,7 +208,6 @@ void scale(mat4* out, mat4* in, vec3* v) { multiply(out, &scalingMatrix, in); } -//! // MULTIPLY in WITH ROTATION MATRIX OF angle AROUND Z AXIS void rotateZ(mat4* out, mat4* in, GLfloat angle) { assert(out != NULL); @@ -231,7 +218,6 @@ void rotateZ(mat4* out, mat4* in, GLfloat angle) { multiply(out, &rotationMatrix, in); } -//! // MULTIPLY in WITH ROTATION MATRIX OF angle AROUND Y AXIS void rotateY(mat4* out, mat4* in, GLfloat angle) { assert(out != NULL); @@ -242,7 +228,6 @@ void rotateY(mat4* out, mat4* in, GLfloat angle) { multiply(out, &rotationMatrix, in); } -//! // MULTIPLY in WITH ROTATION MATRIX OF angle AROUND X AXIS void rotateX(mat4* out, mat4* in, GLfloat angle) { assert(out != NULL); @@ -253,7 +238,6 @@ void rotateX(mat4* out, mat4* in, GLfloat angle) { multiply(out, &rotationMatrix, in); } -//tested // TRANSPOSE MATRIX OF ANY SIZE void transposeAny(GLfloat* out, GLfloat* in, int w, int h) { assert(out != NULL); @@ -271,7 +255,6 @@ void transposeAny(GLfloat* out, GLfloat* in, int w, int h) { result = NULL; } -//tested, da transpose any schon getestet ist // TRANSPOSE 4x4 MATRIX void transpose(mat4* out, mat4* in) { assert(out != NULL); @@ -315,7 +298,7 @@ void mat3Print(mat3* m) { } /* - mat3 functions + mat3 functions (tested) */ // TURN mat4 INTO mat3 BY CUTTING LAST COLUMN AND ROW @@ -328,7 +311,6 @@ void mat3From4(mat3* out, mat4* in) { memcpy(&out->m02, &in->m02, sizeof(vec3)); } -//tested // TRANSPOSE 3x3 MATRIX void mat3Transpose(mat3* out, mat3* in) { assert(out != NULL); @@ -337,7 +319,6 @@ void mat3Transpose(mat3* out, mat3* in) { transposeAny((GLfloat*)out, (GLfloat*)in, 3, 3); } -//tested /** * a - m00 b - m01 c - m02 * d - m10 e - m11 f - m12 @@ -365,7 +346,6 @@ void mat3Minor(mat3* out, mat3* in) { memcpy(out, &result, sizeof(mat3)); } -//tested // GET THE COFACTOR MATRIX OF A 3x3 MATRIX void mat3Cofactor(mat3* out, mat3* in) { assert(out != NULL); @@ -380,7 +360,6 @@ void mat3Cofactor(mat3* out, mat3* in) { out->m12 *= -1; } -//tested // GET ADJOING MATRRIX OF 3x3 MATRIX void mat3Adjoint(mat3* out, mat3* in) { assert(out != NULL); @@ -400,7 +379,6 @@ void mat3MultiplyScalar(mat3* out, mat3* in, GLfloat x) { } } -//tested // CALCULATE DETERMINANT OF 3x3 MATRIX GLfloat mat3Determinant(mat3* M) { assert(M != NULL); @@ -416,7 +394,6 @@ GLfloat mat3Determinant(mat3* M) { ; } -//tested // GET INVERSE OF 3x3 MATRIX void mat3Inverse(mat3* out, mat3* in) { assert(out != NULL); @@ -429,7 +406,6 @@ void mat3Inverse(mat3* out, mat3* in) { memcpy(out, &result, sizeof(mat3)); } -//tested // GET THE SUM OF DIFFERENCES BETWEEN TWO MATRICES GLfloat sumDiffAny(GLfloat* A, GLfloat* B, int w, int h) { assert(A != NULL); @@ -442,7 +418,6 @@ GLfloat sumDiffAny(GLfloat* A, GLfloat* B, int w, int h) { return result; } -//tested // GET THE SUM OF DIFFERENCES BETWEEN TWO 3x3 MATRICES GLfloat mat3SumDiff(mat3* A, mat3* B) { assert(A != NULL); diff --git a/src/matrixMath.h b/src/matrixMath.h index 6b32ac2..4ad783c 100644 --- a/src/matrixMath.h +++ b/src/matrixMath.h @@ -2,6 +2,12 @@ #define MATRIX_MATH #include +#include +#include +#include +#include + +#include typedef struct { GLfloat x; diff --git a/src/objectHandler.c b/src/objectHandler.c index 3c54b53..272ccc0 100644 --- a/src/objectHandler.c +++ b/src/objectHandler.c @@ -1,9 +1,4 @@ #include "objectHandler.h" -#include "wavefrontobj.h" -#include -#include -#include -#include /** * Loads an object. @@ -75,6 +70,7 @@ void load_object(ObjectData* objectData) { /** * Takes a string-pointer, a number of files to read and a number to store the added objects to * Returns an array of objects. + * The increasing count would be used in the main.c. */ ObjectData* readObjFiles(char** path, int numModels, int* count) { assert(path != NULL); diff --git a/src/objectHandler.h b/src/objectHandler.h index efcf724..e180693 100644 --- a/src/objectHandler.h +++ b/src/objectHandler.h @@ -1,7 +1,12 @@ #ifndef OBJECTHANDLER_H #define OBJECTHANDLER_H +#include "wavefrontobj.h" #include "wavefrontobj.h" +#include +#include +#include +#include typedef struct { GLuint vao; diff --git a/src/sceneGraph.c b/src/sceneGraph.c index ecf3376..06bff09 100644 --- a/src/sceneGraph.c +++ b/src/sceneGraph.c @@ -1,12 +1,6 @@ // sceneGraph.c #include "sceneGraph.h" -#include "objectHandler.h" -#include -#include -#include -#include -#include #define STB_IMAGE_IMPLEMENTATION #include "../lib/stb_image.h" diff --git a/src/sceneGraph.h b/src/sceneGraph.h index 7af51a6..ac18022 100644 --- a/src/sceneGraph.h +++ b/src/sceneGraph.h @@ -7,7 +7,11 @@ #include "matrixMath.h" #include "wavefrontobj.h" #include "objectHandler.h" - +#include +#include +#include +#include +#include typedef struct SceneNode SceneNode; diff --git a/src/shader.c b/src/shader.c index e09d8f2..de1ff76 100644 --- a/src/shader.c +++ b/src/shader.c @@ -1,9 +1,9 @@ -#include -#include -#include #include "shader.h" -#include +/** + * Compiles shader from shaderSource. + * The shader given just needs a shader type to be set beforehand, the rest gets set here. + */ void compileShader(const GLchar *shaderSource, Shader *shader) { assert(shaderSource != NULL); assert(shader != NULL); @@ -26,6 +26,9 @@ void compileShader(const GLchar *shaderSource, Shader *shader) { } } +/** + * Compiles multiple shaders. Basically compileShader() for multiple shaders in one go. + */ void compileShaders(Shader* shaders, const GLchar** glslSources, int numShaders) { assert(glslSources != NULL); assert(shaders != NULL); @@ -34,6 +37,9 @@ void compileShaders(Shader* shaders, const GLchar** glslSources, int numShaders) } } +/** + * Creates a shaderProgram object. + */ ShaderProgram createShaderProgram(const GLchar* vertexSource, const GLchar* fragmentSource) { assert(vertexSource != NULL); assert(fragmentSource != NULL); diff --git a/src/shader.h b/src/shader.h index cb2beab..1e401be 100644 --- a/src/shader.h +++ b/src/shader.h @@ -2,6 +2,9 @@ #define SHADER_UTIL_H #include +#include +#include +#include typedef struct { GLenum type; diff --git a/src/transformation.c b/src/transformation.c index b914ab6..3f5303e 100644 --- a/src/transformation.c +++ b/src/transformation.c @@ -1,10 +1,3 @@ -#include -#include -#include -#include -#include - -#include "matrixMath.h" #include "transformation.h" void lookAt(mat4* out, vec3* eye, vec3* look, vec3* up) { diff --git a/src/transformation.h b/src/transformation.h index 9bbc03d..6799dbf 100644 --- a/src/transformation.h +++ b/src/transformation.h @@ -2,6 +2,12 @@ #define TRANSFORMATION_H #include +#include +#include +#include +#include + +#include "matrixMath.h" extern void lookAt(mat4* out, vec3* eye, vec3* look, vec3* up); extern void perspectiveProjection(mat4* out, GLfloat near, GLfloat far); diff --git a/src/wavefrontobj.c b/src/wavefrontobj.c index 7c99811..4ae5a4b 100644 --- a/src/wavefrontobj.c +++ b/src/wavefrontobj.c @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include - #include "wavefrontobj.h" #define OBJ_LINE_BUFFER_SIZE 256 diff --git a/src/wavefrontobj.h b/src/wavefrontobj.h index 61e6873..6a07aee 100644 --- a/src/wavefrontobj.h +++ b/src/wavefrontobj.h @@ -2,7 +2,11 @@ #define WAVEFRONTOBJ_H #include +#include +#include +#include #include "matrixMath.h" +#include typedef struct { vec3 position;