diff --git a/CMakeLists.txt b/CMakeLists.txt index 01086fa..3868b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ add_library(${PROJECT_NAME} src/mat4x2.c src/mat4x3.c src/plane.c + src/perlin.c src/frustum.c src/box.c src/project.c diff --git a/Makefile.am b/Makefile.am index 2a8ce0e..f29bfb0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -67,6 +67,7 @@ cglm_HEADERS = include/cglm/version.h \ include/cglm/util.h \ include/cglm/quat.h \ include/cglm/plane.h \ + include/cglm/perlin.h \ include/cglm/frustum.h \ include/cglm/box.h \ include/cglm/aabb2d.h \ @@ -120,6 +121,7 @@ cglm_call_HEADERS = include/cglm/call/mat4.h \ include/cglm/call/quat.h \ include/cglm/call/euler.h \ include/cglm/call/plane.h \ + include/cglm/call/perlin.h \ include/cglm/call/frustum.h \ include/cglm/call/box.h \ include/cglm/call/project.h \ @@ -210,6 +212,7 @@ cglm_struct_HEADERS = include/cglm/struct/mat4.h \ include/cglm/struct/quat.h \ include/cglm/struct/euler.h \ include/cglm/struct/plane.h \ + include/cglm/struct/perlin.h \ include/cglm/struct/frustum.h \ include/cglm/struct/box.h \ include/cglm/struct/aabb2d.h \ @@ -261,6 +264,7 @@ libcglm_la_SOURCES=\ src/mat4x2.c \ src/mat4x3.c \ src/plane.c \ + src/perlin.c \ src/frustum.c \ src/box.c \ src/project.c \ diff --git a/include/cglm/call.h b/include/cglm/call.h index de775d2..b298052 100644 --- a/include/cglm/call.h +++ b/include/cglm/call.h @@ -32,6 +32,7 @@ extern "C" { #include "call/quat.h" #include "call/euler.h" #include "call/plane.h" +#include "call/perlin.h" #include "call/frustum.h" #include "call/aabb2d.h" #include "call/box.h" diff --git a/include/cglm/call/perlin.h b/include/cglm/call/perlin.h new file mode 100644 index 0000000..521e21d --- /dev/null +++ b/include/cglm/call/perlin.h @@ -0,0 +1,23 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#ifndef cglmc_perlin_h +#define cglmc_perlin_h +#ifdef __cplusplus +extern "C" { +#endif + +#include "../cglm.h" + +CGLM_EXPORT +float +glmc_perlin(vec4 point); + +#ifdef __cplusplus +} +#endif +#endif /* cglmc_perlin_h */ diff --git a/include/cglm/cglm.h b/include/cglm/cglm.h index 5e15a3c..8741422 100644 --- a/include/cglm/cglm.h +++ b/include/cglm/cglm.h @@ -30,6 +30,7 @@ #include "quat.h" #include "euler.h" #include "plane.h" +#include "perlin.h" #include "aabb2d.h" #include "box.h" #include "color.h" diff --git a/include/cglm/struct.h b/include/cglm/struct.h index 1426589..f03b9dd 100644 --- a/include/cglm/struct.h +++ b/include/cglm/struct.h @@ -31,6 +31,7 @@ extern "C" { #include "struct/affine.h" #include "struct/frustum.h" #include "struct/plane.h" +#include "struct/perlin.h" #include "struct/box.h" #include "struct/color.h" #include "struct/io.h" diff --git a/include/cglm/struct/perlin.h b/include/cglm/struct/perlin.h new file mode 100644 index 0000000..4897417 --- /dev/null +++ b/include/cglm/struct/perlin.h @@ -0,0 +1,33 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#ifndef cglms_perlins_h +#define cglms_perlins_h + +#include "../common.h" +#include "../types-struct.h" +#include "../perlin.h" +#include "vec4.h" + +/* + Functions: + CGLM_INLINE float glms_perlin(vec4s point); + */ + +/*! + * @brief Classic perlin noise + * + * @param[in] point 4D vector + * @returns perlin noise value + */ +CGLM_INLINE +float +glms_perlin(vec4s point) { + return glm_perlin(point.raw); +} + +#endif /* cglms_perlins_h */ diff --git a/meson.build b/meson.build index 3afdc4f..f79a007 100644 --- a/meson.build +++ b/meson.build @@ -56,6 +56,7 @@ cglm_src = files( 'src/mat4x2.c', 'src/mat4x3.c', 'src/plane.c', + 'src/perlin.c', 'src/frustum.c', 'src/box.c', 'src/project.c', diff --git a/src/perlin.c b/src/perlin.c new file mode 100644 index 0000000..5c57296 --- /dev/null +++ b/src/perlin.c @@ -0,0 +1,15 @@ +/* + * Copyright (c), Recep Aslantas. + * + * MIT License (MIT), http://opensource.org/licenses/MIT + * Full license can be found in the LICENSE file + */ + +#include "../include/cglm/cglm.h" +#include "../include/cglm/call.h" + +CGLM_EXPORT +float +glmc_perlin(vec4 p) { + return glm_perlin(p); +}