BRL-CAD
shadefuncs.h
Go to the documentation of this file.
1/* S H A D E F U N C S . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup liboptical */
21/** @{ */
22/** @file shadefuncs.h
23 *
24 */
25
26#ifndef OPTICAL_SHADEFUNCS_H
27#define OPTICAL_SHADEFUNCS_H
28
29#include "common.h"
30
31#include "bu/vls.h"
32#include "rt/application.h"
33#include "rt/region.h"
34#include "rt/rt_instance.h"
35#include "optical/defines.h"
36#include "optical/shadework.h"
37
38/**
39 * The interface to the various material property & texture routines.
40 */
41struct mfuncs {
42 uint32_t mf_magic; /**< @brief To validate structure */
43 char *mf_name; /**< @brief Keyword for material */
44 struct mfuncs *mf_forw; /**< @brief Forward link */
45 int mf_inputs; /**< @brief shadework inputs needed */
46 int mf_flags; /**< @brief Flags describing shader */
47 int (*mf_setup)(struct region *rp,
48 struct bu_vls *matparm,
49 void **dpp,
50 const struct mfuncs *mfp,
51 struct rt_i *rtip); /**< @brief Routine for preparing */
52 int (*mf_render)(struct application *ap,
53 const struct partition *pp,
54 struct shadework *swp,
55 void *dp); /**< @brief Routine for rendering */
56 void (*mf_print)(struct region *rp,
57 void *dp); /**< @brief Routine for printing */
58 void (*mf_free)(void *cp); /**< @brief Routine for releasing storage */
59};
60#define MF_NULL ((struct mfuncs *)0)
61#define RT_CK_MF(_p) BU_CKMAG(_p, MF_MAGIC, "mfuncs")
62
63/*
64 * mf_inputs lists what optional shadework fields are needed.
65 * dist, point, color, & default(trans, reflect, ri) are always provided
66 */
67#define MFI_NORMAL 0x01 /**< @brief Need normal */
68#define MFI_UV 0x02 /**< @brief Need uv */
69#define MFI_LIGHT 0x04 /**< @brief Need light visibility */
70#define MFI_HIT 0x08 /**< @brief Need just hit point */
71
72/** for bu_printb() */
73#define MFI_FORMAT "\020" /* print hex */ \
74 "\4HIT" \
75 "\3LIGHT" \
76 "\2UV" \
77 "\1NORMAL"
78
79
80/* mf_flags lists important details about individual shaders */
81#define MFF_PROC 0x01 /**< @brief shader is procedural, computes tr/re/hits */
82
83__BEGIN_DECLS
84
85/* defined in material.c */
86OPTICAL_EXPORT extern void mlib_add_shader(struct mfuncs **headp,
87 struct mfuncs *mfp1);
88
89OPTICAL_EXPORT extern int mlib_setup(struct mfuncs **headp,
90 struct region *rp,
91 struct rt_i *rtip);
92
93OPTICAL_EXPORT extern void mlib_free(struct region *rp);
94
95/**
96 * Given a shader/material name, try to find a DSO to supply the
97 * shader.
98 */
99OPTICAL_EXPORT extern struct mfuncs *load_dynamic_shader(const char *material);
100
101__END_DECLS
102
103#endif /* OPTICAL_SHADEFUNCS_H */
104
105
106/** @} */
107/*
108 * Local Variables:
109 * mode: C
110 * tab-width: 8
111 * indent-tabs-mode: t
112 * c-file-style: "stroustrup"
113 * End:
114 * ex: shiftwidth=4 tabstop=8
115 */
Header file for the BRL-CAD common definitions.
void mlib_add_shader(struct mfuncs **headp, struct mfuncs *mfp1)
int mlib_setup(struct mfuncs **headp, struct region *rp, struct rt_i *rtip)
struct mfuncs * load_dynamic_shader(const char *material)
void mlib_free(struct region *rp)
Definition: vls.h:53
int(* mf_setup)(struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Routine for preparing.
Definition: shadefuncs.h:47
void(* mf_free)(void *cp)
Routine for releasing storage.
Definition: shadefuncs.h:58
struct mfuncs * mf_forw
Forward link.
Definition: shadefuncs.h:44
void(* mf_print)(struct region *rp, void *dp)
Routine for printing.
Definition: shadefuncs.h:56
char * mf_name
Keyword for material.
Definition: shadefuncs.h:43
int(* mf_render)(struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
Routine for rendering.
Definition: shadefuncs.h:52
int mf_inputs
shadework inputs needed
Definition: shadefuncs.h:45
uint32_t mf_magic
To validate structure.
Definition: shadefuncs.h:42
int mf_flags
Flags describing shader.
Definition: shadefuncs.h:46
Definition: region.h:44