color: add luminance function

This commit is contained in:
Recep Aslantas
2018-02-23 11:12:55 +03:00
parent 8a16f358a3
commit 4ce2e86d9f
5 changed files with 33 additions and 1 deletions

View File

@@ -20,6 +20,7 @@
#include "euler.h"
#include "plane.h"
#include "box.h"
#include "color.h"
#include "util.h"
#include "io.h"

26
include/cglm/color.h Normal file
View File

@@ -0,0 +1,26 @@
/*
* Copyright (c), Recep Aslantas.
*
* MIT License (MIT), http://opensource.org/licenses/MIT
* Full license can be found in the LICENSE file
*/
#ifndef cglm_color_h
#define cglm_color_h
#include "common.h"
#include "vec3.h"
/*!
* @brief averages the color channels into one value
*
* @param[in] rgb RGB color
*/
CGLM_INLINE
float
glm_luminance(vec3 rgb) {
vec3 l = {0.212671f, 0.715160f, 0.072169f};
return glm_dot(rgb, l);
}
#endif /* cglm_color_h */

View File

@@ -53,7 +53,8 @@ cglm_HEADERS = include/cglm/version.h \
include/cglm/affine-mat.h \
include/cglm/plane.h \
include/cglm/frustum.h \
include/cglm/box.h
include/cglm/box.h \
include/cglm/color.h
cglm_calldir=$(includedir)/cglm/call
cglm_call_HEADERS = include/cglm/call/mat4.h \

View File

@@ -52,6 +52,7 @@
<ClInclude Include="..\include\cglm\call\vec4.h" />
<ClInclude Include="..\include\cglm\cam.h" />
<ClInclude Include="..\include\cglm\cglm.h" />
<ClInclude Include="..\include\cglm\color.h" />
<ClInclude Include="..\include\cglm\common.h" />
<ClInclude Include="..\include\cglm\euler.h" />
<ClInclude Include="..\include\cglm\frustum.h" />

View File

@@ -203,5 +203,8 @@
<ClInclude Include="..\include\cglm\box.h">
<Filter>include\cglm</Filter>
</ClInclude>
<ClInclude Include="..\include\cglm\color.h">
<Filter>include\cglm</Filter>
</ClInclude>
</ItemGroup>
</Project>