solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit 673b3048ec807677fab039260b80350433c13bda
parent 2414d2303f186b0d7d57ca37bb2cb90ea29a701b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 24 Aug 2016 15:06:50 +0200

Move shader code to a new header file to share it with other tests

Diffstat:
Mcmake/CMakeLists.txt | 1+
Msrc/test_ssol_material.c | 59+++++++----------------------------------------------------
Asrc/test_ssol_materials.h | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 74 insertions(+), 52 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -119,6 +119,7 @@ if(NOT NO_TEST) add_executable(${_name} ${SSOL_SOURCE_DIR}/test_ssol_utils.h ${SSOL_SOURCE_DIR}/test_ssol_geometries.h + ${SSOL_SOURCE_DIR}/test_ssol_materials.h ${SSOL_SOURCE_DIR}/${_name}.c) target_link_libraries(${_name} solstice-solver RSys Star3D StarSP) set(_libraries ${ARGN}) diff --git a/src/test_ssol_material.c b/src/test_ssol_material.c @@ -15,55 +15,10 @@ #include "ssol.h" #include "test_ssol_utils.h" +#include "test_ssol_materials.h" #include <rsys/logger.h> -static void -get_normal - (struct ssol_device* dev, - const double wavelength, - const double P[3], - const double Ng[3], - const double Ns[3], - const double uv[2], - const double w[3], - double* val) -{ - int i; - (void)dev, (void)wavelength, (void)P, (void)Ng, (void)uv, (void)w; - FOR_EACH(i, 0, 3) val[i] = Ns[i]; -} - -static void -get_reflectivity - (struct ssol_device* dev, - const double wavelength, - const double P[3], - const double Ng[3], - const double Ns[3], - const double uv[2], - const double w[3], - double* val) -{ - (void)dev, (void)wavelength, (void)P, (void)Ng, (void)Ns, (void)uv, (void)w; - *val = 1; -} - -static void -get_roughness - (struct ssol_device* dev, - const double wavelength, - const double P[3], - const double Ng[3], - const double Ns[3], - const double uv[2], - const double w[3], - double* val) -{ - (void)dev, (void)wavelength, (void)P, (void)Ng, (void)Ns, (void)uv, (void)w; - *val = 0; -} - /******************************************************************************* * Test main program ******************************************************************************/ @@ -96,9 +51,9 @@ main(int argc, char** argv) CHECK(ssol_material_ref_put(NULL), RES_BAD_ARG); CHECK(ssol_material_ref_put(material), RES_OK); - shader.normal = get_normal; - shader.reflectivity = get_reflectivity; - shader.roughness = get_roughness; + shader.normal = get_shader_normal; + shader.reflectivity = get_shader_reflectivity; + shader.roughness = get_shader_roughness; CHECK(ssol_mirror_set_shader(NULL, &shader), RES_BAD_ARG); CHECK(ssol_mirror_set_shader(material, NULL), RES_BAD_ARG); @@ -106,15 +61,15 @@ main(int argc, char** argv) shader.normal = NULL; CHECK(ssol_mirror_set_shader(material, &shader), RES_BAD_ARG); - shader.normal = get_normal; + shader.normal = get_shader_normal; shader.reflectivity = NULL; CHECK(ssol_mirror_set_shader(material, &shader), RES_BAD_ARG); - shader.reflectivity = get_reflectivity; + shader.reflectivity = get_shader_reflectivity; shader.roughness = NULL; CHECK(ssol_mirror_set_shader(material, &shader), RES_BAD_ARG); - shader.roughness = get_roughness; + shader.roughness = get_shader_roughness; CHECK(ssol_material_ref_put(material), RES_OK); diff --git a/src/test_ssol_materials.h b/src/test_ssol_materials.h @@ -0,0 +1,66 @@ +/* Copyright (C) CNRS 2016 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef TEST_SSOL_MATERIALS_H +#define TEST_SSOL_MATERIALS_H + +static void +get_shader_normal +(struct ssol_device* dev, + const double wavelength, + const double P[3], + const double Ng[3], + const double Ns[3], + const double uv[2], + const double w[3], + double* val) +{ + int i; + (void) dev, (void) wavelength, (void) P, (void) Ng, (void) uv, (void) w; + FOR_EACH(i, 0, 3) val[i] = Ns[i]; +} + +static void +get_shader_reflectivity +(struct ssol_device* dev, + const double wavelength, + const double P[3], + const double Ng[3], + const double Ns[3], + const double uv[2], + const double w[3], + double* val) +{ + (void) dev, (void) wavelength, (void) P, (void) Ng, (void) Ns, (void) uv, (void) w; + *val = 1; +} + +static void +get_shader_roughness +(struct ssol_device* dev, + const double wavelength, + const double P[3], + const double Ng[3], + const double Ns[3], + const double uv[2], + const double w[3], + double* val) +{ + (void) dev, (void) wavelength, (void) P, (void) Ng, (void) Ns, (void) uv, (void) w; + *val = 0; +} + + +#endif /* TEST_SSOL_MATERIALS_H */