stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

test_sdis_camera.c (3023B)


      1 /* Copyright (C) 2016-2025 |Méso|Star> (contact@meso-star.com)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #include "sdis.h"
     17 #include "test_sdis_utils.h"
     18 
     19 #include <rsys/math.h>
     20 
     21 int
     22 main(int argc, char** argv)
     23 {
     24   struct sdis_device* dev;
     25   struct sdis_camera* cam;
     26   double pos[3] = {0};
     27   double tgt[3] = {0};
     28   double up[3] = {0};
     29   (void)argc, (void)argv;
     30 
     31   OK(sdis_device_create(&SDIS_DEVICE_CREATE_ARGS_DEFAULT, &dev));
     32 
     33   BA(sdis_camera_create(NULL, NULL));
     34   BA(sdis_camera_create(dev, NULL));
     35   BA(sdis_camera_create(NULL, &cam));
     36   OK(sdis_camera_create(dev, &cam));
     37 
     38   BA(sdis_camera_ref_get(NULL));
     39   OK(sdis_camera_ref_get(cam));
     40   BA(sdis_camera_ref_put(NULL));
     41   OK(sdis_camera_ref_put(cam));
     42   OK(sdis_camera_ref_put(cam));
     43 
     44   OK(sdis_camera_create(dev, &cam));
     45   BA(sdis_camera_set_proj_ratio(NULL, 0));
     46   BA(sdis_camera_set_proj_ratio(cam, 0));
     47   BA(sdis_camera_set_proj_ratio(NULL, 4.0 / 3.0));
     48   OK(sdis_camera_set_proj_ratio(cam, 4.0/3.0));
     49   BA(sdis_camera_set_proj_ratio(cam, -4.0/3.0));
     50 
     51   BA(sdis_camera_set_fov(NULL, 0));
     52   BA(sdis_camera_set_fov(cam, 0));
     53   BA(sdis_camera_set_fov(NULL, PI/4.0));
     54   OK(sdis_camera_set_fov(cam, PI/4.0));
     55   BA(sdis_camera_set_fov(cam, -PI/4.0));
     56 
     57   pos[0] = 0, pos[1] = 0, pos[2] = 0;
     58   tgt[0] = 0, tgt[1] = 0, tgt[2] = -1;
     59   up[0] = 0, up[1] = 1, up[2] = 0;
     60   BA(sdis_camera_look_at(NULL, NULL, NULL, NULL));
     61   BA(sdis_camera_look_at(cam, NULL, NULL, NULL));
     62   BA(sdis_camera_look_at(NULL, pos, NULL, NULL));
     63   BA(sdis_camera_look_at(cam, pos, NULL, NULL));
     64   BA(sdis_camera_look_at(NULL, NULL, tgt, NULL));
     65   BA(sdis_camera_look_at(cam, NULL, tgt, NULL));
     66   BA(sdis_camera_look_at(NULL, pos, tgt, NULL));
     67   BA(sdis_camera_look_at(cam, pos, tgt, NULL));
     68   BA(sdis_camera_look_at(NULL, NULL, NULL, up));
     69   BA(sdis_camera_look_at(cam, NULL, NULL, up));
     70   BA(sdis_camera_look_at(NULL, pos, NULL, up));
     71   BA(sdis_camera_look_at(cam, pos, NULL, up));
     72   BA(sdis_camera_look_at(NULL, NULL, tgt, up));
     73   BA(sdis_camera_look_at(cam, NULL, tgt, up));
     74   BA(sdis_camera_look_at(NULL, pos, tgt, up));
     75   OK(sdis_camera_look_at(cam, pos, tgt, up));
     76   tgt[0] = 0, tgt[1] = 0, tgt[2] = 0;
     77   BA(sdis_camera_look_at(cam, pos, tgt, up));
     78   tgt[0] = 0, tgt[1] = 0, tgt[2] = -1;
     79   up[0] = 0, up[1] = 0, up[2] = 0;
     80   BA(sdis_camera_look_at(cam, pos, tgt, up));
     81 
     82   OK(sdis_device_ref_put(dev));
     83   OK(sdis_camera_ref_put(cam));
     84 
     85   CHK(mem_allocated_size() == 0);
     86   return 0;
     87 }
     88