BRL-CAD
sh_xxx.c File Reference
#include "common.h"
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "bu/units.h"
#include "vmath.h"
#include "raytrace.h"
#include "optical.h"
Include dependency graph for sh_xxx.c:

Go to the source code of this file.

Data Structures

struct  xxx_specific
 

Macros

#define xxx_MAGIC   0x1834 /* make this a unique number for each shader */
 
#define CK_xxx_SP(_p)   BU_CKMAG(_p, xxx_MAGIC, "xxx_specific")
 
#define SHDR_NULL   ((struct xxx_specific *)0)
 
#define SHDR_O(m)   bu_offsetof(struct xxx_specific, m)
 

Functions

HIDDEN int xxx_setup (register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
 
HIDDEN int xxx_render (struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
 
HIDDEN void xxx_print (register struct region *rp, void *dp)
 
HIDDEN void xxx_free (void *cp)
 

Variables

struct bu_structparse xxx_print_tab []
 
struct bu_structparse xxx_parse_tab []
 
struct mfuncs xxx_mfuncs []
 

Detailed Description

To add a new shader to the "rt" program's LIBOPTICAL library:

1) Copy this file to sh_shadername.c

2) edit sh_shadername.c: change "X X X" to "S H A D E R N A M E" change "xxx" to "shadername" Set a new number for the xxx_MAGIC define define shader specific structure and defaults edit/build parse table for bu_structparse from xxx_parse edit/build shader_mfuncs tables from xxx_mfuncs for each shader name being built. edit the xxx_setup function to do shader-specific setup edit the xxx_render function to do the actual rendering

If you are building a dynamically loaded shader, compile this into a shared library called "shadername.so". If you have a number of shaders for you are adding, you can create a single library called "shaders.so" which contains all of your DSO shaders.

RT will look in the following locations for DSO shaders: ./ $prefix/lib/ $LD_LIBRARY_PATH

If you are adding the shader to "rt" as a permanent shader, then the following steps are necessary:

3) Edit init.c to add extern for xxx_mfuncs and a call to mlib_add_shader().

4) Edit CMakeLists.txt to add shader file to the compilation

5) replace this list with a description of the shader, its parameters and use.

6) Edit shaders.tcl and comb.tcl in the ../tclscripts/mged directory to add a new gui for this shader.

Definition in file sh_xxx.c.

Macro Definition Documentation

#define xxx_MAGIC   0x1834 /* make this a unique number for each shader */

Definition at line 76 of file sh_xxx.c.

#define CK_xxx_SP (   _p)    BU_CKMAG(_p, xxx_MAGIC, "xxx_specific")

Definition at line 77 of file sh_xxx.c.

Referenced by xxx_render().

#define SHDR_NULL   ((struct xxx_specific *)0)

Definition at line 109 of file sh_xxx.c.

#define SHDR_O (   m)    bu_offsetof(struct xxx_specific, m)

Definition at line 110 of file sh_xxx.c.

Function Documentation

HIDDEN int xxx_setup ( register struct region rp,
struct bu_vls matparm,
void **  dpp,
const struct mfuncs *  mfp,
struct rt_i rtip 
)

Definition at line 165 of file sh_xxx.c.

References bn_mat_print(), BU_CK_VLS, BU_GET, bu_log(), bu_struct_parse(), bu_struct_print(), rdebug, RDEBUG_SHADE, region::reg_name, RT_CHECK_RTI, RT_CK_REGION, and xxx_specific::xxx_m_to_sh.

Here is the call graph for this function:

int xxx_render ( struct application ap,
const struct partition pp,
struct shadework *  swp,
void *  dp 
)

Definition at line 243 of file sh_xxx.c.

References bu_struct_print(), CK_xxx_SP, rdebug, RDEBUG_SHADE, rr_render(), RT_AP_CHECK, RT_CHECK_PT, and VSETALL.

Here is the call graph for this function:

HIDDEN void xxx_print ( register struct region rp,
void *  dp 
)

Definition at line 224 of file sh_xxx.c.

References bu_struct_print(), and region::reg_name.

Here is the call graph for this function:

HIDDEN void xxx_free ( void *  cp)

Definition at line 231 of file sh_xxx.c.

References BU_PUT.

Variable Documentation

struct bu_structparse xxx_print_tab[]
Initial value:
= {
{"%g", 1, "val", SHDR_O(xxx_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "dist", SHDR_O(xxx_dist), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "delta", SHDR_O(xxx_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "max", SHDR_O(xxx_max), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%f", 3, "min", SHDR_O(xxx_min), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
#define SHDR_O(m)
Definition: sh_xxx.c:110

Definition at line 117 of file sh_xxx.c.

struct bu_structparse xxx_parse_tab[]
Initial value:
= {
{"%p", 1, "xxx_print_tab", bu_byteoffset(xxx_print_tab[0]), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "v", SHDR_O(xxx_val), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"%g", 1, "dist", SHDR_O(xxx_dist), bu_mm_cvt, NULL, NULL },
{"%f", 3, "d", SHDR_O(xxx_delta), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
{"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
}
#define bu_byteoffset(_i)
Definition: parse.h:81
struct bu_structparse xxx_print_tab[]
Definition: sh_xxx.c:117
void bu_mm_cvt(const struct bu_structparse *sdp, const char *name, void *base, const char *value, void *data)
Definition: units.c:386
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
#define SHDR_O(m)
Definition: sh_xxx.c:110

Definition at line 126 of file sh_xxx.c.

struct mfuncs xxx_mfuncs[]
Initial value:
= {
{MF_MAGIC, "xxx", 0, MFI_NORMAL|MFI_HIT|MFI_UV, 0, xxx_setup, xxx_render, xxx_print, xxx_free },
{0, (char *)0, 0, 0, 0, 0, 0, 0, 0 }
}
#define MF_MAGIC
Definition: magic.h:205
HIDDEN void xxx_print(register struct region *rp, void *dp)
Definition: sh_xxx.c:224
HIDDEN void xxx_free(void *cp)
Definition: sh_xxx.c:231
HIDDEN int xxx_render(struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
Definition: sh_xxx.c:243
HIDDEN int xxx_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_xxx.c:165

Definition at line 148 of file sh_xxx.c.