star-3daw

Create star-3d geometries from OBJ files
git clone git://git.meso-star.fr/star-3daw.git
Log | Files | Refs | README | LICENSE

s3daw.h (3610B)


      1 /* Copyright (C) 2015, 2016, 2020, 2021, 2023 |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 #ifndef S3DAW_H
     17 #define S3DAW_H
     18 
     19 #include <rsys/rsys.h>
     20 
     21 /* Library symbol management */
     22 #if defined(S3DAW_SHARED_BUILD) /* Build shared library */
     23   #define S3DAW_API extern EXPORT_SYM
     24 #elif defined(S3DAW_STATIC) /* Use/build static library */
     25   #define S3DAW_API extern LOCAL_SYM
     26 #else /* Use shared library */
     27   #define S3DAW_API extern IMPORT_SYM
     28 #endif
     29 
     30 /* Helper macro that asserts if the invocation of the s3daw function `Func'
     31  * returns an error. One should use this macro on smc function calls for which
     32  * no explicit error checking is performed */
     33 #ifndef NDEBUG
     34   #define S3DAW(Func) ASSERT(s3daw_ ## Func == RES_OK)
     35 #else
     36   #define S3DAW(Func) s3daw_ ## Func
     37 #endif
     38 
     39 /* Forward declaration of external types */
     40 struct aw_obj;
     41 struct aw_mtl;
     42 struct logger;
     43 struct mem_allocator;
     44 struct s3d_device;
     45 struct s3d_shape;
     46 struct s3d_scene;
     47 
     48 /* Forward declaration *of opaque s3daw types */
     49 struct s3daw;
     50 
     51 /*******************************************************************************
     52  * S3DAW API
     53  ******************************************************************************/
     54 BEGIN_DECLS
     55 
     56 S3DAW_API res_T
     57 s3daw_create
     58   (struct logger* logger, /* May be NULL <=> use default logger */
     59    struct mem_allocator* allocator, /* May be NULL <=> use default allocator */
     60    struct aw_obj* loader_obj, /* May be NULL <=> Internally create the loader */
     61    struct aw_mtl* loader_mtl, /* May be nULL <=> Internally create the loader */
     62    struct s3d_device* s3d,
     63    const int verbose, /* Verbosity level */
     64    struct s3daw** s3daw);
     65 
     66 S3DAW_API res_T
     67 s3daw_ref_get
     68   (struct s3daw* s3daw);
     69 
     70 S3DAW_API res_T
     71 s3daw_ref_put
     72   (struct s3daw* s3daw);
     73 
     74 S3DAW_API res_T
     75 s3daw_get_loaders
     76   (struct s3daw* s3daw,
     77    struct aw_obj** obj, /* May be NULL <=> Do not get the obj loader */
     78    struct aw_mtl** mtl); /* May be NULL <=> Do not get the mtl loader */
     79 
     80 /* Return the internally used Star-3D device. Note that the reference counter
     81  * of device is not incremented. */
     82 S3DAW_API res_T
     83 s3daw_get_s3d_device
     84   (struct s3daw* s3daw,
     85    struct s3d_device** device);
     86 
     87 S3DAW_API res_T
     88 s3daw_load
     89   (struct s3daw* s3daw,
     90    const char* filename);
     91 
     92 S3DAW_API res_T
     93 s3daw_load_stream
     94   (struct s3daw* s3daw,
     95    FILE* stream);
     96 
     97 /* Remove all loaded shapes */
     98 S3DAW_API res_T
     99 s3daw_clear
    100   (struct s3daw* s3daw);
    101 
    102 S3DAW_API res_T
    103 s3daw_get_shapes_count
    104   (const struct s3daw* s3daw,
    105    size_t* nshapes);
    106 
    107 S3DAW_API res_T
    108 s3daw_get_shape
    109   (struct s3daw* s3daw,
    110    const size_t ishape, /* in [0, s3d_get_shapes_count) */
    111    struct s3d_shape** shape);
    112 
    113 /* Attach the loaded s3d shapes to the submitted scene. */
    114 S3DAW_API res_T
    115 s3daw_attach_to_scene
    116   (struct s3daw* s3daw,
    117    struct s3d_scene* scene);
    118 
    119 /* Detach the loaded s3d shapes from the submitted scene. */
    120 S3DAW_API res_T
    121 s3daw_detach_from_scene
    122   (struct s3daw* s3daw,
    123    struct s3d_scene* scene);
    124 
    125 END_DECLS
    126 
    127 #endif /* S3DAW_H */
    128