diff --git a/README.md b/README.md index 2fd0d36..006e98e 100644 --- a/README.md +++ b/README.md @@ -127,27 +127,49 @@ Extensions: * echo area is given as a fraction of the root window ## Transparency + +### PSALCH (DEPRECATED) The ALPHA channel in a structure can be set with CALL PSALCH(X) where X is a floating point number between 0. (fully transparent) and 1. (fully opaque). +### RGBA Color mode +This version supports colors with 4 components. To switch to this mode, use PMODEL_RGBA instead of PMODEL_RGB which is the default. This +can be done via a call to PSCM(WKID, COLORMODE). Note that this call should be done directly after the workstation has been opened. +Use + +COLORMODE=0 for PINDIRECT +COLORMODE=1 for PMODEL_RGB +COLORMODE=2 for PMODEL_RGBA + +### Default colors +To pre-define some colors you can use + +CALL PXSCM(WKID) + +In COLORMODE=1 create 125 colors starting with index 16. Any colors with lower indices will not be touched. +In COLORMODE=2 same as above. In addition, it will create 5 levels of transparent colors for all colors, with offset 200 with decreasing transparency. This is done as well for any existing colors with indices between 1 and 15. + ## Extensions ### Fortran bindings * PXNDEF(STRING NAME): set the configuration location and file name * PXSHCSF(INTEGER IWK, REAL VALUE): Set hardcopy scale factor for workstation ID WKID. Must be set before the workstation is being opened. * PXQHCSF(INTEGER IWK, REAL VALUE): Inquire the current scale factor for workstation ID WKID. The value is returned in the second argument. - -* PSALCH(REAL VALUE): set ALPHA channel to Value. Value is between 0(fully transparent) and 1 (opaque). Added to the current structure. +* PSALCH(REAL VALUE): (deprecated) set ALPHA channel to Value. Value is between 0(fully transparent) and 1 (opaque). Added to the current structure. * PSFNAME(INTEGER IWK, CHARACTER FNAME): set output file name for workstation ID IWK +* PXSCM(): Set color map ### C-bindings * pxset_conf_file_name(char* path): set the configuration location and file name -* pxset_conf_hcsf(WKID, Pfloat value): Set hardcopy scale factor for workstation ID WKID. Must be set before the workstation is being opened -* Pfloat pxinq_conf_hcsf(WKID): Inquire the current hardcopy scale factor for workstation ID WKID. - +* pxset_conf_hcsf(int wkid, Pfloat value): Set hardcopy scale factor for workstation ID WKID. Must be set before the workstation is being opened +* Pfloat pxinq_conf_hcsf(int wkid): Inquire the current hardcopy scale factor for workstation ID WKID. * pset_alpha_channel(float value): C-Binding for PSALCH. Added to the current structure. +* pxset_color_map(int wkid): set color map + +### Configuration file +By default, OpenPHIGS will look for a file named phigs.def in the current directly, and use it to apply default values. This is where you can set window names, backgrounds etc. Explanations can be found in the template shipped with the distribution. ## Versions * 0.0.1-1: Revised code from upstream @@ -159,3 +181,4 @@ where X is a floating point number between 0. (fully transparent) and 1. (fully * v0.3-2: C style fixings * v0.3-3: test_f5 review, code improvements, clipping review * V0.4-1: bug fixes, improve Wayland support, edge-cases on Mac and add support for a second clipping plane +* V0.5-1: Improved support for transparency diff --git a/phigs.def b/phigs.def index 0856b99..c057458 100644 --- a/phigs.def +++ b/phigs.def @@ -2,7 +2,9 @@ Example Parameters for workstation 1 Enabled switches: %XX, Comment by replacing the % by some other character Global flags: -%gs 1 Use shaders (1) or not (0) +%gs 1 Use shaders (1) or not (0) +%vs 120 Vertex shader version 1.30 +%fs 120 Fragment shader version 1.30 %pc 1 print configuration. Set to 0 to disable. Parameters set for all workstations: kept for historical reasons @@ -13,6 +15,8 @@ Parameters set for all workstations: kept for historical reasons %fp 6x13 %cm 3 %pa 2 +%bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A Per workstation configurations %wk 4 workstation for rendering @@ -20,13 +24,15 @@ Per workstation configurations %wn Markers workstation name %in Markers workstation icon name %wg 512 512 0 0 1 Window width height px py border -%bg 0. 0. 0. Background color R G B +%bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A Workstation example for output as tga %wk 99 Workstation for hardcopy %wg 1024 1024 0 0 1 Window width height px py border %wp 0.0 1.0 0.0 1. position %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A %hs 3. scale factor for hardcopy Workstation example for output png @@ -34,6 +40,7 @@ Workstation example for output png %wg 1024 1024 0 0 1 Window width height px py border %wp 0.0 1.0 0.0 1. position %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A %hs 2. scale factor for hardcopy Workstation example for output pnga @@ -42,6 +49,7 @@ Workstation example for output pnga %wp 0.0 1.0 0.0 1. position %hs 1. scale factor for hardcopy %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A Workstation example for output eps %wk 96 Workstation for hardcopy @@ -49,6 +57,7 @@ Workstation example for output eps %wp 0.0 1.0 0.0 1. position %hs 1. scale factor for hardcopy %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A Workstation example for output pdf %wk 95 Workstation for hardcopy @@ -56,6 +65,7 @@ Workstation example for output pdf %wp 0.0 1.0 0.0 1. position %hs 1. scale factor for hardcopy %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A Workstation example for output svg %wk 94 Workstation for hardcopy @@ -63,6 +73,7 @@ Workstation example for output svg %wp 0.0 1.0 0.0 1. position %hs 1. scale factor for hardcopy %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A Workstation example for output obj %wk 93 Workstation for hardcopy @@ -70,3 +81,4 @@ Workstation example for output obj %wp 0.0 1.0 0.0 1. position %hs 1. scale factor for hardcopy %bg 0. 0. 0. Background color R G B +%bga 0. 0. 0. 0.5 Background color R G B A diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba8ddb1..a1ea6a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,7 @@ set(GLEW_VERBOSE ON) # for debugging add_definitions(-g) # add_definitions(-DTEST) +# add_definitions(-DDEBUGA) # add_definitions(-DDEBUG) # add_definitions(-DDEBUGL) # add_definitions(-DDEBUGINP) diff --git a/src/include/phigs/phconf.h b/src/include/phigs/phconf.h index 1b4dd4c..0f58386 100644 --- a/src/include/phigs/phconf.h +++ b/src/include/phigs/phconf.h @@ -34,7 +34,8 @@ extern "C" { char filename[512]; /* Output filename for hard copies */ int set_window_pos; Plimit vpos; - Pcolr_rep background_color; + Pcolr_rep background_color_rgb; + Pcolr_rep background_color_rgba; unsigned int display_width; unsigned int display_height; unsigned int border_width; diff --git a/src/include/phigs/phigs.h b/src/include/phigs/phigs.h index 0c7ddd9..bd31165 100644 --- a/src/include/phigs/phigs.h +++ b/src/include/phigs/phigs.h @@ -55,16 +55,16 @@ SOFTWARE. extern "C" { #endif -/* Max name length */ + /* Max name length */ #define PHIGS_MAX_NAME_LEN 255 -/* Line types */ + /* Line types */ #define PLINE_SOLID 1 #define PLINE_DASH 2 #define PLINE_DOT 3 #define PLINE_DASH_DOT 4 -/* Marker types */ + /* Marker types */ #define PMARKER_DOT 1 #define PMARKER_PLUS 2 #define PMARKER_ASTERISK 3 @@ -75,4126 +75,4148 @@ extern "C" { #define PMARKER_PENTAGON 8 #define PMARKER_HEXAGON 9 -/* Color model */ + /* Color model */ #define PINDIRECT 0 #define PMODEL_RGB 1 +#define PMODEL_RGBA 2 -/* HLHSR constants */ + /* HLHSR constants */ #define PHIGS_HLHSR_MODE_NONE 0 #define PHIGS_HLHSR_MODE_ZBUFF 1 #define PHIGS_HLHSR_ID_OFF 0 #define PHIGS_HLHSR_ID_ON 1 +#define PHIGS_HLHSR_ID_ON_NZ 2 -/* Facet data flags */ + /* Facet data flags */ #define PFACET_NONE 0 #define PFACET_COLOUR 1 #define PFACET_NORMAL 2 #define PFACET_COLOUR_NORMAL 3 -/* Edge data flags */ + /* Edge data flags */ #define PEDGE_NONE 0 #define PEDGE_VISIBILITY 1 -/* Vertex data flags */ + /* Vertex data flags */ #define PVERT_COORD 0 #define PVERT_COORD_COLOUR 1 #define PVERT_COORD_NORMAL 2 #define PVERT_COORD_COLOUR_NORMAL 3 -/* Shading methods */ + /* Shading methods */ #define PSD_NONE 1 #define PSD_COLOUR 2 -/* Surface reflection */ + /* Surface reflection */ #define PREFL_NONE 1 #define PREFL_AMBIENT 2 #define PREFL_AMB_DIFF 3 #define PREFL_AMB_DIFF_SPEC 4 -/* Light source types */ + /* Light source types */ #define PLIGHT_AMBIENT 1 #define PLIGHT_DIRECTIONAL 2 #define PLIGHT_POSITIONAL 3 #define PLIGHT_SPOT 4 -/* PHIGS states */ -typedef enum { - PSYS_ST_PHCL, - PSYS_ST_PHOP -} Psys_st; - -typedef enum { - PWS_ST_WSCL, - PWS_ST_WSOP -} Pws_st; - -typedef enum { - PSTRUCT_ST_STCL, - PSTRUCT_ST_STOP -} Pstruct_st; - -/* Archive releated */ -typedef enum { - PST_ARCL, - PST_AROP -} Par_st; - -typedef enum { - PNET_CSS, - PNET_AR -} Pstruct_net_source; - -/* Workstation related */ -typedef enum { - PCLASS_VEC, - PCLASS_RASTER, - PCLASS_OTHER -} Pws_class; - -typedef enum { - PCAT_OUT, - PCAT_IN, - PCAT_OUTIN, - PCAT_MO, - PCAT_MI, - PCAT_TGA, - PCAT_PNG, - PCAT_PNGA, - PCAT_EPS, - PCAT_PDF, - PCAT_SVG, - PCAT_OBJ -} Pws_cat; - -typedef enum { - PELEM_ALL, - PELEM_NIL, - PELEM_ADD_NAMES_SET, - PELEM_REMOVE_NAMES_SET, - PELEM_FILL_AREA, - PELEM_FILL_AREA3, - PELEM_FILL_AREA_SET, - PELEM_FILL_AREA_SET3, - PELEM_FILL_AREA_SET3_DATA, - PELEM_SET_OF_FILL_AREA_SET3_DATA, - PELEM_POLYLINE, - PELEM_POLYLINE3, - PELEM_POLYMARKER, - PELEM_POLYMARKER3, - PELEM_TEXT, - PELEM_INT_IND, - PELEM_INT_COLR_IND, - PELEM_INT_STYLE, - PELEM_BACK_INT_STYLE, - PELEM_INT_STYLE_IND, - PELEM_BACK_INT_STYLE_IND, - PELEM_LINE_COLR_IND, - PELEM_LINEWIDTH, - PELEM_LINETYPE, - PELEM_LINE_IND, - PELEM_MARKER_IND, - PELEM_MARKER_COLR_IND, - PELEM_MARKER_SIZE, - PELEM_MARKER_TYPE, - PELEM_EDGE_IND, - PELEM_EDGE_COLR_IND, - PELEM_EDGEWIDTH, - PELEM_EDGETYPE, - PELEM_EDGE_FLAG, - PELEM_TEXT_IND, - PELEM_TEXT_FONT, - PELEM_TEXT_PREC, - PELEM_TEXT_PATH, - PELEM_TEXT_ALIGN, - PELEM_CHAR_HT, - PELEM_CHAR_EXPAN, - PELEM_CHAR_SPACE, - PELEM_CHAR_UP_VEC, - PELEM_TEXT_COLR_IND, - PELEM_INDIV_ASF, - PELEM_LOCAL_MODEL_TRAN3, - PELEM_GLOBAL_MODEL_TRAN3, - PELEM_VIEW_IND, - PELEM_EXEC_STRUCT, - PELEM_LABEL, - PELEM_PICK_ID, - PELEM_HLHSR_ID, - PELEM_INT_COLR, - PELEM_BACK_INT_COLR, - PELEM_LINE_COLR, - PELEM_MARKER_COLR, - PELEM_EDGE_COLR, - PELEM_TEXT_COLR, - PELEM_LIGHT_SRC_STATE, - PELEM_INT_SHAD_METH, - PELEM_BACK_INT_SHAD_METH, - PELEM_INT_REFL_EQN, - PELEM_BACK_INT_REFL_EQN, - PELEM_REFL_PROPS, - PELEM_BACK_REFL_PROPS, - PELEM_FACE_DISTING_MODE, - PELEM_FACE_CULL_MODE, - PELEM_ANNO_TEXT_REL3, - PELEM_ANNO_TEXT_REL, - PELEM_ANNO_CHAR_HT, - PELEM_ANNO_CHAR_UP_VEC, - PELEM_ANNO_PATH, - PELEM_ANNO_ALIGN, - PELEM_ANNO_STYLE, - PELEM_MODEL_CLIP_VOL3, - PELEM_MODEL_CLIP_IND, - PELEM_FILL_AREA_SET_DATA, - PELEM_GSE, - PELEM_ALPHA_CHANNEL, - PELEM_TEXT3, - PELEM_INT_REFL_MODEL, - PELEM_NUM_EL_TYPES -} Pelem_type; - -typedef enum { - PGSE_ID_NO_OPERATION, - PGSE_ID_HIGHLIGHT_COLOR -} Pgse_type; - -typedef enum { - PDIR_BACKWARD, - PDIR_FORWARD -} Psearch_dir; - -typedef enum { - PSEARCH_STATUS_FAILURE, - PSEARCH_STATUS_SUCCESS -} Psearch_status; - -typedef enum { - PEDIT_INSERT, - PEDIT_REPLACE -} Pedit_mode; - -typedef enum { - PFLAG_DEL, - PFLAG_KEEP -} Pref_flag; - -typedef enum { - PERR_OFF, - PERR_ON -} Perr_mode; - -typedef enum { - PSTRUCT_NONE, - PSTRUCT_OPEN -} Popen_struct_status; - -typedef enum { - PSTRUCT_STATUS_NON_EXISTENT, - PSTRUCT_STATUS_EMPTY, - PSTRUCT_STATUS_NOT_EMPTY -} Pstruct_status; - -typedef enum { - PORDER_TOP_FIRST, - PORDER_BOTTOM_FIRST -} Ppath_order; - -typedef enum { - PEDGE_OFF, - PEDGE_ON -} Pedge_flag; - -typedef enum { - PSTYLE_EMPTY, - PSTYLE_HOLLOW, - PSTYLE_SOLID, - PSTYLE_HATCH -} Pint_style; - -typedef enum { - PTYPE_PRECONCAT, - PTYPE_POSTCONCAT, - PTYPE_REPLACE -} Pcompose_type; - -typedef enum { - PDISTING_NO, - PDISTING_YES -} Pdisting_mode; - -typedef enum { - PCULL_NONE, - PCULL_BACKFACE, - PCULL_FRONTFACE -} Pcull_mode; - -typedef enum { - PFLAG_COND, - PFLAG_ALWAYS -} Pctrl_flag; - -typedef enum { - PFLAG_POSTPONE, - PFLAG_PERFORM -} Pregen_flag; - -typedef enum { - PIND_NO_CLIP, - PIND_CLIP -} Pclip_ind; - -typedef enum { - PPRI_HIGHER, - PPRI_LOWER -} Prel_pri; - -typedef enum { - PRES_MAINTAIN, - PRES_ABANDON, - PRES_UPD -} Pconf_res; - -typedef enum { - PVISUAL_ST_CORRECT, - PVISUAL_ST_DEFER, - PVISUAL_ST_SIMULATED -} Pvisual_st; - -typedef enum { - PSURF_NOT_EMPTY, - PSURF_EMPTY -} Pdisp_surf_empty; - -typedef enum { - PDEFER_ASAP, - PDEFER_BNIG, - PDEFER_BNIL, - PDEFER_ASTI, - PDEFER_WAIT -} Pdefer_mode; - -typedef enum { - PMODE_NIVE, - PMODE_UWOR, - PMODE_UQUM -} Pmod_mode; - -typedef enum { - PUPD_NOT_PEND, - PUPD_PEND -} Pupd_st; - -typedef enum { - PINQ_SET, - PINQ_REALIZED -} Pinq_type; - -typedef enum { - PTYPE_PARAL, - PTYPE_PERSPECT -} Pproj_type; - -typedef enum { - PASF_BUNDLED, - PASF_INDIV -} Pasf; - -typedef enum { - PASPECT_LINETYPE, - PASPECT_LINEWIDTH, - PASPECT_LINE_COLR_IND, - PASPECT_MARKER_TYPE, - PASPECT_MARKER_SIZE, - PASPECT_MARKER_COLR_IND, - PASPECT_TEXT_FONT, - PASPECT_TEXT_PREC, - PASPECT_CHAR_EXPAN, - PASPECT_CHAR_SPACE, - PASPECT_TEXT_COLR_IND, - PASPECT_INT_STYLE, - PASPECT_INT_STYLE_IND, - PASPECT_INT_COLR_IND, - PASPECT_EDGE_FLAG, - PASPECT_EDGETYPE, - PASPECT_EDGEWIDTH, - PASPECT_EDGE_COLR_IND, - PASPECT_INT_SHAD_METH, - PASPECT_REFL_PROPS, - PASPECT_INT_REFL_EQN, - PASPECT_INT_REFL_MODEL, - PASPECT_BACK_INT_STYLE, - PASPECT_BACK_INT_STYLE_IND, - PASPECT_BACK_INT_COLR, - PASPECT_BACK_INT_SHAD_METH, - PASPECT_BACK_REFL_PROPS, - PASPECT_BACK_INT_REFL_EQN -} Paspect; - -typedef enum { - PFLAG_LINE, - PFLAG_FILL, - PFLAG_FILL_SET -} Pline_fill_ctrl_flag; - -typedef enum { - PREC_STRING, - PREC_CHAR, - PREC_STROKE -} Ptext_prec; - -typedef enum { - PPATH_RIGHT, - PPATH_LEFT, - PPATH_UP, - PPATH_DOWN -} Ptext_path; - -typedef enum { - PHOR_NORM, - PHOR_LEFT, - PHOR_CTR, - PHOR_RIGHT -} Phor_text_align; - -typedef enum { - PVERT_NORM, - PVERT_TOP, - PVERT_CAP, - PVERT_HALF, - PVERT_BASE, - PVERT_BOTTOM -} Pvert_text_align; - -typedef enum { - PPR_OFF, - PPR_ON -} Ppr_switch; - -typedef enum { - PDC_METRES, - PDC_OTHER -} Pdc_units; - -typedef enum { - PIN_STATUS_NONE, - PIN_STATUS_OK, - PIN_STATUS_NO_IN -} Pin_status; - -typedef enum { - PIN_NONE, - PIN_LOC, - PIN_STROKE, - PIN_VAL, - PIN_CHOICE, - PIN_PICK, - PIN_STRING -} Pin_class; - -typedef enum { - POP_REQ, - POP_SAMPLE, - POP_EVENT -} Pop_mode; - -typedef enum { - PSWITCH_NO_ECHO, - PSWITCH_ECHO -} Pecho_switch; - -struct _Pstore; -typedef struct _Pstore *Pstore; - -typedef int Pint; -typedef long Plong; -typedef float Pfloat; - -typedef Pfloat Pmatrix3[4][4]; -typedef Pfloat Pmatrix[3][3]; - -typedef struct { - Pint num_elem_types; - Pelem_type *elem_types; -} Pelem_type_list; - -typedef struct { - Pint struct_id; - Pint elem_pos; -} Pelem_ref; - -typedef struct { - Pint num_elem_refs; - Pelem_ref *elem_refs; -} Pelem_ref_list; - -typedef struct { - Pint type; - union { + /* PHIGS states */ + typedef enum { + PSYS_ST_PHCL, + PSYS_ST_PHOP + } Psys_st; + + typedef enum { + PWS_ST_WSCL, + PWS_ST_WSOP + } Pws_st; + + typedef enum { + PSTRUCT_ST_STCL, + PSTRUCT_ST_STOP + } Pstruct_st; + + /* Archive releated */ + typedef enum { + PST_ARCL, + PST_AROP + } Par_st; + + typedef enum { + PNET_CSS, + PNET_AR + } Pstruct_net_source; + + /* Workstation related */ + typedef enum { + PCLASS_VEC, + PCLASS_RASTER, + PCLASS_OTHER + } Pws_class; + + typedef enum { + PCAT_OUT, + PCAT_IN, + PCAT_OUTIN, + PCAT_MO, + PCAT_MI, + PCAT_TGA, + PCAT_PNG, + PCAT_PNGA, + PCAT_EPS, + PCAT_PDF, + PCAT_SVG, + PCAT_OBJ + } Pws_cat; + + typedef enum { + PELEM_ALL, //0 + PELEM_NIL, + PELEM_ADD_NAMES_SET, + PELEM_REMOVE_NAMES_SET, + PELEM_FILL_AREA, + PELEM_FILL_AREA3, + PELEM_FILL_AREA_SET, + PELEM_FILL_AREA_SET3, + PELEM_FILL_AREA_SET3_DATA, + PELEM_SET_OF_FILL_AREA_SET3_DATA, + PELEM_POLYLINE, //10 + PELEM_POLYLINE3, + PELEM_POLYMARKER, + PELEM_POLYMARKER3, + PELEM_TEXT, + PELEM_INT_IND, + PELEM_INT_COLR_IND, + PELEM_INT_STYLE, + PELEM_BACK_INT_STYLE, + PELEM_INT_STYLE_IND, + PELEM_BACK_INT_STYLE_IND, // 20 + PELEM_LINE_COLR_IND, + PELEM_LINEWIDTH, + PELEM_LINETYPE, + PELEM_LINE_IND, + PELEM_MARKER_IND, + PELEM_MARKER_COLR_IND, + PELEM_MARKER_SIZE, + PELEM_MARKER_TYPE, + PELEM_EDGE_IND, + PELEM_EDGE_COLR_IND, //30 + PELEM_EDGEWIDTH, + PELEM_EDGETYPE, + PELEM_EDGE_FLAG, + PELEM_TEXT_IND, + PELEM_TEXT_FONT, + PELEM_TEXT_PREC, + PELEM_TEXT_PATH, + PELEM_TEXT_ALIGN, + PELEM_CHAR_HT, + PELEM_CHAR_EXPAN, //40 + PELEM_CHAR_SPACE, + PELEM_CHAR_UP_VEC, + PELEM_TEXT_COLR_IND, + PELEM_INDIV_ASF, + PELEM_LOCAL_MODEL_TRAN3, + PELEM_GLOBAL_MODEL_TRAN3, + PELEM_VIEW_IND, + PELEM_EXEC_STRUCT, + PELEM_LABEL, + PELEM_PICK_ID, //50 + PELEM_HLHSR_ID, + PELEM_INT_COLR, + PELEM_BACK_INT_COLR, + PELEM_LINE_COLR, + PELEM_MARKER_COLR, + PELEM_EDGE_COLR, + PELEM_TEXT_COLR, + PELEM_LIGHT_SRC_STATE, + PELEM_INT_SHAD_METH, + PELEM_BACK_INT_SHAD_METH, //60 + PELEM_INT_REFL_EQN, + PELEM_BACK_INT_REFL_EQN, + PELEM_REFL_PROPS, + PELEM_BACK_REFL_PROPS, + PELEM_FACE_DISTING_MODE, + PELEM_FACE_CULL_MODE, + PELEM_ANNO_TEXT_REL3, + PELEM_ANNO_TEXT_REL, + PELEM_ANNO_CHAR_HT, + PELEM_ANNO_CHAR_UP_VEC, //70 + PELEM_ANNO_PATH, + PELEM_ANNO_ALIGN, + PELEM_ANNO_STYLE, + PELEM_MODEL_CLIP_VOL3, + PELEM_MODEL_CLIP_IND, + PELEM_FILL_AREA_SET_DATA, + PELEM_GSE, + PELEM_ALPHA_CHANNEL, + PELEM_TEXT3, + PELEM_INT_REFL_MODEL, //80 + PELEM_NUM_EL_TYPES + } Pelem_type; + + typedef enum { + PGSE_ID_NO_OPERATION, + PGSE_ID_HIGHLIGHT_COLOR + } Pgse_type; + + typedef enum { + PDIR_BACKWARD, + PDIR_FORWARD + } Psearch_dir; + + typedef enum { + PSEARCH_STATUS_FAILURE, + PSEARCH_STATUS_SUCCESS + } Psearch_status; + + typedef enum { + PEDIT_INSERT, + PEDIT_REPLACE + } Pedit_mode; + + typedef enum { + PFLAG_DEL, + PFLAG_KEEP + } Pref_flag; + + typedef enum { + PERR_OFF, + PERR_ON + } Perr_mode; + + typedef enum { + PSTRUCT_NONE, + PSTRUCT_OPEN + } Popen_struct_status; + + typedef enum { + PSTRUCT_STATUS_NON_EXISTENT, + PSTRUCT_STATUS_EMPTY, + PSTRUCT_STATUS_NOT_EMPTY + } Pstruct_status; + + typedef enum { + PORDER_TOP_FIRST, + PORDER_BOTTOM_FIRST + } Ppath_order; + + typedef enum { + PEDGE_OFF, + PEDGE_ON + } Pedge_flag; + + typedef enum { + PSTYLE_EMPTY, + PSTYLE_HOLLOW, + PSTYLE_SOLID, + PSTYLE_HATCH + } Pint_style; + + typedef enum { + PTYPE_PRECONCAT, + PTYPE_POSTCONCAT, + PTYPE_REPLACE + } Pcompose_type; + + typedef enum { + PDISTING_NO, + PDISTING_YES + } Pdisting_mode; + + typedef enum { + PCULL_NONE, + PCULL_BACKFACE, + PCULL_FRONTFACE + } Pcull_mode; + + typedef enum { + PFLAG_COND, + PFLAG_ALWAYS + } Pctrl_flag; + + typedef enum { + PFLAG_POSTPONE, + PFLAG_PERFORM + } Pregen_flag; + + typedef enum { + PIND_NO_CLIP, + PIND_CLIP + } Pclip_ind; + + typedef enum { + PPRI_HIGHER, + PPRI_LOWER + } Prel_pri; + + typedef enum { + PRES_MAINTAIN, + PRES_ABANDON, + PRES_UPD + } Pconf_res; + + typedef enum { + PVISUAL_ST_CORRECT, + PVISUAL_ST_DEFER, + PVISUAL_ST_SIMULATED + } Pvisual_st; + + typedef enum { + PSURF_NOT_EMPTY, + PSURF_EMPTY + } Pdisp_surf_empty; + + typedef enum { + PDEFER_ASAP, + PDEFER_BNIG, + PDEFER_BNIL, + PDEFER_ASTI, + PDEFER_WAIT + } Pdefer_mode; + + typedef enum { + PMODE_NIVE, + PMODE_UWOR, + PMODE_UQUM + } Pmod_mode; + + typedef enum { + PUPD_NOT_PEND, + PUPD_PEND + } Pupd_st; + + typedef enum { + PINQ_SET, + PINQ_REALIZED + } Pinq_type; + + typedef enum { + PTYPE_PARAL, + PTYPE_PERSPECT + } Pproj_type; + + typedef enum { + PASF_BUNDLED, + PASF_INDIV + } Pasf; + + typedef enum { + PASPECT_LINETYPE, + PASPECT_LINEWIDTH, + PASPECT_LINE_COLR_IND, + PASPECT_MARKER_TYPE, + PASPECT_MARKER_SIZE, + PASPECT_MARKER_COLR_IND, + PASPECT_TEXT_FONT, + PASPECT_TEXT_PREC, + PASPECT_CHAR_EXPAN, + PASPECT_CHAR_SPACE, + PASPECT_TEXT_COLR_IND, + PASPECT_INT_STYLE, + PASPECT_INT_STYLE_IND, + PASPECT_INT_COLR_IND, + PASPECT_EDGE_FLAG, + PASPECT_EDGETYPE, + PASPECT_EDGEWIDTH, + PASPECT_EDGE_COLR_IND, + PASPECT_INT_SHAD_METH, + PASPECT_REFL_PROPS, + PASPECT_INT_REFL_EQN, + PASPECT_INT_REFL_MODEL, + PASPECT_BACK_INT_STYLE, + PASPECT_BACK_INT_STYLE_IND, + PASPECT_BACK_INT_COLR, + PASPECT_BACK_INT_SHAD_METH, + PASPECT_BACK_REFL_PROPS, + PASPECT_BACK_INT_REFL_EQN + } Paspect; + + typedef enum { + PFLAG_LINE, + PFLAG_FILL, + PFLAG_FILL_SET + } Pline_fill_ctrl_flag; + + typedef enum { + PREC_STRING, + PREC_CHAR, + PREC_STROKE + } Ptext_prec; + + typedef enum { + PPATH_RIGHT, + PPATH_LEFT, + PPATH_UP, + PPATH_DOWN + } Ptext_path; + + typedef enum { + PHOR_NORM, + PHOR_LEFT, + PHOR_CTR, + PHOR_RIGHT + } Phor_text_align; + + typedef enum { + PVERT_NORM, + PVERT_TOP, + PVERT_CAP, + PVERT_HALF, + PVERT_BASE, + PVERT_BOTTOM + } Pvert_text_align; + + typedef enum { + PPR_OFF, + PPR_ON + } Ppr_switch; + + typedef enum { + PDC_METRES, + PDC_OTHER + } Pdc_units; + + typedef enum { + PIN_STATUS_NONE, + PIN_STATUS_OK, + PIN_STATUS_NO_IN + } Pin_status; + + typedef enum { + PIN_NONE, + PIN_LOC, + PIN_STROKE, + PIN_VAL, + PIN_CHOICE, + PIN_PICK, + PIN_STRING + } Pin_class; + + typedef enum { + POP_REQ, + POP_SAMPLE, + POP_EVENT + } Pop_mode; + + typedef enum { + PSWITCH_NO_ECHO, + PSWITCH_ECHO + } Pecho_switch; + + struct _Pstore; + typedef struct _Pstore *Pstore; + + typedef int Pint; + typedef long Plong; + typedef float Pfloat; + + typedef Pfloat Pmatrix3[4][4]; + typedef Pfloat Pmatrix[3][3]; + + typedef struct { + Pint num_elem_types; + Pelem_type *elem_types; + } Pelem_type_list; + + typedef struct { + Pint struct_id; + Pint elem_pos; + } Pelem_ref; + + typedef struct { + Pint num_elem_refs; + Pelem_ref *elem_refs; + } Pelem_ref_list; + + typedef struct { + Pint type; + union { Pint ind; struct { - Pfloat x; - Pfloat y; - Pfloat z; + Pfloat x; + Pfloat y; + Pfloat z; + Pfloat a; } general; - } val; -} Pgcolr; - -typedef union { - struct Pgse_0 { - Pint noop; - } noop; - struct Pgse_1 { - Pgcolr highlight_colr; - } colr; -} Pgse_data; - -typedef struct { - Pgse_type gse_type; - Pint gse_size; - Pgse_data gse_data; -} Pgse_elem; - -typedef struct { - Pint num_ints; - Pint *ints; -} Pint_list; - -typedef struct { - Pint num_lists; - Pint_list *lists; -} Pint_list_list; - -typedef struct { - Pfloat x; - Pfloat y; -} Ppoint; - -typedef struct { - Pfloat x; - Pfloat y; - Pfloat z; -} Ppoint3; - -typedef struct { - Pfloat x; - Pfloat y; - Pfloat z; - Pfloat w; -} Ppoint4; - -typedef struct { - Pfloat delta_x; - Pfloat delta_y; -} Pvec; - -typedef struct { - Pfloat delta_x; - Pfloat delta_y; - Pfloat delta_z; -} Pvec3; - -typedef struct { - Ppoint p; - Ppoint q; -} Prect; - -typedef struct { - Pfloat x_min, x_max; - Pfloat y_min, y_max; -} Plimit; - -typedef struct { - Pfloat x_min, x_max; - Pfloat y_min, y_max; - Pfloat z_min, z_max; -} Plimit3; - -typedef struct { - Pint num_points; - Ppoint *points; -} Ppoint_list; - -typedef struct { - Pint num_points; - Ppoint3 *points; -} Ppoint_list3; - -typedef struct { - Pint num_point_lists; - Ppoint_list *point_lists; -} Ppoint_list_list; - -typedef struct { - Pint num_point_lists; - Ppoint_list3 *point_lists; -} Ppoint_list_list3; - -typedef struct { - Pint type; - Pfloat width; - Pint colr_ind; -} Pline_bundle; - -typedef struct { - Pint type; - Pfloat width; - Pgcolr colr; -} Pline_bundle_plus; - -typedef struct { - Pint type; - Pfloat size; - Pint colr_ind; -} Pmarker_bundle; - -typedef struct { - Pint type; - Pfloat size; - Pgcolr colr; -} Pmarker_bundle_plus; - -typedef struct { - Pedge_flag flag; - Pint type; - Pfloat width; - Pint colr_ind; -} Pedge_bundle; - -typedef struct { - Pedge_flag flag; - Pint type; - Pfloat width; - Pgcolr colr; -} Pedge_bundle_plus; - -typedef struct { - Pint_style style; - Pint style_ind; - Pint colr_ind; -} Pint_bundle; - -typedef struct { - Pfloat ambient_coef; - Pfloat diffuse_coef; - Pfloat specular_coef; - Pgcolr specular_colr; - Pfloat specular_exp; -} Prefl_props; - -typedef struct { - Pint_style style; - Pint style_ind; - Pgcolr colr; - Pint refl_eqn; - Pint refl_model; - Pint shad_meth; - Prefl_props refl_props; - Pint_style back_style; - Pint back_style_ind; - Pgcolr back_colr; - Pint back_refl_eqn; - Pint back_shad_meth; - Prefl_props back_refl_props; -} Pint_bundle_plus; - -typedef struct { - Pint font; - Ptext_prec prec; - Pfloat char_expan; - Pfloat char_space; - Pint colr_ind; -} Ptext_bundle; - -typedef struct { - Pint font; - Ptext_prec prec; - Pfloat char_expan; - Pfloat char_space; - Pgcolr colr; -} Ptext_bundle_plus; - -typedef struct { - Paspect id; - Pasf source; -} Pasf_info; - -typedef struct { - Phor_text_align hor; - Pvert_text_align vert; -} Ptext_align; - -typedef struct { - Ppoint pos; - char *char_string; -} Ptext; - -typedef struct { - Ppoint3 pos; - Pvec3 plane[2]; - char *char_string; -} Ptext3; - -typedef struct { - Pcompose_type compose_type; - Pmatrix matrix; -} Plocal_tran; - -typedef struct { - Pcompose_type compose_type; - Pmatrix3 matrix; -} Plocal_tran3; - -typedef struct { - Pmatrix3 ori_matrix; - Pmatrix3 map_matrix; - Plimit3 clip_limit; - Pclip_ind xy_clip; - Pclip_ind back_clip; - Pclip_ind front_clip; -} Pview_rep3; - -typedef struct { - Pfloat red; - Pfloat green; - Pfloat blue; -} Prgb; - -typedef struct { - Pfloat hue; - Pfloat satur; - Pfloat value; -} Phsv; - -typedef union { - Prgb rgb; - Phsv hsv; -} Pcolr_rep; - -typedef union { - Pint ind; - Pcolr_rep direct; -} Pcoval; - -typedef struct { - Pcoval colr; - Pvec3 norm; -} Pconorm3; - -typedef union { - Pcoval colr; - Pvec3 norm; - Pconorm3 conorm; -} Pfacet_data3; - -typedef union { - Pcoval *colrs; - Pvec3 *norms; - Pconorm3 *conorms; -} Pfacet_data_arr3; - -typedef union { - Pedge_flag *edges; -} Pedge_data_arr; - -typedef struct { - Pint num_edges; - Pedge_data_arr edgedata; -} Pedge_data_list; - -typedef struct { - Pint num_lists; - Pedge_data_list *edgelist; -} Pedge_data_list_list; - -typedef struct { - Ppoint3 point; - Pcoval colr; -} Pptco3; - -typedef struct { - Ppoint3 point; - Pvec3 norm; -} Pptnorm3; - -typedef struct { - Ppoint3 point; - Pcoval colr; - Pvec3 norm; -} Pptconorm3; - -typedef union { - Ppoint3 *points; - Pptco3 *ptcolrs; - Pptnorm3 *ptnorms; - Pptconorm3 *ptconorms; -} Pfacet_vdata_arr3; - -typedef struct { - Pint num_vertices; - Pfacet_vdata_arr3 vertex_data; -} Pfacet_vdata_list3; - -typedef struct { - Pgcolr colr; -} Pamb_light_src_rec; - -typedef struct { - Pgcolr colr; - Pvec3 dir; -} Pdir_light_src_rec; - -typedef struct { - Pgcolr colr; - Ppoint3 pos; - Pfloat coef[2]; -} Ppos_light_src_rec; - -typedef struct { - Pgcolr colr; - Ppoint3 pos; - Pvec3 dir; - Pfloat exp; - Pfloat coef[2]; - Pfloat angle; -} Pspot_light_src_rec; - -typedef union { - Pamb_light_src_rec ambient; - Pdir_light_src_rec directional; - Ppos_light_src_rec positional; - Pspot_light_src_rec spot; -} Plight_src_rec; - -typedef struct { - Pint type; - Plight_src_rec rec; -} Plight_src_bundle; - -typedef struct { - Pint size_x; - Pint size_y; -} Pint_size; - -typedef struct { - Pint size_x; - Pint size_y; - Pint size_z; -} Pint_size3; - -typedef struct { - Pfloat size_x; - Pfloat size_y; -} Pfloat_size; - -typedef struct { - Pfloat size_x; - Pfloat size_y; - Pfloat size_z; -} Pfloat_size3; - -typedef struct { - Pdc_units dc_units; - Pfloat_size size_dc; - Pint_size size_raster; -} Pdisp_space_size; - -typedef struct { - Pdc_units dc_units; - Pfloat_size3 size_dc; - Pint_size3 size_raster; -} Pdisp_space_size3; - -typedef struct { - Pint id; - Pfloat disp_pri; -} Pposted_struct; - -typedef struct { - Pint num_postings; - Pposted_struct *postings; -} Pposted_struct_list; - -typedef struct { - Pint fflag; - Pint eflag; - Pint vflag; - Pint colr_type; - Pfacet_data3 fdata; - Pint nfa; - Pedge_data_list *edata; - Pfacet_vdata_list3 *vdata; -} Pfasd3; - -typedef struct { - Pint fflag; - Pint eflag; - Pint vflag; - Pint colr_type; - Pint num_sets; - Pfacet_data_arr3 fdata; - Pedge_data_list_list *edata; - Pint_list_list *vlist; - Pfacet_vdata_list3 vdata; -} Psofas3; - -typedef struct { - Pint_list activation; - Pint_list deactivation; -} Plss; - -typedef struct { - Ppoint3 ref_point; /* reference pt */ - Pvec3 offset; /* anno. pt/offset */ - char *char_string; /* text string */ -} Panno_text_rel3; - -typedef struct { - Ppoint ref_point; /* reference pt */ - Pvec offset; /* anno. pt/offset */ - char *char_string; /* text string */ -} Panno_text_rel; - -typedef struct { - size_t size; /* sizeof data */ - void *data; /* pointer to data */ -} Pdata; - -typedef union { - Pint int_data; - Pfloat float_data; - Ppoint_list point_list; - Ppoint_list3 point_list3; - Ppoint_list_list point_list_list; - Ppoint_list_list3 point_list_list3; - Pfasd3 fasd3; - Psofas3 sofas3; - Ptext_prec text_prec; - Ptext_path text_path; - Ptext_align text_align; - Ptext text; - Ptext3 text3; - Panno_text_rel anno_text_rel; - Panno_text_rel3 anno_text_rel3; - Pasf_info asf_info; - Pvec vec; - Plocal_tran local_tran; - Plocal_tran3 local_tran3; - Pmatrix global_tran; - Pmatrix3 global_tran3; - Pint_list int_list; - Pedge_flag edge_flag; - Pint_style int_style; - Pgcolr colr; - Plss lss; - Prefl_props props; - Pdisting_mode disting_mode; - Pcull_mode cull_mode; -} Pelem_data; - -typedef struct { - Plimit win; - Plimit proj_vp; -} Pview_map; - -typedef struct { - Plimit3 win; - Plimit3 proj_vp; - Pproj_type proj_type; - Ppoint3 proj_ref_point; - Pfloat view_plane; - Pfloat back_plane; - Pfloat front_plane; -} Pview_map3; - -typedef struct { - Pasf type_asf; - Pasf width_asf; - Pasf colr_ind_asf; - Pint ind; - Pline_bundle bundle; -} Pline_attrs; - -typedef struct { - Pasf type_asf; - Pasf size_asf; - Pasf colr_ind_asf; - Pint ind; - Pmarker_bundle bundle; -} Pmarker_attrs; - -typedef struct { - Pasf style_asf; - Pasf style_ind_asf; - Pasf colr_ind_asf; - Pint ind; - Pint_bundle bundle; -} Pint_attrs; - -typedef struct { - Pasf flag_asf; - Pasf type_asf; - Pasf widthasf; - Pasf colr_ind_asf; - Pint ind; - Pedge_bundle bundle; -} Pedge_attrs; - -typedef struct { - Pint_list incl_set; - Pint_list excl_set; -} Pfilter; - -typedef struct { - Pint id; - char *name; -} Par_file; - -typedef struct { - Pint num_ar_files; - Par_file *ar_files; -} Par_file_list; - -typedef struct { - Pint struct_id; - Pint pick_id; - Pint elem_pos; -} Ppick_path_elem; - -typedef struct { - Pint depth; - Ppick_path_elem *path_list; -} Ppick_path; - -typedef struct { - Ppoint3 point; - Pvec3 norm; -} Phalf_space3; - -typedef struct { - Pint num_half_spaces; - Phalf_space3 *half_spaces; -} Phalf_space_list3; - -typedef struct { - Pint loc; - Pint stroke; - Pint val; - Pint choice; - Pint pick; - Pint string; -} Pnum_in; - -typedef struct { - union { + } val; + } Pgcolr; + + typedef union { + struct Pgse_0 { + Pint noop; + } noop; + struct Pgse_1 { + Pgcolr highlight_colr; + } colr; + } Pgse_data; + + typedef struct { + Pgse_type gse_type; + Pint gse_size; + Pgse_data gse_data; + } Pgse_elem; + + typedef struct { + Pint num_ints; + Pint *ints; + } Pint_list; + + typedef struct { + Pint num_lists; + Pint_list *lists; + } Pint_list_list; + + typedef struct { + Pfloat x; + Pfloat y; + } Ppoint; + + typedef struct { + Pfloat x; + Pfloat y; + Pfloat z; + } Ppoint3; + + typedef struct { + Pfloat x; + Pfloat y; + Pfloat z; + Pfloat w; + } Ppoint4; + + typedef struct { + Pfloat delta_x; + Pfloat delta_y; + } Pvec; + + typedef struct { + Pfloat delta_x; + Pfloat delta_y; + Pfloat delta_z; + } Pvec3; + + typedef struct { + Ppoint p; + Ppoint q; + } Prect; + + typedef struct { + Pfloat x_min, x_max; + Pfloat y_min, y_max; + } Plimit; + + typedef struct { + Pfloat x_min, x_max; + Pfloat y_min, y_max; + Pfloat z_min, z_max; + } Plimit3; + + typedef struct { + Pint num_points; + Ppoint *points; + } Ppoint_list; + + typedef struct { + Pint num_points; + Ppoint3 *points; + } Ppoint_list3; + + typedef struct { + Pint num_point_lists; + Ppoint_list *point_lists; + } Ppoint_list_list; + + typedef struct { + Pint num_point_lists; + Ppoint_list3 *point_lists; + } Ppoint_list_list3; + + typedef struct { + Pint type; + Pfloat width; + Pint colr_ind; + } Pline_bundle; + + typedef struct { + Pint type; + Pfloat width; + Pgcolr colr; + } Pline_bundle_plus; + + typedef struct { + Pint type; + Pfloat size; + Pint colr_ind; + } Pmarker_bundle; + + typedef struct { + Pint type; + Pfloat size; + Pgcolr colr; + } Pmarker_bundle_plus; + + typedef struct { + Pedge_flag flag; + Pint type; + Pfloat width; + Pint colr_ind; + } Pedge_bundle; + + typedef struct { + Pedge_flag flag; + Pint type; + Pfloat width; + Pgcolr colr; + } Pedge_bundle_plus; + + typedef struct { + Pint_style style; + Pint style_ind; + Pint colr_ind; + } Pint_bundle; + + typedef struct { + Pfloat ambient_coef; + Pfloat diffuse_coef; + Pfloat specular_coef; + Pgcolr specular_colr; + Pfloat specular_exp; + } Prefl_props; + + typedef struct { + Pint_style style; + Pint style_ind; + Pgcolr colr; + Pint refl_eqn; + Pint refl_model; + Pint shad_meth; + Prefl_props refl_props; + Pint_style back_style; + Pint back_style_ind; + Pgcolr back_colr; + Pint back_refl_eqn; + Pint back_shad_meth; + Prefl_props back_refl_props; + } Pint_bundle_plus; + + typedef struct { + Pint font; + Ptext_prec prec; + Pfloat char_expan; + Pfloat char_space; + Pint colr_ind; + } Ptext_bundle; + + typedef struct { + Pint font; + Ptext_prec prec; + Pfloat char_expan; + Pfloat char_space; + Pgcolr colr; + } Ptext_bundle_plus; + + typedef struct { + Paspect id; + Pasf source; + } Pasf_info; + + typedef struct { + Phor_text_align hor; + Pvert_text_align vert; + } Ptext_align; + + typedef struct { + Ppoint pos; + char *char_string; + } Ptext; + + typedef struct { + Ppoint3 pos; + Pvec3 plane[2]; + char *char_string; + } Ptext3; + + typedef struct { + Pcompose_type compose_type; + Pmatrix matrix; + } Plocal_tran; + + typedef struct { + Pcompose_type compose_type; + Pmatrix3 matrix; + } Plocal_tran3; + + typedef struct { + Pmatrix3 ori_matrix; + Pmatrix3 map_matrix; + Plimit3 clip_limit; + Pclip_ind xy_clip; + Pclip_ind back_clip; + Pclip_ind front_clip; + } Pview_rep3; + + typedef struct { + Pfloat red; + Pfloat green; + Pfloat blue; + } Prgb; + + typedef struct { + Pfloat red; + Pfloat green; + Pfloat blue; + Pfloat alpha; + } Prgba; + + typedef struct { + Pfloat hue; + Pfloat satur; + Pfloat value; + } Phsv; + + typedef union { + Prgb rgb; + Prgba rgba; + Phsv hsv; + } Pcolr_rep; + + typedef union { + Pint ind; + Pcolr_rep direct; + } Pcoval; + + typedef struct { + Pcoval colr; + Pvec3 norm; + } Pconorm3; + + typedef union { + Pcoval colr; + Pvec3 norm; + Pconorm3 conorm; + } Pfacet_data3; + + typedef union { + Pcoval *colrs; + Pvec3 *norms; + Pconorm3 *conorms; + } Pfacet_data_arr3; + + typedef union { + Pedge_flag *edges; + } Pedge_data_arr; + + typedef struct { + Pint num_edges; + Pedge_data_arr edgedata; + } Pedge_data_list; + + typedef struct { + Pint num_lists; + Pedge_data_list *edgelist; + } Pedge_data_list_list; + + typedef struct { + Ppoint3 point; + Pcoval colr; + } Pptco3; + + typedef struct { + Ppoint3 point; + Pvec3 norm; + } Pptnorm3; + + typedef struct { + Ppoint3 point; + Pcoval colr; + Pvec3 norm; + } Pptconorm3; + + typedef union { + Ppoint3 *points; + Pptco3 *ptcolrs; + Pptnorm3 *ptnorms; + Pptconorm3 *ptconorms; + } Pfacet_vdata_arr3; + + typedef struct { + Pint num_vertices; + Pfacet_vdata_arr3 vertex_data; + } Pfacet_vdata_list3; + + typedef struct { + Pgcolr colr; + } Pamb_light_src_rec; + + typedef struct { + Pgcolr colr; + Pvec3 dir; + } Pdir_light_src_rec; + + typedef struct { + Pgcolr colr; + Ppoint3 pos; + Pfloat coef[2]; + } Ppos_light_src_rec; + + typedef struct { + Pgcolr colr; + Ppoint3 pos; + Pvec3 dir; + Pfloat exp; + Pfloat coef[2]; + Pfloat angle; + } Pspot_light_src_rec; + + typedef union { + Pamb_light_src_rec ambient; + Pdir_light_src_rec directional; + Ppos_light_src_rec positional; + Pspot_light_src_rec spot; + } Plight_src_rec; + + typedef struct { + Pint type; + Plight_src_rec rec; + } Plight_src_bundle; + + typedef struct { + Pint size_x; + Pint size_y; + } Pint_size; + + typedef struct { + Pint size_x; + Pint size_y; + Pint size_z; + } Pint_size3; + + typedef struct { + Pfloat size_x; + Pfloat size_y; + } Pfloat_size; + + typedef struct { + Pfloat size_x; + Pfloat size_y; + Pfloat size_z; + } Pfloat_size3; + + typedef struct { + Pdc_units dc_units; + Pfloat_size size_dc; + Pint_size size_raster; + } Pdisp_space_size; + + typedef struct { + Pdc_units dc_units; + Pfloat_size3 size_dc; + Pint_size3 size_raster; + } Pdisp_space_size3; + + typedef struct { + Pint id; + Pfloat disp_pri; + } Pposted_struct; + + typedef struct { + Pint num_postings; + Pposted_struct *postings; + } Pposted_struct_list; + + typedef struct { + Pint fflag; + Pint eflag; + Pint vflag; + Pint colr_type; + Pfacet_data3 fdata; + Pint nfa; + Pedge_data_list *edata; + Pfacet_vdata_list3 *vdata; + } Pfasd3; + + typedef struct { + Pint fflag; + Pint eflag; + Pint vflag; + Pint colr_type; + Pint num_sets; + Pfacet_data_arr3 fdata; + Pedge_data_list_list *edata; + Pint_list_list *vlist; + Pfacet_vdata_list3 vdata; + } Psofas3; + + typedef struct { + Pint_list activation; + Pint_list deactivation; + } Plss; + + typedef struct { + Ppoint3 ref_point; /* reference pt */ + Pvec3 offset; /* anno. pt/offset */ + char *char_string; /* text string */ + } Panno_text_rel3; + + typedef struct { + Ppoint ref_point; /* reference pt */ + Pvec offset; /* anno. pt/offset */ + char *char_string; /* text string */ + } Panno_text_rel; + + typedef struct { + size_t size; /* sizeof data */ + void *data; /* pointer to data */ + } Pdata; + + typedef union { + Pint int_data; + Pfloat float_data; + Ppoint_list point_list; + Ppoint_list3 point_list3; + Ppoint_list_list point_list_list; + Ppoint_list_list3 point_list_list3; + Pfasd3 fasd3; + Psofas3 sofas3; + Ptext_prec text_prec; + Ptext_path text_path; + Ptext_align text_align; + Ptext text; + Ptext3 text3; + Panno_text_rel anno_text_rel; + Panno_text_rel3 anno_text_rel3; + Pasf_info asf_info; + Pvec vec; + Plocal_tran local_tran; + Plocal_tran3 local_tran3; + Pmatrix global_tran; + Pmatrix3 global_tran3; + Pint_list int_list; + Pedge_flag edge_flag; + Pint_style int_style; + Pgcolr colr; + Plss lss; + Prefl_props props; + Pdisting_mode disting_mode; + Pcull_mode cull_mode; + } Pelem_data; + + typedef struct { + Plimit win; + Plimit proj_vp; + } Pview_map; + + typedef struct { + Plimit3 win; + Plimit3 proj_vp; + Pproj_type proj_type; + Ppoint3 proj_ref_point; + Pfloat view_plane; + Pfloat back_plane; + Pfloat front_plane; + } Pview_map3; + + typedef struct { + Pasf type_asf; + Pasf width_asf; + Pasf colr_ind_asf; + Pint ind; + Pline_bundle bundle; + } Pline_attrs; + + typedef struct { + Pasf type_asf; + Pasf size_asf; + Pasf colr_ind_asf; + Pint ind; + Pmarker_bundle bundle; + } Pmarker_attrs; + + typedef struct { + Pasf style_asf; + Pasf style_ind_asf; + Pasf colr_ind_asf; + Pint ind; + Pint_bundle bundle; + } Pint_attrs; + + typedef struct { + Pasf flag_asf; + Pasf type_asf; + Pasf widthasf; + Pasf colr_ind_asf; + Pint ind; + Pedge_bundle bundle; + } Pedge_attrs; + + typedef struct { + Pint_list incl_set; + Pint_list excl_set; + } Pfilter; + + typedef struct { + Pint id; + char *name; + } Par_file; + + typedef struct { + Pint num_ar_files; + Par_file *ar_files; + } Par_file_list; + + typedef struct { + Pint struct_id; + Pint pick_id; + Pint elem_pos; + } Ppick_path_elem; + + typedef struct { + Pint depth; + Ppick_path_elem *path_list; + } Ppick_path; + + typedef struct { + Ppoint3 point; + Pvec3 norm; + } Phalf_space3; + + typedef struct { + Pint num_half_spaces; + Phalf_space3 *half_spaces; + } Phalf_space_list3; + + typedef struct { + Pint loc; + Pint stroke; + Pint val; + Pint choice; + Pint pick; + Pint string; + } Pnum_in; + + typedef struct { + union { struct { - Pint unused; + Pint unused; } pet_r1; struct { - Pint unused; + Pint unused; } pet_r2; struct { - Pint unused; + Pint unused; } pet_r3; struct { - Pline_attrs line_attrs; + Pline_attrs line_attrs; } pet_r4; struct { - Pline_fill_ctrl_flag line_fill_ctrl_flag; - union { - Pline_attrs line_attrs; + Pline_fill_ctrl_flag line_fill_ctrl_flag; + union { + Pline_attrs line_attrs; + Pint_attrs int_attrs; + struct { Pint_attrs int_attrs; - struct { - Pint_attrs int_attrs; - Pedge_attrs edge_attrs; - } fill_set; - } attrs; + Pedge_attrs edge_attrs; + } fill_set; + } attrs; } pet_r5; - } pets; -} Ploc_data; + } pets; + } Ploc_data; -typedef Ploc_data Ploc_data3; + typedef Ploc_data Ploc_data3; -typedef struct { - union { + typedef struct { + union { struct { - Pint unused; + Pint unused; } pet_r1; - } pets; -} Ppick_data; + } pets; + } Ppick_data; -typedef Ppick_data Ppick_data3; + typedef Ppick_data Ppick_data3; -typedef struct { - Pint buffer_size; - Pint init_pos; - Pfloat x_interval; - Pfloat y_interval; - Pfloat time_interval; + typedef struct { + Pint buffer_size; + Pint init_pos; + Pfloat x_interval; + Pfloat y_interval; + Pfloat time_interval; - union { + union { struct { - Pint unused; + Pint unused; } pet_r1; struct { - Pint unused; + Pint unused; } pet_r2; struct { - Pmarker_attrs marker_attrs; + Pmarker_attrs marker_attrs; } pet_r3; struct { - Pline_attrs line_attrs; + Pline_attrs line_attrs; } pet_r4; - } pets; + } pets; -} Pstroke_data; + } Pstroke_data; -typedef struct { - Pint buffer_size; - Pint init_pos; - Pfloat x_interval; - Pfloat y_interval; - Pfloat z_interval; - Pfloat time_interval; + typedef struct { + Pint buffer_size; + Pint init_pos; + Pfloat x_interval; + Pfloat y_interval; + Pfloat z_interval; + Pfloat time_interval; - union { + union { struct { - Pint unused; + Pint unused; } pet_r1; struct { - Pint unused; + Pint unused; } pet_r2; struct { - Pmarker_attrs marker_attrs; + Pmarker_attrs marker_attrs; } pet_r3; struct { - Pline_attrs line_attrs; + Pline_attrs line_attrs; } pet_r4; - } pets; + } pets; -} Pstroke_data3; + } Pstroke_data3; -typedef struct { - Pfloat low; - Pfloat high; - Pint num_boxed; + typedef struct { + Pfloat low; + Pfloat high; + Pint num_boxed; - union { + union { struct { - Pint unused; + Pint unused; } pet_r1; struct { - char *label; - char *format; - char *low_label; - char *high_label; + char *label; + char *format; + char *low_label; + char *high_label; } pet_u1; - } pets; -} Pval_data; + } pets; + } Pval_data; -typedef Pval_data Pval_data3; + typedef Pval_data Pval_data3; -typedef struct { + typedef struct { - union { + union { struct { - Pint unused; + Pint unused; } pet_r1; struct { - Pint num_prompts; - Ppr_switch *prompts; + Pint num_prompts; + Ppr_switch *prompts; } pet_r2; struct { - Pint num_strings; - char **strings; + Pint num_strings; + char **strings; } pet_r3; struct { - Pint num_strings; - char **strings; + Pint num_strings; + char **strings; } pet_r4; struct { - Pint struct_id; - Pint num_pick_ids; - Pint *pick_ids; + Pint struct_id; + Pint num_pick_ids; + Pint *pick_ids; } pet_r5; - } pets; + } pets; -} Pchoice_data; + } Pchoice_data; -typedef Pchoice_data Pchoice_data3; + typedef Pchoice_data Pchoice_data3; -typedef struct { - Pint buffer_size; - Pint init_pos; + typedef struct { + Pint buffer_size; + Pint init_pos; - union { + union { struct { - Pint unused; + Pint unused; } pet_r1; - } pets; -} Pstring_data; - -typedef Pstring_data Pstring_data3; - -/******************************************************************************* - * popen_phigs - * - * DESCR: Open phigs - * RETURNS: N/A - */ - -void popen_phigs( - char *error_file, - size_t memory - ); - -/******************************************************************************* - * pclose_phigs - * - * DESCR: Close phigs - * RETURNS: N/A - */ - -void pclose_phigs( - void - ); - -/******************************************************************************* - * pcreate_store - * - * DESCR: Create storage object - * RETURNS: N/A - */ - -void pcreate_store( - Pint *err_ind, - Pstore *store - ); - -/******************************************************************************* - * pdel_store - * - * DESCR: Delete storage object - * RETURNS: N/A - */ - -void pdel_store( - Pstore store - ); - -/* See phgsargs.h for more info */ -struct _Phg_args_conn_info; - -/******************************************************************************* - * popen_ws - * - * DESCR: Open workstation - * RETURNS: N/A - */ - -void popen_ws( - Pint ws_id, - struct _Phg_args_conn_info *conn_id, - Pint ws_type - ); - -/******************************************************************************* - * pclose_ws - * - * DESCR: Close workstation - * RETURNS: N/A - */ - -void pclose_ws( - Pint ws_id - ); - -/******************************************************************************* - * pset_ws_vp - * - * DESCR: Set workstation viewport - * RETURNS: N/A - */ - -void pset_ws_vp( - Pint ws_id, - Plimit *viewport - ); - -/******************************************************************************* - * pset_ws_vp3 - * - * DESCR: Set workstation viewport - * RETURNS: N/A - */ - -void pset_ws_vp3( - Pint ws_id, - Plimit3 *viewport - ); - -/******************************************************************************* - * pset_ws_win - * - * DESCR: Set workstation window - * RETURNS: N/A - */ - -void pset_ws_win( - Pint ws_id, - Plimit *window - ); - -/******************************************************************************* - * pset_ws_win3 - * - * DESCR: Set workstation window - * RETURNS: N/A - */ - -void pset_ws_win3( - Pint ws_id, - Plimit3 *window - ); - -/******************************************************************************* - * pset_invis_filter - * - * DESCR: Set workstation invisibility filter - * RETURNS: N/A - */ - -void pset_invis_filter( - Pint ws_id, - Pfilter *filter - ); - -/******************************************************************************* - * pset_hlhsr_mode - * - * DESCR: Set workstation hlhsr mode - * RETURNS: N/A - */ - -void pset_hlhsr_mode( - Pint ws_id, - Pint hlhsr_mode - ); - -/******************************************************************************* - * pset_line_rep - * - * DESCR: Set workstation line represenation - * RETURNS: N/A - */ - -void pset_line_rep( - Pint ws_id, - Pint line_ind, - Pline_bundle *line_bundle - ); - -/******************************************************************************* - * pset_marker_rep - * - * DESCR: Set workstation marker represenation - * RETURNS: N/A - */ - -void pset_marker_rep( - Pint ws_id, - Pint marker_ind, - Pmarker_bundle *marker_bundle - ); - -/******************************************************************************* - * pset_text_rep - * - * DESCR: Set workstation text represenation - * RETURNS: N/A - */ - -void pset_text_rep( - Pint ws_id, - Pint text_ind, - Ptext_bundle *text_bundle - ); - -/******************************************************************************* - * pset_edge_rep - * - * DESCR: Set workstation edge represenation - * RETURNS: N/A - */ - -void pset_edge_rep( - Pint ws_id, - Pint edge_ind, - Pedge_bundle *edge_bundle - ); - -/******************************************************************************* - * pset_int_rep - * - * DESCR: Set workstation interior represenation - * RETURNS: N/A - */ - -void pset_int_rep( - Pint ws_id, - Pint int_ind, - Pint_bundle *int_bundle - ); - -/******************************************************************************* - * ppost_struct - * - * DESCR: Post structure to workstation - * RETURNS: N/A - */ - -void ppost_struct( - Pint ws_id, - Pint struct_id, - Pfloat priority - ); - -/******************************************************************************* - * punpost_struct - * - * DESCR: Remove posted structure from workstation - * RETURNS: N/A - */ - -void punpost_struct( - Pint ws_id, - Pint struct_id - ); - -/******************************************************************************* - * punpost_all_structs - * - * DESCR: Remove all posted structures from workstation - * RETURNS: N/A - */ - -void punpost_all_structs( - Pint ws_id - ); - -/******************************************************************************* - * predraw_all_structs - * - * DESCR: Redraw all structures on workstation - * RETURNS: N/A - */ - -void predraw_all_structs( - Pint ws_id, - Pctrl_flag ctrl_flag - ); - -/******************************************************************************* - * pupd_ws - * - * DESCR: Set workstation update state - * RETURNS: N/A - */ - -void pupd_ws( - Pint ws_id, - Pregen_flag regen_flag - ); - -/******************************************************************************* - * pset_disp_upd_st - * - * DESCR: Set workstation update state - * RETURNS: N/A - */ - -void pset_disp_upd_st( - Pint ws_id, - Pdefer_mode def_mode, - Pmod_mode mod_mode - ); - -/******************************************************************************* - * pset_view_tran_in_pri - * - * DESCR: Set view input priority - * RETURNS: N/A - */ - -void pset_view_tran_in_pri( - Pint ws_id, - Pint view_ind, - Pint ref_view_ind, - Prel_pri rel_pri - ); - -/******************************************************************************* - * pset_light_src_rep - * - * DESCR: Set light source for workstation - * RETURNS: N/A - */ - -void pset_light_src_rep( - Pint ws_id, - Pint light_src_ind, - Plight_src_bundle *light_src_rep - ); - -/******************************************************************************* - * pset_colr_rep - * - * DESCR: Set workstation colour representation - * RETURNS: N/A - */ - -void pset_colr_rep( - Pint ws_id, - Pint ind, - Pcolr_rep *rep - ); - -/******************************************************************************* - * pinq_ws_st - * - * DESCR: Get workstation state - * RETURNS: N/A - */ - -void pinq_ws_st( - Pws_st *ws_state - ); - -/******************************************************************************* - * pinq_ws_conn_type - * - * DESCR: Get workstation connection type - * RETURNS: N/A - */ - -void pinq_ws_conn_type( - Pint ws_id, - Pstore store, - Pint *err_ind, - void **conn_id, - Pint *ws_type - ); - -/******************************************************************************* - * pinq_open_wss - * - * DESCR: Get list of open workstations - * RETURNS: N/A - */ - -void pinq_open_wss( - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *open_ws_ids, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_view_inds - * - * DESCR: Get workstation list of view indices - * RETURNS: N/A - */ - -void pinq_list_view_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *view_inds, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_line_inds - * - * DESCR: Get workstation list of line indices - * RETURNS: N/A - */ - -void pinq_list_line_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *def_line_ind, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_marker_inds - * - * DESCR: Get workstation list of marker indices - * RETURNS: N/A - */ - -void pinq_list_marker_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *def_marker_ind, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_text_inds - * - * DESCR: Get workstation list of text indices - * RETURNS: N/A - */ - -void pinq_list_text_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *def_text_ind, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_int_inds - * - * DESCR: Get workstation list of interior indices - * RETURNS: N/A - */ - -void pinq_list_int_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *def_int_ind, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_edge_inds - * - * DESCR: Get workstation list of edge indices - * RETURNS: N/A - */ - -void pinq_list_edge_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *def_edge_ind, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_list_colr_inds - * - * DESCR: Get workstation list of colour indices - * RETURNS: N/A - */ - -void pinq_list_colr_inds( - Pint ws_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *colr_ind, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_line_rep - * - * DESCR: Get workstation line representation - * RETURNS: N/A - */ - -void pinq_line_rep( - Pint ws_id, - Pint index, - Pinq_type type, - Pint *err_ind, - Pline_bundle *line_rep - ); - -/******************************************************************************* - * pinq_marker_rep - * - * DESCR: Get workstation marker representation - * RETURNS: N/A - */ - -void pinq_marker_rep( - Pint ws_id, - Pint index, - Pinq_type type, - Pint *err_ind, - Pmarker_bundle *marker_rep - ); - -/******************************************************************************* - * pinq_text_rep - * - * DESCR: Get workstation text representation - * RETURNS: N/A - */ - -void pinq_text_rep( - Pint ws_id, - Pint index, - Pinq_type type, - Pint *err_ind, - Ptext_bundle *text_rep - ); - -/******************************************************************************* - * pinq_int_rep - * - * DESCR: Get workstation interior representation - * RETURNS: N/A - */ - -void pinq_int_rep( - Pint ws_id, - Pint index, - Pinq_type type, - Pint *err_ind, - Pint_bundle *int_rep - ); - -/******************************************************************************* - * pinq_edge_rep - * - * DESCR: Get workstation edge representation - * RETURNS: N/A - */ - -void pinq_edge_rep( - Pint ws_id, - Pint index, - Pinq_type type, - Pint *err_ind, - Pedge_bundle *edge_rep - ); - -/******************************************************************************* - * pinq_colr_rep - * - * DESCR: Get workstation colour representation - * RETURNS: N/A - */ - -void pinq_colr_rep( - Pint ws_id, - Pint colr_ind, - Pinq_type type, - Pint *err_ind, - Pcolr_rep *colr_rep - ); - -/******************************************************************************* - * pinq_invis_filter - * - * DESCR: Get workstation invisibility filter - * RETURNS: N/A - */ - -void pinq_invis_filter( - Pint ws_id, - Pstore store, - Pint *err_ind, - Pfilter **invis_filter - ); - -/******************************************************************************* - * pinq_ws_cat - * - * DESCR: Get workstation category - * RETURNS: N/A - */ - -void pinq_ws_cat( - Pint ws_type, - Pint *err_ind, - Pws_cat *cat - ); - -/******************************************************************************* - * pinq_disp_space_size3 - * - * DESCR: Get workstation type display size 3D - * RETURNS: N/A - */ - -void pinq_disp_space_size3( - Pint ws_type, - Pint *err_ind, - Pdisp_space_size3 *size - ); - -/******************************************************************************* - * popen_struct - * - * DESCR: Opens a structure for appending or editing. - * RETURNS: N/A - */ - -void popen_struct( - Pint struct_id - ); - -/******************************************************************************* - * pclose_struct - * - * DESCR: Closes a previously opened structure. - * RETURNS: N/A - */ - -void pclose_struct( - void - ); - -/******************************************************************************* - * pchange_struct_id - * - * DESCR: Changes structure id - * RETURNS: N/A - */ - -void pchange_struct_id( - Pint orig_struct_id, - Pint result_struct_id - ); - -/******************************************************************************* - * pchange_struct_refs - * - * DESCR: Changes structure references - * RETURNS: N/A - */ - -void pchange_struct_refs( - Pint orig_struct_id, - Pint result_struct_id - ); - -/******************************************************************************* - * pchange_struct_id_refs - * - * DESCR: Changes structure ids and references - * RETURNS: N/A - */ - -void pchange_struct_id_refs( - Pint orig_struct_id, - Pint result_struct_id - ); - -/******************************************************************************* - * pset_edit_mode - * - * DESCR: Set structure edit mode - * RETURNS: N/A - */ - -void pset_edit_mode( - Pedit_mode edit_mode - ); - -/******************************************************************************* - * pset_elem_ptr - * - * DESCR: Make the requested index the "currently active element". - * NOTE: 0 means set element to even before the very first - * element; 1 means set elptr to very first element. - * RETURNS: N/A - */ - -void pset_elem_ptr( - Pint elem_ptr_value - ); - -/******************************************************************************* - * poffset_elem_ptr - * - * DESCR: Offsets the element pointer forward by the given number of - * elements. - * Internal call to pset_elem_ptr does the verification work - * on the index. - * RETURNS: N/A - */ - -void poffset_elem_ptr( - Pint elem_ptr_offset - ); - -/******************************************************************************* - * pset_elem_ptr_label - * - * DESCR: Searches forward in the structure list for the specified - * label, and makes that the current element. Search begins - * with the element after (to the right) of the current one. - * Question: should I include the current element in the search? - * Or does the search begin with the first element after the - * current one? - * This version gives fatal error if label not found. - * RETURNS: N/A - */ - -void pset_elem_ptr_label( - Pint label_id - ); - -/******************************************************************************* - * pdel_elem - * - * DESCR: Deletes the current element. The element pointer is left - * pointing to the element just before (to the left) the one to - * be killed, if any. - * RETURNS: N/A - */ - -void pdel_elem( - void - ); - -/******************************************************************************* - * pdel_elem_range - * - * DESCR: Deletes all elements within and on the bounds of the given - * range. The element pointer is left pointing to the element - * just prior to the first element deleted. - * RETURNS: N/A - */ - -void pdel_elem_range( - Pint elem_ptr1_value, - Pint elem_ptr2_value - ); - -/******************************************************************************* - * pdel_elems_labels - * - * DESCR: Deletes all elements in the structure that lie between the - * given labels, but not the labels themselves. The element - * pointer is left pointing to the first label. - * RETURNS: N/A - */ - -void pdel_elems_labels( - Pint label1_id, - Pint label2_id - ); - -/******************************************************************************* - * pempty_struct - * - * DESCR: Clear structure - * RETURNS: N/A - */ - -void pempty_struct( - Pint struct_id - ); - -/******************************************************************************* - * pdel_struct - * - * DESCR: Delete structure - * RETURNS: N/A - */ - -void pdel_struct( - Pint struct_id - ); - -/******************************************************************************* - * pdel_struct_net - * - * DESCR: Delete structure network - * RETURNS: N/A - */ - -void pdel_struct_net( - Pint struct_id, - Pref_flag ref_flag - ); - -/******************************************************************************* - * pdel_all_structs - * - * DESCR: Delete all structures - * RETURNS: N/A - */ - -void pdel_all_structs( - void - ); - -/******************************************************************************* - * pcopy_all_elems_struct - * - * DESCR: Copies the elements of another structure into the open - * structure after the current element, which is updated to - * point to the last element inserted. A structure can be - * copied into itself. - * RETURNS: N/A - */ - -void pcopy_all_elems_struct( - Pint struct_id - ); - -/******************************************************************************* - * pelem_search - * - * DESCR: Get all matching elements - * RETURNS: N/A - */ - -void pelem_search( - Pint struct_id, - Pint struct_elem, - Psearch_dir dir, - Pelem_type_list *incl, - Pelem_type_list *excl, - Pint *err_ind, - Psearch_status *status, - Pint *found_elem_ptr - ); - -/******************************************************************************* - * pinq_edit_mode - * - * DESCR: Get structure edit mode - * RETURNS: N/A - */ - -void pinq_edit_mode( - Pint *err_ind, - Pedit_mode *edit_mode - ); - -/******************************************************************************* - * pinq_elem_ptr - * - * DESCR: Returns the index of the current element. - * RETURNS: N/A - */ - -void pinq_elem_ptr( - Pint *err_ind, - Pint *elem_ptr_value - ); - -/******************************************************************************* - * pinq_struct_st - * - * DESCR: Get current structure state - * RETURNS: N/A - */ - -void pinq_struct_st( - Pint *struct_st - ); - -/******************************************************************************* - * pinq_open_struct - * - * DESCR: Get current open structure and edit status - * RETURNS: N/A - */ - -void pinq_open_struct( - Pint *err_ind, - Popen_struct_status *status, - Pint *struct_id - ); - -/******************************************************************************* - * pinq_struct_status - * - * DESCR: Get current status of give structure - * RETURNS: N/A - */ - -void pinq_struct_status( - Pint struct_id, - Pint *err_ind, - Pstruct_status *status - ); - -/******************************************************************************* - * pinq_elem_type_size - * - * DESCR: Get element type and size - * RETURNS: N/A - */ - -void pinq_elem_type_size( - Pint struct_id, - Pint elem_num, - Pint *err_ind, - Pelem_type *elem_type, - size_t *elem_size - ); - -/******************************************************************************* - * pinq_cur_elem_type_size - * - * DESCR: Get current element type and size - * RETURNS: N/A - */ - -void pinq_cur_elem_type_size( - Pint *err_ind, - Pelem_type *elem_type, - size_t *elem_size - ); - -/******************************************************************************* - * pinq_elem_content - * - * DESCR: Get element content - * RETURNS: N/A - */ - -void pinq_elem_content( - Pint struct_id, - Pint elem_num, - Pstore store, - Pint *err_ind, - Pelem_data **elem_data - ); - -/******************************************************************************* - * pinq_cur_elem_content - * - * DESCR: Get current element content - * RETURNS: N/A - */ - -void pinq_cur_elem_content( - Pstore store, - Pint *err_ind, - Pelem_data **elem_data - ); - -/******************************************************************************* - * padd_names_set - * - * DESCR: Creates a new element - name set Inclusion - * RETURNS: N/A - */ - -void padd_names_set( - Pint_list *names - ); - -/******************************************************************************* - * premove_names_set - * - * DESCR: Creates a new element - name set Remover - * RETURNS: N/A - */ - -void premove_names_set( - Pint_list *names - ); - -/******************************************************************************* - * pset_indiv_asf - * - * DESCR: Creates a new element - Set attribute source flag - * RETURNS: N/A - */ - -void pset_indiv_asf( - Paspect asf_id, - Pasf asf_source - ); - -/******************************************************************************* - * pset_local_tran3 - * - * DESCR: Creates a new element - Set local model space transformation 3D - * RETURNS: N/A - */ - -void pset_local_tran3( - Pmatrix3 local_tran, - Pcompose_type compose_type - ); - -/******************************************************************************* - * pset_global_tran3 - * - * DESCR: Creates a new element - Set global model space transformation 3D - * RETURNS: N/A - */ - -void pset_global_tran3( - Pmatrix3 global_tran - ); - -/******************************************************************************* - * pset_view_ind - * - * DESCR: Creates a new element - Set view index - * RETURNS: N/A - */ - -void pset_view_ind( - Pint view_ind - ); - -/******************************************************************************* - * ptext - * - * DESCR: Creates a new element - Text - * RETURNS: N/A - */ - -void ptext( - Ppoint *text_pos, - char *char_string - ); - -/******************************************************************************* - * ptext3 - * - * DESCR: Creates a new element - Text - * RETURNS: N/A - */ - -void ptext3( - Ppoint3 *text_pos, - Pvec3 plane[2], - char *char_string - ); - -/******************************************************************************* - * ppolyline - * - * DESCR: Creates a new element - Polyline - * RETURNS: N/A - */ - -void ppolyline( - Ppoint_list *point_list - ); - -/******************************************************************************* - * ppolyline3 - * - * DESCR: Creates a new element - Polyline 3D - * RETURNS: N/A - */ - -void ppolyline3( - Ppoint_list3 *point_list - ); - -/******************************************************************************* - * ppolymarker - * - * DESCR: Creates a new element - Polymarker - * RETURNS: N/A - */ - -void ppolymarker( - Ppoint_list *point_list - ); - -/******************************************************************************* - * ppolymarker3 - * - * DESCR: Creates a new element - Polymarker 3D - * RETURNS: N/A - */ - -void ppolymarker3( - Ppoint_list3 *point_list - ); - -/******************************************************************************* - * pfill_area - * - * DESCR: Creates a new element - Fill area - * RETURNS: N/A - */ - -void pfill_area( - Ppoint_list *point_list - ); - -/******************************************************************************* - * pfill_area3 - * - * DESCR: Creates a new element - Fill area 3D - * RETURNS: N/A - */ - -void pfill_area3( - Ppoint_list3 *point_list - ); - -/******************************************************************************* - * pfill_area_set - * - * DESCR: Creates a new element - Fill area set - * RETURNS: N/A - */ - -void pfill_area_set( - Ppoint_list_list *point_list_list - ); - -/******************************************************************************* - * pfill_area_set3 - * - * DESCR: Creates a new element - Fill area set 3D - * RETURNS: N/A - */ - -void pfill_area_set3( - Ppoint_list_list3 *point_list_list - ); - -/******************************************************************************* - * pfill_area_set_data - * - * DESCR: Creates a new element - Fill area set with data 3D - * RETURNS: N/A - */ - -void pfill_area_set_data( - Pint fflag, - Pint eflag, - Pint vflag, - Pint colr_type, - Pfacet_data3 *fdata, - Pint nfa, - Pedge_data_list *edata, - Pfacet_vdata_list3 *vdata - ); - -/******************************************************************************* - * pfill_area_set3_data - * - * DESCR: Creates a new element - Fill area set with data 3D - * RETURNS: N/A - */ - -void pfill_area_set3_data( - Pint fflag, - Pint eflag, - Pint vflag, - Pint colr_type, - Pfacet_data3 *fdata, - Pint nfa, - Pedge_data_list *edata, - Pfacet_vdata_list3 *vdata - ); - -/******************************************************************************* - * pset_of_fill_area_set3_data - * - * DESCR: Creates a new element - Set of fill area set with data 3D - * RETURNS: N/A - */ - -void pset_of_fill_area_set3_data( - Pint fflag, - Pint eflag, - Pint vflag, - Pint colr_type, - Pint num_sets, - Pfacet_data_arr3 *fdata, - Pedge_data_list_list *edata, - Pint_list_list *vlist, - Pfacet_vdata_list3 *vdata - ); - -/******************************************************************************* - * plabel - * - * DESCR: Creates a new element - Label - * RETURNS: N/A - */ - -void plabel( - Pint label_id - ); - -/******************************************************************************* - * pset_pick_id - * - * DESCR: Creates a new element - Pick ID - * RETURNS: N/A - */ - -void pset_pick_id( - Pint pick_id - ); - -/******************************************************************************* - * pset_hlhsr_id - * - * DESCR: Create hidden lines, surface removal flag element - * RETURNS: N/A - */ - -void pset_hlhsr_id( - Pint hlhsr_id - ); - -/******************************************************************************* - * pset_int_ind - * - * DESCR: Creates a new element - Facet Interiour Attribute Index - * RETURNS: N/A - */ - -void pset_int_ind( - Pint int_ind - ); - -/******************************************************************************* - * pset_int_colr_ind - * - * DESCR: Creates a new element - Facet Color Attribute - * RETURNS: N/A - */ - -void pset_int_colr_ind( - Pint colr_ind - ); - -/******************************************************************************* - * pset_int_style - * - * DESCR: Creates a new element - Face Interiour Style - * RETURNS: N/A - */ - -void pset_int_style( - Pint_style int_style - ); - -/******************************************************************************* - * pset_int_style_ind - * - * DESCR: Creates a new element - Face Interiour Pattern Index - * RETURNS: N/A - */ - -void pset_int_style_ind( - Pint int_style_ind - ); - -/******************************************************************************* - * pset_back_int_style - * - * DESCR: Creates a new element - Backface Interiour Style - * RETURNS: N/A - */ - -void pset_back_int_style( - Pint_style int_style - ); - -/******************************************************************************* - * pset_back_int_style_ind - * - * DESCR: Creates a new element - Backface Interiour Pattern Index - * RETURNS: N/A - */ - -void pset_back_int_style_ind( - Pint int_style_ind - ); - -/******************************************************************************* - * pset_line_ind - * - * DESCR: Creates a new element - Line Attribute Index - * RETURNS: N/A - */ - -void pset_line_ind( - Pint line_ind - ); - -/******************************************************************************* - * pset_line_colr_ind - * - * DESCR: Creates a new element - Line Color Attribute - * RETURNS: N/A - */ - -void pset_line_colr_ind( - Pint colr_ind - ); - -/******************************************************************************* - * pset_linewidth - * - * DESCR: Creates a new element - Line Width Attribute - * RETURNS: N/A - */ - -void pset_linewidth( - Pfloat linewidth - ); - -/******************************************************************************* - * pset_linetype - * - * DESCR: Creates a new element - Line Type Attribute - * RETURNS: N/A - */ - -void pset_linetype( - Pint linetype - ); - -/******************************************************************************* - * pset_marker_ind - * - * DESCR: Creates a new element - Marker Attribute Index - * RETURNS: N/A - */ - -void pset_marker_ind( - Pint marker_ind - ); - -/******************************************************************************* - * pset_marker_colr_ind - * - * DESCR: Creates a new element - Marker Color Attribute - * RETURNS: N/A - */ - -void pset_marker_colr_ind( - Pint colr_ind - ); - -/******************************************************************************* - * pset_marker_size - * - * DESCR: Creates a new element - Marker Size Attribute - * RETURNS: N/A - */ - -void pset_marker_size( - Pfloat marker_size - ); - -/******************************************************************************* - * pset_marker_type - * - * DESCR: Creates a new element - Marker Type Attribute - * RETURNS: N/A - */ - -void pset_marker_type( - Pint marker_type - ); - -/******************************************************************************* - * pset_edge_ind - * - * DESCR: Creates a new element - Edge Attribute Index - * RETURNS: N/A - */ - -void pset_edge_ind( - Pint edge_ind - ); - -/******************************************************************************* - * pset_edge_colr_ind - * - * DESCR: Creates a new element - Edge Color Attribute - * RETURNS: N/A - */ - -void pset_edge_colr_ind( - Pint colr_ind - ); - -/******************************************************************************* - * pset_edgetype - * - * DESCR: Creates a new element - Edge Type Attribute - * RETURNS: N/A - */ - -void pset_edgetype( - Pint edgetype - ); - -/******************************************************************************* - * pset_edge_flag - * - * DESCR: Creates a new element - Edge Flag Attribute - * RETURNS: N/A - */ - -void pset_edge_flag( - Pedge_flag edge_flag - ); - -/******************************************************************************* - * pset_edgewidth - * - * DESCR: Creates a new element - Edge Width Attribute - * RETURNS: N/A - */ - -void pset_edgewidth( - Pfloat edgewidth - ); - -/******************************************************************************* - * pset_text_font - * - * DESCR: Creates a new element - Text Font Attribute - * RETURNS: N/A - */ - -void pset_text_font( - Pint font - ); - -/******************************************************************************* - * pset_text_prec - * - * DESCR: Creates a new element - Text Precision Attribute - * RETURNS: N/A - */ - -void pset_text_prec( - Ptext_prec prec - ); - -/******************************************************************************* - * pset_text_path - * - * DESCR: Creates a new element - Text Path Attribute - * RETURNS: N/A - */ - -void pset_text_path( - Ptext_path text_path - ); - -/******************************************************************************* - * pset_text_align - * - * DESCR: Creates a new element - Text Alignment Attribute - * RETURNS: N/A - */ - -void pset_text_align( - Ptext_align *text_align - ); - -/******************************************************************************* - * pset_char_ht - * - * DESCR: Creates a new element - Character height Attribute - * RETURNS: N/A - */ - -void pset_char_ht( - Pfloat char_ht - ); - -/******************************************************************************* - * pset_char_expan - * - * DESCR: Creates a new element - Character expansion factor Attribute - * RETURNS: N/A - */ - -void pset_char_expan( - Pfloat char_expan - ); - -/******************************************************************************* - * pset_char_space - * - * DESCR: Creates a new element - Character spaceing Attribute - * RETURNS: N/A - */ - -void pset_char_space( - Pfloat char_space - ); - -/******************************************************************************* - * pset_char_up_vec - * - * DESCR: Creates a new element - Character up vector Attribute - * RETURNS: N/A - */ - -void pset_char_up_vec( - Pvec *char_up_vec - ); - -/******************************************************************************* - * pset_anno_char_up_vec - * - * DESCR: Creates a new element - Character up vector Attribute - * RETURNS: N/A - */ - -void pset_anno_char_up_vec( - Pvec *char_up_vec - ); - -/******************************************************************************* - * pset_text_ind - * - * DESCR: Creates a new element - Text Attribute Index - * RETURNS: N/A - */ - -void pset_text_ind( - Pint text_ind - ); - -/******************************************************************************* - * pset_text_colr_ind - * - * DESCR: Creates a new element - Text Color Attribute - * RETURNS: N/A - */ - -void pset_text_colr_ind( - Pint colr_ind - ); - -/******************************************************************************* - * pexec_struct - * - * DESCR: Creates a new element - Nested Structure - * RETURNS: N/A - */ - -void pexec_struct( - Pint struct_id - ); - -/******************************************************************************* - * pset_int_colr - * - * DESCR: Creates a new element - Facet Color Attribute - * RETURNS: N/A - */ - -void pset_int_colr( - Pgcolr *colr - ); - -/******************************************************************************* - * pset_back_int_colr - * - * DESCR: Creates a new element - Backface Color Attribute - * RETURNS: N/A - */ - -void pset_back_int_colr( - Pgcolr *colr - ); - -/******************************************************************************* - * pset_line_colr - * - * DESCR: Creates a new element - Line Color Attribute - * RETURNS: N/A - */ - -void pset_line_colr( - Pgcolr *colr - ); - -/******************************************************************************* - * pset_marker_colr - * - * DESCR: Creates a new element - Marker Color Attribute - * RETURNS: N/A - */ - -void pset_marker_colr( - Pgcolr *colr - ); - -/******************************************************************************* - * pset_edge_colr - * - * DESCR: Creates a new element - Edge Color Attribute - * RETURNS: N/A - */ - -void pset_edge_colr( - Pgcolr *colr - ); - -/******************************************************************************* - * pset_text_colr - * - * DESCR: Creates a new element - Text Color Attribute - * RETURNS: N/A - */ - -void pset_text_colr( - Pgcolr *colr - ); - -/******************************************************************************* - * pset_light_src_state - * - * DESCR: Creates a new element - Set light source state - * RETURNS: N/A - */ - -void pset_light_src_state( - Pint_list *activation, - Pint_list *deactivation - ); - -/******************************************************************************* - * pset_int_shad_meth - * - * DESCR: Creates a new element - Set interiour shading method - * RETURNS: N/A - */ - -void pset_int_shad_meth( - Pint shad_meth - ); - -/******************************************************************************* - * pset_back_int_shad_meth - * - * DESCR: Creates a new element - Set backface interiour shading method - * RETURNS: N/A - */ - -void pset_back_int_shad_meth( - Pint shad_meth - ); - -/******************************************************************************* - * pset_refl_model - * - * DESCR: Creates a new element - Set reflectance model - * RETURNS: N/A - */ - -void pset_refl_model( - Pint refl_model - ); - -/******************************************************************************* - * pset_refl_eqn - * - * DESCR: Creates a new element - Set surface reflectance equation - * RETURNS: N/A - */ - -void pset_refl_eqn( - Pint refl_equ - ); - -/******************************************************************************* - * pset_back_refl_eqn - * - * DESCR: Creates a new element - Set backsurface reflectance equation - * RETURNS: N/A - */ - -void pset_back_refl_eqn( - Pint refl_equ - ); - -/******************************************************************************* - * pset_refl_props - * - * DESCR: Creates a new element - Set surface reflectance properties - * RETURNS: N/A - */ - -void pset_refl_props( - Prefl_props *refl_props - ); - -/******************************************************************************* - * pset_back_refl_props - * - * DESCR: Creates a new element - Set backsurface reflectance properties - * RETURNS: N/A - */ - -void pset_back_refl_props( - Prefl_props *refl_props - ); - -/******************************************************************************* - * pset_face_disting_mode - * - * DESCR: Creates a new element - Set facet distinguish mode - * RETURNS: N/A - */ - -void pset_face_disting_mode( - Pdisting_mode disting_mode - ); - -/******************************************************************************* - * pset_face_cull_mode - * - * DESCR: Creates a new element - Set face culling mode - * RETURNS: N/A - */ - -void pset_face_cull_mode( - Pcull_mode cull_mode - ); - -/******************************************************************************* - * ptranslate3 - * - * DESCR: Generate 3D translation matrix - * RETURNS: N/A - */ - -void ptranslate3( - Pvec3 *trans_vector, /* translation vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * ptranslate - * - * DESCR: Generate translation matrix - * RETURNS: N/A - */ - -void ptranslate( - Pvec *trans_vector, /* translation vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * pscale3 - * - * DESCR: Generate 3D scaling matrix - * RETURNS: N/A - */ - -void pscale3( - Pvec3 *scale_vector, /* scale factor vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * pscale - * - * DESCR: Generate scaling matrix - * RETURNS: N/A - */ - -void pscale( - Pvec *scale_vector, /* scale factor vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * protate_x - * - * DESCR: Generate matrix for rotation around x-axis - * RETURNS: N/A - */ - -void protate_x( - Pfloat angle, /* rotation angle */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * protate_y - * - * DESCR: Generate matrix for rotation around y-axis - * RETURNS: N/A - */ - -void protate_y( - Pfloat angle, /* rotation angle */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * protate_z - * - * DESCR: Generate matrix for rotation around z-axis - * RETURNS: N/A - */ - -void protate_z( - Pfloat angle, /* rotation angle */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * protate - * - * DESCR: Generate rotation matrix - * RETURNS: N/A - */ - -void protate( - Pfloat angle, /* rotation angle */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix m /* OUT transformation matrix */ - ); - -/******************************************************************************* - * pcompose_matrix3 - * - * DESCR: Generate combined 3D transformation matrix - * RETURNS: N/A - */ - -void pcompose_matrix3( - Pmatrix3 a, /* matrix a */ - Pmatrix3 b, /* matrix b */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT result matrix */ - ); - -/******************************************************************************* - * pcompose_matrix - * - * DESCR: Generate combined transformation matrix - * RETURNS: N/A - */ - -void pcompose_matrix( - Pmatrix a, /* matrix a */ - Pmatrix b, /* matrix b */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix m /* OUT result matrix */ - ); - -/******************************************************************************* - * ptran_point3 - * - * DESCR: Translate 3D point using transformation matrix - * RETURNS: N/A - */ - -void ptran_point3( - Ppoint3 *p, /* point */ - Pmatrix3 m, /* transformation matrix */ - Pint *error_ind, /* OUT error indicator */ - Ppoint3 *r /* OUT transformed point */ - ); - -/******************************************************************************* - * ptran_point - * - * DESCR: Translate point using transformation matrix - * RETURNS: N/A - */ - -void ptran_point( - Ppoint *p, /* point */ - Pmatrix m, /* transformation matrix */ - Pint *error_ind, /* OUT error indicator */ - Ppoint *r /* OUT transformed point */ - ); - -/******************************************************************************* - * pbuild_tran_matrix3 - * - * DESCR: Generate 3D transformation matrix - * RETURNS: N/A - */ - -void pbuild_tran_matrix3( - Ppoint3 *pt, /* fixed point */ - Pvec3 *shift, /* shift vector */ - Pfloat x_angle, /* rotation angle X */ - Pfloat y_angle, /* rotation angle Y */ - Pfloat z_angle, /* rotation angle Z */ - Pvec3 *scale, /* scale vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 matrix /* OUT transformation matrix */ - ); - -/******************************************************************************* - * void build_tran_matrix - * - * DESCR: Generate transformation matrix - * RETURNS: N/A - */ - -void pbuild_tran_matrix( - Ppoint *pt, /* fixed point */ - Pvec *shift, /* shift vector */ - Pfloat angle, /* rotation angle */ - Pvec *scale, /* scale vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix matrix /* OUT transformation matrix */ - ); - -/******************************************************************************* - * pcompose_tran_matrix3 - * - * DESCR: Combine 3D transformation with other transformation matrix - * RETURNS: N/A - */ - -void pcompose_tran_matrix3( - Pmatrix3 m, /* transformation matrix */ - Ppoint3 *pt, /* fixed point */ - Pvec3 *shift, /* shift vector */ - Pfloat x_ang, /* rotation angle X */ - Pfloat y_ang, /* rotation angle Y */ - Pfloat z_ang, /* rotation angle Z */ - Pvec3 *scale, /* scale vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 result /* OUT transformation matrix */ - ); - -/******************************************************************************* - * pcompose_tran_matrix - * - * DESCR: Combine transformation with other transformation matrix - * RETURNS: N/A - */ - -void pcompose_tran_matrix( - Pmatrix m, /* transformation matrix */ - Ppoint *pt, /* fixed point */ - Pvec *shift, /* shift vector */ - Pfloat angle, /* rotation angle */ - Pvec *scale, /* scale vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix result /* OUT transformation matrix */ - ); - -/******************************************************************************* - * peval_view_ori_matrix3 - * - * DESCR: Generate 3D view orientation matrix - * RETURNS: N/A - */ - -void peval_view_ori_matrix3( - Ppoint3 *vrp, /* view reference point */ - Pvec3 *vpn, /* view plane normal */ - Pvec3 *vup, /* view up vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT view orientation matrix */ - ); - -/******************************************************************************* - * peval_view_ori_matrix - * - * DESCR: Generate view orientation matrix - * RETURNS: N/A - */ - -void peval_view_ori_matrix( - Ppoint *vrp, /* view reference point */ - Pvec *vup, /* view up vector */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix m /* OUT view orientation matrix */ - ); - -/******************************************************************************* - * peval_view_map_matrix3 - * - * DESCR: Generate 3D view mapping matrix - * RETURNS: N/A - */ - -void peval_view_map_matrix3( - Pview_map3 *map, /* view mapping */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix3 m /* OUT view mapping matrix */ - ); - -/******************************************************************************* - * peval_view_map_matrix - * - * DESCR: Generate view mapping matrix - * RETURNS: N/A - */ - -void peval_view_map_matrix( - Pview_map *map, /* view mapping */ - Pint *error_ind, /* OUT error indicator */ - Pmatrix m /* OUT view mapping matrix */ - ); - -/******************************************************************************* - * pinit_loc3 - * - * DESCR: Initialize locator device 3D - * RETURNS: N/A - */ - -void pinit_loc3( - Pint ws_id, - Pint loc_num, - Pint init_view_ind, - Ppoint3 *init_loc_pos, - Pint pet, - Plimit3 *echo_vol, - Ploc_data3 *loc_data - ); - -/******************************************************************************* - * pinit_stroke3 - * - * DESCR: Initialize stroke device 3D - * RETURNS: N/A - */ - -void pinit_stroke3( - Pint ws_id, - Pint stroke_num, - Pint init_view_ind, - Ppoint_list3 *init_stroke, - Pint pet, - Plimit3 *echo_vol, - Pstroke_data3 *stroke_data - ); - -/******************************************************************************* - * pinit_pick3 - * - * DESCR: Initialize pick device 3D - * RETURNS: N/A - */ - -void pinit_pick3( - Pint ws_id, - Pint pick_num, - Pin_status init_status, - Ppick_path *init_pick, - Pint pet, - Plimit3 *echo_vol, - Ppick_data3 *pick_data, - Ppath_order order - ); - - /******************************************************************************* - * pinit_string - * - * DESCR: Initialize string device - * RETURNS: N/A - */ -void pinit_string( - Pint ws_id, - Pint string_dev, - char * init_string, - Pint pet, - Plimit * area, - Pstring_data *data_rec - ); - - /******************************************************************************* - * pinit_string3 - * - * DESCR: Initialize string device 3d - * RETURNS: N/A - */ -void pinit_string3( - Pint ws_id, - Pint string_dev, - char * init_string, - Pint pet, - Plimit3 * area, - Pstring_data3 *data_rec - ); - -/******************************************************************************* - * pinit_choice3 - * - * DESCR: Initialize string - * RETURNS: N/A - */ -void pinit_choice3( - Pint ws_id, - Pint choice_dev, - Pin_status init_status, - Pint init_choice, - Pint pet, - Plimit3 * echo_volume, - Pchoice_data3 *choice_data_rec -); - -/******************************************************************************* - * pinit_val3 - * - * DESCR: Initialize string - * RETURNS: N/A - */ - -void pinit_val3( - Pint ws_id, - Pint val_dev, - Pfloat init_value, - Pint pet, - Plimit3 * echo_volume, - Pval_data *val_data_rec -); - -/******************************************************************************* - * pset_pick_filter - * - * DESCR: Set pick device filter - * RETURNS: N/A - */ - -void pset_pick_filter( - Pint ws_id, - Pint pick_num, - Pfilter *filter - ); - -/******************************************************************************* - * pset_loc_mode - * - * DESCR: Set locator input device mode - * RETURNS: N/A - */ - -void pset_loc_mode( - Pint ws_id, - Pint loc_num, - Pop_mode op_mode, - Pecho_switch echo_switch - ); - -/******************************************************************************* - * pset_stroke_mode - * - * DESCR: Set stroke input device mode - * RETURNS: N/A - */ - -void pset_stroke_mode( - Pint ws_id, - Pint stroke_num, - Pop_mode op_mode, - Pecho_switch echo_switch - ); - -/******************************************************************************* - * pset_pick_mode - * - * DESCR: Set pick input device mode - * RETURNS: N/A - */ - -void pset_pick_mode( - Pint ws_id, - Pint pick_num, - Pop_mode op_mode, - Pecho_switch echo_switch - ); - -/******************************************************************************* - * pset_string_mode - * - * DESCR: Set string input device mode - * RETURNS: N/A - */ -void pset_string_mode( - Pint ws_id, - Pint string_dev, - Pop_mode op_mode, - Pecho_switch echo_switch -); - -/******************************************************************************* - * pset_choice_mode - * - * DESCR: Set choice input device mode - * RETURNS: N/A - */ -void pset_choice_mode( - Pint ws_id, - Pint choice_dev, - Pop_mode op_mode, - Pecho_switch echo_switch -); - -/******************************************************************************* - * pset_val_mode - * - * DESCR: Set string input device mode - * RETURNS: N/A - */ -void pset_val_mode( - Pint ws_id, - Pint val_dev, - Pop_mode op_mode, - Pecho_switch echo_switch -); - -/******************************************************************************* - * psample_loc - * - * DESCR: Sample locator device - * RETURNS: N/A - */ - -void psample_loc( - Pint ws_id, - Pint loc_num, - Pint *view_ind, - Ppoint *loc_pos - ); - -/******************************************************************************* - * psample_loc3 - * - * DESCR: Sample locator device 3D - * RETURNS: N/A - */ - -void psample_loc3( - Pint ws_id, - Pint loc_num, - Pint *view_ind, - Ppoint3 *loc_pos - ); - -/******************************************************************************* - * psample_stroke - * - * DESCR: Sample stroke device - * RETURNS: N/A - */ - -void psample_stroke( - Pint ws_id, - Pint stroke_num, - Pint *view_ind, - Ppoint_list *stroke - ); - -/******************************************************************************* - * psample_stroke3 - * - * DESCR: Sample stroke device 3D - * RETURNS: N/A - */ - -void psample_stroke3( - Pint ws_id, - Pint stroke_num, - Pint *view_ind, - Ppoint_list3 *stroke - ); - -/******************************************************************************* - * psample_pick - * - * DESCR: Sample pick device - * RETURNS: N/A - */ -void psample_pick( - Pint ws_id, - Pint pick_num, - Pint depth, - Pin_status *pick_in_status, - Ppick_path *pick -); - -/******************************************************************************* - * psample_string - * - * DESCR: Sample string device - * RETURNS: String - */ - -void psample_string( - Pint ws_id, - Pint string_dev, - char* string -); - -/******************************************************************************* - * pawait_event - * - * DESCR: Wait for event to occur - * RETURNS: N/A - */ - -void pawait_event( - Pfloat timeout, - Pint *ws_id, - Pin_class *dev_class, - Pint *in_num - ); - -/******************************************************************************* - * pget_loc - * - * DESCR: Get locator event from event queue - * RETURNS: N/A - */ - -void pget_loc( - Pint *view_ind, - Ppoint *loc_pos - ); - -/******************************************************************************* - * pget_loc3 - * - * DESCR: Get locator event from event queue 3D - * RETURNS: N/A - */ - -void pget_loc3( - Pint *view_ind, - Ppoint3 *loc_pos - ); - -/******************************************************************************* - * pget_stroke - * - * DESCR: Get stroke event from event queue - * RETURNS: N/A - */ - -void pget_stroke( - Pint *view_ind, - Ppoint_list *stroke - ); - -/******************************************************************************* - * pget_stroke3 - * - * DESCR: Get stroke event from event queue 3D - * RETURNS: N/A - */ - -void pget_stroke3( - Pint *view_ind, - Ppoint_list3 *stroke - ); - -/******************************************************************************* - * pget_pick - * - * DESCR: Get pick event from event queue - * RETURNS: N/A - */ - -void pget_pick( - Pint depth, - Pin_status *in_status, - Ppick_path *pick - ); - -/******************************************************************************* - * pget_val - * - * DESCR: Get valuator event from event queue - * RETURNS: N/A - */ - -void pget_val( - Pfloat *val - ); - -/******************************************************************************* - * pget_choice - * - * DESCR: Get choice event from event queue - * RETURNS: N/A - */ - -void pget_choice( - Pin_status *in_status, - Pint *choice - ); - -/******************************************************************************* - * preq_loc3 - * - * DESCR: Request input from locater device - * RETURNS: N/A - */ - -void preq_loc3( - Pint ws_id, - Pint loc_num, - Pin_status *in_status, - Pint *view_ind, - Ppoint3 *loc_pos - ); - -/******************************************************************************* - * preq_pick - * - * DESCR: Request input from pick device - * RETURNS: N/A - */ - -void preq_pick( - Pint ws_id, - Pint pick_num, - Pint depth, - Pin_status *status, - Ppick_path *pick - ); - -/******************************************************************************* - * preq_choice - * - * DESCR: Request input from choice device - * RETURNS: N/A - */ + } pets; + } Pstring_data; + + typedef Pstring_data Pstring_data3; + + /******************************************************************************* + * popen_phigs + * + * DESCR: Open phigs + * RETURNS: N/A + */ + + void popen_phigs( + char *error_file, + size_t memory + ); + + /******************************************************************************* + * pclose_phigs + * + * DESCR: Close phigs + * RETURNS: N/A + */ + + void pclose_phigs( + void + ); + + /******************************************************************************* + * pcreate_store + * + * DESCR: Create storage object + * RETURNS: N/A + */ + + void pcreate_store( + Pint *err_ind, + Pstore *store + ); - void preq_choice( - Pint ws_id, - Pint choice_dev, - Pin_status *status, - Pint *choice - ); - -/******************************************************************************* - * preq_valuator - * - * DESCR: Request input from valuator device - * RETURNS: N/A - */ + /******************************************************************************* + * pdel_store + * + * DESCR: Delete storage object + * RETURNS: N/A + */ + + void pdel_store( + Pstore store + ); + + /* See phgsargs.h for more info */ + struct _Phg_args_conn_info; + + /******************************************************************************* + * popen_ws + * + * DESCR: Open workstation + * RETURNS: N/A + */ + + void popen_ws( + Pint ws_id, + struct _Phg_args_conn_info *conn_id, + Pint ws_type + ); + + /******************************************************************************* + * pclose_ws + * + * DESCR: Close workstation + * RETURNS: N/A + */ + + void pclose_ws( + Pint ws_id + ); + + /******************************************************************************* + * pset_ws_vp + * + * DESCR: Set workstation viewport + * RETURNS: N/A + */ + + void pset_ws_vp( + Pint ws_id, + Plimit *viewport + ); + + /******************************************************************************* + * pset_ws_vp3 + * + * DESCR: Set workstation viewport + * RETURNS: N/A + */ + + void pset_ws_vp3( + Pint ws_id, + Plimit3 *viewport + ); + + /******************************************************************************* + * pset_ws_win + * + * DESCR: Set workstation window + * RETURNS: N/A + */ + + void pset_ws_win( + Pint ws_id, + Plimit *window + ); + + /******************************************************************************* + * pset_ws_win3 + * + * DESCR: Set workstation window + * RETURNS: N/A + */ + + void pset_ws_win3( + Pint ws_id, + Plimit3 *window + ); + + /******************************************************************************* + * pset_invis_filter + * + * DESCR: Set workstation invisibility filter + * RETURNS: N/A + */ + + void pset_invis_filter( + Pint ws_id, + Pfilter *filter + ); - void preq_valuator( - Pint ws_id, - Pint val_dev, - Pin_status *status, - Pfloat *choice - ); - -/******************************************************************************* - * preq_stroke3 - * - * DESCR: Request input from stroke device 3D - * RETURNS: N/A - */ - -void preq_stroke3( - Pint ws_id, - Pint stroke_num, - Pin_status *in_status, - Pint *view_ind, - Ppoint_list3 *stroke - ); - -/******************************************************************************* - * preq_string - * - * DESCR: Request input from string - * RETURNS: N/A - */ - -void preq_string( - Pint ws_id, - Pint string_dev, - Pin_status *status, - char *string - ); - -/******************************************************************************* - * pflush_events - * - * DESCR: Flush events for device - * RETURNS: N/A - */ -void pflush_events( - Pint ws_id, - Pin_class inp_class, - Pint dev - ); - -/******************************************************************************* - * popen_ar_file - * - * DESCR: Open archive file - * RETURNS: N/A - */ - -void popen_ar_file( - Pint archive_id, - char *archive_file - ); - -/******************************************************************************* - * pclose_ar_file - * - * DESCR: Close archive file - * RETURNS: N/A - */ - -void pclose_ar_file( - Pint archive_id - ); - -/******************************************************************************* - * pset_conf_res - * - * DESCR: Set structure conflict resolution for archive - * RETURNS: N/A - */ - -void pset_conf_res( - Pconf_res archive_res, - Pconf_res retrieval_res - ); - -/******************************************************************************* - * par_structs - * - * DESCR: Store structures in archive - * RETURNS: N/A - */ - -void par_structs( - Pint archive_id, - Pint_list *struct_ids - ); - -/******************************************************************************* - * par_struct_nets - * - * DESCR: Store structure networks in archive - * RETURNS: N/A - */ - -void par_struct_nets( - Pint archive_id, - Pint_list *struct_ids - ); - -/******************************************************************************* - * par_all_structs - * - * DESCR: Store all structures in archive - * RETURNS: N/A - */ - -void par_all_structs( - Pint archive_id - ); - -/******************************************************************************* - * pret_struct_ids - * - * DESCR: Retreive all structures identifiers for archive - * RETURNS: N/A - */ - -void pret_struct_ids( - Pint archive_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint_list *ids, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pret_structs - * - * DESCR: Retreive structures from archive - * RETURNS: N/A - */ - -void pret_structs( - Pint archive_id, - Pint_list *struct_ids - ); - -/******************************************************************************* - * pret_struct_nets - * - * DESCR: Retreive structure networks from archive - * RETURNS: N/A - */ - -void pret_struct_nets( - Pint archive_id, - Pint_list *struct_ids - ); - -/******************************************************************************* - * pret_all_structs - * - * DESCR: Retreive all structures from archive - * RETURNS: N/A - */ - -void pret_all_structs( - Pint archive_id - ); - -/******************************************************************************* - * pdel_structs_ar - * - * DESCR: Delete structures from archive - * RETURNS: N/A - */ - -void pdel_structs_ar( - Pint archive_id, - Pint_list *struct_ids - ); - -/******************************************************************************* - * pdel_struct_nets_ar - * - * DESCR: Delete structure networks from archive - * RETURNS: N/A - */ - -void pdel_struct_nets_ar( - Pint archive_id, - Pint_list *struct_ids - ); - -/******************************************************************************* - * pdel_all_structs_ar - * - * DESCR: Delete all structures from archive - * RETURNS: N/A - */ - -void pdel_all_structs_ar( - Pint archive_id - ); - -/******************************************************************************* - * pinq_ar_st - * - * DESCR: Get archive state - * RETURNS: N/A - */ - -void pinq_ar_st( - Par_st *ar_st - ); - -/******************************************************************************* - * pinq_ar_files - * - * DESCR: Get open archive files - * RETURNS: N/A - */ - -void pinq_ar_files( - Pstore store, - Pint *err_ind, - Par_file_list **ar_files - ); - -/******************************************************************************* - * pinq_conf_res - * - * DESCR: Get archive conflict resolution - * RETURNS: N/A - */ - -void pinq_conf_res( - Pint *err_ind, - Pconf_res *archive_res, - Pconf_res *retrieval_res - ); - -/******************************************************************************* - * pinq_all_conf_structs - * - * DESCR: Get conflicting structure ids - * RETURNS: N/A - */ - -void pinq_all_conf_structs( - Pint ar_id, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *ids, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_conf_structs_net - * - * DESCR: Get conflicting structure ids in network - * RETURNS: N/A - */ - -void pinq_conf_structs_net( - Pint ar_id, - Pint struct_id, - Pstruct_net_source source, - Pint num_elems_appl_list, - Pint start_ind, - Pint *err_ind, - Pint_list *ids, - Pint *num_elems_impl_list - ); - -/******************************************************************************* - * pinq_light_src_rep - * - * DESCR: inquire light source respresentation - * RETURNS: N/A - */ - -void pinq_light_src_rep( - Pint ws_id, - Pint index, - Pinq_type type, - Pint *err_ind, - Plight_src_bundle *rep - ); - -/******************************************************************************* - * pannot_text_rel3 - * - * DESCR: annotation text relative 3 - * RETURNS: N/A - */ -void panno_text_rel3( - Ppoint3 *ref_point, - Pvec3 *offset, - char *text); - - -/******************************************************************************* - * pannot_text_rel - * - * DESCR: annotation text relative - * RETURNS: N/A - */ -void panno_text_rel( - Ppoint *ref_point, - Pvec *offset, - char *text); - -/******************************************************************************* - * set_anno_char_ht - * - * DESCR: annotation text height - * RETURNS: N/A - */ -void pset_anno_char_ht( - Pfloat height + /******************************************************************************* + * pset_hlhsr_mode + * + * DESCR: Set workstation hlhsr mode + * RETURNS: N/A + */ + + void pset_hlhsr_mode( + Pint ws_id, + Pint hlhsr_mode ); -/******************************************************************************* - * set_anno_align - * - * DESCR: annotation text height - * RETURNS: N/A - */ -void pset_anno_align( - Ptext_align *text_align + /******************************************************************************* + * pset_line_rep + * + * DESCR: Set workstation line represenation + * RETURNS: N/A + */ + + void pset_line_rep( + Pint ws_id, + Pint line_ind, + Pline_bundle *line_bundle ); -/******************************************************************************* - * set_anno_path - * - * DESCR: annotation text path - * RETURNS: N/A - */ - void pset_anno_path( - Ptext_path text_path + /******************************************************************************* + * pset_marker_rep + * + * DESCR: Set workstation marker represenation + * RETURNS: N/A + */ + + void pset_marker_rep( + Pint ws_id, + Pint marker_ind, + Pmarker_bundle *marker_bundle + ); + + /******************************************************************************* + * pset_text_rep + * + * DESCR: Set workstation text represenation + * RETURNS: N/A + */ + + void pset_text_rep( + Pint ws_id, + Pint text_ind, + Ptext_bundle *text_bundle + ); + + /******************************************************************************* + * pset_edge_rep + * + * DESCR: Set workstation edge represenation + * RETURNS: N/A + */ + + void pset_edge_rep( + Pint ws_id, + Pint edge_ind, + Pedge_bundle *edge_bundle + ); + + /******************************************************************************* + * pset_int_rep + * + * DESCR: Set workstation interior represenation + * RETURNS: N/A + */ + + void pset_int_rep( + Pint ws_id, + Pint int_ind, + Pint_bundle *int_bundle + ); + + /******************************************************************************* + * ppost_struct + * + * DESCR: Post structure to workstation + * RETURNS: N/A + */ + + void ppost_struct( + Pint ws_id, + Pint struct_id, + Pfloat priority + ); + + /******************************************************************************* + * punpost_struct + * + * DESCR: Remove posted structure from workstation + * RETURNS: N/A + */ + + void punpost_struct( + Pint ws_id, + Pint struct_id ); -/******************************************************************************* - * GS element - * - * DESCR: generalised structure element - * RETURNS: N/A - */ -void pgse( - Pgse_type gse_type, - Pgse_data * gse_data - ); - -/******************************************************************************* - * set highlighting color - * - * DESCR: set the highlighting color - * RETURNS: N/A - */ -void pxset_highlight_colr ( - Pgcolr *colr + /******************************************************************************* + * punpost_all_structs + * + * DESCR: Remove all posted structures from workstation + * RETURNS: N/A + */ + + void punpost_all_structs( + Pint ws_id + ); + + /******************************************************************************* + * predraw_all_structs + * + * DESCR: Redraw all structures on workstation + * RETURNS: N/A + */ + + void predraw_all_structs( + Pint ws_id, + Pctrl_flag ctrl_flag ); -/******************************************************************************* - * set highlighting filter - * - * DESCR: set the highlighting filter - * RETURNS: N/A - */ -void pset_highl_filter ( + /******************************************************************************* + * pupd_ws + * + * DESCR: Set workstation update state + * RETURNS: N/A + */ + + void pupd_ws( + Pint ws_id, + Pregen_flag regen_flag + ); + + /******************************************************************************* + * pset_disp_upd_st + * + * DESCR: Set workstation update state + * RETURNS: N/A + */ + + void pset_disp_upd_st( Pint ws_id, - Pfilter *filter + Pdefer_mode def_mode, + Pmod_mode mod_mode + ); + + /******************************************************************************* + * pset_view_tran_in_pri + * + * DESCR: Set view input priority + * RETURNS: N/A + */ + + void pset_view_tran_in_pri( + Pint ws_id, + Pint view_ind, + Pint ref_view_ind, + Prel_pri rel_pri + ); + + /******************************************************************************* + * pset_light_src_rep + * + * DESCR: Set light source for workstation + * RETURNS: N/A + */ + + void pset_light_src_rep( + Pint ws_id, + Pint light_src_ind, + Plight_src_bundle *light_src_rep + ); + + /******************************************************************************* + * pset_colr_model + * + * DESCR: Set workstation colour model + * RETURNS: N/A + */ + void pset_colr_model( + Pint ws_id, + Pint model + ); + + /******************************************************************************* + * pset_colr_rep + * + * DESCR: Set workstation colour representation + * RETURNS: N/A + */ + + void pset_colr_rep( + Pint ws_id, + Pint ind, + Pcolr_rep *rep + ); + + /******************************************************************************* + * pinq_ws_st + * + * DESCR: Get workstation state + * RETURNS: N/A + */ + + void pinq_ws_st( + Pws_st *ws_state + ); + + /******************************************************************************* + * pinq_ws_conn_type + * + * DESCR: Get workstation connection type + * RETURNS: N/A + */ + + void pinq_ws_conn_type( + Pint ws_id, + Pstore store, + Pint *err_ind, + void **conn_id, + Pint *ws_type + ); + + /******************************************************************************* + * pinq_open_wss + * + * DESCR: Get list of open workstations + * RETURNS: N/A + */ + + void pinq_open_wss( + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *open_ws_ids, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_view_inds + * + * DESCR: Get workstation list of view indices + * RETURNS: N/A + */ + + void pinq_list_view_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *view_inds, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_line_inds + * + * DESCR: Get workstation list of line indices + * RETURNS: N/A + */ + + void pinq_list_line_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *def_line_ind, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_marker_inds + * + * DESCR: Get workstation list of marker indices + * RETURNS: N/A + */ + + void pinq_list_marker_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *def_marker_ind, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_text_inds + * + * DESCR: Get workstation list of text indices + * RETURNS: N/A + */ + + void pinq_list_text_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *def_text_ind, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_int_inds + * + * DESCR: Get workstation list of interior indices + * RETURNS: N/A + */ + + void pinq_list_int_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *def_int_ind, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_edge_inds + * + * DESCR: Get workstation list of edge indices + * RETURNS: N/A + */ + + void pinq_list_edge_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *def_edge_ind, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_list_colr_inds + * + * DESCR: Get workstation list of colour indices + * RETURNS: N/A + */ + + void pinq_list_colr_inds( + Pint ws_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *colr_ind, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_line_rep + * + * DESCR: Get workstation line representation + * RETURNS: N/A + */ + + void pinq_line_rep( + Pint ws_id, + Pint index, + Pinq_type type, + Pint *err_ind, + Pline_bundle *line_rep + ); + + /******************************************************************************* + * pinq_marker_rep + * + * DESCR: Get workstation marker representation + * RETURNS: N/A + */ + + void pinq_marker_rep( + Pint ws_id, + Pint index, + Pinq_type type, + Pint *err_ind, + Pmarker_bundle *marker_rep + ); + + /******************************************************************************* + * pinq_text_rep + * + * DESCR: Get workstation text representation + * RETURNS: N/A + */ + + void pinq_text_rep( + Pint ws_id, + Pint index, + Pinq_type type, + Pint *err_ind, + Ptext_bundle *text_rep + ); + + /******************************************************************************* + * pinq_int_rep + * + * DESCR: Get workstation interior representation + * RETURNS: N/A + */ + + void pinq_int_rep( + Pint ws_id, + Pint index, + Pinq_type type, + Pint *err_ind, + Pint_bundle *int_rep + ); + + /******************************************************************************* + * pinq_edge_rep + * + * DESCR: Get workstation edge representation + * RETURNS: N/A + */ + + void pinq_edge_rep( + Pint ws_id, + Pint index, + Pinq_type type, + Pint *err_ind, + Pedge_bundle *edge_rep + ); + + /******************************************************************************* + * pinq_colr_rep + * + * DESCR: Get workstation colour representation + * RETURNS: N/A + */ + + void pinq_colr_rep( + Pint ws_id, + Pint colr_ind, + Pinq_type type, + Pint *err_ind, + Pcolr_rep *colr_rep + ); + + /******************************************************************************* + * pinq_invis_filter + * + * DESCR: Get workstation invisibility filter + * RETURNS: N/A + */ + + void pinq_invis_filter( + Pint ws_id, + Pstore store, + Pint *err_ind, + Pfilter **invis_filter + ); + + /******************************************************************************* + * pinq_ws_cat + * + * DESCR: Get workstation category + * RETURNS: N/A + */ + + void pinq_ws_cat( + Pint ws_type, + Pint *err_ind, + Pws_cat *cat + ); + + /******************************************************************************* + * pinq_disp_space_size3 + * + * DESCR: Get workstation type display size 3D + * RETURNS: N/A + */ + + void pinq_disp_space_size3( + Pint ws_type, + Pint *err_ind, + Pdisp_space_size3 *size + ); + + /******************************************************************************* + * popen_struct + * + * DESCR: Opens a structure for appending or editing. + * RETURNS: N/A + */ + + void popen_struct( + Pint struct_id + ); + + /******************************************************************************* + * pclose_struct + * + * DESCR: Closes a previously opened structure. + * RETURNS: N/A + */ + + void pclose_struct( + void + ); + + /******************************************************************************* + * pchange_struct_id + * + * DESCR: Changes structure id + * RETURNS: N/A + */ + + void pchange_struct_id( + Pint orig_struct_id, + Pint result_struct_id + ); + + /******************************************************************************* + * pchange_struct_refs + * + * DESCR: Changes structure references + * RETURNS: N/A + */ + + void pchange_struct_refs( + Pint orig_struct_id, + Pint result_struct_id + ); + + /******************************************************************************* + * pchange_struct_id_refs + * + * DESCR: Changes structure ids and references + * RETURNS: N/A + */ + + void pchange_struct_id_refs( + Pint orig_struct_id, + Pint result_struct_id + ); + + /******************************************************************************* + * pset_edit_mode + * + * DESCR: Set structure edit mode + * RETURNS: N/A + */ + + void pset_edit_mode( + Pedit_mode edit_mode + ); + + /******************************************************************************* + * pset_elem_ptr + * + * DESCR: Make the requested index the "currently active element". + * NOTE: 0 means set element to even before the very first + * element; 1 means set elptr to very first element. + * RETURNS: N/A + */ + + void pset_elem_ptr( + Pint elem_ptr_value + ); + + /******************************************************************************* + * poffset_elem_ptr + * + * DESCR: Offsets the element pointer forward by the given number of + * elements. + * Internal call to pset_elem_ptr does the verification work + * on the index. + * RETURNS: N/A + */ + + void poffset_elem_ptr( + Pint elem_ptr_offset + ); + + /******************************************************************************* + * pset_elem_ptr_label + * + * DESCR: Searches forward in the structure list for the specified + * label, and makes that the current element. Search begins + * with the element after (to the right) of the current one. + * Question: should I include the current element in the search? + * Or does the search begin with the first element after the + * current one? + * This version gives fatal error if label not found. + * RETURNS: N/A + */ + + void pset_elem_ptr_label( + Pint label_id + ); + + /******************************************************************************* + * pdel_elem + * + * DESCR: Deletes the current element. The element pointer is left + * pointing to the element just before (to the left) the one to + * be killed, if any. + * RETURNS: N/A + */ + + void pdel_elem( + void + ); + + /******************************************************************************* + * pdel_elem_range + * + * DESCR: Deletes all elements within and on the bounds of the given + * range. The element pointer is left pointing to the element + * just prior to the first element deleted. + * RETURNS: N/A + */ + + void pdel_elem_range( + Pint elem_ptr1_value, + Pint elem_ptr2_value + ); + + /******************************************************************************* + * pdel_elems_labels + * + * DESCR: Deletes all elements in the structure that lie between the + * given labels, but not the labels themselves. The element + * pointer is left pointing to the first label. + * RETURNS: N/A + */ + + void pdel_elems_labels( + Pint label1_id, + Pint label2_id + ); + + /******************************************************************************* + * pempty_struct + * + * DESCR: Clear structure + * RETURNS: N/A + */ + + void pempty_struct( + Pint struct_id + ); + + /******************************************************************************* + * pdel_struct + * + * DESCR: Delete structure + * RETURNS: N/A + */ + + void pdel_struct( + Pint struct_id + ); + + /******************************************************************************* + * pdel_struct_net + * + * DESCR: Delete structure network + * RETURNS: N/A + */ + + void pdel_struct_net( + Pint struct_id, + Pref_flag ref_flag + ); + + /******************************************************************************* + * pdel_all_structs + * + * DESCR: Delete all structures + * RETURNS: N/A + */ + + void pdel_all_structs( + void + ); + + /******************************************************************************* + * pcopy_all_elems_struct + * + * DESCR: Copies the elements of another structure into the open + * structure after the current element, which is updated to + * point to the last element inserted. A structure can be + * copied into itself. + * RETURNS: N/A + */ + + void pcopy_all_elems_struct( + Pint struct_id + ); + + /******************************************************************************* + * pelem_search + * + * DESCR: Get all matching elements + * RETURNS: N/A + */ + + void pelem_search( + Pint struct_id, + Pint struct_elem, + Psearch_dir dir, + Pelem_type_list *incl, + Pelem_type_list *excl, + Pint *err_ind, + Psearch_status *status, + Pint *found_elem_ptr + ); + + /******************************************************************************* + * pinq_edit_mode + * + * DESCR: Get structure edit mode + * RETURNS: N/A + */ + + void pinq_edit_mode( + Pint *err_ind, + Pedit_mode *edit_mode + ); + + /******************************************************************************* + * pinq_elem_ptr + * + * DESCR: Returns the index of the current element. + * RETURNS: N/A + */ + + void pinq_elem_ptr( + Pint *err_ind, + Pint *elem_ptr_value + ); + + /******************************************************************************* + * pinq_struct_st + * + * DESCR: Get current structure state + * RETURNS: N/A + */ + + void pinq_struct_st( + Pint *struct_st + ); + + /******************************************************************************* + * pinq_open_struct + * + * DESCR: Get current open structure and edit status + * RETURNS: N/A + */ + + void pinq_open_struct( + Pint *err_ind, + Popen_struct_status *status, + Pint *struct_id + ); + + /******************************************************************************* + * pinq_struct_status + * + * DESCR: Get current status of give structure + * RETURNS: N/A + */ + + void pinq_struct_status( + Pint struct_id, + Pint *err_ind, + Pstruct_status *status + ); + + /******************************************************************************* + * pinq_elem_type_size + * + * DESCR: Get element type and size + * RETURNS: N/A + */ + + void pinq_elem_type_size( + Pint struct_id, + Pint elem_num, + Pint *err_ind, + Pelem_type *elem_type, + size_t *elem_size + ); + + /******************************************************************************* + * pinq_cur_elem_type_size + * + * DESCR: Get current element type and size + * RETURNS: N/A + */ + + void pinq_cur_elem_type_size( + Pint *err_ind, + Pelem_type *elem_type, + size_t *elem_size + ); + + /******************************************************************************* + * pinq_elem_content + * + * DESCR: Get element content + * RETURNS: N/A + */ + + void pinq_elem_content( + Pint struct_id, + Pint elem_num, + Pstore store, + Pint *err_ind, + Pelem_data **elem_data + ); + + /******************************************************************************* + * pinq_cur_elem_content + * + * DESCR: Get current element content + * RETURNS: N/A + */ + + void pinq_cur_elem_content( + Pstore store, + Pint *err_ind, + Pelem_data **elem_data + ); + + /******************************************************************************* + * padd_names_set + * + * DESCR: Creates a new element - name set Inclusion + * RETURNS: N/A + */ + + void padd_names_set( + Pint_list *names + ); + + /******************************************************************************* + * premove_names_set + * + * DESCR: Creates a new element - name set Remover + * RETURNS: N/A + */ + + void premove_names_set( + Pint_list *names + ); + + /******************************************************************************* + * pset_indiv_asf + * + * DESCR: Creates a new element - Set attribute source flag + * RETURNS: N/A + */ + + void pset_indiv_asf( + Paspect asf_id, + Pasf asf_source + ); + + /******************************************************************************* + * pset_local_tran3 + * + * DESCR: Creates a new element - Set local model space transformation 3D + * RETURNS: N/A + */ + + void pset_local_tran3( + Pmatrix3 local_tran, + Pcompose_type compose_type ); -/******************************************************************************* - * pset_model_clip_ind - * - * DESCR: Creates a new element - set clipping indicator - * RETURNS: N/A - */ + /******************************************************************************* + * pset_global_tran3 + * + * DESCR: Creates a new element - Set global model space transformation 3D + * RETURNS: N/A + */ -void pset_model_clip_ind( - Pclip_ind clipi + void pset_global_tran3( + Pmatrix3 global_tran ); -/******************************************************************************* - * pset_model_clip_vol3 - * - * DESCR: Creates a new element - set clipping volume 3 - * RETURNS: N/A - */ + /******************************************************************************* + * pset_view_ind + * + * DESCR: Creates a new element - Set view index + * RETURNS: N/A + */ + + void pset_view_ind( + Pint view_ind + ); + + /******************************************************************************* + * ptext + * + * DESCR: Creates a new element - Text + * RETURNS: N/A + */ + + void ptext( + Ppoint *text_pos, + char *char_string + ); + + /******************************************************************************* + * ptext3 + * + * DESCR: Creates a new element - Text + * RETURNS: N/A + */ + + void ptext3( + Ppoint3 *text_pos, + Pvec3 plane[2], + char *char_string + ); + + /******************************************************************************* + * ppolyline + * + * DESCR: Creates a new element - Polyline + * RETURNS: N/A + */ + + void ppolyline( + Ppoint_list *point_list + ); + + /******************************************************************************* + * ppolyline3 + * + * DESCR: Creates a new element - Polyline 3D + * RETURNS: N/A + */ + + void ppolyline3( + Ppoint_list3 *point_list + ); + + /******************************************************************************* + * ppolymarker + * + * DESCR: Creates a new element - Polymarker + * RETURNS: N/A + */ + + void ppolymarker( + Ppoint_list *point_list + ); + + /******************************************************************************* + * ppolymarker3 + * + * DESCR: Creates a new element - Polymarker 3D + * RETURNS: N/A + */ + + void ppolymarker3( + Ppoint_list3 *point_list + ); + + /******************************************************************************* + * pfill_area + * + * DESCR: Creates a new element - Fill area + * RETURNS: N/A + */ + + void pfill_area( + Ppoint_list *point_list + ); + + /******************************************************************************* + * pfill_area3 + * + * DESCR: Creates a new element - Fill area 3D + * RETURNS: N/A + */ + + void pfill_area3( + Ppoint_list3 *point_list + ); + + /******************************************************************************* + * pfill_area_set + * + * DESCR: Creates a new element - Fill area set + * RETURNS: N/A + */ + + void pfill_area_set( + Ppoint_list_list *point_list_list + ); + + /******************************************************************************* + * pfill_area_set3 + * + * DESCR: Creates a new element - Fill area set 3D + * RETURNS: N/A + */ + + void pfill_area_set3( + Ppoint_list_list3 *point_list_list + ); -void pset_model_clip_vol3 ( - Pint op, - Phalf_space_list3 spacelist + /******************************************************************************* + * pfill_area_set_data + * + * DESCR: Creates a new element - Fill area set with data 3D + * RETURNS: N/A + */ + + void pfill_area_set_data( + Pint fflag, + Pint eflag, + Pint vflag, + Pint colr_type, + Pfacet_data3 *fdata, + Pint nfa, + Pedge_data_list *edata, + Pfacet_vdata_list3 *vdata + ); + + /******************************************************************************* + * pfill_area_set3_data + * + * DESCR: Creates a new element - Fill area set with data 3D + * RETURNS: N/A + */ + + void pfill_area_set3_data( + Pint fflag, + Pint eflag, + Pint vflag, + Pint colr_type, + Pfacet_data3 *fdata, + Pint nfa, + Pedge_data_list *edata, + Pfacet_vdata_list3 *vdata ); -/******************************************************************************* - * predefine colors - * - * DESCR: set color map - * RETURNS: N/A - * Note: DELPHI extension - */ -void pxset_color_map( - Pint ws_id + /******************************************************************************* + * pset_of_fill_area_set3_data + * + * DESCR: Creates a new element - Set of fill area set with data 3D + * RETURNS: N/A + */ + + void pset_of_fill_area_set3_data( + Pint fflag, + Pint eflag, + Pint vflag, + Pint colr_type, + Pint num_sets, + Pfacet_data_arr3 *fdata, + Pedge_data_list_list *edata, + Pint_list_list *vlist, + Pfacet_vdata_list3 *vdata + ); + + /******************************************************************************* + * plabel + * + * DESCR: Creates a new element - Label + * RETURNS: N/A + */ + + void plabel( + Pint label_id + ); + + /******************************************************************************* + * pset_pick_id + * + * DESCR: Creates a new element - Pick ID + * RETURNS: N/A + */ + + void pset_pick_id( + Pint pick_id + ); + + /******************************************************************************* + * pset_hlhsr_id + * + * DESCR: Create hidden lines, surface removal flag element + * RETURNS: N/A + */ + + void pset_hlhsr_id( + Pint hlhsr_id + ); + + /******************************************************************************* + * pset_int_ind + * + * DESCR: Creates a new element - Facet Interiour Attribute Index + * RETURNS: N/A + */ + + void pset_int_ind( + Pint int_ind + ); + + /******************************************************************************* + * pset_int_colr_ind + * + * DESCR: Creates a new element - Facet Color Attribute + * RETURNS: N/A + */ + + void pset_int_colr_ind( + Pint colr_ind + ); + + /******************************************************************************* + * pset_int_style + * + * DESCR: Creates a new element - Face Interiour Style + * RETURNS: N/A + */ + + void pset_int_style( + Pint_style int_style + ); + + /******************************************************************************* + * pset_int_style_ind + * + * DESCR: Creates a new element - Face Interiour Pattern Index + * RETURNS: N/A + */ + + void pset_int_style_ind( + Pint int_style_ind + ); + + /******************************************************************************* + * pset_back_int_style + * + * DESCR: Creates a new element - Backface Interiour Style + * RETURNS: N/A + */ + + void pset_back_int_style( + Pint_style int_style + ); + + /******************************************************************************* + * pset_back_int_style_ind + * + * DESCR: Creates a new element - Backface Interiour Pattern Index + * RETURNS: N/A + */ + + void pset_back_int_style_ind( + Pint int_style_ind + ); + + /******************************************************************************* + * pset_line_ind + * + * DESCR: Creates a new element - Line Attribute Index + * RETURNS: N/A + */ + + void pset_line_ind( + Pint line_ind ); -/******************************************************************************* - * print invisibility filter - * - * DESCR: print invisibility filter - * RETURNS: N/A - * Note: moved here from testing suite for debugging - */ -void print_invis_filter( - Pint ws_id + /******************************************************************************* + * pset_line_colr_ind + * + * DESCR: Creates a new element - Line Color Attribute + * RETURNS: N/A + */ + + void pset_line_colr_ind( + Pint colr_ind + ); + + /******************************************************************************* + * pset_linewidth + * + * DESCR: Creates a new element - Line Width Attribute + * RETURNS: N/A + */ + + void pset_linewidth( + Pfloat linewidth + ); + + /******************************************************************************* + * pset_linetype + * + * DESCR: Creates a new element - Line Type Attribute + * RETURNS: N/A + */ + + void pset_linetype( + Pint linetype + ); + + /******************************************************************************* + * pset_marker_ind + * + * DESCR: Creates a new element - Marker Attribute Index + * RETURNS: N/A + */ + + void pset_marker_ind( + Pint marker_ind + ); + + /******************************************************************************* + * pset_marker_colr_ind + * + * DESCR: Creates a new element - Marker Color Attribute + * RETURNS: N/A + */ + + void pset_marker_colr_ind( + Pint colr_ind + ); + + /******************************************************************************* + * pset_marker_size + * + * DESCR: Creates a new element - Marker Size Attribute + * RETURNS: N/A + */ + + void pset_marker_size( + Pfloat marker_size ); -/******************************************************************************* - * set alpha channel - * - * DESCR: set alpha channel - * RETURNS: N/A - * Note: extending the standard - */ -void pset_alpha_channel( - Pfloat alpha + /******************************************************************************* + * pset_marker_type + * + * DESCR: Creates a new element - Marker Type Attribute + * RETURNS: N/A + */ + + void pset_marker_type( + Pint marker_type ); -/******************************************************************************* - * phigs message - * - * DESCR: message in a box - * RETURNS: N/A - * Note: extending the standard - */ - -void pmessage( - Pint ws_id, - char* message + /******************************************************************************* + * pset_edge_ind + * + * DESCR: Creates a new element - Edge Attribute Index + * RETURNS: N/A + */ + + void pset_edge_ind( + Pint edge_ind + ); + + /******************************************************************************* + * pset_edge_colr_ind + * + * DESCR: Creates a new element - Edge Color Attribute + * RETURNS: N/A + */ + + void pset_edge_colr_ind( + Pint colr_ind + ); + + /******************************************************************************* + * pset_edgetype + * + * DESCR: Creates a new element - Edge Type Attribute + * RETURNS: N/A + */ + + void pset_edgetype( + Pint edgetype + ); + + /******************************************************************************* + * pset_edge_flag + * + * DESCR: Creates a new element - Edge Flag Attribute + * RETURNS: N/A + */ + + void pset_edge_flag( + Pedge_flag edge_flag + ); + + /******************************************************************************* + * pset_edgewidth + * + * DESCR: Creates a new element - Edge Width Attribute + * RETURNS: N/A + */ + + void pset_edgewidth( + Pfloat edgewidth + ); + + /******************************************************************************* + * pset_text_font + * + * DESCR: Creates a new element - Text Font Attribute + * RETURNS: N/A + */ + + void pset_text_font( + Pint font + ); + + /******************************************************************************* + * pset_text_prec + * + * DESCR: Creates a new element - Text Precision Attribute + * RETURNS: N/A + */ + + void pset_text_prec( + Ptext_prec prec + ); + + /******************************************************************************* + * pset_text_path + * + * DESCR: Creates a new element - Text Path Attribute + * RETURNS: N/A + */ + + void pset_text_path( + Ptext_path text_path + ); + + /******************************************************************************* + * pset_text_align + * + * DESCR: Creates a new element - Text Alignment Attribute + * RETURNS: N/A + */ + + void pset_text_align( + Ptext_align *text_align + ); + + /******************************************************************************* + * pset_char_ht + * + * DESCR: Creates a new element - Character height Attribute + * RETURNS: N/A + */ + + void pset_char_ht( + Pfloat char_ht + ); + + /******************************************************************************* + * pset_char_expan + * + * DESCR: Creates a new element - Character expansion factor Attribute + * RETURNS: N/A + */ + + void pset_char_expan( + Pfloat char_expan + ); + + /******************************************************************************* + * pset_char_space + * + * DESCR: Creates a new element - Character spaceing Attribute + * RETURNS: N/A + */ + + void pset_char_space( + Pfloat char_space + ); + + /******************************************************************************* + * pset_char_up_vec + * + * DESCR: Creates a new element - Character up vector Attribute + * RETURNS: N/A + */ + + void pset_char_up_vec( + Pvec *char_up_vec + ); + + /******************************************************************************* + * pset_anno_char_up_vec + * + * DESCR: Creates a new element - Character up vector Attribute + * RETURNS: N/A + */ + + void pset_anno_char_up_vec( + Pvec *char_up_vec + ); + + /******************************************************************************* + * pset_text_ind + * + * DESCR: Creates a new element - Text Attribute Index + * RETURNS: N/A + */ + + void pset_text_ind( + Pint text_ind + ); + + /******************************************************************************* + * pset_text_colr_ind + * + * DESCR: Creates a new element - Text Color Attribute + * RETURNS: N/A + */ + + void pset_text_colr_ind( + Pint colr_ind + ); + + /******************************************************************************* + * pexec_struct + * + * DESCR: Creates a new element - Nested Structure + * RETURNS: N/A + */ + + void pexec_struct( + Pint struct_id + ); + + /******************************************************************************* + * pset_int_colr + * + * DESCR: Creates a new element - Facet Color Attribute + * RETURNS: N/A + */ + + void pset_int_colr( + Pgcolr *colr + ); + + /******************************************************************************* + * pset_back_int_colr + * + * DESCR: Creates a new element - Backface Color Attribute + * RETURNS: N/A + */ + + void pset_back_int_colr( + Pgcolr *colr + ); + + /******************************************************************************* + * pset_line_colr + * + * DESCR: Creates a new element - Line Color Attribute + * RETURNS: N/A + */ + + void pset_line_colr( + Pgcolr *colr + ); + + /******************************************************************************* + * pset_marker_colr + * + * DESCR: Creates a new element - Marker Color Attribute + * RETURNS: N/A + */ + + void pset_marker_colr( + Pgcolr *colr + ); + + /******************************************************************************* + * pset_edge_colr + * + * DESCR: Creates a new element - Edge Color Attribute + * RETURNS: N/A + */ + + void pset_edge_colr( + Pgcolr *colr + ); + + /******************************************************************************* + * pset_text_colr + * + * DESCR: Creates a new element - Text Color Attribute + * RETURNS: N/A + */ + + void pset_text_colr( + Pgcolr *colr + ); + + /******************************************************************************* + * pset_light_src_state + * + * DESCR: Creates a new element - Set light source state + * RETURNS: N/A + */ + + void pset_light_src_state( + Pint_list *activation, + Pint_list *deactivation + ); + + /******************************************************************************* + * pset_int_shad_meth + * + * DESCR: Creates a new element - Set interiour shading method + * RETURNS: N/A + */ + + void pset_int_shad_meth( + Pint shad_meth + ); + + /******************************************************************************* + * pset_back_int_shad_meth + * + * DESCR: Creates a new element - Set backface interiour shading method + * RETURNS: N/A + */ + + void pset_back_int_shad_meth( + Pint shad_meth + ); + + /******************************************************************************* + * pset_refl_model + * + * DESCR: Creates a new element - Set reflectance model + * RETURNS: N/A + */ + + void pset_refl_model( + Pint refl_model + ); + + /******************************************************************************* + * pset_refl_eqn + * + * DESCR: Creates a new element - Set surface reflectance equation + * RETURNS: N/A + */ + + void pset_refl_eqn( + Pint refl_equ + ); + + /******************************************************************************* + * pset_back_refl_eqn + * + * DESCR: Creates a new element - Set backsurface reflectance equation + * RETURNS: N/A + */ + + void pset_back_refl_eqn( + Pint refl_equ + ); + + /******************************************************************************* + * pset_refl_props + * + * DESCR: Creates a new element - Set surface reflectance properties + * RETURNS: N/A + */ + + void pset_refl_props( + Prefl_props *refl_props + ); + + /******************************************************************************* + * pset_back_refl_props + * + * DESCR: Creates a new element - Set backsurface reflectance properties + * RETURNS: N/A + */ + + void pset_back_refl_props( + Prefl_props *refl_props + ); + + /******************************************************************************* + * pset_face_disting_mode + * + * DESCR: Creates a new element - Set facet distinguish mode + * RETURNS: N/A + */ + + void pset_face_disting_mode( + Pdisting_mode disting_mode + ); + + /******************************************************************************* + * pset_face_cull_mode + * + * DESCR: Creates a new element - Set face culling mode + * RETURNS: N/A + */ + + void pset_face_cull_mode( + Pcull_mode cull_mode + ); + + /******************************************************************************* + * ptranslate3 + * + * DESCR: Generate 3D translation matrix + * RETURNS: N/A + */ + + void ptranslate3( + Pvec3 *trans_vector, /* translation vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * ptranslate + * + * DESCR: Generate translation matrix + * RETURNS: N/A + */ + + void ptranslate( + Pvec *trans_vector, /* translation vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * pscale3 + * + * DESCR: Generate 3D scaling matrix + * RETURNS: N/A + */ + + void pscale3( + Pvec3 *scale_vector, /* scale factor vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * pscale + * + * DESCR: Generate scaling matrix + * RETURNS: N/A + */ + + void pscale( + Pvec *scale_vector, /* scale factor vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix m /* OUT transformation matrix */ ); -/******************************************************************************* - * set config file name - * - * DESCR: set config file name - * RETURNS: N/A - * Note: extending the standard - */ -void pxset_conf_file_name( - char * name + /******************************************************************************* + * protate_x + * + * DESCR: Generate matrix for rotation around x-axis + * RETURNS: N/A + */ + + void protate_x( + Pfloat angle, /* rotation angle */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * protate_y + * + * DESCR: Generate matrix for rotation around y-axis + * RETURNS: N/A + */ + + void protate_y( + Pfloat angle, /* rotation angle */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * protate_z + * + * DESCR: Generate matrix for rotation around z-axis + * RETURNS: N/A + */ + + void protate_z( + Pfloat angle, /* rotation angle */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * protate + * + * DESCR: Generate rotation matrix + * RETURNS: N/A + */ + + void protate( + Pfloat angle, /* rotation angle */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix m /* OUT transformation matrix */ + ); + + /******************************************************************************* + * pcompose_matrix3 + * + * DESCR: Generate combined 3D transformation matrix + * RETURNS: N/A + */ + + void pcompose_matrix3( + Pmatrix3 a, /* matrix a */ + Pmatrix3 b, /* matrix b */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT result matrix */ + ); + + /******************************************************************************* + * pcompose_matrix + * + * DESCR: Generate combined transformation matrix + * RETURNS: N/A + */ + + void pcompose_matrix( + Pmatrix a, /* matrix a */ + Pmatrix b, /* matrix b */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix m /* OUT result matrix */ + ); + + /******************************************************************************* + * ptran_point3 + * + * DESCR: Translate 3D point using transformation matrix + * RETURNS: N/A + */ + + void ptran_point3( + Ppoint3 *p, /* point */ + Pmatrix3 m, /* transformation matrix */ + Pint *error_ind, /* OUT error indicator */ + Ppoint3 *r /* OUT transformed point */ + ); + + /******************************************************************************* + * ptran_point + * + * DESCR: Translate point using transformation matrix + * RETURNS: N/A + */ + + void ptran_point( + Ppoint *p, /* point */ + Pmatrix m, /* transformation matrix */ + Pint *error_ind, /* OUT error indicator */ + Ppoint *r /* OUT transformed point */ + ); + + /******************************************************************************* + * pbuild_tran_matrix3 + * + * DESCR: Generate 3D transformation matrix + * RETURNS: N/A + */ + + void pbuild_tran_matrix3( + Ppoint3 *pt, /* fixed point */ + Pvec3 *shift, /* shift vector */ + Pfloat x_angle, /* rotation angle X */ + Pfloat y_angle, /* rotation angle Y */ + Pfloat z_angle, /* rotation angle Z */ + Pvec3 *scale, /* scale vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 matrix /* OUT transformation matrix */ + ); + + /******************************************************************************* + * void build_tran_matrix + * + * DESCR: Generate transformation matrix + * RETURNS: N/A + */ + + void pbuild_tran_matrix( + Ppoint *pt, /* fixed point */ + Pvec *shift, /* shift vector */ + Pfloat angle, /* rotation angle */ + Pvec *scale, /* scale vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix matrix /* OUT transformation matrix */ ); -/******************************************************************************* - *set hardcopy scale factor - * - * DESCR: set harcopy scale factor for workstation - * RETURNS: N/A - * Note: extending the standard - */ -void pxset_conf_hcsf( - Pint wkid, - Pfloat hcsf + /******************************************************************************* + * pcompose_tran_matrix3 + * + * DESCR: Combine 3D transformation with other transformation matrix + * RETURNS: N/A + */ + + void pcompose_tran_matrix3( + Pmatrix3 m, /* transformation matrix */ + Ppoint3 *pt, /* fixed point */ + Pvec3 *shift, /* shift vector */ + Pfloat x_ang, /* rotation angle X */ + Pfloat y_ang, /* rotation angle Y */ + Pfloat z_ang, /* rotation angle Z */ + Pvec3 *scale, /* scale vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 result /* OUT transformation matrix */ + ); + + /******************************************************************************* + * pcompose_tran_matrix + * + * DESCR: Combine transformation with other transformation matrix + * RETURNS: N/A + */ + + void pcompose_tran_matrix( + Pmatrix m, /* transformation matrix */ + Ppoint *pt, /* fixed point */ + Pvec *shift, /* shift vector */ + Pfloat angle, /* rotation angle */ + Pvec *scale, /* scale vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix result /* OUT transformation matrix */ + ); + + /******************************************************************************* + * peval_view_ori_matrix3 + * + * DESCR: Generate 3D view orientation matrix + * RETURNS: N/A + */ + + void peval_view_ori_matrix3( + Ppoint3 *vrp, /* view reference point */ + Pvec3 *vpn, /* view plane normal */ + Pvec3 *vup, /* view up vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT view orientation matrix */ + ); + + /******************************************************************************* + * peval_view_ori_matrix + * + * DESCR: Generate view orientation matrix + * RETURNS: N/A + */ + + void peval_view_ori_matrix( + Ppoint *vrp, /* view reference point */ + Pvec *vup, /* view up vector */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix m /* OUT view orientation matrix */ + ); + + /******************************************************************************* + * peval_view_map_matrix3 + * + * DESCR: Generate 3D view mapping matrix + * RETURNS: N/A + */ + + void peval_view_map_matrix3( + Pview_map3 *map, /* view mapping */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix3 m /* OUT view mapping matrix */ + ); + + /******************************************************************************* + * peval_view_map_matrix + * + * DESCR: Generate view mapping matrix + * RETURNS: N/A + */ + + void peval_view_map_matrix( + Pview_map *map, /* view mapping */ + Pint *error_ind, /* OUT error indicator */ + Pmatrix m /* OUT view mapping matrix */ + ); + + /******************************************************************************* + * pinit_loc3 + * + * DESCR: Initialize locator device 3D + * RETURNS: N/A + */ + + void pinit_loc3( + Pint ws_id, + Pint loc_num, + Pint init_view_ind, + Ppoint3 *init_loc_pos, + Pint pet, + Plimit3 *echo_vol, + Ploc_data3 *loc_data + ); + + /******************************************************************************* + * pinit_stroke3 + * + * DESCR: Initialize stroke device 3D + * RETURNS: N/A + */ + + void pinit_stroke3( + Pint ws_id, + Pint stroke_num, + Pint init_view_ind, + Ppoint_list3 *init_stroke, + Pint pet, + Plimit3 *echo_vol, + Pstroke_data3 *stroke_data + ); + + /******************************************************************************* + * pinit_pick3 + * + * DESCR: Initialize pick device 3D + * RETURNS: N/A + */ + + void pinit_pick3( + Pint ws_id, + Pint pick_num, + Pin_status init_status, + Ppick_path *init_pick, + Pint pet, + Plimit3 *echo_vol, + Ppick_data3 *pick_data, + Ppath_order order + ); + + /******************************************************************************* + * pinit_string + * + * DESCR: Initialize string device + * RETURNS: N/A + */ + void pinit_string( + Pint ws_id, + Pint string_dev, + char * init_string, + Pint pet, + Plimit * area, + Pstring_data *data_rec + ); + + /******************************************************************************* + * pinit_string3 + * + * DESCR: Initialize string device 3d + * RETURNS: N/A + */ + void pinit_string3( + Pint ws_id, + Pint string_dev, + char * init_string, + Pint pet, + Plimit3 * area, + Pstring_data3 *data_rec ); -/******************************************************************************* - * pxinq_conf_hcsf - * - * DESCR: inquire the hardcopy scale factor - * RETURNS: current hard copy scale factor for given workstation - */ -Pint pxinq_conf_hcsf( - Pint wkid + /******************************************************************************* + * pinit_choice3 + * + * DESCR: Initialize string + * RETURNS: N/A + */ + void pinit_choice3( + Pint ws_id, + Pint choice_dev, + Pin_status init_status, + Pint init_choice, + Pint pet, + Plimit3 * echo_volume, + Pchoice_data3 *choice_data_rec ); + /******************************************************************************* + * pinit_val3 + * + * DESCR: Initialize string + * RETURNS: N/A + */ + + void pinit_val3( + Pint ws_id, + Pint val_dev, + Pfloat init_value, + Pint pet, + Plimit3 * echo_volume, + Pval_data *val_data_rec + ); + + /******************************************************************************* + * pset_pick_filter + * + * DESCR: Set pick device filter + * RETURNS: N/A + */ + + void pset_pick_filter( + Pint ws_id, + Pint pick_num, + Pfilter *filter + ); + + /******************************************************************************* + * pset_loc_mode + * + * DESCR: Set locator input device mode + * RETURNS: N/A + */ + + void pset_loc_mode( + Pint ws_id, + Pint loc_num, + Pop_mode op_mode, + Pecho_switch echo_switch + ); + + /******************************************************************************* + * pset_stroke_mode + * + * DESCR: Set stroke input device mode + * RETURNS: N/A + */ + + void pset_stroke_mode( + Pint ws_id, + Pint stroke_num, + Pop_mode op_mode, + Pecho_switch echo_switch + ); + + /******************************************************************************* + * pset_pick_mode + * + * DESCR: Set pick input device mode + * RETURNS: N/A + */ + + void pset_pick_mode( + Pint ws_id, + Pint pick_num, + Pop_mode op_mode, + Pecho_switch echo_switch + ); + + /******************************************************************************* + * pset_string_mode + * + * DESCR: Set string input device mode + * RETURNS: N/A + */ + void pset_string_mode( + Pint ws_id, + Pint string_dev, + Pop_mode op_mode, + Pecho_switch echo_switch + ); + + /******************************************************************************* + * pset_choice_mode + * + * DESCR: Set choice input device mode + * RETURNS: N/A + */ + void pset_choice_mode( + Pint ws_id, + Pint choice_dev, + Pop_mode op_mode, + Pecho_switch echo_switch + ); + + /******************************************************************************* + * pset_val_mode + * + * DESCR: Set string input device mode + * RETURNS: N/A + */ + void pset_val_mode( + Pint ws_id, + Pint val_dev, + Pop_mode op_mode, + Pecho_switch echo_switch + ); + + /******************************************************************************* + * psample_loc + * + * DESCR: Sample locator device + * RETURNS: N/A + */ + + void psample_loc( + Pint ws_id, + Pint loc_num, + Pint *view_ind, + Ppoint *loc_pos + ); + + /******************************************************************************* + * psample_loc3 + * + * DESCR: Sample locator device 3D + * RETURNS: N/A + */ + + void psample_loc3( + Pint ws_id, + Pint loc_num, + Pint *view_ind, + Ppoint3 *loc_pos + ); + + /******************************************************************************* + * psample_stroke + * + * DESCR: Sample stroke device + * RETURNS: N/A + */ + + void psample_stroke( + Pint ws_id, + Pint stroke_num, + Pint *view_ind, + Ppoint_list *stroke + ); + + /******************************************************************************* + * psample_stroke3 + * + * DESCR: Sample stroke device 3D + * RETURNS: N/A + */ + + void psample_stroke3( + Pint ws_id, + Pint stroke_num, + Pint *view_ind, + Ppoint_list3 *stroke + ); + + /******************************************************************************* + * psample_pick + * + * DESCR: Sample pick device + * RETURNS: N/A + */ + void psample_pick( + Pint ws_id, + Pint pick_num, + Pint depth, + Pin_status *pick_in_status, + Ppick_path *pick + ); + + /******************************************************************************* + * psample_string + * + * DESCR: Sample string device + * RETURNS: String + */ + + void psample_string( + Pint ws_id, + Pint string_dev, + char* string + ); + + /******************************************************************************* + * pawait_event + * + * DESCR: Wait for event to occur + * RETURNS: N/A + */ + + void pawait_event( + Pfloat timeout, + Pint *ws_id, + Pin_class *dev_class, + Pint *in_num + ); + + /******************************************************************************* + * pget_loc + * + * DESCR: Get locator event from event queue + * RETURNS: N/A + */ + + void pget_loc( + Pint *view_ind, + Ppoint *loc_pos + ); + + /******************************************************************************* + * pget_loc3 + * + * DESCR: Get locator event from event queue 3D + * RETURNS: N/A + */ + + void pget_loc3( + Pint *view_ind, + Ppoint3 *loc_pos + ); + + /******************************************************************************* + * pget_stroke + * + * DESCR: Get stroke event from event queue + * RETURNS: N/A + */ + + void pget_stroke( + Pint *view_ind, + Ppoint_list *stroke + ); + + /******************************************************************************* + * pget_stroke3 + * + * DESCR: Get stroke event from event queue 3D + * RETURNS: N/A + */ + + void pget_stroke3( + Pint *view_ind, + Ppoint_list3 *stroke + ); + + /******************************************************************************* + * pget_pick + * + * DESCR: Get pick event from event queue + * RETURNS: N/A + */ + + void pget_pick( + Pint depth, + Pin_status *in_status, + Ppick_path *pick + ); + + /******************************************************************************* + * pget_val + * + * DESCR: Get valuator event from event queue + * RETURNS: N/A + */ + + void pget_val( + Pfloat *val + ); + + /******************************************************************************* + * pget_choice + * + * DESCR: Get choice event from event queue + * RETURNS: N/A + */ + + void pget_choice( + Pin_status *in_status, + Pint *choice + ); + + /******************************************************************************* + * preq_loc3 + * + * DESCR: Request input from locater device + * RETURNS: N/A + */ + + void preq_loc3( + Pint ws_id, + Pint loc_num, + Pin_status *in_status, + Pint *view_ind, + Ppoint3 *loc_pos + ); + + /******************************************************************************* + * preq_pick + * + * DESCR: Request input from pick device + * RETURNS: N/A + */ + + void preq_pick( + Pint ws_id, + Pint pick_num, + Pint depth, + Pin_status *status, + Ppick_path *pick + ); + + /******************************************************************************* + * preq_choice + * + * DESCR: Request input from choice device + * RETURNS: N/A + */ + + void preq_choice( + Pint ws_id, + Pint choice_dev, + Pin_status *status, + Pint *choice + ); + + /******************************************************************************* + * preq_valuator + * + * DESCR: Request input from valuator device + * RETURNS: N/A + */ + + void preq_valuator( + Pint ws_id, + Pint val_dev, + Pin_status *status, + Pfloat *choice + ); + + /******************************************************************************* + * preq_stroke3 + * + * DESCR: Request input from stroke device 3D + * RETURNS: N/A + */ + + void preq_stroke3( + Pint ws_id, + Pint stroke_num, + Pin_status *in_status, + Pint *view_ind, + Ppoint_list3 *stroke + ); + + /******************************************************************************* + * preq_string + * + * DESCR: Request input from string + * RETURNS: N/A + */ + + void preq_string( + Pint ws_id, + Pint string_dev, + Pin_status *status, + char *string + ); + + /******************************************************************************* + * pflush_events + * + * DESCR: Flush events for device + * RETURNS: N/A + */ + void pflush_events( + Pint ws_id, + Pin_class inp_class, + Pint dev + ); + + /******************************************************************************* + * popen_ar_file + * + * DESCR: Open archive file + * RETURNS: N/A + */ + + void popen_ar_file( + Pint archive_id, + char *archive_file + ); + + /******************************************************************************* + * pclose_ar_file + * + * DESCR: Close archive file + * RETURNS: N/A + */ + + void pclose_ar_file( + Pint archive_id + ); + + /******************************************************************************* + * pset_conf_res + * + * DESCR: Set structure conflict resolution for archive + * RETURNS: N/A + */ + + void pset_conf_res( + Pconf_res archive_res, + Pconf_res retrieval_res + ); + + /******************************************************************************* + * par_structs + * + * DESCR: Store structures in archive + * RETURNS: N/A + */ + + void par_structs( + Pint archive_id, + Pint_list *struct_ids + ); + + /******************************************************************************* + * par_struct_nets + * + * DESCR: Store structure networks in archive + * RETURNS: N/A + */ + + void par_struct_nets( + Pint archive_id, + Pint_list *struct_ids + ); + + /******************************************************************************* + * par_all_structs + * + * DESCR: Store all structures in archive + * RETURNS: N/A + */ + + void par_all_structs( + Pint archive_id + ); + + /******************************************************************************* + * pret_struct_ids + * + * DESCR: Retreive all structures identifiers for archive + * RETURNS: N/A + */ + + void pret_struct_ids( + Pint archive_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint_list *ids, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pret_structs + * + * DESCR: Retreive structures from archive + * RETURNS: N/A + */ + + void pret_structs( + Pint archive_id, + Pint_list *struct_ids + ); + + /******************************************************************************* + * pret_struct_nets + * + * DESCR: Retreive structure networks from archive + * RETURNS: N/A + */ + + void pret_struct_nets( + Pint archive_id, + Pint_list *struct_ids + ); + + /******************************************************************************* + * pret_all_structs + * + * DESCR: Retreive all structures from archive + * RETURNS: N/A + */ + + void pret_all_structs( + Pint archive_id + ); + + /******************************************************************************* + * pdel_structs_ar + * + * DESCR: Delete structures from archive + * RETURNS: N/A + */ + + void pdel_structs_ar( + Pint archive_id, + Pint_list *struct_ids + ); + + /******************************************************************************* + * pdel_struct_nets_ar + * + * DESCR: Delete structure networks from archive + * RETURNS: N/A + */ + + void pdel_struct_nets_ar( + Pint archive_id, + Pint_list *struct_ids + ); + + /******************************************************************************* + * pdel_all_structs_ar + * + * DESCR: Delete all structures from archive + * RETURNS: N/A + */ + + void pdel_all_structs_ar( + Pint archive_id + ); + + /******************************************************************************* + * pinq_ar_st + * + * DESCR: Get archive state + * RETURNS: N/A + */ + + void pinq_ar_st( + Par_st *ar_st + ); + + /******************************************************************************* + * pinq_ar_files + * + * DESCR: Get open archive files + * RETURNS: N/A + */ + + void pinq_ar_files( + Pstore store, + Pint *err_ind, + Par_file_list **ar_files + ); + + /******************************************************************************* + * pinq_conf_res + * + * DESCR: Get archive conflict resolution + * RETURNS: N/A + */ + + void pinq_conf_res( + Pint *err_ind, + Pconf_res *archive_res, + Pconf_res *retrieval_res + ); + + /******************************************************************************* + * pinq_all_conf_structs + * + * DESCR: Get conflicting structure ids + * RETURNS: N/A + */ + + void pinq_all_conf_structs( + Pint ar_id, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *ids, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_conf_structs_net + * + * DESCR: Get conflicting structure ids in network + * RETURNS: N/A + */ + + void pinq_conf_structs_net( + Pint ar_id, + Pint struct_id, + Pstruct_net_source source, + Pint num_elems_appl_list, + Pint start_ind, + Pint *err_ind, + Pint_list *ids, + Pint *num_elems_impl_list + ); + + /******************************************************************************* + * pinq_light_src_rep + * + * DESCR: inquire light source respresentation + * RETURNS: N/A + */ + + void pinq_light_src_rep( + Pint ws_id, + Pint index, + Pinq_type type, + Pint *err_ind, + Plight_src_bundle *rep + ); + + /******************************************************************************* + * pannot_text_rel3 + * + * DESCR: annotation text relative 3 + * RETURNS: N/A + */ + void panno_text_rel3( + Ppoint3 *ref_point, + Pvec3 *offset, + char *text); + + + /******************************************************************************* + * pannot_text_rel + * + * DESCR: annotation text relative + * RETURNS: N/A + */ + void panno_text_rel( + Ppoint *ref_point, + Pvec *offset, + char *text); + + /******************************************************************************* + * set_anno_char_ht + * + * DESCR: annotation text height + * RETURNS: N/A + */ + void pset_anno_char_ht( + Pfloat height + ); + + /******************************************************************************* + * set_anno_align + * + * DESCR: annotation text height + * RETURNS: N/A + */ + void pset_anno_align( + Ptext_align *text_align + ); + + /******************************************************************************* + * set_anno_path + * + * DESCR: annotation text path + * RETURNS: N/A + */ + void pset_anno_path( + Ptext_path text_path + ); + + /******************************************************************************* + * GS element + * + * DESCR: generalised structure element + * RETURNS: N/A + */ + void pgse( + Pgse_type gse_type, + Pgse_data * gse_data + ); + + /******************************************************************************* + * set highlighting color + * + * DESCR: set the highlighting color + * RETURNS: N/A + */ + void pxset_highlight_colr ( + Pgcolr *colr + ); + + /******************************************************************************* + * set highlighting filter + * + * DESCR: set the highlighting filter + * RETURNS: N/A + */ + void pset_highl_filter ( + Pint ws_id, + Pfilter *filter + ); + + /******************************************************************************* + * pset_model_clip_ind + * + * DESCR: Creates a new element - set clipping indicator + * RETURNS: N/A + */ + + void pset_model_clip_ind( + Pclip_ind clipi + ); + + /******************************************************************************* + * pset_model_clip_vol3 + * + * DESCR: Creates a new element - set clipping volume 3 + * RETURNS: N/A + */ + + void pset_model_clip_vol3 ( + Pint op, + Phalf_space_list3 spacelist + ); + + /******************************************************************************* + * predefine colors + * + * DESCR: set color map + * RETURNS: N/A + * Note: DELPHI extension + */ + void pxset_color_map( + Pint ws_id + ); + + /******************************************************************************* + * print invisibility filter + * + * DESCR: print invisibility filter + * RETURNS: N/A + * Note: moved here from testing suite for debugging + */ + void print_invis_filter( + Pint ws_id + ); + + /******************************************************************************* + * set alpha channel + * + * DESCR: set alpha channel + * RETURNS: N/A + * Note: extending the standard + */ + void pset_alpha_channel( + Pfloat alpha + ); + + /******************************************************************************* + * phigs message + * + * DESCR: message in a box + * RETURNS: N/A + * Note: extending the standard + */ + + void pmessage( + Pint ws_id, + char* message + ); + + /******************************************************************************* + * set config file name + * + * DESCR: set config file name + * RETURNS: N/A + * Note: extending the standard + */ + void pxset_conf_file_name( + char * name + ); + + /******************************************************************************* + *set hardcopy scale factor + * + * DESCR: set harcopy scale factor for workstation + * RETURNS: N/A + * Note: extending the standard + */ + void pxset_conf_hcsf( + Pint wkid, + Pfloat hcsf + ); + + /******************************************************************************* + * pxinq_conf_hcsf + * + * DESCR: inquire the hardcopy scale factor + * RETURNS: current hard copy scale factor for given workstation + */ + Pint pxinq_conf_hcsf( + Pint wkid + ); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/include/phigs/phigsf77.h b/src/include/phigs/phigsf77.h index 08a489e..36a444a 100644 --- a/src/include/phigs/phigsf77.h +++ b/src/include/phigs/phigsf77.h @@ -118,8 +118,8 @@ C----- Input classes PARAMETER (PEXPOS=10,PRSIZE=11,PENWIN=12,PEXWIN=13) C---- Colour model, Color type - INTEGER PIND, PINDIR, PRGB - PARAMETER (PIND=0, PINDIR=0, PRGB=1) + INTEGER PIND, PINDIR, PRGB, PRGBA + PARAMETER (PIND=0, PINDIR=0, PRGB=1, PRGBA=2) C---- Search direction INTEGER PBWD, PFWD diff --git a/src/include/phigs/private/wsglP.h b/src/include/phigs/private/wsglP.h index 6338928..ef7e869 100644 --- a/src/include/phigs/private/wsglP.h +++ b/src/include/phigs/private/wsglP.h @@ -1,23 +1,23 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* (C) 2022-2025 CERN -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * (C) 2022-2025 CERN + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ******************************************************************************/ #ifndef _wsglP_h #define _wsglP_h @@ -32,1274 +32,1290 @@ extern "C" { #define WS_CLEAR_AREA_OFFSET 2.0 #define WS_FILL_AREA_OFFSET 1.0 -/* option to switch usage of shaders on or off */ -extern short int wsgl_use_shaders; - -typedef struct { - Pint x, y; - Pfloat distance; -} Ws_hit_box; - -typedef struct { - Pint sid; - Pint pickid; - Pint offset; -} Ws_pick_elmt; - -typedef enum { - WS_RENDER_MODE_DRAW, - WS_RENDER_MODE_SELECT -} Ws_render_mode; - -typedef struct { - Pattr_group bundl_group; - Pattr_group indiv_group; - Pfloat char_ht; - Ptext_path text_path; - Ptext_align text_align; - Pvec char_up_vec; - Pdisting_mode disting_mode; - Pcull_mode cull_mode; - Nset asf_nameset; - uint32_t ast_buf[1]; - Pgcolr highlighting_color; - Pfloat anno_char_ht; - Ptext_path anno_text_path; - Ptext_align anno_text_align; - Pvec anno_char_up_vec; -} Ws_attr_st; - -typedef struct { - Pint id; - Pint offset; - Pint hlhsr_id; - Ws_attr_st ast; - Nset cur_nameset; - uint32_t nameset_buf[WS_MAX_NAMES_IN_NAMESET / 32]; - Pview_rep3 view_rep; - Pmatrix3 local_tran; - Pmatrix3 global_tran; - Pint pick_id; - Pint lighting; - Nset lightstat; - uint32_t lightstat_buf[1]; -} Ws_struct; - -typedef struct { - int used; - Nameset incl; - Nameset excl; -} Ws_filter; - -typedef struct { - Pint_style int_style; - Pint int_style_ind; - Pint int_shad_meth; -} Ws_dev_st; - -typedef struct _Wsgl { - Plimit3 cur_win; - int win_changed; - Plimit3 cur_vp; - int vp_changed; - int hlhsr_changed; - Pint hlhsr_mode; - Pgcolr background; - Ws_render_mode render_mode; - Stack struct_stack; - Ws_struct cur_struct; - Pmatrix3 composite_tran; - Pmatrix3 model_tran; - Pmatrix3 pick_tran; - Ws_filter invis_filter; - Ws_filter pick_filter; - Ws_filter highl_filter; - Pint select_size; - GLuint *select_buf; - Ws_dev_st dev_st; -} Wsgl; - -/* record geometry */ -typedef enum { + /* option to switch usage of shaders on or off */ + extern short int wsgl_use_shaders; + extern short int wsgl_vert_shader_version; + extern short int wsgl_frag_shader_version; + + typedef struct { + Pint x, y; + Pfloat distance; + } Ws_hit_box; + + typedef struct { + Pint sid; + Pint pickid; + Pint offset; + } Ws_pick_elmt; + + typedef enum { + WS_RENDER_MODE_DRAW, + WS_RENDER_MODE_SELECT + } Ws_render_mode; + + typedef struct { + Pattr_group bundl_group; + Pattr_group indiv_group; + Pfloat char_ht; + Ptext_path text_path; + Ptext_align text_align; + Pvec char_up_vec; + Pdisting_mode disting_mode; + Pcull_mode cull_mode; + Nset asf_nameset; + uint32_t ast_buf[1]; + Pgcolr highlighting_color; + Pfloat anno_char_ht; + Ptext_path anno_text_path; + Ptext_align anno_text_align; + Pvec anno_char_up_vec; + Pfloat alpha_channel; + Pfloat color_model; + } Ws_attr_st; + + typedef struct { + Pint id; + Pint offset; + Pint hlhsr_id; + Ws_attr_st ast; + Nset cur_nameset; + uint32_t nameset_buf[WS_MAX_NAMES_IN_NAMESET / 32]; + Pview_rep3 view_rep; + Pmatrix3 local_tran; + Pmatrix3 global_tran; + Pint pick_id; + Pint lighting; + Nset lightstat; + uint32_t lightstat_buf[1]; + } Ws_struct; + + typedef struct { + int used; + Nameset incl; + Nameset excl; + } Ws_filter; + + typedef struct { + Pint_style int_style; + Pint int_style_ind; + Pint int_shad_meth; + } Ws_dev_st; + + typedef struct _Wsgl { + Plimit3 cur_win; + int win_changed; + Plimit3 cur_vp; + int vp_changed; + int hlhsr_changed; + Pint hlhsr_mode; + Pgcolr background; + Ws_render_mode render_mode; + Stack struct_stack; + Ws_struct cur_struct; + Pmatrix3 composite_tran; + Pmatrix3 model_tran; + Pmatrix3 pick_tran; + Ws_filter invis_filter; + Ws_filter pick_filter; + Ws_filter highl_filter; + Pint select_size; + GLuint *select_buf; + Ws_dev_st dev_st; + } Wsgl; + + /* record geometry */ + typedef enum { GEOM_LINE, GEOM_FACE -} GeomType; + } GeomType; -typedef struct { + typedef struct { GeomType type; int* indices; int* norms; int count; -} Geometry; + } Geometry; -extern Ppoint3 * vertices; -extern Ppoint3 * normals; -extern int vertex_count; -extern int normal_count; + extern Ppoint3 * vertices; + extern Ppoint3 * normals; + extern int vertex_count; + extern int normal_count; -extern Geometry* geometries; -extern int geom_count; -extern Ppoint3 current_normal; + extern Geometry* geometries; + extern int geom_count; + extern Ppoint3 current_normal; -extern int record_geom; -extern int record_geom_fill; -extern int normal_valid; + extern int record_geom; + extern int record_geom_fill; + extern int normal_valid; #define MAX_VERTICES 10000 -/******************************************************************************* - * wsgl_set_current_normal(float x, float y, float z) - * - * DESCR: add 3d vertex - * RETURNS: Non zero or zero on error - */ + /******************************************************************************* + * wsgl_set_current_normal(float x, float y, float z) + * + * DESCR: add 3d vertex + * RETURNS: Non zero or zero on error + */ void wsgl_set_current_normal(float x, float y, float z); -/******************************************************************************* - * wsgl_add_vertex(float x, float y, float z) - * - * DESCR: add 3d vertex - * RETURNS: Non zero or zero on error - */ + /******************************************************************************* + * wsgl_add_vertex(float x, float y, float z) + * + * DESCR: add 3d vertex + * RETURNS: Non zero or zero on error + */ int wsgl_add_vertex(float x, float y, float z); -/******************************************************************************* - * wsgl_add_normal(float x, float y, float z) - * - * DESCR: add 3d vertex - * RETURNS: Non zero or zero on error - */ + /******************************************************************************* + * wsgl_add_normal(float x, float y, float z) + * + * DESCR: add 3d vertex + * RETURNS: Non zero or zero on error + */ int wsgl_add_normal(float x, float y, float z); -/******************************************************************************* - * wsgl_add_geometry(GeomType type, const int* verts, const int* norms, int count) - * - * DESCR: add 3d geometry - * RETURNS: Non zero or zero on error - */ + /******************************************************************************* + * wsgl_add_geometry(GeomType type, const int* verts, const int* norms, int count) + * + * DESCR: add 3d geometry + * RETURNS: Non zero or zero on error + */ void wsgl_add_geometry(GeomType type, const int* verts, const int* norms, int count); -/******************************************************************************* - * wsgl_export_obj(const char* filename, const char* title) - * DESCR: export as OBJ file - * RETURNS: Non zero or zero on error - */ + /******************************************************************************* + * wsgl_export_obj(const char* filename, const char* title) + * DESCR: export as OBJ file + * RETURNS: Non zero or zero on error + */ void wsgl_export_obj(const char* filename, const char* title); -/******************************************************************************* - * wsgl_clear_geometry() - * - * DESCR: cleanup geometry records - * RETURNS: Non zero or zero on error - */ + /******************************************************************************* + * wsgl_clear_geometry() + * + * DESCR: cleanup geometry records + * RETURNS: Non zero or zero on error + */ void wsgl_clear_geometry(); -/******************************************************************************* - * wsgl_init - * - * DESCR: Initialize renderer - * RETURNS: Non zero or zero on error - */ - -int wsgl_init( - Ws *ws, - Pgcolr *background, - Pint select_size - ); - -/******************************************************************************* - * wsgl_close - * - * DESCR: Close - * RETURNS: N/A - */ - -void wsgl_close( - Ws *ws - ); - -/******************************************************************************* - * wsgl_set_window - * - * DESCR: Set render window coordinates - * RETURNS: N/A - */ - -void wsgl_set_window( - Ws *ws, - Plimit3 *win - ); - -/******************************************************************************* - * wsgl_set_viewport - * - * DESCR: Set render window viewport - * RETURNS: N/A - */ - -void wsgl_set_viewport( - Ws *ws, - Plimit3 *vp - ); - -/******************************************************************************* - * wsgl_set_hlhsr_mode - * - * DESCR: Set render depth mode - * RETURNS: N/A - */ - -void wsgl_set_hlhsr_mode( - Ws *ws, - Pint hlhsr_mode - ); - -/******************************************************************************* - * wsgl_set_asf - * - * DESCR: Setup asf - * RETURNS: N/A - */ - -void wsgl_set_asf( - Ws_attr_st *ast, - void *asf_info - ); - -/******************************************************************************* - * wsgl_set_colr - * - * DESCR: Set colour value - * RETURNS: N/A - */ - -void wsgl_set_colr( - Pint colr_type, - Pcoval *colr - ); - -/******************************************************************************* - * wsgl_set_gcolr - * - * DESCR: Set colour - * RETURNS: N/A - */ - -void wsgl_set_gcolr( - Pgcolr *gcolr - ); - -/******************************************************************************* - * wsgl_colr_from_gcolr - * - * DESCR: Get colour value from Pgcolr - * RETURNS: N/A - */ - -void wsgl_colr_from_gcolr( - Pcoval *pcoval, - Pgcolr *gcolr - ); - -/******************************************************************************* - * wsgl_clear - * - * DESCR: Clear render window - * RETURNS: N/A - */ - -void wsgl_clear( - Ws *ws - ); - -/******************************************************************************* - * wsgl_flush - * - * DESCR: Flush settings to render window - * RETURNS: N/A - */ - -void wsgl_flush( - Ws *ws - ); - -/******************************************************************************* - * wsgl_begin_rendering - * - * DESCR: Start a rendiering session for workstation - * RETURNS: N/A - */ - -void wsgl_begin_rendering( - Ws *ws - ); - -/******************************************************************************* - * wsgl_end_rendering - * - * DESCR: End a rendiering session - * RETURNS: N/A - */ - -void wsgl_end_rendering( - Ws *ws - ); - -/******************************************************************************* - * wsgl_begin_structure - * - * DESCR: Mark the beginning of a new structure element - * RETURNS: N/A - */ - -void wsgl_begin_structure( - Ws *ws, - Pint struct_id - ); - -/******************************************************************************* - * wsgl_end_structure - * - * DESCR: Mark the ending of a structure element - * RETURNS: N/A - */ - -void wsgl_end_structure( - Ws *ws - ); - -/******************************************************************************* - * wsgl_render_element - * - * DESCR: Render element to current workstation rendering window - * RETURNS: N/A - */ - -void wsgl_render_element( - Ws *ws, - El_handle el - ); - -/******************************************************************************* - * wsgl_set_filter - * - * DESCR: Set filter - * RETURNS: N/A - */ - -void wsgl_set_filter( - Ws *ws, - Phg_args_flt_type type, - Nameset incl, - Nameset excl - ); - -/******************************************************************************* - * wsgl_begin_pick - * - * DESCR: Begin pick process - * RETURNS: N/A - */ - -void wsgl_begin_pick( - Ws *ws, - Ws_hit_box *box - ); - -/******************************************************************************* - * wsgl_end_pick - * - * DESCR: End pick process - * RETURNS: N/A - */ - -void wsgl_end_pick( - Ws *ws, - Pint *err_ind, - Pint *depth, - Ws_pick_elmt **elmts - ); - -/******************************************************************************* - * wsgl_update_projection - * - * DESCR: Update projection matrix - * RETURNS: N/A - */ - -void wsgl_update_projection( - Ws *ws - ); - -/******************************************************************************* - * wsgl_update_modelview - * - * DESCR: Update modelview matrix - * RETURNS: N/A - */ - -void wsgl_update_modelview( - Ws *ws - ); - -/******************************************************************************* - * wsgl_set_view_ind - * - * DESCR: Setup view - * RETURNS: N/A - */ - -void wsgl_set_view_ind( - Ws *ws, - Pint ind - ); - -/******************************************************************************* - * wsgl_set_clip_ind - * - * DESCR: Setup clip indicator - * RETURNS: N/A - */ - - void wsgl_set_clip_ind( - Ws *ws, - Pint ind - ); - -/******************************************************************************* - * wsgl_set_clip_vol3 - * - * DESCR: Setup clipping volume - * RETURNS: N/A - */ + /******************************************************************************* + * wsgl_init + * + * DESCR: Initialize renderer + * RETURNS: Non zero or zero on error + */ + + int wsgl_init( + Ws *ws, + Pgcolr *background, + Pint select_size + ); + + /******************************************************************************* + * wsgl_close + * + * DESCR: Close + * RETURNS: N/A + */ + + void wsgl_close( + Ws *ws + ); + + /******************************************************************************* + * wsgl_set_window + * + * DESCR: Set render window coordinates + * RETURNS: N/A + */ + + void wsgl_set_window( + Ws *ws, + Plimit3 *win + ); + + /******************************************************************************* + * wsgl_set_viewport + * + * DESCR: Set render window viewport + * RETURNS: N/A + */ + + void wsgl_set_viewport( + Ws *ws, + Plimit3 *vp + ); + + /******************************************************************************* + * wsgl_set_hlhsr_mode + * + * DESCR: Set render depth mode + * RETURNS: N/A + */ + + void wsgl_set_hlhsr_mode( + Ws *ws, + Pint hlhsr_mode + ); + + /******************************************************************************* + * wsgl_set_asf + * + * DESCR: Setup asf + * RETURNS: N/A + */ + + void wsgl_set_asf( + Ws_attr_st *ast, + void *asf_info + ); + + /******************************************************************************* + * wsgl_set_colr + * + * DESCR: Set colour value + * RETURNS: N/A + */ + + void wsgl_set_colr( + Pint colr_type, + Pcoval *colr + ); + + /******************************************************************************* + * wsgl_set_gcolr + * + * DESCR: Set colour + * RETURNS: N/A + */ + + void wsgl_set_gcolr( + Pgcolr *gcolr + ); + + /******************************************************************************* + * wsgl_convert_gcolr + * + * DESCR: convert gcolr to target model + * RETURNS: N/A + */ + void wsgl_convert_gcolr( + Pgcolr *gcolr, + int model + ); + + /******************************************************************************* + * wsgl_colr_from_gcolr + * + * DESCR: Get colour value from Pgcolr + * RETURNS: N/A + */ + + void wsgl_colr_from_gcolr( + Pcoval *pcoval, + Pgcolr *gcolr, + Pint mode + ); + + /******************************************************************************* + * wsgl_clear + * + * DESCR: Clear render window + * RETURNS: N/A + */ + + void wsgl_clear( + Ws *ws + ); + + /******************************************************************************* + * wsgl_flush + * + * DESCR: Flush settings to render window + * RETURNS: N/A + */ + + void wsgl_flush( + Ws *ws + ); + + /******************************************************************************* + * wsgl_begin_rendering + * + * DESCR: Start a rendiering session for workstation + * RETURNS: N/A + */ + + void wsgl_begin_rendering( + Ws *ws + ); + + /******************************************************************************* + * wsgl_end_rendering + * + * DESCR: End a rendiering session + * RETURNS: N/A + */ + + void wsgl_end_rendering( + Ws *ws + ); + + /******************************************************************************* + * wsgl_begin_structure + * + * DESCR: Mark the beginning of a new structure element + * RETURNS: N/A + */ + + void wsgl_begin_structure( + Ws *ws, + Pint struct_id + ); + + /******************************************************************************* + * wsgl_end_structure + * + * DESCR: Mark the ending of a structure element + * RETURNS: N/A + */ + + void wsgl_end_structure( + Ws *ws + ); + + /******************************************************************************* + * wsgl_render_element + * + * DESCR: Render element to current workstation rendering window + * RETURNS: N/A + */ + + void wsgl_render_element( + Ws *ws, + El_handle el + ); + + /******************************************************************************* + * wsgl_set_filter + * + * DESCR: Set filter + * RETURNS: N/A + */ + + void wsgl_set_filter( + Ws *ws, + Phg_args_flt_type type, + Nameset incl, + Nameset excl + ); + + /******************************************************************************* + * wsgl_begin_pick + * + * DESCR: Begin pick process + * RETURNS: N/A + */ + + void wsgl_begin_pick( + Ws *ws, + Ws_hit_box *box + ); + + /******************************************************************************* + * wsgl_end_pick + * + * DESCR: End pick process + * RETURNS: N/A + */ + + void wsgl_end_pick( + Ws *ws, + Pint *err_ind, + Pint *depth, + Ws_pick_elmt **elmts + ); + + /******************************************************************************* + * wsgl_update_projection + * + * DESCR: Update projection matrix + * RETURNS: N/A + */ + + void wsgl_update_projection( + Ws *ws + ); + + /******************************************************************************* + * wsgl_update_modelview + * + * DESCR: Update modelview matrix + * RETURNS: N/A + */ + + void wsgl_update_modelview( + Ws *ws + ); + + /******************************************************************************* + * wsgl_set_view_ind + * + * DESCR: Setup view + * RETURNS: N/A + */ + + void wsgl_set_view_ind( + Ws *ws, + Pint ind + ); + + /******************************************************************************* + * wsgl_set_clip_ind + * + * DESCR: Setup clip indicator + * RETURNS: N/A + */ + + void wsgl_set_clip_ind( + Ws *ws, + Pint ind + ); + + /******************************************************************************* + * wsgl_set_clip_vol3 + * + * DESCR: Setup clipping volume + * RETURNS: N/A + */ void wsgl_set_clip_vol3( - Ws *ws, - char * data - ); - -/******************************************************************************* - * wsgl_set_alpha_channel - * - * DESCR: Setup alpha channel - * RETURNS: N/A - */ - - void wsgl_set_alpha_channel( - Ws *ws, - Pfloat alpha - ); - - -/******************************************************************************* - * wsgl_update_hlhsr_id - * - * DESCR: Update depth buffer checking flag - * RETURNS: N/A - */ - -void wsgl_update_hlhsr_id( - Ws *ws - ); - -/******************************************************************************* - * wsgl_set_line_ind - * - * DESCR: Setup line index - * RETURNS: N/A - */ - -void wsgl_set_line_ind( - Ws *ws, - Pattr_group *attr_group, - Pint ind - ); - -/******************************************************************************* - * wsgl_setup_line_attr - * - * DESCR: Setup line attributes - * RETURNS: N/A - */ - -void wsgl_setup_line_attr( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_int_ind - * - * DESCR: Setup interior index - * RETURNS: N/A - */ - -void wsgl_set_int_ind( - Ws *ws, - Pattr_group *attr_group, - Pint ind - ); - -/******************************************************************************* - * wsgl_get_int_colr - * - * DESCR: Get interior colur - * RETURNS: Pointer to interiour colour - */ - -Pgcolr* wsgl_get_int_colr( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_get_int_style - * - * DESCR: Get interior style - * RETURNS: Interiour style - */ - -Pint_style wsgl_get_int_style( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_int_style - * - * DESCR: Setup interior style - * RETURNS: N/A - */ - -void wsgl_setup_int_style( - Pint_style style - ); - -/******************************************************************************* - * wsgl_setup_int_attr_nocol - * - * DESCR: Setup interior attributes without color - * RETURNS: N/A - */ - -void wsgl_setup_int_attr_nocol( - Ws *ws, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_int_attr - * - * DESCR: Setup interior attributes - * RETURNS: N/A - */ - -void wsgl_setup_int_attr( - Ws *ws, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_get_back_int_colr - * - * DESCR: Get backface interior colur - * RETURNS: Pointer to interiour colour - */ - -Pgcolr* wsgl_get_back_int_colr( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_back_int_attr_nocol - * - * DESCR: Setup backface interior attributes without color - * RETURNS: N/A - */ - -void wsgl_setup_back_int_attr_nocol( - Ws *ws, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_int_reflectance_model - * - * DESCR: - * RETURNS: N/A - */ - -void wsgl_setup_int_reflectance_model( - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast -); - -/******************************************************************************* - * wsgl_setup_int_refl_props - * - * DESCR: Setup surface reflection and colour properties - * RETURNS: N/A - */ - -void wsgl_setup_int_refl_props( - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_int_colr - * - * DESCR: Setup surface colour - * RETURNS: Lighting state - */ - -int wsgl_setup_int_colr( - Ws *ws, - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_int_attr_plus - * - * DESCR: Setup interiour attributes for PHIGS Plus - * RETURNS: Lighting state - */ - -int wsgl_setup_int_attr_plus( - Ws *ws, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_back_int_refl_props - * - * DESCR: Setup backface surface reflection and colour properties - * RETURNS: N/A - */ - -void wsgl_setup_back_int_refl_props( - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_back_int_colr - * - * DESCR: Setup back-surface colour - * RETURNS: Lighting state - */ - -int wsgl_setup_back_int_colr( - Ws *ws, - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_back_int_attr_plus - * - * DESCR: Setup backface interiour attributes for PHIGS Plus - * RETURNS: Lighting state - */ - -int wsgl_setup_back_int_attr_plus( - Ws *ws, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_edge_ind - * - * DESCR: Setup edge index - * RETURNS: N/A - */ - -void wsgl_set_edge_ind( - Ws *ws, - Pattr_group *attr_group, - Pint ind - ); - -/******************************************************************************* - * wsgl_get_edge_flag - * - * DESCR: Get edge flag - * RETURNS: Edge flag - */ - -Pedge_flag wsgl_get_edge_flag( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_get_edge_width - * - * DESCR: Get edge width - * RETURNS: Edge width - */ - -Pfloat wsgl_get_edge_width( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_edge_attr - * - * DESCR: Setup edge attributes - * RETURNS: N/A - */ - -void wsgl_setup_edge_attr( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_marker_ind - * - * DESCR: Setup marker index - * RETURNS: N/A - */ - -void wsgl_set_marker_ind( - Ws *ws, - Pattr_group *attr_group, - Pint ind - ); - -/******************************************************************************* - * wsgl_setup_marker_attr - * - * DESCR: Setup marker attributes - * RETURNS: N/A - */ - -void wsgl_setup_marker_attr( - Ws_attr_st *ast, - Pint *type, - Pfloat *size - ); - -/******************************************************************************* - * wsgl_setup_background - * - * DESCR: Setup background colour - * RETURNS: N/A - */ - -void wsgl_setup_background( - Ws *ws - ); - -/******************************************************************************* - * wsgl_set_text_ind - * - * DESCR: Setup text index - * RETURNS: N/A - */ - -void wsgl_set_text_ind( - Ws *ws, - Pattr_group *attr_group, - Pint ind - ); - -/******************************************************************************* - * wsgl_get_text_prec - * - * DESCR: Get text precision - * RETURNS: Text precision - */ - -Ptext_prec wsgl_get_text_prec( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_setup_text_attr - * - * DESCR: Setup text attributes - * RETURNS: N/A - */ - -void wsgl_setup_text_attr( - Ws_attr_st *ast, - Phg_font **fnt, - Pfloat *char_expan - ); - -/******************************************************************************* - * wsgl_get_char_space - * - * DESCR: Get char spacing - * RETURNS: Character spacing - */ - -Pfloat wsgl_get_char_space( - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_add_names_set - * - * DESCR: Add names to nameset - * RETURNS: N/A - */ - -void wsgl_add_names_set( - Ws *ws, - void *names - ); - -/******************************************************************************* - * wsgl_remove_names_set - * - * DESCR: Remove names from nameset - * RETURNS: N/A - */ - -void wsgl_remove_names_set( - Ws *ws, - void *names - ); - -/******************************************************************************* - * wsgl_polymarker - * - * DESCR: Draw markers - * RETURNS: N/A - */ - -void wsgl_polymarker( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_polymarker3 - * - * DESCR: Draw markers 3D - * RETURNS: N/A - */ - -void wsgl_polymarker3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_polyline - * - * DESCR: Draw lines - * RETURNS: N/A - */ - -void wsgl_polyline( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_polyline3 - * - * DESCR: Draw lines 3D - * RETURNS: N/A - */ - -void wsgl_polyline3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_clear_area3 - * - * DESCR: Clear area 3D - * RETURNS: N/A - */ - -void wsgl_clear_area3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_clear_area_set3 - * - * DESCR: Clear area set 3D - * RETURNS: N/A - */ - -void wsgl_clear_area_set3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area - * - * DESCR: Draw fill area - * RETURNS: N/A - */ - -void wsgl_fill_area( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area3 - * - * DESCR: Draw fill area 3D - * RETURNS: N/A - */ - -void wsgl_fill_area3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_back_area3 - * - * DESCR: Draw backface area 3D - * RETURNS: N/A - */ - -void wsgl_back_area3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area_set - * - * DESCR: Draw fill area set - * RETURNS: N/A - */ - -void wsgl_fill_area_set( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area_set3 - * - * DESCR: Draw fill area set 3D - * RETURNS: N/A - */ - -void wsgl_fill_area_set3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_edge_area - * - * DESCR: Draw fill area edge - * RETURNS: N/A - */ - -void wsgl_edge_area( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_edge_area3 - * - * DESCR: Draw fill area edge 3D - * RETURNS: N/A - */ - -void wsgl_edge_area3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_edge_area_set - * - * DESCR: Draw fill area set edge - * RETURNS: N/A - */ - -void wsgl_edge_area_set( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_text - * - * DESCR: Draw text - * RETURNS: N/A - */ - -void wsgl_text( - Ws *ws, - void *tdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_text - * - * DESCR: Draw text - * RETURNS: N/A - */ - -void wsgl_text3( - Ws *ws, - void *tdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_edge_area_set3 - * - * DESCR: Draw fill area set edge 3D - * RETURNS: N/A - */ - -void wsgl_edge_area_set3( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_clear_area_set3_data - * - * DESCR: Clear fill area set with data 3D - * RETURNS: N/A - */ - -void wsgl_clear_area_set_data( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area_set3_data_front - * - * DESCR: Draw fill area set with data 3D front faces - * RETURNS: N/A - */ - -void wsgl_fill_area_set_data_front( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area_set3_data_back - * - * DESCR: Draw fill area set with data 3D back faces - * RETURNS: N/A - */ - -void wsgl_fill_area_set_data_back( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_edge_area_set3_data - * - * DESCR: Draw fill area set edges with data 3D - * RETURNS: N/A - */ - -void wsgl_edge_area_set_data( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_clear_area_set3_data - * - * DESCR: Clear fill area set with data 3D - * RETURNS: N/A - */ - -void wsgl_clear_area_set3_data( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area_set3_data_front - * - * DESCR: Draw fill area set with data 3D front faces - * RETURNS: N/A - */ - -void wsgl_fill_area_set3_data_front( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_fill_area_set3_data_back - * - * DESCR: Draw fill area set with data 3D back faces - * RETURNS: N/A - */ - -void wsgl_fill_area_set3_data_back( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_edge_area_set3_data - * - * DESCR: Draw fill area set edges with data 3D - * RETURNS: N/A - */ - -void wsgl_edge_area_set3_data( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_of_clear_area_set3_data - * - * DESCR: Clear set of fill area set with data 3D - * RETURNS: N/A - */ - -void wsgl_set_of_clear_area_set3_data( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_of_fill_area_set3_data_front - * - * DESCR: Draw set of fill area set with data 3D front faces - * RETURNS: N/A - */ - -void wsgl_set_of_fill_area_set3_data_front( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_of_fill_area_set3_data_back - * - * DESCR: Draw set of fill area set with data 3D back faces - * RETURNS: N/A - */ - -void wsgl_set_of_fill_area_set3_data_back( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_of_edge_area_set3_data - * - * DESCR: Draw set of fill area set edges with data 3D - * RETURNS: N/A - */ - -void wsgl_set_of_edge_area_set3_data( - Ws *ws, - void *pdata, - Ws_attr_st *ast - ); - -/******************************************************************************* - * wsgl_set_light_src_state - * - * DESCR: Set light source state for workstation - * RETURNS: N/A - */ - -void wsgl_set_light_src_state( - Ws *ws, - void *pdata - ); - -/******************************************************************************* - * wsgl_update_light_src_state - * - * DESCR: Update light source state for workstation - * RETURNS: N/A - */ - -void wsgl_update_light_src_state( - Ws *ws - ); - -/******************************************************************************* - * wsgl_anno_text_rel - * - * DESCR: Draw annotation text - * RETURNS: N/A - */ -void wsgl_anno_text_rel3( - Ws *ws, - void *data, - Ws_attr_st *ast, - Pmatrix3 wc_to_vrc -); - -/******************************************************************************* - * wsgl_anno_text_rel3 - * - * DESCR: Draw annotation text - * RETURNS: N/A - */ -void wsgl_anno_text_rel( - Ws *ws, - void *data, - Ws_attr_st *ast, - Pmatrix3 wc_to_npc - ); - -/******************************************************************************* - * wsgl_shaders - * - * DESCR: Initialise shaders - * RETURNS: N/A - */ -void wsgl_shaders(Ws * ws); - -extern Phg_font *fnt_fonts[]; -extern unsigned char *wsgl_hatch_tbl[]; + Ws *ws, + char * data + ); + + /******************************************************************************* + * wsgl_set_alpha_channel + * + * DESCR: Setup alpha channel + * RETURNS: N/A + */ + + void wsgl_set_alpha_channel( + Ws *ws, + Pfloat alpha + ); + + + /******************************************************************************* + * wsgl_update_hlhsr_id + * + * DESCR: Update depth buffer checking flag + * RETURNS: N/A + */ + + void wsgl_update_hlhsr_id( + Ws *ws + ); + + /******************************************************************************* + * wsgl_set_line_ind + * + * DESCR: Setup line index + * RETURNS: N/A + */ + + void wsgl_set_line_ind( + Ws *ws, + Pattr_group *attr_group, + Pint ind + ); + + /******************************************************************************* + * wsgl_setup_line_attr + * + * DESCR: Setup line attributes + * RETURNS: N/A + */ + + void wsgl_setup_line_attr( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_int_ind + * + * DESCR: Setup interior index + * RETURNS: N/A + */ + + void wsgl_set_int_ind( + Ws *ws, + Pattr_group *attr_group, + Pint ind + ); + + /******************************************************************************* + * wsgl_get_int_colr + * + * DESCR: Get interior colur + * RETURNS: Pointer to interiour colour + */ + + Pgcolr* wsgl_get_int_colr( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_get_int_style + * + * DESCR: Get interior style + * RETURNS: Interiour style + */ + + Pint_style wsgl_get_int_style( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_int_style + * + * DESCR: Setup interior style + * RETURNS: N/A + */ + + void wsgl_setup_int_style( + Pint_style style + ); + + /******************************************************************************* + * wsgl_setup_int_attr_nocol + * + * DESCR: Setup interior attributes without color + * RETURNS: N/A + */ + + void wsgl_setup_int_attr_nocol( + Ws *ws, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_int_attr + * + * DESCR: Setup interior attributes + * RETURNS: N/A + */ + + void wsgl_setup_int_attr( + Ws *ws, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_get_back_int_colr + * + * DESCR: Get backface interior colur + * RETURNS: Pointer to interiour colour + */ + + Pgcolr* wsgl_get_back_int_colr( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_back_int_attr_nocol + * + * DESCR: Setup backface interior attributes without color + * RETURNS: N/A + */ + + void wsgl_setup_back_int_attr_nocol( + Ws *ws, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_int_reflectance_model + * + * DESCR: + * RETURNS: N/A + */ + + void wsgl_setup_int_reflectance_model( + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_int_refl_props + * + * DESCR: Setup surface reflection and colour properties + * RETURNS: N/A + */ + + void wsgl_setup_int_refl_props( + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_int_colr + * + * DESCR: Setup surface colour + * RETURNS: Lighting state + */ + + int wsgl_setup_int_colr( + Ws *ws, + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_int_attr_plus + * + * DESCR: Setup interiour attributes for PHIGS Plus + * RETURNS: Lighting state + */ + + int wsgl_setup_int_attr_plus( + Ws *ws, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_back_int_refl_props + * + * DESCR: Setup backface surface reflection and colour properties + * RETURNS: N/A + */ + + void wsgl_setup_back_int_refl_props( + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_back_int_colr + * + * DESCR: Setup back-surface colour + * RETURNS: Lighting state + */ + + int wsgl_setup_back_int_colr( + Ws *ws, + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_back_int_attr_plus + * + * DESCR: Setup backface interiour attributes for PHIGS Plus + * RETURNS: Lighting state + */ + + int wsgl_setup_back_int_attr_plus( + Ws *ws, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_edge_ind + * + * DESCR: Setup edge index + * RETURNS: N/A + */ + + void wsgl_set_edge_ind( + Ws *ws, + Pattr_group *attr_group, + Pint ind + ); + + /******************************************************************************* + * wsgl_get_edge_flag + * + * DESCR: Get edge flag + * RETURNS: Edge flag + */ + + Pedge_flag wsgl_get_edge_flag( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_get_edge_width + * + * DESCR: Get edge width + * RETURNS: Edge width + */ + + Pfloat wsgl_get_edge_width( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_edge_attr + * + * DESCR: Setup edge attributes + * RETURNS: N/A + */ + + void wsgl_setup_edge_attr( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_marker_ind + * + * DESCR: Setup marker index + * RETURNS: N/A + */ + + void wsgl_set_marker_ind( + Ws *ws, + Pattr_group *attr_group, + Pint ind + ); + + /******************************************************************************* + * wsgl_setup_marker_attr + * + * DESCR: Setup marker attributes + * RETURNS: N/A + */ + + void wsgl_setup_marker_attr( + Ws_attr_st *ast, + Pint *type, + Pfloat *size + ); + + /******************************************************************************* + * wsgl_setup_background + * + * DESCR: Setup background colour + * RETURNS: N/A + */ + + void wsgl_setup_background( + Ws *ws + ); + + /******************************************************************************* + * wsgl_set_text_ind + * + * DESCR: Setup text index + * RETURNS: N/A + */ + + void wsgl_set_text_ind( + Ws *ws, + Pattr_group *attr_group, + Pint ind + ); + + /******************************************************************************* + * wsgl_get_text_prec + * + * DESCR: Get text precision + * RETURNS: Text precision + */ + + Ptext_prec wsgl_get_text_prec( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_setup_text_attr + * + * DESCR: Setup text attributes + * RETURNS: N/A + */ + + void wsgl_setup_text_attr( + Ws_attr_st *ast, + Phg_font **fnt, + Pfloat *char_expan + ); + + /******************************************************************************* + * wsgl_get_char_space + * + * DESCR: Get char spacing + * RETURNS: Character spacing + */ + + Pfloat wsgl_get_char_space( + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_add_names_set + * + * DESCR: Add names to nameset + * RETURNS: N/A + */ + + void wsgl_add_names_set( + Ws *ws, + void *names + ); + + /******************************************************************************* + * wsgl_remove_names_set + * + * DESCR: Remove names from nameset + * RETURNS: N/A + */ + + void wsgl_remove_names_set( + Ws *ws, + void *names + ); + + /******************************************************************************* + * wsgl_polymarker + * + * DESCR: Draw markers + * RETURNS: N/A + */ + + void wsgl_polymarker( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_polymarker3 + * + * DESCR: Draw markers 3D + * RETURNS: N/A + */ + + void wsgl_polymarker3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_polyline + * + * DESCR: Draw lines + * RETURNS: N/A + */ + + void wsgl_polyline( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_polyline3 + * + * DESCR: Draw lines 3D + * RETURNS: N/A + */ + + void wsgl_polyline3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_clear_area3 + * + * DESCR: Clear area 3D + * RETURNS: N/A + */ + + void wsgl_clear_area3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_clear_area_set3 + * + * DESCR: Clear area set 3D + * RETURNS: N/A + */ + + void wsgl_clear_area_set3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area + * + * DESCR: Draw fill area + * RETURNS: N/A + */ + + void wsgl_fill_area( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area3 + * + * DESCR: Draw fill area 3D + * RETURNS: N/A + */ + + void wsgl_fill_area3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_back_area3 + * + * DESCR: Draw backface area 3D + * RETURNS: N/A + */ + + void wsgl_back_area3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area_set + * + * DESCR: Draw fill area set + * RETURNS: N/A + */ + + void wsgl_fill_area_set( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area_set3 + * + * DESCR: Draw fill area set 3D + * RETURNS: N/A + */ + + void wsgl_fill_area_set3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_edge_area + * + * DESCR: Draw fill area edge + * RETURNS: N/A + */ + + void wsgl_edge_area( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_edge_area3 + * + * DESCR: Draw fill area edge 3D + * RETURNS: N/A + */ + + void wsgl_edge_area3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_edge_area_set + * + * DESCR: Draw fill area set edge + * RETURNS: N/A + */ + + void wsgl_edge_area_set( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_text + * + * DESCR: Draw text + * RETURNS: N/A + */ + + void wsgl_text( + Ws *ws, + void *tdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_text + * + * DESCR: Draw text + * RETURNS: N/A + */ + + void wsgl_text3( + Ws *ws, + void *tdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_edge_area_set3 + * + * DESCR: Draw fill area set edge 3D + * RETURNS: N/A + */ + + void wsgl_edge_area_set3( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_clear_area_set3_data + * + * DESCR: Clear fill area set with data 3D + * RETURNS: N/A + */ + + void wsgl_clear_area_set_data( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area_set3_data_front + * + * DESCR: Draw fill area set with data 3D front faces + * RETURNS: N/A + */ + + void wsgl_fill_area_set_data_front( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area_set3_data_back + * + * DESCR: Draw fill area set with data 3D back faces + * RETURNS: N/A + */ + + void wsgl_fill_area_set_data_back( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_edge_area_set3_data + * + * DESCR: Draw fill area set edges with data 3D + * RETURNS: N/A + */ + + void wsgl_edge_area_set_data( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_clear_area_set3_data + * + * DESCR: Clear fill area set with data 3D + * RETURNS: N/A + */ + + void wsgl_clear_area_set3_data( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area_set3_data_front + * + * DESCR: Draw fill area set with data 3D front faces + * RETURNS: N/A + */ + + void wsgl_fill_area_set3_data_front( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_fill_area_set3_data_back + * + * DESCR: Draw fill area set with data 3D back faces + * RETURNS: N/A + */ + + void wsgl_fill_area_set3_data_back( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_edge_area_set3_data + * + * DESCR: Draw fill area set edges with data 3D + * RETURNS: N/A + */ + + void wsgl_edge_area_set3_data( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_of_clear_area_set3_data + * + * DESCR: Clear set of fill area set with data 3D + * RETURNS: N/A + */ + + void wsgl_set_of_clear_area_set3_data( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_of_fill_area_set3_data_front + * + * DESCR: Draw set of fill area set with data 3D front faces + * RETURNS: N/A + */ + + void wsgl_set_of_fill_area_set3_data_front( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_of_fill_area_set3_data_back + * + * DESCR: Draw set of fill area set with data 3D back faces + * RETURNS: N/A + */ + + void wsgl_set_of_fill_area_set3_data_back( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_of_edge_area_set3_data + * + * DESCR: Draw set of fill area set edges with data 3D + * RETURNS: N/A + */ + + void wsgl_set_of_edge_area_set3_data( + Ws *ws, + void *pdata, + Ws_attr_st *ast + ); + + /******************************************************************************* + * wsgl_set_light_src_state + * + * DESCR: Set light source state for workstation + * RETURNS: N/A + */ + + void wsgl_set_light_src_state( + Ws *ws, + void *pdata + ); + + /******************************************************************************* + * wsgl_update_light_src_state + * + * DESCR: Update light source state for workstation + * RETURNS: N/A + */ + + void wsgl_update_light_src_state( + Ws *ws + ); + + /******************************************************************************* + * wsgl_anno_text_rel + * + * DESCR: Draw annotation text + * RETURNS: N/A + */ + void wsgl_anno_text_rel3( + Ws *ws, + void *data, + Ws_attr_st *ast, + Pmatrix3 wc_to_vrc + ); + + /******************************************************************************* + * wsgl_anno_text_rel3 + * + * DESCR: Draw annotation text + * RETURNS: N/A + */ + void wsgl_anno_text_rel( + Ws *ws, + void *data, + Ws_attr_st *ast, + Pmatrix3 wc_to_npc + ); + + /******************************************************************************* + * wsgl_shaders + * + * DESCR: Initialise shaders + * RETURNS: N/A + */ + void wsgl_shaders(Ws * ws); + + extern Phg_font *fnt_fonts[]; + extern unsigned char *wsgl_hatch_tbl[]; #ifdef __cplusplus } diff --git a/src/libphigs/CMakeLists.txt b/src/libphigs/CMakeLists.txt index 2320351..7ffb86d 100644 --- a/src/libphigs/CMakeLists.txt +++ b/src/libphigs/CMakeLists.txt @@ -156,13 +156,14 @@ SET(OPHIGS_ALL ${P_CP_SRCS} ) - add_library(phigs STATIC ${OPHIGS_ALL}) add_library(phigs-shared SHARED ${OPHIGS_ALL}) +ADD_SUBDIRECTORY(shaders) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include/phigs) if (APPLE) set_target_properties(phigs-shared PROPERTIES OUTPUT_NAME phigs LINK_FLAGS "-undefined dynamic_lookup -flat_namespace") else() - set_target_properties(phigs-shared PROPERTIES OUTPUT_NAME phigs) + set_target_properties(phigs-shared PROPERTIES OUTPUT_NAME phigs LINK_FLAGS "--shared") target_link_libraries(phigs-shared ${X11_LIBRARIES}) target_link_libraries(phigs-shared ${XLIBS}) target_link_libraries(phigs-shared ${X11_Xaw_LIB}) diff --git a/src/libphigs/c_binding/cb_ws.c b/src/libphigs/c_binding/cb_ws.c index 0252a95..4b90cd8 100644 --- a/src/libphigs/c_binding/cb_ws.c +++ b/src/libphigs/c_binding/cb_ws.c @@ -1,24 +1,24 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include #include @@ -70,7 +70,6 @@ void popen_ws( read_config("phigs.def"); }; /* save the current shader settings */ - printf("popen_ws: %d %d\n", wsgl_use_shaders, wsgl_use_shaders_settings); wsgl_use_shaders_settings = wsgl_use_shaders; if (phg_entry_check(PHG_ERH, ERR2, Pfn_open_ws)) { if ((ws_id < 0) || (ws_id > MAX_NO_OPEN_WS)) { @@ -157,12 +156,16 @@ void popen_ws( } /* predefine some colors */ pxset_color_map(ws_id); - /* set background as specified in configuration file */ - pset_colr_rep(ws_id, 0, &(config[ws_id].background_color)); wsinfo = phg_psl_get_ws_info(PHG_PSL, ws_id); dt = &wsinfo->wstype->desc_tbl.phigs_dt; /* init the file name */ wsh = PHG_WSID(ws_id); + /* set background as specified in configuration file */ + if (wsh->current_colour_model == PMODEL_RGBA){ + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgba)); + } else { + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgb)); + } if (strlen(config[ws_id].filename) == 0){ switch (dt->ws_category){ case PCAT_TGA: @@ -277,36 +280,36 @@ void pclose_ws( } for (i=0; ifd = fopen(wsh->filename, "w+"); - setjmp(png_jmpbuf(png)); - png_init_io(png, wsh->fd); - png_set_IHDR( - png, - info, - width, height, - 8, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT - ); - png_write_info(png, info); - png_write_image(png, png_rows); - png_write_end(png, NULL); - fclose(wsh->fd); - } else { - printf("PNG export error: failed to create info structure\n"); - } - png_destroy_write_struct(&png, &info); + } + png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png) { + png_infop info = png_create_info_struct(png); + if (info){ + wsh->fd = fopen(wsh->filename, "w+"); + setjmp(png_jmpbuf(png)); + png_init_io(png, wsh->fd); + png_set_IHDR( + png, + info, + width, height, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT + ); + png_write_info(png, info); + png_write_image(png, png_rows); + png_write_end(png, NULL); + fclose(wsh->fd); } else { - printf("PNG export error: failed to create write structure\n"); + printf("PNG export error: failed to create info structure\n"); } - free(pixel_buffer); + png_destroy_write_struct(&png, &info); + } else { + printf("PNG export error: failed to create write structure\n"); + } + free(pixel_buffer); free(png_rows); clean_fb = TRUE; break; @@ -383,7 +386,11 @@ void pclose_ws( /* redefine colors and redraw */ ctrl_flag = 0; pxset_color_map(ws_id); - pset_colr_rep(ws_id, 0, &(config[ws_id].background_color)); + if (wsh->current_colour_model == PMODEL_RGBA){ + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgba)); + } else { + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgb)); + } predraw_all_structs(ws_id, ctrl_flag); int state = gl2psEndPage(); if (state == GL2PS_OVERFLOW) { @@ -536,43 +543,43 @@ void pset_ws_win( Plimit *window ) { - Psl_ws_info *wsinfo; - Wst_phigs_dt *dt; - Ws_handle wsh; - Plimit3 win; - - ERR_SET_CUR_FUNC(PHG_ERH, Pfn_set_ws_win); - - if (PSL_WS_STATE(PHG_PSL) != PWS_ST_WSOP) { - ERR_REPORT(PHG_ERH, ERR3); - } - else if ((wsinfo = phg_psl_get_ws_info(PHG_PSL, ws_id)) == NULL) { - ERR_REPORT(PHG_ERH, ERR54); - } - else { - dt = &wsinfo->wstype->desc_tbl.phigs_dt; - if (dt->ws_category == PCAT_MI) { - ERR_REPORT(PHG_ERH, ERR57); - } - else if (!PHG_IN_RANGE(PDT_NPC_XMIN, PDT_NPC_XMAX, window->x_min) || - !PHG_IN_RANGE(PDT_NPC_XMIN, PDT_NPC_XMAX, window->x_max) || - !PHG_IN_RANGE(PDT_NPC_YMIN, PDT_NPC_YMAX, window->y_min) || - !PHG_IN_RANGE(PDT_NPC_YMIN, PDT_NPC_YMAX, window->y_max)) { - ERR_REPORT(PHG_ERH, ERR156); - } - else if (!(window->x_min < window->x_max) || - !(window->y_min < window->y_max)) { - ERR_REPORT(PHG_ERH, ERR151); - } - else { - wsh = PHG_WSID(ws_id); - win.x_min = window->x_min; - win.x_max = window->x_max; - win.y_min = window->y_min; - win.y_max = window->y_max; - (*wsh->set_ws_window)(wsh, 1, &win); - } - } + Psl_ws_info *wsinfo; + Wst_phigs_dt *dt; + Ws_handle wsh; + Plimit3 win; + + ERR_SET_CUR_FUNC(PHG_ERH, Pfn_set_ws_win); + + if (PSL_WS_STATE(PHG_PSL) != PWS_ST_WSOP) { + ERR_REPORT(PHG_ERH, ERR3); + } + else if ((wsinfo = phg_psl_get_ws_info(PHG_PSL, ws_id)) == NULL) { + ERR_REPORT(PHG_ERH, ERR54); + } + else { + dt = &wsinfo->wstype->desc_tbl.phigs_dt; + if (dt->ws_category == PCAT_MI) { + ERR_REPORT(PHG_ERH, ERR57); + } + else if (!PHG_IN_RANGE(PDT_NPC_XMIN, PDT_NPC_XMAX, window->x_min) || + !PHG_IN_RANGE(PDT_NPC_XMIN, PDT_NPC_XMAX, window->x_max) || + !PHG_IN_RANGE(PDT_NPC_YMIN, PDT_NPC_YMAX, window->y_min) || + !PHG_IN_RANGE(PDT_NPC_YMIN, PDT_NPC_YMAX, window->y_max)) { + ERR_REPORT(PHG_ERH, ERR156); + } + else if (!(window->x_min < window->x_max) || + !(window->y_min < window->y_max)) { + ERR_REPORT(PHG_ERH, ERR151); + } + else { + wsh = PHG_WSID(ws_id); + win.x_min = window->x_min; + win.x_max = window->x_max; + win.y_min = window->y_min; + win.y_max = window->y_max; + (*wsh->set_ws_window)(wsh, 1, &win); + } + } } /******************************************************************************* @@ -1111,6 +1118,47 @@ void pset_light_src_rep( } } +/******************************************************************************* + * pset_colr_model + * + * DESCR: Set workstation colour model + * RETURNS: N/A + */ +void pset_colr_model( + Pint ws_id, + Pint model + ) +{ + Ws *wsh; + Pint original_model; + wsh = PHG_WSID(ws_id); + original_model = wsh->current_colour_model; + switch (model){ + case PINDIRECT: + wsh->current_colour_model = PINDIRECT; + break; + case PMODEL_RGB: + wsh->current_colour_model = PMODEL_RGB; + break; + case PMODEL_RGBA: + wsh->current_colour_model = PMODEL_RGBA; + break; + default: + wsh->current_colour_model = wsh->type->desc_tbl.phigs_dt.out_dt.default_colour_model; + printf("WARNING: pset_colr_model: Unknown color model, using default\n"); + break; + } + /* if the model has changed we should update the background */ + if (original_model != model){ + if (wsh->current_colour_model == PMODEL_RGBA){ + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgba)); + } else { + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgb)); + } + } + +} + /******************************************************************************* * pset_colr_rep * @@ -2137,28 +2185,95 @@ void pinq_invis_filter( } /*********************************** - * predefine some colors - * + * predefine 125 colors + * in RGBA mode + * - prepeated with offset 200*i and increasing transparency + * - dito for any already existing first 16 colors **********************************/ void pxset_color_map(Pint ws_id){ - int i, j, k; + int i, j, k, l; int n = 5; int index = 0; + int offset = 16; float delta_n = 1.0/(n-1); Pcolr_rep rep; - for (i=0; i<5; i++){ - for (j=0; j<5; j++){ - for (k=0; k<5; k++){ - rep.rgb.red = i*delta_n; - rep.rgb.green = j*delta_n; - rep.rgb.blue = k*delta_n; - pset_colr_rep(ws_id, 16+index, &rep); + Ws_handle wsh; + Pgcolr gcolr; + Pfloat def_alpha[n]; + memcpy(def_alpha, (float[]) { 1.0, 0.7, 0.5, 0.3, 0.1}, sizeof def_alpha); + + wsh = PHG_WSID(ws_id); + switch (wsh->current_colour_model){ + case PINDIRECT: + break; + case PMODEL_RGB: + for (i=0; iwindow_title, phg_default_window_name); strcpy(config->window_icon, phg_default_icon_name); memset(config->filename, 0, sizeof(config->filename)); - config->background_color.rgb.red = 0.; - config->background_color.rgb.green = 0.; - config->background_color.rgb.blue = 0.; + config->background_color_rgb.rgb.red = 0.; + config->background_color_rgb.rgb.green = 0.; + config->background_color_rgb.rgb.blue = 0.; + + config->background_color_rgba.rgba.red = 0.; + config->background_color_rgba.rgba.green = 0.; + config->background_color_rgba.rgba.blue = 0.; + config->background_color_rgba.rgba.alpha = 1.0; + config->display_width = DISPLAY_WIDTH; config->display_height = DISPLAY_HEIGHT; config->border_width = 1; @@ -76,9 +82,15 @@ void query_settings(){ printf("Workstation ID %d:\n", cf->wkid); printf(" Title: %s\n", cf->window_title); printf(" Background rgb %f %f %f\n", - cf->background_color.rgb.red, - cf->background_color.rgb.green, - cf->background_color.rgb.blue); + cf->background_color_rgb.rgb.red, + cf->background_color_rgb.rgb.green, + cf->background_color_rgb.rgb.blue); + printf(" Background rgba %f %f %f %f\n", + cf->background_color_rgba.rgba.red, + cf->background_color_rgba.rgba.green, + cf->background_color_rgba.rgba.blue, + cf->background_color_rgba.rgba.alpha + ); printf(" Width, height: %d %d\n", cf->display_width, cf->display_height); printf(" Position x, y: %d %d\n", cf->xpos, cf->ypos); printf(" Border width: %d\n", cf->border_width); @@ -102,12 +114,14 @@ void read_config(char * config_file){ int wk; int i; float xmin, xmax, ymin, ymax; - float red, green, blue; + float red, green, blue, alpha; float hcsf; unsigned int width, height, border; int xpos, ypos; Pophconf newconfig; int use_shaders; + int vertex_shader; + int fragment_shader; /* initialize output */ newconfig.wkid = -1; @@ -180,9 +194,15 @@ void read_config(char * config_file){ newconfig.border_width = border; } if (sscanf(line, "%%bg %f %f %f", &red, &green, &blue) > 0){ - newconfig.background_color.rgb.red = red; - newconfig.background_color.rgb.green = green; - newconfig.background_color.rgb.blue = blue; + newconfig.background_color_rgb.rgb.red = red; + newconfig.background_color_rgb.rgb.green = green; + newconfig.background_color_rgb.rgb.blue = blue; + } + if (sscanf(line, "%%bga %f %f %f %f", &red, &green, &blue, &alpha) > 0){ + newconfig.background_color_rgba.rgba.red = red; + newconfig.background_color_rgba.rgba.green = green; + newconfig.background_color_rgba.rgba.blue = blue; + newconfig.background_color_rgba.rgba.alpha = alpha; } if (sscanf(line, "%%hs %f", &hcsf) > 0){ newconfig.hcsf = hcsf; @@ -197,6 +217,12 @@ void read_config(char * config_file){ printf("Shaders are ENABLED by configuration\n"); } } + if (sscanf(line, "%%vs %d", &vertex_shader) > 0){ + wsgl_vert_shader_version = (short)vertex_shader; + } + if (sscanf(line, "%%fs %d", &fragment_shader) > 0){ + wsgl_frag_shader_version = (short)fragment_shader; + } if (sscanf(line, "%%pc %d", &printconf) > 0){ if (printconf == 0){ printf("Printing configuration will be suppressed\n"); diff --git a/src/libphigs/css/css_pr.c b/src/libphigs/css/css_pr.c index 225ca68..47a8c22 100644 --- a/src/libphigs/css/css_pr.c +++ b/src/libphigs/css/css_pr.c @@ -67,42 +67,42 @@ static void css_print_i_refer_to(Css_set_ptr s); void phg_css_print_struct(Struct_handle structp, int arflag) { - El_handle elptr; - Css_ws_list wsptr; - int i = 1; - - if (!structp) { - fprintf(stderr, "*** structp is NULL ***\n\n"); - return; + El_handle elptr; + Css_ws_list wsptr; + int i = 1; + + if (!structp) { + fprintf(stderr, "*** structp is NULL ***\n\n"); + return; + } + fprintf(stderr, "structure id: %d\n", structp->struct_id); + fprintf(stderr, "workstations posted to: "); + if ( !(wsptr = structp->ws_posted_to) ) + fprintf(stderr, "none"); + else + while (wsptr->wsh) { + fprintf(stderr, "%d(x%d) ", wsptr->wsh->id, wsptr->count); + wsptr++; } - fprintf(stderr, "structure id: %d\n", structp->struct_id); - fprintf(stderr, "workstations posted to: "); - if ( !(wsptr = structp->ws_posted_to) ) - fprintf(stderr, "none"); - else - while (wsptr->wsh) { - fprintf(stderr, "%d(x%d) ", wsptr->wsh->id, wsptr->count); - wsptr++; - } - fprintf(stderr, "\nworkstations appearing on: "); - if ( !(wsptr = structp->ws_appear_on) ) - fprintf(stderr, "none"); - else - while (wsptr->wsh) { - fprintf(stderr, "%d(x%d) ", wsptr->wsh->id, wsptr->count); - wsptr++; - } - fprintf(stderr, "\n"); - css_print_refer_to_me(structp->refer_to_me); - css_print_i_refer_to(structp->i_refer_to); - fprintf(stderr, "number of elements: %d\n\n", structp->num_el); - elptr = structp->first_el->next; - while (elptr != structp->last_el) { - fprintf(stderr, "%d. ", i++); - phg_css_print_eldata(elptr, arflag); - elptr = elptr->next; + fprintf(stderr, "\nworkstations appearing on: "); + if ( !(wsptr = structp->ws_appear_on) ) + fprintf(stderr, "none"); + else + while (wsptr->wsh) { + fprintf(stderr, "%d(x%d) ", wsptr->wsh->id, wsptr->count); + wsptr++; } - fprintf(stderr, "---------------------\n"); + fprintf(stderr, "\n"); + css_print_refer_to_me(structp->refer_to_me); + css_print_i_refer_to(structp->i_refer_to); + fprintf(stderr, "number of elements: %d\n\n", structp->num_el); + elptr = structp->first_el->next; + while (elptr != structp->last_el) { + fprintf(stderr, "%d. ", i++); + phg_css_print_eldata(elptr, arflag); + elptr = elptr->next; + } + fprintf(stderr, "---------------------\n"); } /******************* @@ -114,37 +114,51 @@ void phg_css_print_struct(Struct_handle structp, int arflag) void phg_css_print_eldata(El_handle elptr, int arflag) { Struct_handle structp; - if (!elptr) { - fprintf(stderr, "*** elptr is NULL ***\n"); - return; - } - css_print_eltype(elptr->eltype); - - switch(elptr->eltype) { - /* TODO: Print the element data. */ - case PELEM_HLHSR_ID: - case PELEM_INT_IND: - case PELEM_EDGE_IND: - case PELEM_LINETYPE: - case PELEM_VIEW_IND: - case PELEM_LABEL: - case PELEM_INT_STYLE: - case PELEM_EDGE_COLR_IND: - case PELEM_INT_COLR_IND: - case PELEM_INT_SHAD_METH: - case PELEM_INT_REFL_EQN: - case PELEM_MODEL_CLIP_IND: - fprintf(stderr, "%d", PHG_INT(elptr)); - case PELEM_ALPHA_CHANNEL: - fprintf(stderr, "%f", PHG_FLOAT(elptr)); - case PELEM_NIL: - default: - /* no data */ - fprintf(stderr, "\n"); - break; - } + if (!elptr) { + fprintf(stderr, "*** elptr is NULL ***\n"); + return; + } + css_print_eltype(elptr->eltype); + + switch(elptr->eltype) { + /* TODO: Print the element data. */ + case PELEM_HLHSR_ID: + case PELEM_INT_IND: + case PELEM_EDGE_IND: + case PELEM_LINETYPE: + case PELEM_VIEW_IND: + case PELEM_LABEL: + case PELEM_INT_STYLE: + case PELEM_EDGE_COLR_IND: + case PELEM_INT_COLR_IND: + case PELEM_INT_SHAD_METH: + case PELEM_MODEL_CLIP_IND: + case PELEM_FACE_CULL_MODE: + case PELEM_INT_STYLE_IND: + case PELEM_FACE_DISTING_MODE: + case PELEM_INT_REFL_MODEL: + case PELEM_EDGE_FLAG: + case PELEM_INT_REFL_EQN: + case PELEM_BACK_INT_REFL_EQN: + case PELEM_EDGETYPE: + fprintf(stderr, "%d", PHG_INT(elptr)); + break; + case PELEM_EDGEWIDTH: + case PELEM_ALPHA_CHANNEL: + case PELEM_ANNO_CHAR_HT: + case PELEM_MARKER_SIZE: + case PELEM_CHAR_HT: + case PELEM_CHAR_SPACE:PELEM_LINEWIDTH: + fprintf(stderr, "%f", PHG_FLOAT(elptr)); + break; + case PELEM_NIL: + default: + /* no data */ fprintf(stderr, "\n"); - fflush(stdout); + break; + } + fprintf(stderr, "\n"); + fflush(stdout); } /******************* @@ -155,98 +169,100 @@ void phg_css_print_eldata(El_handle elptr, int arflag) void css_print_eltype(Pelem_type eltype) { - char *name = NULL; - - switch(eltype) { - case PELEM_NIL: name = "PELEM_NIL"; break; - case PELEM_POLYLINE3: name = "PELEM_POLYLINE3"; break; - case PELEM_POLYLINE: name = "PELEM_POLYLINE"; break; - case PELEM_POLYMARKER3: name = "PELEM_POLYMARKER3"; break; - case PELEM_POLYMARKER: name = "PELEM_POLYMARKER"; break; - case PELEM_TEXT: name = "PELEM_TEXT"; break; - case PELEM_TEXT3: name = "PELEM_TEXT3"; break; - case PELEM_FILL_AREA3: name = "PELEM_FILL_AREA3"; break; - case PELEM_FILL_AREA_SET: name = "PELEM_FILL_AREA_SET"; break; - case PELEM_FILL_AREA_SET3: name = "PELEM_FILL_AREA_SET3"; break; - case PELEM_FILL_AREA_SET_DATA: - name = "PELEM_FILL_AREA_SET_DATA"; - break; - case PELEM_FILL_AREA_SET3_DATA: - name = "PELEM_FILL_AREA_SET3_DATA"; - break; - case PELEM_SET_OF_FILL_AREA_SET3_DATA: - name = "PELEM_FILL_AREA_SET3_DATA"; - break; - case PELEM_FILL_AREA: name = "PELEM_FILL_AREA"; break; - case PELEM_LINE_IND: name = "PELEM_LINE_IND"; break; - case PELEM_LINETYPE: name = "PELEM_LINETYPE"; break; - case PELEM_LINEWIDTH: name = "PELEM_LINEWIDTH"; break; - case PELEM_LINE_COLR_IND: name = "PELEM_LINE_COLR_IND"; break; - case PELEM_MARKER_IND: name = "PELEM_MARKER_IND"; break; - case PELEM_MARKER_TYPE: name = "PELEM_MARKER_TYPE"; break; - case PELEM_MARKER_SIZE: name = "PELEM_MARKER_SIZE"; break; - case PELEM_MARKER_COLR_IND: name = "PELEM_MARKER_COLR_IND"; break; - case PELEM_TEXT_IND: name = "PELEM_TEXT_IND"; break; - case PELEM_TEXT_FONT: name = "PELEM_TEXT_FONT"; break; - case PELEM_TEXT_PREC: name = "PELEM_TEXT_PREC"; break; - case PELEM_TEXT_PATH: name = "PELEM_TEXT_PATH"; break; - case PELEM_TEXT_ALIGN: name = "PELEM_TEXT_ALIGN"; break; - case PELEM_CHAR_HT: name = "PELEM_CHAR_HT"; break; - case PELEM_CHAR_EXPAN: name = "PELEM_CHAR_EXPAN"; break; - case PELEM_CHAR_SPACE: name = "PELEM_CHAR_SPACE"; break; - case PELEM_CHAR_UP_VEC: name = "PELEM_CHAR_UP_VEC"; break; - case PELEM_TEXT_COLR_IND: name = "PELEM_TEXT_COLR_IND"; break; - case PELEM_INT_IND: name = "PELEM_INT_IND"; break; - case PELEM_INT_STYLE: name = "PELEM_INT_STYLE"; break; - case PELEM_BACK_INT_STYLE: name = "PELEM_BACK_INT_STYLE"; break; - case PELEM_INT_STYLE_IND: name = "PELEM_INT_STYLE_IND"; break; - case PELEM_BACK_INT_STYLE_IND: name = "PELEM_BACK_INT_STYLE_IND"; break; - case PELEM_INT_COLR_IND: name = "PELEM_INT_COLR_IND"; break; - case PELEM_EDGE_IND: name = "PELEM_EDGE_IND"; break; - case PELEM_EDGE_FLAG: name = "PELEM_EDGE_FLAG"; break; - case PELEM_EDGETYPE: name = "PELEM_EDGETYPE"; break; - case PELEM_EDGEWIDTH: name = "PELEM_EDGEWIDTH"; break; - case PELEM_EDGE_COLR_IND: name = "PELEM_EDGE_COLR_IND"; break; - case PELEM_ADD_NAMES_SET: name = "PELEM_ADD_NAMES_SET"; break; - case PELEM_REMOVE_NAMES_SET: name = "PELEM_REMOVE_NAMES_SET"; break; - case PELEM_INDIV_ASF: name = "PELEM_INDIV_ASF"; break; - case PELEM_LOCAL_MODEL_TRAN3: name = "PELEM_LOCAL_MODEL_TRAN3"; break; - case PELEM_GLOBAL_MODEL_TRAN3: name = "PELEM_GLOBAL_MODEL_TRAN3"; break; - case PELEM_VIEW_IND: name = "PELEM_VIEW_IND"; break; - case PELEM_EXEC_STRUCT: name = "PELEM_EXEC_STRUCT"; break; - case PELEM_LABEL: name = "PELEM_LABEL"; break; - case PELEM_PICK_ID: name = "PELEM_PICK_ID"; break; - case PELEM_HLHSR_ID: name = "PELEM_HLHSR_ID"; break; - case PELEM_INT_COLR: name = "PELEM_INT_COLR"; break; - case PELEM_BACK_INT_COLR: name = "PELEM_BACK_INT_COLR"; break; - case PELEM_LINE_COLR: name = "PELEM_LINE_COLR"; break; - case PELEM_MARKER_COLR: name = "PELEM_MARKER_COLR"; break; - case PELEM_EDGE_COLR: name = "PELEM_EDGE_COLR"; break; - case PELEM_TEXT_COLR: name = "PELEM_TEXT_COLR"; break; - case PELEM_LIGHT_SRC_STATE: name = "PELEM_LIGHT_SRC_STATE"; break; - case PELEM_INT_SHAD_METH: name = "PELEM_INT_SHAD_METH"; break; - case PELEM_BACK_INT_SHAD_METH: name = "PELEM_BACK_INT_SHAD_METH"; break; - case PELEM_INT_REFL_EQN: name = "PELEM_INT_REFL_EQN"; break; - case PELEM_BACK_INT_REFL_EQN: name = "PELEM_BACK_INT_REFL_EQN"; break; - case PELEM_REFL_PROPS: name = "PELEM_REFL_PROP"; break; - case PELEM_BACK_REFL_PROPS: name = "PELEM_BACK_REFL_PROP"; break; - case PELEM_FACE_DISTING_MODE: name = "PELEM_FACE_DISTING_MODE"; break; - case PELEM_FACE_CULL_MODE: name = "PELEM_FACE_CULL_MODE"; break; - case PELEM_ANNO_TEXT_REL3: name = "PELEM_ANNO_TEXT_REL3"; break; - case PELEM_ANNO_TEXT_REL: name = "PELEM_ANNO_TEXT_REL"; break; - case PELEM_ANNO_ALIGN: name = "PELEM_ANNO_ALIGN"; break; - case PELEM_ANNO_CHAR_HT: name = "PELEM_ANNO_CHAR_HT"; break; - case PELEM_MODEL_CLIP_VOL3: name = "PELEM_MODEL_CLIP_VOL3"; break; - case PELEM_MODEL_CLIP_IND: name = "PELEM_MODEL_CLIP_IND"; break; - case PELEM_GSE: name = "PELEM_GSE"; break; - - default: - fprintf(stderr, "UNKNOWN TYPE: %d\n", eltype); - break; - } - - if ( name ) - fprintf( stderr, "%s\n", name ); + char *name = NULL; + + switch(eltype) { + case PELEM_NIL: name = "PELEM_NIL"; break; + case PELEM_POLYLINE3: name = "PELEM_POLYLINE3"; break; + case PELEM_POLYLINE: name = "PELEM_POLYLINE"; break; + case PELEM_POLYMARKER3: name = "PELEM_POLYMARKER3"; break; + case PELEM_POLYMARKER: name = "PELEM_POLYMARKER"; break; + case PELEM_TEXT: name = "PELEM_TEXT"; break; + case PELEM_TEXT3: name = "PELEM_TEXT3"; break; + case PELEM_FILL_AREA3: name = "PELEM_FILL_AREA3"; break; + case PELEM_FILL_AREA_SET: name = "PELEM_FILL_AREA_SET"; break; + case PELEM_FILL_AREA_SET3: name = "PELEM_FILL_AREA_SET3"; break; + case PELEM_FILL_AREA_SET_DATA: + name = "PELEM_FILL_AREA_SET_DATA"; + break; + case PELEM_FILL_AREA_SET3_DATA: + name = "PELEM_FILL_AREA_SET3_DATA"; + break; + case PELEM_SET_OF_FILL_AREA_SET3_DATA: + name = "PELEM_FILL_AREA_SET3_DATA"; + break; + case PELEM_FILL_AREA: name = "PELEM_FILL_AREA"; break; + case PELEM_LINE_IND: name = "PELEM_LINE_IND"; break; + case PELEM_LINETYPE: name = "PELEM_LINETYPE"; break; + case PELEM_LINEWIDTH: name = "PELEM_LINEWIDTH"; break; + case PELEM_LINE_COLR_IND: name = "PELEM_LINE_COLR_IND"; break; + case PELEM_MARKER_IND: name = "PELEM_MARKER_IND"; break; + case PELEM_MARKER_TYPE: name = "PELEM_MARKER_TYPE"; break; + case PELEM_MARKER_SIZE: name = "PELEM_MARKER_SIZE"; break; + case PELEM_MARKER_COLR_IND: name = "PELEM_MARKER_COLR_IND"; break; + case PELEM_TEXT_IND: name = "PELEM_TEXT_IND"; break; + case PELEM_TEXT_FONT: name = "PELEM_TEXT_FONT"; break; + case PELEM_TEXT_PREC: name = "PELEM_TEXT_PREC"; break; + case PELEM_TEXT_PATH: name = "PELEM_TEXT_PATH"; break; + case PELEM_TEXT_ALIGN: name = "PELEM_TEXT_ALIGN"; break; + case PELEM_CHAR_HT: name = "PELEM_CHAR_HT"; break; + case PELEM_CHAR_EXPAN: name = "PELEM_CHAR_EXPAN"; break; + case PELEM_CHAR_SPACE: name = "PELEM_CHAR_SPACE"; break; + case PELEM_CHAR_UP_VEC: name = "PELEM_CHAR_UP_VEC"; break; + case PELEM_TEXT_COLR_IND: name = "PELEM_TEXT_COLR_IND"; break; + case PELEM_INT_IND: name = "PELEM_INT_IND"; break; + case PELEM_INT_STYLE: name = "PELEM_INT_STYLE"; break; + case PELEM_BACK_INT_STYLE: name = "PELEM_BACK_INT_STYLE"; break; + case PELEM_INT_STYLE_IND: name = "PELEM_INT_STYLE_IND"; break; + case PELEM_BACK_INT_STYLE_IND: name = "PELEM_BACK_INT_STYLE_IND"; break; + case PELEM_INT_COLR_IND: name = "PELEM_INT_COLR_IND"; break; + case PELEM_EDGE_IND: name = "PELEM_EDGE_IND"; break; + case PELEM_EDGE_FLAG: name = "PELEM_EDGE_FLAG"; break; + case PELEM_EDGETYPE: name = "PELEM_EDGETYPE"; break; + case PELEM_EDGEWIDTH: name = "PELEM_EDGEWIDTH"; break; + case PELEM_EDGE_COLR_IND: name = "PELEM_EDGE_COLR_IND"; break; + case PELEM_ADD_NAMES_SET: name = "PELEM_ADD_NAMES_SET"; break; + case PELEM_REMOVE_NAMES_SET: name = "PELEM_REMOVE_NAMES_SET"; break; + case PELEM_INDIV_ASF: name = "PELEM_INDIV_ASF"; break; + case PELEM_LOCAL_MODEL_TRAN3: name = "PELEM_LOCAL_MODEL_TRAN3"; break; + case PELEM_GLOBAL_MODEL_TRAN3: name = "PELEM_GLOBAL_MODEL_TRAN3"; break; + case PELEM_VIEW_IND: name = "PELEM_VIEW_IND"; break; + case PELEM_EXEC_STRUCT: name = "PELEM_EXEC_STRUCT"; break; + case PELEM_LABEL: name = "PELEM_LABEL"; break; + case PELEM_PICK_ID: name = "PELEM_PICK_ID"; break; + case PELEM_HLHSR_ID: name = "PELEM_HLHSR_ID"; break; + case PELEM_INT_COLR: name = "PELEM_INT_COLR"; break; + case PELEM_BACK_INT_COLR: name = "PELEM_BACK_INT_COLR"; break; + case PELEM_LINE_COLR: name = "PELEM_LINE_COLR"; break; + case PELEM_MARKER_COLR: name = "PELEM_MARKER_COLR"; break; + case PELEM_EDGE_COLR: name = "PELEM_EDGE_COLR"; break; + case PELEM_TEXT_COLR: name = "PELEM_TEXT_COLR"; break; + case PELEM_LIGHT_SRC_STATE: name = "PELEM_LIGHT_SRC_STATE"; break; + case PELEM_INT_SHAD_METH: name = "PELEM_INT_SHAD_METH"; break; + case PELEM_BACK_INT_SHAD_METH: name = "PELEM_BACK_INT_SHAD_METH"; break; + case PELEM_INT_REFL_EQN: name = "PELEM_INT_REFL_EQN"; break; + case PELEM_BACK_INT_REFL_EQN: name = "PELEM_BACK_INT_REFL_EQN"; break; + case PELEM_REFL_PROPS: name = "PELEM_REFL_PROP"; break; + case PELEM_BACK_REFL_PROPS: name = "PELEM_BACK_REFL_PROP"; break; + case PELEM_FACE_DISTING_MODE: name = "PELEM_FACE_DISTING_MODE"; break; + case PELEM_FACE_CULL_MODE: name = "PELEM_FACE_CULL_MODE"; break; + case PELEM_ANNO_TEXT_REL3: name = "PELEM_ANNO_TEXT_REL3"; break; + case PELEM_ANNO_TEXT_REL: name = "PELEM_ANNO_TEXT_REL"; break; + case PELEM_ANNO_ALIGN: name = "PELEM_ANNO_ALIGN"; break; + case PELEM_ANNO_CHAR_HT: name = "PELEM_ANNO_CHAR_HT"; break; + case PELEM_MODEL_CLIP_VOL3: name = "PELEM_MODEL_CLIP_VOL3"; break; + case PELEM_MODEL_CLIP_IND: name = "PELEM_MODEL_CLIP_IND"; break; + case PELEM_GSE: name = "PELEM_GSE"; break; + case PELEM_ALPHA_CHANNEL: name = "PELEM_ALPHA_CHANNEL"; break; + case PELEM_INT_REFL_MODEL: name = "PELEM_INT_REFL_MODEL"; break; + + default: + fprintf(stderr, "UNKNOWN TYPE: %d\n", eltype); + break; + } + + if ( name ) + fprintf( stderr, "%s\n", name ); } /******************* @@ -257,19 +273,19 @@ void css_print_eltype(Pelem_type eltype) static void css_print_refer_to_me(Css_set_ptr s) { - Css_set_element *el; - - fprintf(stderr, "structures that refer to me: "); - if ( !(el = s->elements->next) ) - fprintf(stderr, "none"); - else { - while (el) { - fprintf(stderr, "%d(x%d) ", - ((Struct_handle)el->key)->struct_id, (unsigned)((long)el->data)); - el = el->next; - } + Css_set_element *el; + + fprintf(stderr, "structures that refer to me: "); + if ( !(el = s->elements->next) ) + fprintf(stderr, "none"); + else { + while (el) { + fprintf(stderr, "%d(x%d) ", + ((Struct_handle)el->key)->struct_id, (unsigned)((long)el->data)); + el = el->next; } - fprintf(stderr, "\n"); + } + fprintf(stderr, "\n"); } /******************* @@ -280,28 +296,28 @@ static void css_print_refer_to_me(Css_set_ptr s) static void css_print_i_refer_to(Css_set_ptr s) { - Css_set_element *el1, *el2; - int eindex, i, n; - - fprintf(stderr, "structures i execute: "); - if ( !(el1 = s->elements->next) ) - fprintf(stderr, "none"); - else { - while (el1) { - fprintf(stderr, "%d(", ((Struct_handle)el1->key)->struct_id); - n = ((Css_set_ptr)el1->data)->num_elements; - i = 1; - el2 = ((Css_set_ptr)el1->data)->elements->next; - while (el2) { - /* get index of execute structure element */ - CSS_GET_EL_INDEX((El_handle)el2->key, eindex) - fprintf(stderr, (i < n ? "%d, " : "%d"), eindex); - el2 = el2->next; - i++; - } - fprintf(stderr, ") "); - el1 = el1->next; - } + Css_set_element *el1, *el2; + int eindex, i, n; + + fprintf(stderr, "structures i execute: "); + if ( !(el1 = s->elements->next) ) + fprintf(stderr, "none"); + else { + while (el1) { + fprintf(stderr, "%d(", ((Struct_handle)el1->key)->struct_id); + n = ((Css_set_ptr)el1->data)->num_elements; + i = 1; + el2 = ((Css_set_ptr)el1->data)->elements->next; + while (el2) { + /* get index of execute structure element */ + CSS_GET_EL_INDEX((El_handle)el2->key, eindex) + fprintf(stderr, (i < n ? "%d, " : "%d"), eindex); + el2 = el2->next; + i++; + } + fprintf(stderr, ") "); + el1 = el1->next; } - fprintf(stderr, "\n"); + } + fprintf(stderr, "\n"); } diff --git a/src/libphigs/f_binding/fb_el.c b/src/libphigs/f_binding/fb_el.c index 51f3d8b..ce21b04 100644 --- a/src/libphigs/f_binding/fb_el.c +++ b/src/libphigs/f_binding/fb_el.c @@ -672,10 +672,16 @@ FTN_SUBROUTINE(pshrid)( #ifdef DEBUG printf("DEBUG: PSHRID set hlrs id to %d.\n", hrmode); #endif - if (hrmode == 0) { + switch(hrmode){ + case 0: pset_hlhsr_id(PHIGS_HLHSR_ID_OFF); - } else { + break; + case 1: pset_hlhsr_id(PHIGS_HLHSR_ID_ON); + break; + case 2: + pset_hlhsr_id(PHIGS_HLHSR_ID_ON_NZ); + break; } } diff --git a/src/libphigs/f_binding/fb_extel.c b/src/libphigs/f_binding/fb_extel.c index b5ce861..f08ef51 100644 --- a/src/libphigs/f_binding/fb_extel.c +++ b/src/libphigs/f_binding/fb_extel.c @@ -156,9 +156,6 @@ FTN_SUBROUTINE(psrfp)( int ncc = here[2]; int index = here[3]; refl_properties.specular_colr.type = col_type; - if (col_type == PINDIRECT){ - refl_properties.specular_colr.val.ind = index; - } fp = (float*) &here[5]; refl_properties.ambient_coef = fp[0]; refl_properties.diffuse_coef = fp[1]; @@ -171,14 +168,28 @@ FTN_SUBROUTINE(psrfp)( refl_properties.specular_coef, refl_properties.specular_exp); #endif - if (col_type == PMODEL_RGB){ + switch (col_type){ + case PINDIRECT: + refl_properties.specular_colr.val.ind = index; + break; + case PMODEL_RGB: refl_properties.specular_colr.val.general.x = fp[4]; refl_properties.specular_colr.val.general.y = fp[5]; refl_properties.specular_colr.val.general.z = fp[6]; + refl_properties.specular_colr.val.general.a = 1.0; + break; + case PMODEL_RGBA: + refl_properties.specular_colr.val.general.x = fp[4]; + refl_properties.specular_colr.val.general.y = fp[5]; + refl_properties.specular_colr.val.general.z = fp[6]; + refl_properties.specular_colr.val.general.z = fp[7]; + break; + default: + printf("ERROR in psrfp: unknown color model %d.", col_type); } pset_refl_props(&refl_properties); } else { - printf("PSRFP: unknown reflection type. Ignorning function.\n"); + printf("ERROR in psrfp: unknown reflection type. Ignorning function.\n"); } } @@ -748,19 +759,38 @@ FTN_SUBROUTINE(psbic)( #ifdef DEBUG printf("DEBUG: pset interior color index set to %d\n", colr_ind); #endif - if (colr_typ == PINDIRECT){ + switch (colr_typ) { + case PINDIRECT: colr.type = PINDIRECT; colr.val.ind = colr_ind; - } else { + break; + case PMODEL_RGB: colr.type = PMODEL_RGB; if (ncc == 3){ colr.val.general.x = FTN_REAL_ARRAY_GET(rcolr, 0); colr.val.general.y = FTN_REAL_ARRAY_GET(rcolr, 1); colr.val.general.z = FTN_REAL_ARRAY_GET(rcolr, 2); + colr.val.general.a = 1.0; + } + else { + printf("PSBCI: not enough color values provided. Ignoring function.\n"); + } + break; + case PMODEL_RGBA: + colr.type = PMODEL_RGBA; + if (ncc == 4){ + colr.val.general.x = FTN_REAL_ARRAY_GET(rcolr, 0); + colr.val.general.y = FTN_REAL_ARRAY_GET(rcolr, 1); + colr.val.general.z = FTN_REAL_ARRAY_GET(rcolr, 2); + colr.val.general.a = FTN_REAL_ARRAY_GET(rcolr, 3); } else { printf("PSBCI: not enough color values provided. Ignoring function.\n"); } + break; + default: + printf("PSBCI: Unknown color mode given. Ignoring function.\n"); + break; } pset_back_int_colr(&colr); } diff --git a/src/libphigs/f_binding/fb_pgse.c b/src/libphigs/f_binding/fb_pgse.c index 06f92ae..3ef42ba 100644 --- a/src/libphigs/f_binding/fb_pgse.c +++ b/src/libphigs/f_binding/fb_pgse.c @@ -43,12 +43,25 @@ FTN_SUBROUTINE(pxshlc)( #endif Pgcolr pgcolr; pgcolr.type = FTN_INTEGER_GET(ctype); - if (pgcolr.type == PINDIRECT){ + switch (pgcolr.type){ + case PINDIRECT: pgcolr.val.ind = FTN_INTEGER_GET(coli); - } else { + break; + case PMODEL_RGB: pgcolr.val.general.x = FTN_REAL_ARRAY_GET(colr, 0); pgcolr.val.general.y = FTN_REAL_ARRAY_GET(colr, 1); pgcolr.val.general.z = FTN_REAL_ARRAY_GET(colr, 2); + pgcolr.val.general.a = 1.0; + break; + case PMODEL_RGBA: + pgcolr.val.general.x = FTN_REAL_ARRAY_GET(colr, 0); + pgcolr.val.general.y = FTN_REAL_ARRAY_GET(colr, 1); + pgcolr.val.general.z = FTN_REAL_ARRAY_GET(colr, 2); + pgcolr.val.general.a = FTN_REAL_ARRAY_GET(colr, 3); + break; + default: + printf("WARNING in pxshlc: Unknown color model %d. Ignoring function.\n", pgcolr.type); + break; }; pxset_highlight_colr(&pgcolr); }; diff --git a/src/libphigs/f_binding/fb_str.c b/src/libphigs/f_binding/fb_str.c index 8c80127..3e41360 100644 --- a/src/libphigs/f_binding/fb_str.c +++ b/src/libphigs/f_binding/fb_str.c @@ -369,20 +369,32 @@ FTN_SUBROUTINE(pqeco)( case PELEM_MARKER_COLR: case PELEM_EDGE_COLR: case PELEM_TEXT_COLR: - if (elem_data->colr.type == PMODEL_RGB){ + switch (elem_data->colr.type){ + case PMODEL_RGB: ra[0] = elem_data->colr.val.general.x; ra[1] = elem_data->colr.val.general.y; ra[3] = elem_data->colr.val.general.z; + ra[4] = 1.0; *rl = 3; - } else { + break; + case PMODEL_RGBA: + ra[0] = elem_data->colr.val.general.x; + ra[1] = elem_data->colr.val.general.y; + ra[3] = elem_data->colr.val.general.z; + ra[4] = elem_data->colr.val.general.a; + *rl = 4; + break; + default: *err_ind=4; printf("ERROR in PQECO: RGB requested but colr type is not RGB: %d elem_type %d\n", (int)elem_data->colr.type, (int)elem_type); + break; } break; default: css_print_eltype(elem_type); printf("ERROR in PQECO: unknown element type %d. Ignoring function\n", (int)elem_type); *err_ind = 2; + break; } } } diff --git a/src/libphigs/f_binding/fb_ws.c b/src/libphigs/f_binding/fb_ws.c index d6551ea..5db3e59 100644 --- a/src/libphigs/f_binding/fb_ws.c +++ b/src/libphigs/f_binding/fb_ws.c @@ -1,24 +1,24 @@ /****************************************************************************** -* Do NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * Do NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include @@ -165,10 +165,14 @@ FTN_SUBROUTINE(popwk)( } /* predefine some colors */ pxset_color_map(ws_id); - /* set background as specified in configuration file */ - pset_colr_rep(ws_id, 0, &(config[ws_id].background_color)); /* init output file name */ wsh = PHG_WSID(ws_id); + /* set background as specified in configuration file */ + if (wsh->current_colour_model == PMODEL_RGBA){ + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgba)); + } else { + pset_colr_rep(ws_id, 0, &(config[ws_id].background_color_rgb)); + } if (strlen(config[ws_id].filename) == 0){ sprintf(filename, "fort.%d", lun); strncpy(wsh->filename, filename, strlen(filename)); @@ -219,6 +223,23 @@ FTN_SUBROUTINE(ppost)( } } +/******************************************************************************* + * pscm + * + * DESCR: Set colour model + * RETURNS: N/A + */ + +FTN_SUBROUTINE(pscm)( + FTN_INTEGER(wkid), + FTN_INTEGER(cmodel) + ) +{ + Pint ws_id = FTN_INTEGER_GET(wkid); + Pint model = FTN_INTEGER_GET(cmodel); + pset_colr_model(ws_id, model); +} + /******************************************************************************* * pscr * @@ -236,17 +257,47 @@ FTN_SUBROUTINE(pscr)( Pint ws_id = FTN_INTEGER_GET(wkid); Pint ind = FTN_INTEGER_GET(ci); Pint ncc = FTN_INTEGER_GET(nccs); + Pint color_model; Pcolr_rep rep; + Ws *wsh; + wsh = PHG_WSID(ws_id); + color_model = wsh->current_colour_model; #ifdef DEBUG printf("DEBUG: PSCR workstation color representation %d\n", *wkid); #endif - if (ncc == 3) { + if (ncc<3 || ncc>4){ + printf("WARNING: PSCR not enough or too many color components %d. Ignoring function.\n", ncc); + }; + switch (color_model) { + case PMODEL_RGB: rep.rgb.red = FTN_REAL_ARRAY_GET(cspec, 0); rep.rgb.green = FTN_REAL_ARRAY_GET(cspec, 1); rep.rgb.blue = FTN_REAL_ARRAY_GET(cspec, 2); - } - else { + break; + case PMODEL_RGBA: + rep.rgba.red = FTN_REAL_ARRAY_GET(cspec, 0); + rep.rgba.green = FTN_REAL_ARRAY_GET(cspec, 1); + rep.rgba.blue = FTN_REAL_ARRAY_GET(cspec, 2); + if (ncc == 4) { + rep.rgba.alpha = FTN_REAL_ARRAY_GET(cspec, 3); + } else { + printf("INFO: psrc no alpha component specified in RGBA mode. Using 1.\n"); + rep.rgba.alpha = 1,0; + }; +#ifdef DEBUGA + printf("INFO: psrc set color RGBA %f%f %f %f\n", + rep.rgba.red, + rep.rgba.green, + rep.rgba.blue, + rep.rgba.alpha + ); +#endif + break; + case PINDIRECT: rep.rgb.red = rep.rgb.green = rep.rgb.blue = FTN_REAL_ARRAY_GET(cspec, 0); + break; + default: + printf("WARNING: Unknown color model %d. Ignoring function.\n", color_model); } pset_colr_rep(ws_id, ind, &rep); } @@ -896,9 +947,9 @@ FTN_SUBROUTINE(pqwkpo)( ) { /* -This needs to loop over all work stations and all their posted structures, and if the given structure is found, -remember that WKID and the number of matches we had. Then we return the WKID of the N'th match in wkid and the number of matches in ol -FIXME: this one does not seem to find anything for some reason. + This needs to loop over all work stations and all their posted structures, and if the given structure is found, + remember that WKID and the number of matches we had. Then we return the WKID of the N'th match in wkid and the number of matches in ol + FIXME: this one does not seem to find anything for some reason. */ Pint struct_id = FTN_INTEGER_GET(strid); @@ -1155,10 +1206,21 @@ FTN_SUBROUTINE(pqcr)( if (buf_size >= 3){ pinq_colr_rep(ws_id, colr_ind, type, err_ind, &colr_rep); if (*err_ind == 0){ - *ol = 3; - cspec[0] = colr_rep.rgb.red; - cspec[1] = colr_rep.rgb.green; - cspec[2] = colr_rep.rgb.blue; + switch (buf_size) { + case 3: + *ol = 3; + cspec[0] = colr_rep.rgb.red; + cspec[1] = colr_rep.rgb.green; + cspec[2] = colr_rep.rgb.blue; + break; + case 4: + default: + cspec[0] = colr_rep.rgba.red; + cspec[1] = colr_rep.rgba.green; + cspec[2] = colr_rep.rgba.blue; + cspec[3] = colr_rep.rgba.alpha; + break; + } } } else { *err_ind = 1; @@ -1271,10 +1333,17 @@ FTN_SUBROUTINE(pslsr)( switch (type) { case PLIGHT_AMBIENT: amblight.colr.type = col_type; - if (col_type == PINDIRECT){ + switch (col_type){ + case PINDIRECT: amblight.colr.val.ind = col_indx; - } else { + break; + case PMODEL_RGB: memcpy(&amblight.colr.val.general.x, &fhere[0], 3*sizeof(Pfloat)); + amblight.colr.val.general.a = 1.0; + break; + case PMODEL_RGBA: + memcpy(&amblight.colr.val.general.x, &fhere[0], 4*sizeof(Pfloat)); + break; } light_src_rep.type = type; light_src_rep.rec.ambient = amblight; @@ -1283,10 +1352,17 @@ FTN_SUBROUTINE(pslsr)( case PLIGHT_DIRECTIONAL: dirlight.colr.type = col_type; memcpy(&dirlight.dir.delta_x, &fhere[0], 3*sizeof(Pfloat)); - if (col_type == PINDIRECT){ + switch (col_type){ + case PINDIRECT: dirlight.colr.val.ind = col_indx; - } else { + break; + case PMODEL_RGB: memcpy(&dirlight.colr.val.general.x, &fhere[3], 3*sizeof(Pfloat)); + dirlight.colr.val.general.a = 1.0; + break; + case PMODEL_RGBA: + memcpy(&dirlight.colr.val.general.x, &fhere[3], 4*sizeof(Pfloat)); + break; } light_src_rep.type = type; light_src_rep.rec.directional = dirlight; @@ -1296,10 +1372,17 @@ FTN_SUBROUTINE(pslsr)( poslight.colr.type = col_type; memcpy(&poslight.pos.x, &fhere[0], 3*sizeof(Pfloat)); memcpy(&poslight.coef, &fhere[3], 2*sizeof(Pfloat)); - if (col_type == PINDIRECT){ + switch (col_type){ + case PINDIRECT: poslight.colr.val.ind = col_indx; - } else { + break; + case PMODEL_RGB: memcpy(&poslight.colr.val.general.x, &fhere[5], 3*sizeof(Pfloat)); + poslight.colr.val.general.a = 1.0; + break; + case PMODEL_RGBA: + memcpy(&poslight.colr.val.general.x, &fhere[5], 4*sizeof(Pfloat)); + break; } light_src_rep.type = type; light_src_rep.rec.positional = poslight; diff --git a/src/libphigs/phg/phg.c b/src/libphigs/phg/phg.c index 00d4e92..06c5822 100644 --- a/src/libphigs/phg/phg.c +++ b/src/libphigs/phg/phg.c @@ -261,20 +261,19 @@ void phg_del_struct( if (structh != NULL) { ws_list = CSS_GET_WS_ON(structh); if (ws_list != NULL) { - for (; ws_list->wsh != NULL; ws_list++) { - if (*ws_list->wsh->delete_struct == NULL) { - printf("ERROR: Cannot delete this structure as wsh->>delete_struct is NULL\n"); - } else if (ws_list->wsh->id <= 0 || ws_list->wsh->id > 10){ - printf("ERROR: Refusing to delete structure as the WS Id looks like garbage: %d.\n", ws_list->wsh->id); - } else { - if ((*ws_list->wsh->delete_struct)(ws_list->wsh, structh, - WS_PRE_CSS_DELETE)) { - *wsp++ = ws_list->wsh; - } + for (; ws_list->wsh != NULL; ws_list++) { + if (*ws_list->wsh->delete_struct == NULL) { + printf("ERROR: Cannot delete this structure as wsh->>delete_struct is NULL\n"); + } else if (ws_list->wsh->id <= 0 || ws_list->wsh->id > 10){ + printf("ERROR: Refusing to delete structure as the WS Id looks like garbage: %d.\n", ws_list->wsh->id); + } else { + if ((*ws_list->wsh->delete_struct)(ws_list->wsh, structh, + WS_PRE_CSS_DELETE)) { + *wsp++ = ws_list->wsh; } - } + } + } } - phg_css_delete_struct(cssh, structh); while (wsp-- != cb_list) { @@ -452,22 +451,47 @@ void phg_get_colr_ind( { Phg_ret ret; - gcolr->type = ws->current_colour_model; - - if (ws->current_colour_model == PINDIRECT) { - gcolr->val.ind = ind; - } - else { - (*ws->inq_representation)(ws, - ind, - PINQ_REALIZED, - PHG_ARGS_COREP, - &ret); - if (ret.err == 0) { - gcolr->val.general.x = ret.data.rep.corep.rgb.red; - gcolr->val.general.y = ret.data.rep.corep.rgb.green; - gcolr->val.general.z = ret.data.rep.corep.rgb.blue; - } + (*ws->inq_representation)(ws, + ind, + PINQ_REALIZED, + PHG_ARGS_COREP, + &ret); + if (ret.err == 0) { + gcolr->type = ws->current_colour_model; + switch (ws->current_colour_model){ + case PINDIRECT: + gcolr->val.ind = ind; + break; + case PMODEL_RGB: + gcolr->val.general.x = ret.data.rep.corep.rgb.red; + gcolr->val.general.y = ret.data.rep.corep.rgb.green; + gcolr->val.general.z = ret.data.rep.corep.rgb.blue; + gcolr->val.general.a = 1.0; + break; + case PMODEL_RGBA: + gcolr->val.general.x = ret.data.rep.corep.rgba.red; + gcolr->val.general.y = ret.data.rep.corep.rgba.green; + gcolr->val.general.z = ret.data.rep.corep.rgba.blue; + gcolr->val.general.a = ret.data.rep.corep.rgba.alpha; + break; + default: + printf("WARNING in phg_get_colr_ind. Unknown color model %d\n", gcolr->type); + gcolr->type = -1; + gcolr->val.general.x = 0.; + gcolr->val.general.y = 0.; + gcolr->val.general.z = 0.; + gcolr->val.general.a = 1.0; + break; + } + } else { +#ifdef DEBUGA + printf("WARNING in phg_get_colr_ind. Index %d not defined\n", ind); +#endif + gcolr->type = -1; + gcolr->val.general.x = 0.; + gcolr->val.general.y = 0.; + gcolr->val.general.z = 0.; + gcolr->val.general.a = 1.0; } } diff --git a/src/libphigs/phg/phg_attr.c b/src/libphigs/phg/phg_attr.c index 2b413c7..8319be4 100644 --- a/src/libphigs/phg/phg_attr.c +++ b/src/libphigs/phg/phg_attr.c @@ -188,5 +188,9 @@ void phg_attr_group_set_int_bundle( &attr_group->int_bundle.colr, attr_group->int_bundle.colr.val.ind); } + if (attr_group->int_bundle.back_colr.type == PINDIRECT) { + phg_get_colr_ind(ws, + &attr_group->int_bundle.back_colr, + attr_group->int_bundle.back_colr.val.ind); + } } - diff --git a/src/libphigs/phg/phg_swap.c b/src/libphigs/phg/phg_swap.c index bb63823..708c369 100644 --- a/src/libphigs/phg/phg_swap.c +++ b/src/libphigs/phg/phg_swap.c @@ -331,6 +331,13 @@ static void phg_swap_gcolr( (*swp->conv_float)((float *) &fdata[1]); (*swp->conv_float)((float *) &fdata[2]); } + else if (gcolr.type == PMODEL_RGBA) { + fdata = (Pfloat *) &idata[1]; + (*swp->conv_float)((float *) &fdata[0]); + (*swp->conv_float)((float *) &fdata[1]); + (*swp->conv_float)((float *) &fdata[2]); + (*swp->conv_float)((float *) &fdata[3]); + } } /****************************************************************************** diff --git a/src/libphigs/shaders/CMakeLists.txt b/src/libphigs/shaders/CMakeLists.txt new file mode 100644 index 0000000..26af4b7 --- /dev/null +++ b/src/libphigs/shaders/CMakeLists.txt @@ -0,0 +1,30 @@ +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/phigs/private/vs120.h + COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/create_shader_include_files.py + ${CMAKE_SOURCE_DIR}/libphigs/shaders/vs120.vert vertex_shader_text_120 > ${CMAKE_BINARY_DIR}/include/phigs/private/vs120.h + DEPENDS ${CMAKE_SOURCE_DIR}/libphigs/shaders/vs120.vert +) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/phigs/private/fs120.h + COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/create_shader_include_files.py + ${CMAKE_SOURCE_DIR}/libphigs/shaders/fs120.frag fragment_shader_text_120 > ${CMAKE_BINARY_DIR}/include/phigs/private/fs120.h + DEPENDS ${CMAKE_SOURCE_DIR}/libphigs/shaders/fs120.frag +) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/phigs/private/vs130.h + COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/create_shader_include_files.py + ${CMAKE_SOURCE_DIR}/libphigs/shaders/vs130.vert vertex_shader_text_130 > ${CMAKE_BINARY_DIR}/include/phigs/private/vs130.h + DEPENDS ${CMAKE_SOURCE_DIR}/libphigs/shaders/vs130.vert +) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/phigs/private/fs130.h + COMMAND python3 ${CMAKE_SOURCE_DIR}/tools/create_shader_include_files.py + ${CMAKE_SOURCE_DIR}/libphigs/shaders/fs130.frag fragment_shader_text_130 > ${CMAKE_BINARY_DIR}/include/phigs/private/fs130.h + DEPENDS ${CMAKE_SOURCE_DIR}/libphigs/shaders/fs130.frag +) +add_custom_target(generate_shaders_vs120 DEPENDS ${CMAKE_BINARY_DIR}/include/phigs/private/vs120.h) +add_custom_target(generate_shaders_vs130 DEPENDS ${CMAKE_BINARY_DIR}/include/phigs/private/vs130.h) +add_custom_target(generate_shaders_fs120 DEPENDS ${CMAKE_BINARY_DIR}/include/phigs/private/fs120.h) +add_custom_target(generate_shaders_fs130 DEPENDS ${CMAKE_BINARY_DIR}/include/phigs/private/fs130.h) +add_dependencies(phigs generate_shaders_vs120 generate_shaders_vs130 generate_shaders_fs120 generate_shaders_fs130) +add_dependencies(phigs-shared generate_shaders_vs120 generate_shaders_vs130 generate_shaders_fs120 generate_shaders_fs130) diff --git a/src/libphigs/shaders/fs120.frag b/src/libphigs/shaders/fs120.frag new file mode 100644 index 0000000..c083645 --- /dev/null +++ b/src/libphigs/shaders/fs120.frag @@ -0,0 +1,133 @@ +#version 120 +uniform int ShadingMode; +uniform vec4 vAmbient; +uniform vec4 vDiffuse; +uniform vec4 vSpecular; +uniform int lightSource0; +uniform int lightSourceTyp0; +uniform vec4 lightSourceCol0; +uniform vec4 lightSourcePos0; +uniform vec4 lightSourceCoef0; +uniform int lightSource1; +uniform int lightSourceTyp1; +uniform vec4 lightSourceCol1; +uniform vec4 lightSourcePos1; +uniform vec4 lightSourceCoef1; +uniform int lightSource2; +uniform int lightSourceTyp2; +uniform vec4 lightSourceCol2; +uniform vec4 lightSourcePos2; +uniform vec4 lightSourceCoef2; +uniform int lightSource3; +uniform int lightSourceTyp3; +uniform vec4 lightSourceCol3; +uniform vec4 lightSourcePos3; +uniform vec4 lightSourceCoef3; +uniform int lightSource4; +uniform int lightSourceTyp4; +uniform vec4 lightSourceCol4; +uniform vec4 lightSourcePos4; +uniform vec4 lightSourceCoef4; +uniform int lightSource5; +uniform int lightSourceTyp5; +uniform vec4 lightSourceCol5; +uniform vec4 lightSourcePos5; +uniform vec4 lightSourceCoef5; +uniform int lightSource6; +uniform int lightSourceTyp6; +uniform vec4 lightSourceCol6; +uniform vec4 lightSourcePos6; +uniform vec4 lightSourceCoef6; +varying vec4 Normal; +varying vec4 Color; +varying float v_clipDist0; +varying float v_clipDist1; + +/* + * getLight: returns the RGB contribution of a single light source. + * + * Fix 1 (darkness): removed the global "/tot" normalization that divided + * every light's contribution by the combined magnitude of vAmbient + + * vDiffuse + vSpecular. That division could easily exceed 4.0 for + * ordinary material colors, crushing brightness well below intended + * levels, especially with few lights active. Standard ambient+diffuse+ + * specular summation does not require this step; the final min(...,1.0) + * clamp in main() already guards against over-brightening when many + * lights are summed. + * + * Fix 2 (alpha): alpha is no longer computed here at all. Previously each + * light contributed its own alpha value (vAmbient.w, vDiffuse.w, or a + * hardcoded 1.0 for specular), and main() summed these across every + * active light, so final alpha depended on how many lights were on + * rather than on the material's actual transparency. Alpha is now + * handled once in main(), from Color.a. + */ +vec4 getLight(int type, vec4 color, vec4 pos, vec4 coef){ + vec3 light = vec3(0.5, 0.5, 0.5); + float refl = 0.0; + float angle = Normal.x*pos.x+Normal.y*pos.y+Normal.z*pos.z; + float lennorm = sqrt(Normal.x*Normal.x+Normal.y*Normal.y+Normal.z*Normal.z); + float lenpos = sqrt(pos.x*pos.x+pos.y*pos.y+pos.z*pos.z); + if (lennorm == 0.0) lennorm = 1.0; + if (lenpos == 0.0) lenpos = 1.0; + angle = max(angle/lennorm/lenpos, 0.0); + + if (type == 1) { + /* ambient: flat contribution, independent of angle */ + light = color.rgb * vAmbient.rgb; + }; + if (type == 2) { + /* diffuse: falls off with angle between normal and light direction */ + light = color.rgb * vDiffuse.rgb * angle; + }; + if (type == 3) { + /* specular: NOTE this still uses N.L ("angle"), not a true reflection + or half-vector dot product, so it behaves like a sharpened diffuse + term rather than a physically-correct specular highlight. Left + unchanged from the original behavior; flagging in case you want to + revisit it separately. */ + refl = coef.x * pow(angle, coef.y); + light = vSpecular.rgb * refl; + }; + return vec4(light, 0.0); +} + +void main() +{ + int i; + /* clipping */ + if (v_clipDist0 < 0.0 || v_clipDist1 < 0.0) discard; + if (ShadingMode > 0) { + int n = 0; + gl_FragColor = vec4(0., 0., 0., 0.); + for (i=0; i<7; i++){ + if (i==0) { + if (lightSource0 > 0){ gl_FragColor += getLight(lightSourceTyp0, lightSourceCol0, lightSourcePos0, lightSourceCoef0);n += 1;}; + } + if (i==1) { + if (lightSource1 > 0){ gl_FragColor += getLight(lightSourceTyp1, lightSourceCol1, lightSourcePos1, lightSourceCoef1);n += 1;}; + } + if (i==2) { + if (lightSource2 > 0){ gl_FragColor += getLight(lightSourceTyp2, lightSourceCol2, lightSourcePos2, lightSourceCoef2);n += 1;}; + } + if (i==3) { + if (lightSource3 > 0){ gl_FragColor += getLight(lightSourceTyp3, lightSourceCol3, lightSourcePos3, lightSourceCoef3);n += 1;}; + } + if (i==4) { + if (lightSource4 > 0){ gl_FragColor += getLight(lightSourceTyp4, lightSourceCol4, lightSourcePos4, lightSourceCoef4);n += 1;}; + } + if (i==5) { + if (lightSource5 > 0){ gl_FragColor += getLight(lightSourceTyp5, lightSourceCol5, lightSourcePos5, lightSourceCoef5);n += 1;}; + } + if (i==6) { + if (lightSource6 > 0){ gl_FragColor += getLight(lightSourceTyp6, lightSourceCol6, lightSourcePos6, lightSourceCoef6);n += 1;}; + } + }; + if (n > 0){ + gl_FragColor.rgb = min(gl_FragColor.rgb, vec3(1., 1., 1.)); + gl_FragColor.a = Color.a; + } else { gl_FragColor = Color;}; + } else { + gl_FragColor = Color; + }; +}; diff --git a/src/libphigs/shaders/fs130.frag b/src/libphigs/shaders/fs130.frag new file mode 100644 index 0000000..0d12bd5 --- /dev/null +++ b/src/libphigs/shaders/fs130.frag @@ -0,0 +1,123 @@ +#version 130 +uniform int ShadingMode; +uniform vec4 vAmbient; +uniform vec4 vDiffuse; +uniform vec4 vSpecular; + +uniform int lightSource0; +uniform int lightSourceTyp0; +uniform vec4 lightSourceCol0; +uniform vec4 lightSourcePos0; +uniform vec4 lightSourceCoef0; + +uniform int lightSource1; +uniform int lightSourceTyp1; +uniform vec4 lightSourceCol1; +uniform vec4 lightSourcePos1; +uniform vec4 lightSourceCoef1; + +uniform int lightSource2; +uniform int lightSourceTyp2; +uniform vec4 lightSourceCol2; +uniform vec4 lightSourcePos2; +uniform vec4 lightSourceCoef2; + +uniform int lightSource3; +uniform int lightSourceTyp3; +uniform vec4 lightSourceCol3; +uniform vec4 lightSourcePos3; +uniform vec4 lightSourceCoef3; + +uniform int lightSource4; +uniform int lightSourceTyp4; +uniform vec4 lightSourceCol4; +uniform vec4 lightSourcePos4; +uniform vec4 lightSourceCoef4; + +uniform int lightSource5; +uniform int lightSourceTyp5; +uniform vec4 lightSourceCol5; +uniform vec4 lightSourcePos5; +uniform vec4 lightSourceCoef5; + +uniform int lightSource6; +uniform int lightSourceTyp6; +uniform vec4 lightSourceCol6; +uniform vec4 lightSourcePos6; +uniform vec4 lightSourceCoef6; + +in vec4 Color; +in vec4 Normal; +out vec4 FragColor; + +vec4 getLight(int type, vec4 color, vec4 pos, vec4 coef){ + vec4 light; + float refl = 0.0; + float angle = Normal.x*pos.x+Normal.y*pos.y+Normal.z*pos.z; + float lennorm = sqrt(Normal.x*Normal.x+Normal.y*Normal.y+Normal.z*Normal.z); + float lenpos = sqrt(pos.x*pos.x+pos.y*pos.y+pos.z*pos.z); + float atot = sqrt(vAmbient.x*vAmbient.x+vAmbient.y*vAmbient.y+vAmbient.z*vAmbient.z+vAmbient.w*vAmbient.w); + float dtot = sqrt(vDiffuse.x*vDiffuse.x+vDiffuse.y*vDiffuse.y+vDiffuse.z*vDiffuse.z+vDiffuse.w*vDiffuse.w); + float stot = sqrt(vSpecular.x*vSpecular.x+vSpecular.y*vSpecular.y+vSpecular.z*vSpecular.z+vSpecular.w*vSpecular.w); + float tot = atot+dtot+stot; + if (tot <= 0) tot = 0.2; + if (lennorm == 0.0) lennorm = 1.0; + if (lenpos == 0.0) lenpos = 1.0; + angle = max(angle/lennorm/lenpos, 0.0); + switch (type) { + case 1: + light = color * vAmbient * vec4(1.0/tot, 1.0/tot, 1.0/tot, 1.0); + break; + case 2: + light = color * vDiffuse * angle * vec4(1.0/tot, 1.0/tot, 1.0/tot, 1.0);; + break; + case 3: + refl = coef.x * pow(angle, coef.y); + light = vSpecular * vec4(refl/tot, refl/tot, refl/tot, 1.0); + break; + default: + light = vec4(0.5, 0.5, 0.5, 1.0); + break; + }; + return light; +} +void main() +{ + int i; + if (ShadingMode > 0) { + int n = 0; + FragColor = vec4(0., 0., 0, 1.); + for (i=0; i<7; i++){ + switch (i) { + case 0: + if (lightSource0 > 0){ FragColor += getLight(lightSourceTyp0, lightSourceCol0, lightSourcePos0, lightSourceCoef0);n += 1;}; + break; + case 1: + if (lightSource1 > 0){ FragColor += getLight(lightSourceTyp1, lightSourceCol1, lightSourcePos1, lightSourceCoef1);n += 1;}; + break; + case 2: + if (lightSource2 > 0){ FragColor += getLight(lightSourceTyp2, lightSourceCol2, lightSourcePos2, lightSourceCoef2);n += 1;}; + break; + case 3: + if (lightSource3 > 0){ FragColor += getLight(lightSourceTyp3, lightSourceCol3, lightSourcePos3, lightSourceCoef3);n += 1;}; + break; + case 4: + if (lightSource4 > 0){ FragColor += getLight(lightSourceTyp4, lightSourceCol4, lightSourcePos4, lightSourceCoef4);n += 1;}; + break; + case 5: + if (lightSource5 > 0){ FragColor += getLight(lightSourceTyp5, lightSourceCol5, lightSourcePos5, lightSourceCoef5);n += 1;}; + break; + case 6: + if (lightSource6 > 0){ FragColor += getLight(lightSourceTyp6, lightSourceCol6, lightSourcePos6, lightSourceCoef6);n += 1;}; + break; + default: + break; + }; + }; + if (n > 0){ + FragColor = min(FragColor, vec4(1., 1., 1., 1.)); + } else { FragColor = Color;}; + } else { + FragColor = Color; + }; +}; diff --git a/src/libphigs/shaders/vs120.vert b/src/libphigs/shaders/vs120.vert new file mode 100644 index 0000000..d218fc6 --- /dev/null +++ b/src/libphigs/shaders/vs120.vert @@ -0,0 +1,39 @@ +#version 120 +uniform mat4 ModelViewMatrix; +uniform mat4 ProjectionMatrix; +attribute vec4 vColor; +varying vec4 Color; +varying vec4 Normal; +uniform int num_clip_planes; +uniform int clipping_ind; +uniform vec4 plane0; +uniform vec4 point0; +uniform vec4 plane1; +uniform vec4 point1; + +varying float v_clipDist0; +varying float v_clipDist1; + + +void main() +{ + Color = vColor; + Normal = normalize(ModelViewMatrix * vec4(gl_Normal, 1)); + gl_Position = ProjectionMatrix * ModelViewMatrix * gl_Vertex; + + if (clipping_ind > 0) { + if (num_clip_planes == 1) { + v_clipDist0 = dot(gl_Vertex - point0, plane0); + v_clipDist1 = 1.0; + } else if (num_clip_planes == 2) { + v_clipDist0 = dot(gl_Vertex - point0, plane0); + v_clipDist1 = dot(gl_Vertex - point1, plane1); + } else { + v_clipDist0 = 1.0; + v_clipDist1 = 1.0; + } + } else { + v_clipDist0 = 1.0; + v_clipDist1 = 1.0; + } +}; diff --git a/src/libphigs/shaders/vs130.vert b/src/libphigs/shaders/vs130.vert new file mode 100644 index 0000000..27b1638 --- /dev/null +++ b/src/libphigs/shaders/vs130.vert @@ -0,0 +1,36 @@ +#version 130 +in vec4 vColor; +out vec4 Color; +out vec4 Normal; +out float gl_ClipDistance[6]; +uniform mat4 ModelViewMatrix; +uniform mat4 ProjectionMatrix; +uniform int num_clip_planes; +uniform int clipping_ind; +uniform vec4 plane0; +uniform vec4 point0; +uniform vec4 plane1; +uniform vec4 point1; +float distance; + +void main() +{ + Color = vColor; + Normal = normalize(ModelViewMatrix * vec4(gl_Normal, 1)); + gl_Position = ProjectionMatrix * ModelViewMatrix * gl_Vertex; + + if (clipping_ind > 0) { + if (num_clip_planes == 1) { + gl_ClipDistance[0] = dot(gl_Vertex-point0, plane0); + } else if (num_clip_planes == 2) { + gl_ClipDistance[0] = dot(gl_Vertex-point0, plane0); + gl_ClipDistance[1] = -dot(gl_Vertex-point1, plane1); + } else { + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 1.0; + } + } else { + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 1.0; + }; +}; diff --git a/src/libphigs/utils/fasd3.c b/src/libphigs/utils/fasd3.c index 7406fcb..7965596 100644 --- a/src/libphigs/utils/fasd3.c +++ b/src/libphigs/utils/fasd3.c @@ -1,25 +1,25 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* (C) 2022-2024 CERN -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * (C) 2022-2024 CERN + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include @@ -39,78 +39,78 @@ */ void fasd3_head( - Pfasd3 *fasd3, - void *pdata - ) + Pfasd3 *fasd3, + void *pdata + ) { - Pint i, num_edges; - char *tp; - Pint *data = (Pint *) pdata; - - fasd3->fflag = data[0]; - fasd3->eflag = data[1]; - fasd3->vflag = data[2]; - fasd3->colr_type = data[3]; - tp = (char *) &data[4]; - - switch (fasd3->fflag) { - case PFACET_COLOUR: - memcpy(&fasd3->fdata.colr, tp, sizeof(Pcoval)); - tp += sizeof(Pcoval); - break; - - case PFACET_NORMAL: - memcpy(&fasd3->fdata.norm, tp, sizeof(Pvec3)); - tp += sizeof(Pvec3); - break; - - case PFACET_COLOUR_NORMAL: - memcpy(&fasd3->fdata.conorm, tp, sizeof(Pconorm3)); - tp += sizeof(Pconorm3); - break; - - default: - break; - } - - data = (Pint *) tp; - fasd3->nfa = data[0]; - tp = (char *) &data[1]; - - if (fasd3->eflag == PEDGE_VISIBILITY) { + Pint i, num_edges; + char *tp; + Pint *data = (Pint *) pdata; + + fasd3->fflag = data[0]; + fasd3->eflag = data[1]; + fasd3->vflag = data[2]; + fasd3->colr_type = data[3]; + tp = (char *) &data[4]; + + switch (fasd3->fflag) { + case PFACET_COLOUR: + memcpy(&fasd3->fdata.colr, tp, sizeof(Pcoval)); + tp += sizeof(Pcoval); + break; + + case PFACET_NORMAL: + memcpy(&fasd3->fdata.norm, tp, sizeof(Pvec3)); + tp += sizeof(Pvec3); + break; + + case PFACET_COLOUR_NORMAL: + memcpy(&fasd3->fdata.conorm, tp, sizeof(Pconorm3)); + tp += sizeof(Pconorm3); + break; + + default: + break; + } + + data = (Pint *) tp; + fasd3->nfa = data[0]; + tp = (char *) &data[1]; + + if (fasd3->eflag == PEDGE_VISIBILITY) { + data = (Pint *) tp; + fasd3->edata->num_edges = data[0]; + fasd3->edata->edgedata.edges = (Pedge_flag *) &data[1]; + + for (i = 0; i < fasd3->nfa; i++) { data = (Pint *) tp; - fasd3->edata->num_edges = data[0]; - fasd3->edata->edgedata.edges = (Pedge_flag *) &data[1]; - - for (i = 0; i < fasd3->nfa; i++) { - data = (Pint *) tp; - num_edges = data[0]; - tp += sizeof(Pedge_flag) * num_edges + sizeof(Pint); - } - } - - data = (Pint *) tp; - fasd3->vdata->num_vertices = data[0]; - switch (fasd3->vflag) { - case PVERT_COORD: - fasd3->vdata->vertex_data.points = (Ppoint3 *) &data[1]; - break; - - case PVERT_COORD_COLOUR: - fasd3->vdata->vertex_data.ptcolrs = (Pptco3 *) &data[1]; - break; - - case PVERT_COORD_NORMAL: - fasd3->vdata->vertex_data.ptnorms = (Pptnorm3 *) &data[1]; - break; - - case PVERT_COORD_COLOUR_NORMAL: - fasd3->vdata->vertex_data.ptconorms = (Pptconorm3 *) &data[1]; - break; - - default: - break; - } + num_edges = data[0]; + tp += sizeof(Pedge_flag) * num_edges + sizeof(Pint); + } + } + + data = (Pint *) tp; + fasd3->vdata->num_vertices = data[0]; + switch (fasd3->vflag) { + case PVERT_COORD: + fasd3->vdata->vertex_data.points = (Ppoint3 *) &data[1]; + break; + + case PVERT_COORD_COLOUR: + fasd3->vdata->vertex_data.ptcolrs = (Pptco3 *) &data[1]; + break; + + case PVERT_COORD_NORMAL: + fasd3->vdata->vertex_data.ptnorms = (Pptnorm3 *) &data[1]; + break; + + case PVERT_COORD_COLOUR_NORMAL: + fasd3->vdata->vertex_data.ptconorms = (Pptconorm3 *) &data[1]; + break; + + default: + break; + } } /******************************************************************************* @@ -123,19 +123,19 @@ void fasd3_head( */ void fasd3_next_edata( - Pfasd3 *fasd3 - ) + Pfasd3 *fasd3 + ) { - Pint *data; - char *tp; - Pint num_edges; - - num_edges = fasd3->edata->num_edges; - tp = (char *) fasd3->edata->edgedata.edges; - tp += sizeof(Pedge_flag) * num_edges; - data = (Pint *) tp; - fasd3->edata->num_edges = data[0]; - fasd3->edata->edgedata.edges = (Pedge_flag *) &data[1]; + Pint *data; + char *tp; + Pint num_edges; + + num_edges = fasd3->edata->num_edges; + tp = (char *) fasd3->edata->edgedata.edges; + tp += sizeof(Pedge_flag) * num_edges; + data = (Pint *) tp; + fasd3->edata->num_edges = data[0]; + fasd3->edata->edgedata.edges = (Pedge_flag *) &data[1]; } /******************************************************************************* @@ -148,49 +148,49 @@ void fasd3_next_edata( */ void fasd3_next_vdata3( - Pfasd3 *fasd3 - ) + Pfasd3 *fasd3 + ) { - Pint *data; - char *tp; - Pint num_vertices = fasd3->vdata->num_vertices; - - switch (fasd3->vflag) { - case PVERT_COORD: - tp = (char *) fasd3->vdata->vertex_data.points; - tp += sizeof(Ppoint3) * num_vertices; - data = (Pint *) tp; - fasd3->vdata->num_vertices = data[0]; - fasd3->vdata->vertex_data.points = (Ppoint3 *) &data[1]; - break; - - case PVERT_COORD_COLOUR: - tp = (char *) fasd3->vdata->vertex_data.ptcolrs; - tp += sizeof(Pptco3) * num_vertices; - data = (Pint *) tp; - fasd3->vdata->num_vertices = data[0]; - fasd3->vdata->vertex_data.ptcolrs = (Pptco3 *) &data[1]; - break; - - case PVERT_COORD_NORMAL: - tp = (char *) fasd3->vdata->vertex_data.ptnorms; - tp += sizeof(Pptnorm3); - data = (Pint *) tp; - fasd3->vdata->num_vertices = data[0]; - fasd3->vdata->vertex_data.ptnorms = (Pptnorm3 *) &data[1]; - break; - - case PVERT_COORD_COLOUR_NORMAL: - tp = (char *) fasd3->vdata->vertex_data.ptconorms; - tp += sizeof(Pptconorm3) * num_vertices; - data = (Pint *) tp; - fasd3->vdata->num_vertices = data[0]; - fasd3->vdata->vertex_data.ptconorms = (Pptconorm3 *) &data[1]; - break; - - default: - break; - } + Pint *data; + char *tp; + Pint num_vertices = fasd3->vdata->num_vertices; + + switch (fasd3->vflag) { + case PVERT_COORD: + tp = (char *) fasd3->vdata->vertex_data.points; + tp += sizeof(Ppoint3) * num_vertices; + data = (Pint *) tp; + fasd3->vdata->num_vertices = data[0]; + fasd3->vdata->vertex_data.points = (Ppoint3 *) &data[1]; + break; + + case PVERT_COORD_COLOUR: + tp = (char *) fasd3->vdata->vertex_data.ptcolrs; + tp += sizeof(Pptco3) * num_vertices; + data = (Pint *) tp; + fasd3->vdata->num_vertices = data[0]; + fasd3->vdata->vertex_data.ptcolrs = (Pptco3 *) &data[1]; + break; + + case PVERT_COORD_NORMAL: + tp = (char *) fasd3->vdata->vertex_data.ptnorms; + tp += sizeof(Pptnorm3); + data = (Pint *) tp; + fasd3->vdata->num_vertices = data[0]; + fasd3->vdata->vertex_data.ptnorms = (Pptnorm3 *) &data[1]; + break; + + case PVERT_COORD_COLOUR_NORMAL: + tp = (char *) fasd3->vdata->vertex_data.ptconorms; + tp += sizeof(Pptconorm3) * num_vertices; + data = (Pint *) tp; + fasd3->vdata->num_vertices = data[0]; + fasd3->vdata->vertex_data.ptconorms = (Pptconorm3 *) &data[1]; + break; + + default: + break; + } } /******************************************************************************* @@ -201,68 +201,68 @@ void fasd3_next_vdata3( */ void fasd3_normal3( - Pvec3 *norm, - Pfasd3 *fasd3 - ) + Pvec3 *norm, + Pfasd3 *fasd3 + ) { - Pvec3 a, b, c; - Pvec3 v1, v2; - Pfloat angle; - - switch(fasd3->vflag) { - case PVERT_COORD: - a.delta_x = fasd3->vdata->vertex_data.points[0].x; - a.delta_y = fasd3->vdata->vertex_data.points[0].y; - a.delta_z = fasd3->vdata->vertex_data.points[0].z; - b.delta_x = fasd3->vdata->vertex_data.points[1].x; - b.delta_y = fasd3->vdata->vertex_data.points[1].y; - b.delta_z = fasd3->vdata->vertex_data.points[1].z; - c.delta_x = fasd3->vdata->vertex_data.points[2].x; - c.delta_y = fasd3->vdata->vertex_data.points[2].y; - c.delta_z = fasd3->vdata->vertex_data.points[2].z; - break; - - case PVERT_COORD_COLOUR: - a.delta_x = fasd3->vdata->vertex_data.ptcolrs[0].point.x; - a.delta_y = fasd3->vdata->vertex_data.ptcolrs[0].point.y; - a.delta_z = fasd3->vdata->vertex_data.ptcolrs[0].point.z; - b.delta_x = fasd3->vdata->vertex_data.ptcolrs[1].point.x; - b.delta_y = fasd3->vdata->vertex_data.ptcolrs[1].point.y; - b.delta_z = fasd3->vdata->vertex_data.ptcolrs[1].point.z; - c.delta_x = fasd3->vdata->vertex_data.ptcolrs[2].point.x; - c.delta_y = fasd3->vdata->vertex_data.ptcolrs[2].point.y; - c.delta_z = fasd3->vdata->vertex_data.ptcolrs[2].point.z; - break; - - case PVERT_COORD_NORMAL: - a.delta_x = fasd3->vdata->vertex_data.ptnorms[0].point.x; - a.delta_y = fasd3->vdata->vertex_data.ptnorms[0].point.y; - a.delta_z = fasd3->vdata->vertex_data.ptnorms[0].point.z; - b.delta_x = fasd3->vdata->vertex_data.ptnorms[1].point.x; - b.delta_y = fasd3->vdata->vertex_data.ptnorms[1].point.y; - b.delta_z = fasd3->vdata->vertex_data.ptnorms[1].point.z; - c.delta_x = fasd3->vdata->vertex_data.ptnorms[2].point.x; - c.delta_y = fasd3->vdata->vertex_data.ptnorms[2].point.y; - c.delta_z = fasd3->vdata->vertex_data.ptnorms[2].point.z; - break; - - case PVERT_COORD_COLOUR_NORMAL: - a.delta_x = fasd3->vdata->vertex_data.ptconorms[0].point.x; - a.delta_y = fasd3->vdata->vertex_data.ptconorms[0].point.y; - a.delta_z = fasd3->vdata->vertex_data.ptconorms[0].point.z; - b.delta_x = fasd3->vdata->vertex_data.ptconorms[1].point.x; - b.delta_y = fasd3->vdata->vertex_data.ptconorms[1].point.y; - b.delta_z = fasd3->vdata->vertex_data.ptconorms[1].point.z; - c.delta_x = fasd3->vdata->vertex_data.ptconorms[2].point.x; - c.delta_y = fasd3->vdata->vertex_data.ptconorms[2].point.y; - c.delta_z = fasd3->vdata->vertex_data.ptconorms[2].point.z; - break; - } - - phg_vector_sub(&v1, &b, &a); - phg_vector_sub(&v2, &c, &a); - phg_vector_cross_prod(norm, &v1, &v2); - /* ensure the direction to point outward */ - angle = phg_vector_dot_prod(norm, &a); - if (angle > 0) phg_vector_cross_prod(norm, &v2, &v1); + Pvec3 a, b, c; + Pvec3 v1, v2; + Pfloat angle; + + switch(fasd3->vflag) { + case PVERT_COORD: + a.delta_x = fasd3->vdata->vertex_data.points[0].x; + a.delta_y = fasd3->vdata->vertex_data.points[0].y; + a.delta_z = fasd3->vdata->vertex_data.points[0].z; + b.delta_x = fasd3->vdata->vertex_data.points[1].x; + b.delta_y = fasd3->vdata->vertex_data.points[1].y; + b.delta_z = fasd3->vdata->vertex_data.points[1].z; + c.delta_x = fasd3->vdata->vertex_data.points[2].x; + c.delta_y = fasd3->vdata->vertex_data.points[2].y; + c.delta_z = fasd3->vdata->vertex_data.points[2].z; + break; + + case PVERT_COORD_COLOUR: + a.delta_x = fasd3->vdata->vertex_data.ptcolrs[0].point.x; + a.delta_y = fasd3->vdata->vertex_data.ptcolrs[0].point.y; + a.delta_z = fasd3->vdata->vertex_data.ptcolrs[0].point.z; + b.delta_x = fasd3->vdata->vertex_data.ptcolrs[1].point.x; + b.delta_y = fasd3->vdata->vertex_data.ptcolrs[1].point.y; + b.delta_z = fasd3->vdata->vertex_data.ptcolrs[1].point.z; + c.delta_x = fasd3->vdata->vertex_data.ptcolrs[2].point.x; + c.delta_y = fasd3->vdata->vertex_data.ptcolrs[2].point.y; + c.delta_z = fasd3->vdata->vertex_data.ptcolrs[2].point.z; + break; + + case PVERT_COORD_NORMAL: + a.delta_x = fasd3->vdata->vertex_data.ptnorms[0].point.x; + a.delta_y = fasd3->vdata->vertex_data.ptnorms[0].point.y; + a.delta_z = fasd3->vdata->vertex_data.ptnorms[0].point.z; + b.delta_x = fasd3->vdata->vertex_data.ptnorms[1].point.x; + b.delta_y = fasd3->vdata->vertex_data.ptnorms[1].point.y; + b.delta_z = fasd3->vdata->vertex_data.ptnorms[1].point.z; + c.delta_x = fasd3->vdata->vertex_data.ptnorms[2].point.x; + c.delta_y = fasd3->vdata->vertex_data.ptnorms[2].point.y; + c.delta_z = fasd3->vdata->vertex_data.ptnorms[2].point.z; + break; + + case PVERT_COORD_COLOUR_NORMAL: + a.delta_x = fasd3->vdata->vertex_data.ptconorms[0].point.x; + a.delta_y = fasd3->vdata->vertex_data.ptconorms[0].point.y; + a.delta_z = fasd3->vdata->vertex_data.ptconorms[0].point.z; + b.delta_x = fasd3->vdata->vertex_data.ptconorms[1].point.x; + b.delta_y = fasd3->vdata->vertex_data.ptconorms[1].point.y; + b.delta_z = fasd3->vdata->vertex_data.ptconorms[1].point.z; + c.delta_x = fasd3->vdata->vertex_data.ptconorms[2].point.x; + c.delta_y = fasd3->vdata->vertex_data.ptconorms[2].point.y; + c.delta_z = fasd3->vdata->vertex_data.ptconorms[2].point.z; + break; + } + + phg_vector_sub(&v1, &b, &a); + phg_vector_sub(&v2, &c, &a); + phg_vector_cross_prod(norm, &v1, &v2); + /* ensure the direction to point outward */ + angle = phg_vector_dot_prod(norm, &a); + if (angle > 0) phg_vector_cross_prod(norm, &v2, &v1); } diff --git a/src/libphigs/utils/sofas3.c b/src/libphigs/utils/sofas3.c index 116411c..2ecbee9 100644 --- a/src/libphigs/utils/sofas3.c +++ b/src/libphigs/utils/sofas3.c @@ -1,22 +1,22 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ******************************************************************************/ #include #include @@ -37,32 +37,32 @@ */ static void priv_vdata( - Psofas3 *sofas3 - ) + Psofas3 *sofas3 + ) { - Pint *data = (Pint *) sofas3->vlist; + Pint *data = (Pint *) sofas3->vlist; - sofas3->vdata.num_vertices = *data; - switch (sofas3->vflag) { - case PVERT_COORD: - sofas3->vdata.vertex_data.points = (Ppoint3 *) &data[1]; - break; + sofas3->vdata.num_vertices = *data; + switch (sofas3->vflag) { + case PVERT_COORD: + sofas3->vdata.vertex_data.points = (Ppoint3 *) &data[1]; + break; - case PVERT_COORD_COLOUR: - sofas3->vdata.vertex_data.ptcolrs = (Pptco3 *) &data[1]; - break; + case PVERT_COORD_COLOUR: + sofas3->vdata.vertex_data.ptcolrs = (Pptco3 *) &data[1]; + break; - case PVERT_COORD_NORMAL: - sofas3->vdata.vertex_data.ptnorms = (Pptnorm3 *) &data[1]; - break; + case PVERT_COORD_NORMAL: + sofas3->vdata.vertex_data.ptnorms = (Pptnorm3 *) &data[1]; + break; - case PVERT_COORD_COLOUR_NORMAL: - sofas3->vdata.vertex_data.ptconorms = (Pptconorm3 *) &data[1]; - break; + case PVERT_COORD_COLOUR_NORMAL: + sofas3->vdata.vertex_data.ptconorms = (Pptconorm3 *) &data[1]; + break; - default: - break; - } + default: + break; + } } /******************************************************************************* @@ -73,77 +73,77 @@ static void priv_vdata( */ void sofas3_head( - Psofas3 *sofas3, - void *pdata - ) + Psofas3 *sofas3, + void *pdata + ) { - Pint i, j; - Pint num_lists; - Pint_list vlist; - Pedge_data_list elist; - Pedge_data_list_list *estart; - char *tp; - Pint *data = (Pint *) pdata; - - sofas3->fflag = data[0]; - sofas3->eflag = data[1]; - sofas3->vflag = data[2]; - sofas3->colr_type = data[3]; - sofas3->num_sets = data[4]; - tp = (char *) &data[5]; - - switch (sofas3->fflag) { - case PFACET_COLOUR: - sofas3->fdata.colrs = (Pcoval *) tp; - tp += sizeof(Pcoval) * sofas3->num_sets; - break; - - case PFACET_NORMAL: - sofas3->fdata.norms = (Pvec3 *) tp; - tp += sizeof(Pvec3) * sofas3->num_sets; - break; - - case PFACET_COLOUR_NORMAL: - sofas3->fdata.conorms = (Pconorm3 *) tp; - tp += sizeof(Pconorm3) * sofas3->num_sets; - break; - - default: - break; - } - - if (sofas3->eflag == PEDGE_VISIBILITY) { - sofas3->edata = (Pedge_data_list_list *) tp; - estart = sofas3->edata; - - /* Move forward and setup edge lists */ - for (i = 0; i < sofas3->num_sets; i++) { - num_lists = sofas3_num_elists(sofas3); - for (j = 0; j < num_lists; j++) { - sofas3_next_elist(&elist, sofas3); - } + Pint i, j; + Pint num_lists; + Pint_list vlist; + Pedge_data_list elist; + Pedge_data_list_list *estart; + char *tp; + Pint *data = (Pint *) pdata; + + sofas3->fflag = data[0]; + sofas3->eflag = data[1]; + sofas3->vflag = data[2]; + sofas3->colr_type = data[3]; + sofas3->num_sets = data[4]; + tp = (char *) &data[5]; + + switch (sofas3->fflag) { + case PFACET_COLOUR: + sofas3->fdata.colrs = (Pcoval *) tp; + tp += sizeof(Pcoval) * sofas3->num_sets; + break; + + case PFACET_NORMAL: + sofas3->fdata.norms = (Pvec3 *) tp; + tp += sizeof(Pvec3) * sofas3->num_sets; + break; + + case PFACET_COLOUR_NORMAL: + sofas3->fdata.conorms = (Pconorm3 *) tp; + tp += sizeof(Pconorm3) * sofas3->num_sets; + break; + + default: + break; + } + + if (sofas3->eflag == PEDGE_VISIBILITY) { + sofas3->edata = (Pedge_data_list_list *) tp; + estart = sofas3->edata; + + /* Move forward and setup edge lists */ + for (i = 0; i < sofas3->num_sets; i++) { + num_lists = sofas3_num_elists(sofas3); + for (j = 0; j < num_lists; j++) { + sofas3_next_elist(&elist, sofas3); } - tp = (char *) sofas3->edata; + } + tp = (char *) sofas3->edata; - /* Restore pointer to first edge list */ - sofas3->edata = estart; - } + /* Restore pointer to first edge list */ + sofas3->edata = estart; + } - sofas3->vlist = (Pint_list_list *) tp; + sofas3->vlist = (Pint_list_list *) tp; - /* Move forward and setup vertext lists */ - for (i = 0; i < sofas3->num_sets; i++) { - num_lists = sofas3_num_vlists(sofas3); - for (j = 0; j < num_lists; j++) { - sofas3_next_vlist(&vlist, sofas3); - } - } + /* Move forward and setup vertext lists */ + for (i = 0; i < sofas3->num_sets; i++) { + num_lists = sofas3_num_vlists(sofas3); + for (j = 0; j < num_lists; j++) { + sofas3_next_vlist(&vlist, sofas3); + } + } - /* Setup pointers to vertex data */ - priv_vdata(sofas3); + /* Setup pointers to vertex data */ + priv_vdata(sofas3); - /* Restore pointer to first vertex list */ - sofas3->vlist = (Pint_list_list *) tp; + /* Restore pointer to first vertex list */ + sofas3->vlist = (Pint_list_list *) tp; } /******************************************************************************* @@ -154,14 +154,14 @@ void sofas3_head( */ int sofas3_num_vlists( - Psofas3 *sofas3 - ) + Psofas3 *sofas3 + ) { - Pint *data = (Pint *) sofas3->vlist; - Pint num_lists = data[0]; - sofas3->vlist = (Pint_list_list *) &data[1]; + Pint *data = (Pint *) sofas3->vlist; + Pint num_lists = data[0]; + sofas3->vlist = (Pint_list_list *) &data[1]; - return num_lists; + return num_lists; } /******************************************************************************* @@ -172,15 +172,15 @@ int sofas3_num_vlists( */ void sofas3_get_vlist( - Pint_list *vlist, - Psofas3 *sofas3 - ) + Pint_list *vlist, + Psofas3 *sofas3 + ) { - Pint *data = (Pint *) sofas3->vlist; + Pint *data = (Pint *) sofas3->vlist; - vlist->num_ints = data[0]; - data = &data[1]; - vlist->ints = data; + vlist->num_ints = data[0]; + data = &data[1]; + vlist->ints = data; } /******************************************************************************* @@ -191,16 +191,16 @@ void sofas3_get_vlist( */ void sofas3_next_vlist( - Pint_list *vlist, - Psofas3 *sofas3 - ) + Pint_list *vlist, + Psofas3 *sofas3 + ) { - Pint *data = (Pint *) sofas3->vlist; + Pint *data = (Pint *) sofas3->vlist; - vlist->num_ints = data[0]; - data = &data[1]; - vlist->ints = data; - sofas3->vlist = (Pint_list_list *) &data[vlist->num_ints]; + vlist->num_ints = data[0]; + data = &data[1]; + vlist->ints = data; + sofas3->vlist = (Pint_list_list *) &data[vlist->num_ints]; } /******************************************************************************* @@ -211,14 +211,14 @@ void sofas3_next_vlist( */ int sofas3_num_elists( - Psofas3 *sofas3 - ) + Psofas3 *sofas3 + ) { - Pint *data = (Pint *) sofas3->edata; - Pint num_lists = data[0]; - sofas3->edata = (Pedge_data_list_list *) &data[1]; + Pint *data = (Pint *) sofas3->edata; + Pint num_lists = data[0]; + sofas3->edata = (Pedge_data_list_list *) &data[1]; - return num_lists; + return num_lists; } /******************************************************************************* @@ -229,18 +229,18 @@ int sofas3_num_elists( */ void sofas3_next_elist( - Pedge_data_list *elist, - Psofas3 *sofas3 - ) + Pedge_data_list *elist, + Psofas3 *sofas3 + ) { - Pint *data = (Pint *) sofas3->edata; - Pedge_flag *edata; - - elist->num_edges = data[0]; - data = &data[1]; - edata = (Pedge_flag *) data; - elist->edgedata.edges = edata; - sofas3->edata = (Pedge_data_list_list *) &edata[elist->num_edges]; + Pint *data = (Pint *) sofas3->edata; + Pedge_flag *edata; + + elist->num_edges = data[0]; + data = &data[1]; + edata = (Pedge_flag *) data; + elist->edgedata.edges = edata; + sofas3->edata = (Pedge_data_list_list *) &edata[elist->num_edges]; } /******************************************************************************* @@ -251,72 +251,72 @@ void sofas3_next_elist( */ void sofas3_normal3( - Pvec3 *norm, - Psofas3 *sofas3, - Pint_list *vlist - ) + Pvec3 *norm, + Psofas3 *sofas3, + Pint_list *vlist + ) { - Pint vert1, vert2, vert3; - Pvec3 a, b, c; - Pvec3 v1, v2; - - vert1 = vlist->ints[0]; - vert2 = vlist->ints[1]; - vert3 = vlist->ints[2]; - - switch(sofas3->vflag) { - case PVERT_COORD: - a.delta_x = sofas3->vdata.vertex_data.points[vert1].x; - a.delta_y = sofas3->vdata.vertex_data.points[vert1].y; - a.delta_z = sofas3->vdata.vertex_data.points[vert1].z; - b.delta_x = sofas3->vdata.vertex_data.points[vert2].x; - b.delta_y = sofas3->vdata.vertex_data.points[vert2].y; - b.delta_z = sofas3->vdata.vertex_data.points[vert2].z; - c.delta_x = sofas3->vdata.vertex_data.points[vert3].x; - c.delta_y = sofas3->vdata.vertex_data.points[vert3].y; - c.delta_z = sofas3->vdata.vertex_data.points[vert3].z; - break; - - case PVERT_COORD_COLOUR: - a.delta_x = sofas3->vdata.vertex_data.ptcolrs[vert1].point.x; - a.delta_y = sofas3->vdata.vertex_data.ptcolrs[vert1].point.y; - a.delta_z = sofas3->vdata.vertex_data.ptcolrs[vert1].point.z; - b.delta_x = sofas3->vdata.vertex_data.ptcolrs[vert2].point.x; - b.delta_y = sofas3->vdata.vertex_data.ptcolrs[vert2].point.y; - b.delta_z = sofas3->vdata.vertex_data.ptcolrs[vert2].point.z; - c.delta_x = sofas3->vdata.vertex_data.ptcolrs[vert3].point.x; - c.delta_y = sofas3->vdata.vertex_data.ptcolrs[vert3].point.y; - c.delta_z = sofas3->vdata.vertex_data.ptcolrs[vert3].point.z; - break; - - case PVERT_COORD_NORMAL: - a.delta_x = sofas3->vdata.vertex_data.ptnorms[vert1].point.x; - a.delta_y = sofas3->vdata.vertex_data.ptnorms[vert1].point.y; - a.delta_z = sofas3->vdata.vertex_data.ptnorms[vert1].point.z; - b.delta_x = sofas3->vdata.vertex_data.ptnorms[vert2].point.x; - b.delta_y = sofas3->vdata.vertex_data.ptnorms[vert2].point.y; - b.delta_z = sofas3->vdata.vertex_data.ptnorms[vert2].point.z; - c.delta_x = sofas3->vdata.vertex_data.ptnorms[vert3].point.x; - c.delta_y = sofas3->vdata.vertex_data.ptnorms[vert3].point.y; - c.delta_z = sofas3->vdata.vertex_data.ptnorms[vert3].point.z; - break; - - case PVERT_COORD_COLOUR_NORMAL: - a.delta_x = sofas3->vdata.vertex_data.ptconorms[vert1].point.x; - a.delta_y = sofas3->vdata.vertex_data.ptconorms[vert1].point.y; - a.delta_z = sofas3->vdata.vertex_data.ptconorms[vert1].point.z; - b.delta_x = sofas3->vdata.vertex_data.ptconorms[vert2].point.x; - b.delta_y = sofas3->vdata.vertex_data.ptconorms[vert2].point.y; - b.delta_z = sofas3->vdata.vertex_data.ptconorms[vert2].point.z; - c.delta_x = sofas3->vdata.vertex_data.ptconorms[vert3].point.x; - c.delta_y = sofas3->vdata.vertex_data.ptconorms[vert3].point.y; - c.delta_z = sofas3->vdata.vertex_data.ptconorms[vert3].point.z; - break; - } - - phg_vector_sub(&v1, &b, &a); - phg_vector_sub(&v2, &c, &a); - phg_vector_cross_prod(norm, &v1, &v2); + Pint vert1, vert2, vert3; + Pvec3 a, b, c; + Pvec3 v1, v2; + + vert1 = vlist->ints[0]; + vert2 = vlist->ints[1]; + vert3 = vlist->ints[2]; + + switch(sofas3->vflag) { + case PVERT_COORD: + a.delta_x = sofas3->vdata.vertex_data.points[vert1].x; + a.delta_y = sofas3->vdata.vertex_data.points[vert1].y; + a.delta_z = sofas3->vdata.vertex_data.points[vert1].z; + b.delta_x = sofas3->vdata.vertex_data.points[vert2].x; + b.delta_y = sofas3->vdata.vertex_data.points[vert2].y; + b.delta_z = sofas3->vdata.vertex_data.points[vert2].z; + c.delta_x = sofas3->vdata.vertex_data.points[vert3].x; + c.delta_y = sofas3->vdata.vertex_data.points[vert3].y; + c.delta_z = sofas3->vdata.vertex_data.points[vert3].z; + break; + + case PVERT_COORD_COLOUR: // FIXME ? + a.delta_x = sofas3->vdata.vertex_data.ptcolrs[vert1].point.x; + a.delta_y = sofas3->vdata.vertex_data.ptcolrs[vert1].point.y; + a.delta_z = sofas3->vdata.vertex_data.ptcolrs[vert1].point.z; + b.delta_x = sofas3->vdata.vertex_data.ptcolrs[vert2].point.x; + b.delta_y = sofas3->vdata.vertex_data.ptcolrs[vert2].point.y; + b.delta_z = sofas3->vdata.vertex_data.ptcolrs[vert2].point.z; + c.delta_x = sofas3->vdata.vertex_data.ptcolrs[vert3].point.x; + c.delta_y = sofas3->vdata.vertex_data.ptcolrs[vert3].point.y; + c.delta_z = sofas3->vdata.vertex_data.ptcolrs[vert3].point.z; + break; + + case PVERT_COORD_NORMAL: + a.delta_x = sofas3->vdata.vertex_data.ptnorms[vert1].point.x; + a.delta_y = sofas3->vdata.vertex_data.ptnorms[vert1].point.y; + a.delta_z = sofas3->vdata.vertex_data.ptnorms[vert1].point.z; + b.delta_x = sofas3->vdata.vertex_data.ptnorms[vert2].point.x; + b.delta_y = sofas3->vdata.vertex_data.ptnorms[vert2].point.y; + b.delta_z = sofas3->vdata.vertex_data.ptnorms[vert2].point.z; + c.delta_x = sofas3->vdata.vertex_data.ptnorms[vert3].point.x; + c.delta_y = sofas3->vdata.vertex_data.ptnorms[vert3].point.y; + c.delta_z = sofas3->vdata.vertex_data.ptnorms[vert3].point.z; + break; + + case PVERT_COORD_COLOUR_NORMAL: + a.delta_x = sofas3->vdata.vertex_data.ptconorms[vert1].point.x; + a.delta_y = sofas3->vdata.vertex_data.ptconorms[vert1].point.y; + a.delta_z = sofas3->vdata.vertex_data.ptconorms[vert1].point.z; + b.delta_x = sofas3->vdata.vertex_data.ptconorms[vert2].point.x; + b.delta_y = sofas3->vdata.vertex_data.ptconorms[vert2].point.y; + b.delta_z = sofas3->vdata.vertex_data.ptconorms[vert2].point.z; + c.delta_x = sofas3->vdata.vertex_data.ptconorms[vert3].point.x; + c.delta_y = sofas3->vdata.vertex_data.ptconorms[vert3].point.y; + c.delta_z = sofas3->vdata.vertex_data.ptconorms[vert3].point.z; + break; + } + + phg_vector_sub(&v1, &b, &a); + phg_vector_sub(&v2, &c, &a); + phg_vector_cross_prod(norm, &v1, &v2); } /******************************************************************************* @@ -327,94 +327,112 @@ void sofas3_normal3( */ void sofas3_print( - Psofas3 *sofas3 - ) + Psofas3 *sofas3 + ) { - Pint i, j, k; - Pint num_lists; - Pint_list vlist; - Pedge_data_list elist; - - printf("Facet flags:\t%d\n", sofas3->fflag); - printf("Edge flags:\t%d\n", sofas3->eflag); - printf("Vertex flags:\t%d\n", sofas3->vflag); - printf("Colour type:\t%d\n", sofas3->colr_type); - printf("Num sets:\t%d\n", sofas3->num_sets); - - printf("\n"); - for (i = 0; i < sofas3->num_sets; i++) { - printf("Set #%d\t", i); - switch (sofas3->fflag) { - case PFACET_COLOUR: - printf("Colour: %g, %g, %g\n", - sofas3->fdata.colrs[i].direct.rgb.red, - sofas3->fdata.colrs[i].direct.rgb.green, - sofas3->fdata.colrs[i].direct.rgb.blue); - break; - - case PFACET_NORMAL: - printf("Normal: %g, %g, %g\n", - sofas3->fdata.norms[i].delta_x, - sofas3->fdata.norms[i].delta_y, - sofas3->fdata.norms[i].delta_z); - break; - - case PFACET_COLOUR_NORMAL: - printf("Colour: %g, %g, %g\n", - sofas3->fdata.conorms[i].colr.direct.rgb.red, - sofas3->fdata.conorms[i].colr.direct.rgb.green, - sofas3->fdata.conorms[i].colr.direct.rgb.blue); - printf("Normal: %g, %g, %g\n", - sofas3->fdata.conorms[i].norm.delta_x, - sofas3->fdata.conorms[i].norm.delta_y, - sofas3->fdata.conorms[i].norm.delta_z); - break; - - default: - break; + Pint i, j, k; + Pint num_lists; + Pint_list vlist; + Pedge_data_list elist; + + printf("Facet flags:\t%d\n", sofas3->fflag); + printf("Edge flags:\t%d\n", sofas3->eflag); + printf("Vertex flags:\t%d\n", sofas3->vflag); + printf("Colour type:\t%d\n", sofas3->colr_type); + printf("Num sets:\t%d\n", sofas3->num_sets); + + printf("\n"); + for (i = 0; i < sofas3->num_sets; i++) { + printf("Set #%d\t", i); + switch (sofas3->fflag) { + case PFACET_COLOUR: + if ( sofas3->colr_type == PMODEL_RGB){ + printf("Colour: %g, %g, %g\n", + sofas3->fdata.colrs[i].direct.rgb.red, + sofas3->fdata.colrs[i].direct.rgb.green, + sofas3->fdata.colrs[i].direct.rgb.blue + ); + } else { + printf("Colour: %g, %g, %g %g\n", + sofas3->fdata.colrs[i].direct.rgba.red, + sofas3->fdata.colrs[i].direct.rgba.green, + sofas3->fdata.colrs[i].direct.rgba.blue, + sofas3->fdata.colrs[i].direct.rgba.alpha + ); } - } - - if (sofas3->eflag == PEDGE_VISIBILITY) { - printf("\n"); - for (i = 0; i < sofas3->num_sets; i++) { - num_lists = sofas3_num_elists(sofas3); - printf("Set #%d, num lists: %d\n", i, num_lists); - for (j = 0; j < num_lists; j++) { - sofas3_next_elist(&elist, sofas3); - printf("\tList #%d, num_edges: %d\t", j, elist.num_edges); - for (k = 0; k < elist.num_edges; k++) { - printf("%s ", - (elist.edgedata.edges[k] == PEDGE_ON) ? "ON" : "OFF"); - } - printf("\n"); - } + break; + + case PFACET_NORMAL: + printf("Normal: %g, %g, %g\n", + sofas3->fdata.norms[i].delta_x, + sofas3->fdata.norms[i].delta_y, + sofas3->fdata.norms[i].delta_z); + break; + + case PFACET_COLOUR_NORMAL: + if ( sofas3->colr_type == PMODEL_RGB){ + printf("Colour: %g, %g, %g\n", + sofas3->fdata.conorms[i].colr.direct.rgb.red, + sofas3->fdata.conorms[i].colr.direct.rgb.green, + sofas3->fdata.conorms[i].colr.direct.rgb.blue); + } else { + printf("Colour: %g, %g, %g %g\n", + sofas3->fdata.conorms[i].colr.direct.rgba.red, + sofas3->fdata.conorms[i].colr.direct.rgba.green, + sofas3->fdata.conorms[i].colr.direct.rgba.blue, + sofas3->fdata.conorms[i].colr.direct.rgba.alpha + ); } - } - - - printf("\n"); - for (i = 0; i < sofas3->num_sets; i++) { - num_lists = sofas3_num_vlists(sofas3); + printf("Normal: %g, %g, %g\n", + sofas3->fdata.conorms[i].norm.delta_x, + sofas3->fdata.conorms[i].norm.delta_y, + sofas3->fdata.conorms[i].norm.delta_z); + break; + + default: + break; + } + } + + if (sofas3->eflag == PEDGE_VISIBILITY) { + printf("\n"); + for (i = 0; i < sofas3->num_sets; i++) { + num_lists = sofas3_num_elists(sofas3); printf("Set #%d, num lists: %d\n", i, num_lists); for (j = 0; j < num_lists; j++) { - sofas3_next_vlist(&vlist, sofas3); - printf("\tList #%d, num_ints: %d\t", j, vlist.num_ints); - for (k = 0; k < vlist.num_ints; k++) { - printf("%d ", vlist.ints[k]); - } - printf("\n"); + sofas3_next_elist(&elist, sofas3); + printf("\tList #%d, num_edges: %d\t", j, elist.num_edges); + for (k = 0; k < elist.num_edges; k++) { + printf("%s ", + (elist.edgedata.edges[k] == PEDGE_ON) ? "ON" : "OFF"); + } + printf("\n"); } - } - - priv_vdata(sofas3); - printf("\nNum vertices: %d\n", sofas3->vdata.num_vertices); - for (i = 0; i < sofas3->vdata.num_vertices; i++) { - printf("#%d:\t%g %g %g\n", i, - sofas3->vdata.vertex_data.points[i].x, - sofas3->vdata.vertex_data.points[i].y, - sofas3->vdata.vertex_data.points[i].z); - } + } + } + + printf("\n"); + for (i = 0; i < sofas3->num_sets; i++) { + num_lists = sofas3_num_vlists(sofas3); + printf("Set #%d, num lists: %d\n", i, num_lists); + for (j = 0; j < num_lists; j++) { + sofas3_next_vlist(&vlist, sofas3); + printf("\tList #%d, num_ints: %d\t", j, vlist.num_ints); + for (k = 0; k < vlist.num_ints; k++) { + printf("%d ", vlist.ints[k]); + } + printf("\n"); + } + } + + priv_vdata(sofas3); + printf("\nNum vertices: %d\n", sofas3->vdata.num_vertices); + for (i = 0; i < sofas3->vdata.num_vertices; i++) { + printf("#%d:\t%g %g %g\n", i, + sofas3->vdata.vertex_data.points[i].x, + sofas3->vdata.vertex_data.points[i].y, + sofas3->vdata.vertex_data.points[i].z); + } } /******************************************************************************* @@ -425,12 +443,11 @@ void sofas3_print( */ void sofas3_list( - void *pdata - ) + void *pdata + ) { - Psofas3 sofas3; + Psofas3 sofas3; - sofas3_head(&sofas3, pdata); - sofas3_print(&sofas3); + sofas3_head(&sofas3, pdata); + sofas3_print(&sofas3); } - diff --git a/src/libphigs/ws/wsb.c b/src/libphigs/ws/wsb.c index 550b35c..e6e1edc 100644 --- a/src/libphigs/ws/wsb.c +++ b/src/libphigs/ws/wsb.c @@ -1620,12 +1620,30 @@ void phg_wsb_set_rep( case PHG_ARGS_COREP: /* Store in current colour model. */ gcolr.type = ws->current_colour_model; - gcolr.val.general.x = rep->bundl.corep.rgb.red; - gcolr.val.general.y = rep->bundl.corep.rgb.green; - gcolr.val.general.z = rep->bundl.corep.rgb.blue; + switch(gcolr.type){ + case PMODEL_RGB: + gcolr.val.general.x = rep->bundl.corep.rgb.red; + gcolr.val.general.y = rep->bundl.corep.rgb.green; + gcolr.val.general.z = rep->bundl.corep.rgb.blue; + break; + case PMODEL_RGBA: + gcolr.val.general.x = rep->bundl.corep.rgba.red; + gcolr.val.general.y = rep->bundl.corep.rgba.green; + gcolr.val.general.z = rep->bundl.corep.rgba.blue; + gcolr.val.general.a = rep->bundl.corep.rgba.alpha; +#ifdef DEBUG + printf("Index: %d colors %f %f %f %f\n", + rep->index, + gcolr.val.general.x, + gcolr.val.general.y, + gcolr.val.general.z, + gcolr.val.general.a + ); +#endif + break; + } phg_wsb_set_LUT_entry(ws, type, rep, &gcolr); break; - case PHG_ARGS_VIEWREP: #ifdef DEBUG printf("Set view: %d\n", rep->index); @@ -1782,7 +1800,8 @@ void phg_wsb_inq_rep( Pgcolr gcolr; Pcolr_rep *cb; Pview_rep3 vrep; - + int * crash; + crash = NULL; ret->err = 0; switch ( rep_type ) { case PHG_ARGS_LNREP: @@ -1809,16 +1828,44 @@ void phg_wsb_inq_rep( /* Need to convert to current colour model. */ phg_wsb_inq_LUT_entry(ws, index, how, rep_type, ret, &gcolr, NULL); - - /* NOTE: - * Convert to correct colour model here if needed - */ - - cb->rgb.red = gcolr.val.general.x; - cb->rgb.green = gcolr.val.general.y; - cb->rgb.blue = gcolr.val.general.z; - break; - + if (ret->err == 0){ +#ifdef DEBUGA + printf("inq_rep index %d rgba=%f %f %f %f\n",index, + gcolr.type, gcolr.val.general.x, + gcolr.type, gcolr.val.general.y, + gcolr.type, gcolr.val.general.z, + gcolr.type, gcolr.val.general.a + ); +#endif + /* NOTE: + * Convert to correct colour model here if needed + */ + switch (gcolr.type) { + case PMODEL_RGB: + cb->rgb.red = gcolr.val.general.x; + cb->rgb.green = gcolr.val.general.y; + cb->rgb.blue = gcolr.val.general.z; + break; + case PMODEL_RGBA: + cb->rgba.red = gcolr.val.general.x; + cb->rgba.green = gcolr.val.general.y; + cb->rgba.blue = gcolr.val.general.z; + cb->rgba.alpha = gcolr.val.general.a; + break; + default: +#ifdef DEBUGA + printf("FATA: Provoking crash: %d\n", gcolr.type); + *crash = 0; +#endif + break; + }; + break; + } else { + gcolr.type = -1; +#ifdef DEBUGA + printf("INFO: Color index %d is not defined.\n", index); +#endif + } case PHG_ARGS_VIEWREP: phg_wsb_inq_LUT_entry(ws, index, how, rep_type, ret, NULL, &vrep); memcpy(&ret->data.rep.viewrep, &vrep, sizeof(Pview_rep3)); diff --git a/src/libphigs/ws/wsb_lut.c b/src/libphigs/ws/wsb_lut.c index 3ff1f87..3831b20 100644 --- a/src/libphigs/ws/wsb_lut.c +++ b/src/libphigs/ws/wsb_lut.c @@ -1,24 +1,24 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include @@ -44,23 +44,23 @@ */ static int phg_create_table( - Hash_table *htab, - Pint *err, - int hash_size - ) + Hash_table *htab, + Pint *err, + int hash_size + ) { - int status; - - *htab = phg_htab_create(hash_size); - if (*htab == NULL) { - *err = ERR900; - status = 0; - } - else { - status = 1; - } - - return status; + int status; + + *htab = phg_htab_create(hash_size); + if (*htab == NULL) { + *err = ERR900; + status = 0; + } + else { + status = 1; + } + + return status; } /******************************************************************************* @@ -71,60 +71,60 @@ static int phg_create_table( */ int phg_wsb_create_LUTs( - Ws *ws - ) + Ws *ws + ) { - Pint err; - int status = 1; - Ws_output_ws *ows = &ws->out_ws; - - if (!phg_create_table(&ows->htab.line, &err, HASH_SIZE)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.marker, &err, HASH_SIZE)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.text, &err, HASH_SIZE)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.interior, &err, HASH_SIZE)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.edge, &err, HASH_SIZE)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.colour, &err, 100)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.view, &err, 20)) { - status = 0; - goto end; - } - - if (!phg_create_table(&ows->htab.light_source, &err, HASH_SIZE)) { - status = 0; - goto end; - } - -end: - - if (!status) { - phg_wsb_destroy_LUTs(ws); - } - - return status; + Pint err; + int status = 1; + Ws_output_ws *ows = &ws->out_ws; + + if (!phg_create_table(&ows->htab.line, &err, HASH_SIZE)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.marker, &err, HASH_SIZE)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.text, &err, HASH_SIZE)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.interior, &err, HASH_SIZE)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.edge, &err, HASH_SIZE)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.colour, &err, 100)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.view, &err, 20)) { + status = 0; + goto end; + } + + if (!phg_create_table(&ows->htab.light_source, &err, HASH_SIZE)) { + status = 0; + goto end; + } + + end: + + if (!status) { + phg_wsb_destroy_LUTs(ws); + } + + return status; } /******************************************************************************* @@ -135,27 +135,27 @@ int phg_wsb_create_LUTs( */ void phg_wsb_destroy_LUTs( - Ws *ws - ) + Ws *ws + ) { - Ws_output_ws *ows = &ws->out_ws; - - if (ows->htab.line) - phg_htab_destroy(ows->htab.line, (void(*)(int, char *))NULL); - if (ows->htab.marker) - phg_htab_destroy(ows->htab.marker, (void(*)(int, char *))NULL); - if (ows->htab.text) - phg_htab_destroy(ows->htab.text, (void(*)(int, char *))NULL); - if (ows->htab.interior) - phg_htab_destroy(ows->htab.interior, (void(*)(int, char *))NULL); - if (ows->htab.edge) - phg_htab_destroy(ows->htab.edge, (void(*)(int, char*))NULL); - if (ows->htab.colour) - phg_htab_destroy(ows->htab.colour, (void(*)(int, char *))NULL); - if (ows->htab.view) - phg_htab_destroy(ows->htab.view, (void(*)(int, char *))NULL); - if (ows->htab.light_source) - phg_htab_destroy(ows->htab.light_source, (void(*)(int, char *))NULL); + Ws_output_ws *ows = &ws->out_ws; + + if (ows->htab.line) + phg_htab_destroy(ows->htab.line, (void(*)(int, char *))NULL); + if (ows->htab.marker) + phg_htab_destroy(ows->htab.marker, (void(*)(int, char *))NULL); + if (ows->htab.text) + phg_htab_destroy(ows->htab.text, (void(*)(int, char *))NULL); + if (ows->htab.interior) + phg_htab_destroy(ows->htab.interior, (void(*)(int, char *))NULL); + if (ows->htab.edge) + phg_htab_destroy(ows->htab.edge, (void(*)(int, char*))NULL); + if (ows->htab.colour) + phg_htab_destroy(ows->htab.colour, (void(*)(int, char *))NULL); + if (ows->htab.view) + phg_htab_destroy(ows->htab.view, (void(*)(int, char *))NULL); + if (ows->htab.light_source) + phg_htab_destroy(ows->htab.light_source, (void(*)(int, char *))NULL); } /******************************************************************************* @@ -166,616 +166,620 @@ void phg_wsb_destroy_LUTs( */ void phg_wsb_set_LUT_entry( - Ws *ws, - Phg_args_rep_type type, - Phg_args_rep_data *rep, - Pgcolr *gcolr - ) + Ws *ws, + Phg_args_rep_type type, + Phg_args_rep_data *rep, + Pgcolr *gcolr + ) { - caddr_t data; - Ws_output_ws *ows = &ws->out_ws; + caddr_t data; + Ws_output_ws *ows = &ws->out_ws; - switch(type) { - case PHG_ARGS_LNREP: + switch(type) { + case PHG_ARGS_LNREP: #ifdef DEBUG - printf("Set lnrep %d\n", rep->index); + printf("Set lnrep %d\n", rep->index); #endif - data = malloc(sizeof(Pline_bundle_plus)); - if (data != NULL) { - memset(data, 0, sizeof(Pline_bundle_plus)); - ((Pline_bundle_plus *) data)->type = rep->bundl.lnrep.type; - ((Pline_bundle_plus *) data)->width = rep->bundl.lnrep.width; - ((Pline_bundle_plus *) data)->colr.type = PINDIRECT; - ((Pline_bundle_plus *) data)->colr.val.ind = - rep->bundl.lnrep.colr_ind; - if (!phg_htab_add_entry(ows->htab.line, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_EXTLNREP: + data = malloc(sizeof(Pline_bundle_plus)); + if (data != NULL) { + memset(data, 0, sizeof(Pline_bundle_plus)); + ((Pline_bundle_plus *) data)->type = rep->bundl.lnrep.type; + ((Pline_bundle_plus *) data)->width = rep->bundl.lnrep.width; + ((Pline_bundle_plus *) data)->colr.type = PINDIRECT; + ((Pline_bundle_plus *) data)->colr.val.ind = + rep->bundl.lnrep.colr_ind; + if (!phg_htab_add_entry(ows->htab.line, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_EXTLNREP: #ifdef DEBUG - printf("Set extlnrep: %d\n", rep->index); + printf("Set extlnrep: %d\n", rep->index); #endif - data = malloc(sizeof(Pline_bundle_plus)); - if (data != NULL) { - memcpy(data, &rep->bundl.extlnrep, sizeof(Pline_bundle_plus)); - if (!phg_htab_add_entry(ows->htab.line, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_MKREP: + data = malloc(sizeof(Pline_bundle_plus)); + if (data != NULL) { + memcpy(data, &rep->bundl.extlnrep, sizeof(Pline_bundle_plus)); + if (!phg_htab_add_entry(ows->htab.line, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_MKREP: #ifdef DEBUG - printf("Set mkrep: %d\n", rep->index); + printf("Set mkrep: %d\n", rep->index); #endif - data = malloc(sizeof(Pmarker_bundle_plus)); - if (data != NULL) { - memset(data, 0, sizeof(Pmarker_bundle_plus)); - ((Pmarker_bundle_plus *) data)->type = rep->bundl.mkrep.type; - ((Pmarker_bundle_plus *) data)->size = rep->bundl.mkrep.size; - ((Pmarker_bundle_plus *) data)->colr.type = PINDIRECT; - ((Pmarker_bundle_plus *) data)->colr.val.ind = - rep->bundl.mkrep.colr_ind; - if (!phg_htab_add_entry(ows->htab.marker, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_EXTMKREP: + data = malloc(sizeof(Pmarker_bundle_plus)); + if (data != NULL) { + memset(data, 0, sizeof(Pmarker_bundle_plus)); + ((Pmarker_bundle_plus *) data)->type = rep->bundl.mkrep.type; + ((Pmarker_bundle_plus *) data)->size = rep->bundl.mkrep.size; + ((Pmarker_bundle_plus *) data)->colr.type = PINDIRECT; + ((Pmarker_bundle_plus *) data)->colr.val.ind = + rep->bundl.mkrep.colr_ind; + if (!phg_htab_add_entry(ows->htab.marker, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_EXTMKREP: #ifdef DEBUG - printf("Set extmkrep: %d\n", rep->index); + printf("Set extmkrep: %d\n", rep->index); #endif - data = malloc(sizeof(Pmarker_bundle_plus)); - if (data != NULL) { - memcpy(data, &rep->bundl.extmkrep, sizeof(Pmarker_bundle_plus)); - if (!phg_htab_add_entry(ows->htab.marker, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_TXREP: + data = malloc(sizeof(Pmarker_bundle_plus)); + if (data != NULL) { + memcpy(data, &rep->bundl.extmkrep, sizeof(Pmarker_bundle_plus)); + if (!phg_htab_add_entry(ows->htab.marker, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_TXREP: #ifdef DEBUG - printf("Set txrep: %d\n", rep->index); + printf("Set txrep: %d\n", rep->index); #endif - data = malloc(sizeof(Ptext_bundle_plus)); - if (data != NULL) { - memset(data, 0, sizeof(Ptext_bundle_plus)); - ((Ptext_bundle_plus *) data)->font = rep->bundl.txrep.font; - ((Ptext_bundle_plus *) data)->colr.type = PINDIRECT; - ((Ptext_bundle_plus *) data)->colr.val.ind = - rep->bundl.txrep.colr_ind; - if (!phg_htab_add_entry(ows->htab.text, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_EXTTXREP: + data = malloc(sizeof(Ptext_bundle_plus)); + if (data != NULL) { + memset(data, 0, sizeof(Ptext_bundle_plus)); + ((Ptext_bundle_plus *) data)->font = rep->bundl.txrep.font; + ((Ptext_bundle_plus *) data)->colr.type = PINDIRECT; + ((Ptext_bundle_plus *) data)->colr.val.ind = + rep->bundl.txrep.colr_ind; + if (!phg_htab_add_entry(ows->htab.text, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_EXTTXREP: #ifdef DEBUG - printf("Set exttxrep: %d\n", rep->index); + printf("Set exttxrep: %d\n", rep->index); #endif - data = malloc(sizeof(Ptext_bundle_plus)); - if (data != NULL) { - memcpy(data, &rep->bundl.exttxrep, sizeof(Ptext_bundle_plus)); - if (!phg_htab_add_entry(ows->htab.text, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_INTERREP: + data = malloc(sizeof(Ptext_bundle_plus)); + if (data != NULL) { + memcpy(data, &rep->bundl.exttxrep, sizeof(Ptext_bundle_plus)); + if (!phg_htab_add_entry(ows->htab.text, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_INTERREP: #ifdef DEBUG - printf("Set interrep: %d\n", rep->index); + printf("Set interrep: %d\n", rep->index); #endif - data = malloc(sizeof(Pint_bundle_plus)); - if (data != NULL) { - memset(data, 0, sizeof(Pint_bundle_plus)); - ((Pint_bundle_plus *) data)->style = rep->bundl.interrep.style; - ((Pint_bundle_plus *) data)->style_ind = - rep->bundl.interrep.style_ind; - ((Pint_bundle_plus *) data)->colr.type = PINDIRECT; - ((Pint_bundle_plus *) data)->colr.val.ind = - rep->bundl.interrep.colr_ind; - if (!phg_htab_add_entry(ows->htab.interior, - rep->index, - data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_EXTINTERREP: + data = malloc(sizeof(Pint_bundle_plus)); + if (data != NULL) { + memset(data, 0, sizeof(Pint_bundle_plus)); + ((Pint_bundle_plus *) data)->style = rep->bundl.interrep.style; + ((Pint_bundle_plus *) data)->style_ind = + rep->bundl.interrep.style_ind; + ((Pint_bundle_plus *) data)->colr.type = PINDIRECT; + ((Pint_bundle_plus *) data)->colr.val.ind = + rep->bundl.interrep.colr_ind; + ((Pint_bundle_plus *) data)->back_colr.type = PINDIRECT; + ((Pint_bundle_plus *) data)->back_colr.val.ind = + rep->bundl.interrep.colr_ind; + if (!phg_htab_add_entry(ows->htab.interior, + rep->index, + data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_EXTINTERREP: #ifdef DEBUG - printf("Set extinterrep: %d\n", rep->index); + printf("Set extinterrep: %d\n", rep->index); #endif - data = malloc(sizeof(Pint_bundle_plus)); - if (data != NULL) { - memcpy(data, - &rep->bundl.extinterrep, - sizeof(Pint_bundle_plus)); - if (!phg_htab_add_entry(ows->htab.interior, - rep->index, - data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_EDGEREP: + data = malloc(sizeof(Pint_bundle_plus)); + if (data != NULL) { + memcpy(data, + &rep->bundl.extinterrep, + sizeof(Pint_bundle_plus)); + if (!phg_htab_add_entry(ows->htab.interior, + rep->index, + data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_EDGEREP: #ifdef DEBUG - printf("Set edgerep: %d\n", rep->index); + printf("Set edgerep: %d\n", rep->index); #endif - data = malloc(sizeof(Pedge_bundle_plus)); - if (data != NULL) { - memset(data, 0, sizeof(Pedge_bundle_plus)); - ((Pedge_bundle_plus *) data)->flag = rep->bundl.edgerep.flag; - ((Pedge_bundle_plus *) data)->type = rep->bundl.edgerep.type; - ((Pedge_bundle_plus *) data)->width = rep->bundl.edgerep.width; - ((Pedge_bundle_plus *) data)->colr.type = PINDIRECT; - ((Pedge_bundle_plus *) data)->colr.val.ind = - rep->bundl.edgerep.colr_ind; - if (!phg_htab_add_entry(ows->htab.edge, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_EXTEDGEREP: + data = malloc(sizeof(Pedge_bundle_plus)); + if (data != NULL) { + memset(data, 0, sizeof(Pedge_bundle_plus)); + ((Pedge_bundle_plus *) data)->flag = rep->bundl.edgerep.flag; + ((Pedge_bundle_plus *) data)->type = rep->bundl.edgerep.type; + ((Pedge_bundle_plus *) data)->width = rep->bundl.edgerep.width; + ((Pedge_bundle_plus *) data)->colr.type = PINDIRECT; + ((Pedge_bundle_plus *) data)->colr.val.ind = + rep->bundl.edgerep.colr_ind; + if (!phg_htab_add_entry(ows->htab.edge, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_EXTEDGEREP: #ifdef DEBUG - printf("Set extedgerep: %d\n", rep->index); + printf("Set extedgerep: %d\n", rep->index); #endif - data = malloc(sizeof(Pedge_bundle_plus)); - if (data != NULL) { - memcpy(data, &rep->bundl.extedgerep, sizeof(Pedge_bundle_plus)); - if (!phg_htab_add_entry(ows->htab.edge, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_COREP: + data = malloc(sizeof(Pedge_bundle_plus)); + if (data != NULL) { + memcpy(data, &rep->bundl.extedgerep, sizeof(Pedge_bundle_plus)); + if (!phg_htab_add_entry(ows->htab.edge, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_COREP: #ifdef DEBUG - printf("Set corep: %d\n", rep->index); + printf("Set corep: %d\n", rep->index); #endif - data = malloc(sizeof(Pgcolr)); - if (data != NULL) { + data = malloc(sizeof(Pgcolr)); + if (data != NULL) { #ifdef DEBUG - printf("Setting gcolr for index=%d %f %f %f\n", rep->index, - gcolr->val.general.x, - gcolr->val.general.y, - gcolr->val.general.z - ); + printf("Setting gcolr for index=%d %f %f %f\n", rep->index, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a + ); #endif - memcpy(data, gcolr, sizeof(Pgcolr)); - if (!phg_htab_add_entry(ows->htab.colour, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_VIEWREP: + memcpy(data, gcolr, sizeof(Pgcolr)); + if (!phg_htab_add_entry(ows->htab.colour, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_VIEWREP: #ifdef DEBUG - printf("Set view: %d\n", rep->index); - phg_mat_print(rep->bundl.viewrep.ori_matrix); - printf("\n"); - phg_mat_print(rep->bundl.viewrep.map_matrix); + printf("Set view: %d\n", rep->index); + phg_mat_print(rep->bundl.viewrep.ori_matrix); + printf("\n"); + phg_mat_print(rep->bundl.viewrep.map_matrix); #endif - data = malloc(sizeof(Pview_rep3)); - if (data != NULL) { - memcpy(data, &rep->bundl.viewrep, sizeof(Pview_rep3)); - if (!phg_htab_add_entry(ows->htab.view, rep->index, data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - case PHG_ARGS_LIGHTSRCREP: + data = malloc(sizeof(Pview_rep3)); + if (data != NULL) { + memcpy(data, &rep->bundl.viewrep, sizeof(Pview_rep3)); + if (!phg_htab_add_entry(ows->htab.view, rep->index, data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); + } + break; + + case PHG_ARGS_LIGHTSRCREP: #ifdef DEBUG - printf("Set lightsrcrep: %d\n", rep->index); + printf("Set lightsrcrep: %d\n", rep->index); #endif - data = malloc(sizeof(Plight_src_bundle)); - if (data != NULL) { - memcpy(data, - &rep->bundl.lightsrcrep, - sizeof(Plight_src_bundle)); - if (!phg_htab_add_entry(ows->htab.light_source, - rep->index, - data)) { - ERR_BUF(ws->erh, ERR900); - } - } - else { - ERR_BUF(ws->erh, ERR900); - } - break; - - default: - break; + data = malloc(sizeof(Plight_src_bundle)); + if (data != NULL) { + memcpy(data, + &rep->bundl.lightsrcrep, + sizeof(Plight_src_bundle)); + if (!phg_htab_add_entry(ows->htab.light_source, + rep->index, + data)) { + ERR_BUF(ws->erh, ERR900); + } + } + else { + ERR_BUF(ws->erh, ERR900); } + break; + + default: + break; + } } /******************************************************************************* * phg_wsb_inq_LUT_entry * - * DESCR: Get workstation table entry - * RETURNS: N/A + * DESCR: Get workstation table entry + * RETURNS: N/A */ void phg_wsb_inq_LUT_entry( - Ws *ws, - Pint index, - Pinq_type type, - Phg_args_rep_type rep_type, - Phg_ret *ret, - Pgcolr *gcolr, - Pview_rep3 *vrep - ) + Ws *ws, + Pint index, + Pinq_type type, + Phg_args_rep_type rep_type, + Phg_ret *ret, + Pgcolr *gcolr, + Pview_rep3 *vrep + ) { - caddr_t data; - Phg_ret_rep *rep = &ret->data.rep; - Ws_output_ws *ows = &ws->out_ws; - switch(rep_type) { - case PHG_ARGS_LNREP: - case PHG_ARGS_EXTLNREP: + caddr_t data; + Phg_ret_rep *rep = &ret->data.rep; + Ws_output_ws *ows = &ws->out_ws; + switch(rep_type) { + case PHG_ARGS_LNREP: + case PHG_ARGS_EXTLNREP: #ifdef DEBUG - printf("Inq line: %d\n", index); + printf("Inq line: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.line, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(&rep->extlnrep, data, sizeof(Pline_bundle_plus)); - ret->err = 0; - } - break; - - case PHG_ARGS_MKREP: - case PHG_ARGS_EXTMKREP: + if (!phg_htab_get_entry(ows->htab.line, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(&rep->extlnrep, data, sizeof(Pline_bundle_plus)); + ret->err = 0; + } + break; + + case PHG_ARGS_MKREP: + case PHG_ARGS_EXTMKREP: #ifdef DEBUG - printf("Inq marker: %d\n", index); + printf("Inq marker: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.marker, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(&rep->extmkrep, data, sizeof(Pmarker_bundle_plus)); - ret->err = 0; - } - break; - - case PHG_ARGS_TXREP: - case PHG_ARGS_EXTTXREP: + if (!phg_htab_get_entry(ows->htab.marker, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(&rep->extmkrep, data, sizeof(Pmarker_bundle_plus)); + ret->err = 0; + } + break; + + case PHG_ARGS_TXREP: + case PHG_ARGS_EXTTXREP: #ifdef DEBUG - printf("Inq text: %d\n", index); + printf("Inq text: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.text, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(&rep->exttxrep, data, sizeof(Ptext_bundle_plus)); - ret->err = 0; - } - break; - - case PHG_ARGS_INTERREP: - case PHG_ARGS_EXTINTERREP: + if (!phg_htab_get_entry(ows->htab.text, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(&rep->exttxrep, data, sizeof(Ptext_bundle_plus)); + ret->err = 0; + } + break; + + case PHG_ARGS_INTERREP: + case PHG_ARGS_EXTINTERREP: #ifdef DEBUG - printf("Inq interior: %d\n", index); + printf("Inq interior: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.interior, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(&rep->extinterrep, data, sizeof(Pint_bundle_plus)); - ret->err = 0; - } - break; - - case PHG_ARGS_EDGEREP: - case PHG_ARGS_EXTEDGEREP: + if (!phg_htab_get_entry(ows->htab.interior, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(&rep->extinterrep, data, sizeof(Pint_bundle_plus)); + ret->err = 0; + } + break; + + case PHG_ARGS_EDGEREP: + case PHG_ARGS_EXTEDGEREP: #ifdef DEBUG - printf("Inq edge: %d\n", index); + printf("Inq edge: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.edge, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(&rep->extedgerep, data, sizeof(Pedge_bundle_plus)); - ret->err = 0; - } - break; - - case PHG_ARGS_COREP: + if (!phg_htab_get_entry(ows->htab.edge, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(&rep->extedgerep, data, sizeof(Pedge_bundle_plus)); + ret->err = 0; + } + break; + + case PHG_ARGS_COREP: #ifdef DEBUG - printf("Inq colour: %d\n", index); + printf("Inq colour: %d\n", index); #endif - if (ows == NULL || ows->htab.colour == NULL || !phg_htab_get_entry(ows->htab.colour, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(gcolr, data, sizeof(Pgcolr)); - ret->err = 0; - } - break; - - case PHG_ARGS_VIEWREP: + if (ows == NULL || ows->htab.colour == NULL || !phg_htab_get_entry(ows->htab.colour, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(gcolr, data, sizeof(Pgcolr)); + ret->err = 0; + } + break; + + case PHG_ARGS_VIEWREP: #ifdef DEBUG - printf("Inq view: %d\n", index); + printf("Inq view: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.view, index, &data)) { + if (!phg_htab_get_entry(ows->htab.view, index, &data)) { #ifdef DEBUG - printf("No such view\n"); + printf("No such view\n"); #endif - ret->err = ERR101; - } - else { - memcpy(vrep, data, sizeof(Pview_rep3)); + ret->err = ERR101; + } + else { + memcpy(vrep, data, sizeof(Pview_rep3)); #ifdef DEBUG - printf("Got view:\n"); - phg_mat_print(vrep->ori_matrix); - printf("\n"); - phg_mat_print(vrep->map_matrix); + printf("Got view:\n"); + phg_mat_print(vrep->ori_matrix); + printf("\n"); + phg_mat_print(vrep->map_matrix); #endif - ret->err = 0; - } - break; + ret->err = 0; + } + break; - case PHG_ARGS_LIGHTSRCREP: + case PHG_ARGS_LIGHTSRCREP: #ifdef DEBUG - printf("Inq light source: %d\n", index); + printf("Inq light source: %d\n", index); #endif - if (!phg_htab_get_entry(ows->htab.light_source, index, &data)) { - ret->err = ERR101; - } - else { - memcpy(&rep->lightsrcrep, data, sizeof(Plight_src_bundle)); - ret->err = 0; - } - break; - - default: - break; + if (!phg_htab_get_entry(ows->htab.light_source, index, &data)) { + ret->err = ERR101; + } + else { + memcpy(&rep->lightsrcrep, data, sizeof(Plight_src_bundle)); + ret->err = 0; } + break; + + default: + break; + } } /******************************************************************************* * phg_wsb_inq_LUT_indices * - * DESCR: Get workstation indices in table - * RETURNS: N/A + * DESCR: Get workstation indices in table + * RETURNS: N/A */ void phg_wsb_inq_LUT_indices( - Ws *ws, - Phg_args_rep_type rep_type, - Phg_ret *ret - ) + Ws *ws, + Phg_args_rep_type rep_type, + Phg_ret *ret + ) { - Hash_table htab; - int count; - - switch(rep_type) { - case PHG_ARGS_LNREP: - case PHG_ARGS_EXTLNREP: - htab = ws->out_ws.htab.line; - break; - - case PHG_ARGS_MKREP: - case PHG_ARGS_EXTMKREP: - htab = ws->out_ws.htab.marker; - break; - - case PHG_ARGS_TXREP: - case PHG_ARGS_EXTTXREP: - htab = ws->out_ws.htab.text; - break; - - case PHG_ARGS_INTERREP: - case PHG_ARGS_EXTINTERREP: - htab = ws->out_ws.htab.interior; - break; - - case PHG_ARGS_EDGEREP: - case PHG_ARGS_EXTEDGEREP: - htab = ws->out_ws.htab.edge; - break; - - case PHG_ARGS_COREP: - htab = ws->out_ws.htab.colour; - break; - - case PHG_ARGS_VIEWREP: - htab = ws->out_ws.htab.view; - break; - - case PHG_ARGS_LIGHTSRCREP: - htab = ws->out_ws.htab.light_source; - break; - - default: - ret->data.int_list.num_ints = 0; - return; - } - - count = phg_htab_num_entries(htab); - if (count <= 0) { - ret->data.int_list.num_ints = 0; - ret->err = 0; - } - else if (PHG_SCRATCH_SPACE(&ws->scratch, count * sizeof(Pint))) { - ret->data.int_list.ints = (Pint *) ws->scratch.buf; - ret->data.int_list.num_ints = - phg_htab_get_keys(htab, ret->data.int_list.ints); - ret->err = 0; - } - else { - ret->data.int_list.num_ints = 0; - ret->err = ERR900; - } + Hash_table htab; + int count; + + switch(rep_type) { + case PHG_ARGS_LNREP: + case PHG_ARGS_EXTLNREP: + htab = ws->out_ws.htab.line; + break; + + case PHG_ARGS_MKREP: + case PHG_ARGS_EXTMKREP: + htab = ws->out_ws.htab.marker; + break; + + case PHG_ARGS_TXREP: + case PHG_ARGS_EXTTXREP: + htab = ws->out_ws.htab.text; + break; + + case PHG_ARGS_INTERREP: + case PHG_ARGS_EXTINTERREP: + htab = ws->out_ws.htab.interior; + break; + + case PHG_ARGS_EDGEREP: + case PHG_ARGS_EXTEDGEREP: + htab = ws->out_ws.htab.edge; + break; + + case PHG_ARGS_COREP: + htab = ws->out_ws.htab.colour; + break; + + case PHG_ARGS_VIEWREP: + htab = ws->out_ws.htab.view; + break; + + case PHG_ARGS_LIGHTSRCREP: + htab = ws->out_ws.htab.light_source; + break; + + default: + ret->data.int_list.num_ints = 0; + return; + } + + count = phg_htab_num_entries(htab); + if (count <= 0) { + ret->data.int_list.num_ints = 0; + ret->err = 0; + } + else if (PHG_SCRATCH_SPACE(&ws->scratch, count * sizeof(Pint))) { + ret->data.int_list.ints = (Pint *) ws->scratch.buf; + ret->data.int_list.num_ints = + phg_htab_get_keys(htab, ret->data.int_list.ints); + ret->err = 0; + } + else { + ret->data.int_list.num_ints = 0; + ret->err = ERR900; + } } /******************************************************************************* * phg_wsb_set_name_set * - * DESCR: Set filter name set - * RETURNS: N/A + * DESCR: Set filter name set + * RETURNS: N/A */ void phg_wsb_set_name_set( - Ws *ws, - Phg_args_flt_type type, - Pint dev_id, - Pint_list *incl_set, - Pint_list *excl_set - ) + Ws *ws, + Phg_args_flt_type type, + Pint dev_id, + Pint_list *incl_set, + Pint_list *excl_set + ) { - Ws_inp_pick *pick; - Ws_output_ws *ows = &ws->out_ws; - - switch (type) { - case PHG_ARGS_FLT_INVIS: - phg_nset_names_set(ows->nset.invis_incl, - incl_set->num_ints, - incl_set->ints); - phg_nset_names_set(ows->nset.invis_excl, - excl_set->num_ints, - excl_set->ints); - wsgl_set_filter(ws, - PHG_ARGS_FLT_INVIS, - ows->nset.invis_incl, - ows->nset.invis_excl); - break; - - case PHG_ARGS_FLT_PICK: - pick = &ws->in_ws.devs.pick[dev_id - 1]; - phg_nset_names_set(pick->filter.incl, - incl_set->num_ints, - incl_set->ints); - phg_nset_names_set(pick->filter.excl, - excl_set->num_ints, - excl_set->ints); - break; - - case PHG_ARGS_FLT_HIGH: - phg_nset_names_set(ows->hnset.high_incl, - incl_set->num_ints, - incl_set->ints); - phg_nset_names_set(ows->hnset.high_excl, - excl_set->num_ints, - excl_set->ints); - wsgl_set_filter(ws, - PHG_ARGS_FLT_HIGH, - ows->hnset.high_incl, - ows->hnset.high_excl); - break; - default: - /* TODO: Other filter types */ - break; - } + Ws_inp_pick *pick; + Ws_output_ws *ows = &ws->out_ws; + + switch (type) { + case PHG_ARGS_FLT_INVIS: + phg_nset_names_set(ows->nset.invis_incl, + incl_set->num_ints, + incl_set->ints); + phg_nset_names_set(ows->nset.invis_excl, + excl_set->num_ints, + excl_set->ints); + wsgl_set_filter(ws, + PHG_ARGS_FLT_INVIS, + ows->nset.invis_incl, + ows->nset.invis_excl); + break; + + case PHG_ARGS_FLT_PICK: + pick = &ws->in_ws.devs.pick[dev_id - 1]; + phg_nset_names_set(pick->filter.incl, + incl_set->num_ints, + incl_set->ints); + phg_nset_names_set(pick->filter.excl, + excl_set->num_ints, + excl_set->ints); + break; + + case PHG_ARGS_FLT_HIGH: + phg_nset_names_set(ows->hnset.high_incl, + incl_set->num_ints, + incl_set->ints); + phg_nset_names_set(ows->hnset.high_excl, + excl_set->num_ints, + excl_set->ints); + wsgl_set_filter(ws, + PHG_ARGS_FLT_HIGH, + ows->hnset.high_incl, + ows->hnset.high_excl); + break; + default: + /* TODO: Other filter types */ + break; + } } /******************************************************************************* * phg_wsb_inq_name_set * - * DESCR: Inquery filter name set - * RETURNS: N/A + * DESCR: Inquery filter name set + * RETURNS: N/A */ void phg_wsb_inq_name_set( - Ws *ws, - Phg_args_flt_type type, - Pint dev_id, - Phg_ret *ret - ) + Ws *ws, + Phg_args_flt_type type, + Pint dev_id, + Phg_ret *ret + ) { - Nameset incl; - Nameset excl; - int incl_count; - int excl_count; - Ws_output_ws *ows = &ws->out_ws; - - ret->err = 0; - switch (type) { - case PHG_ARGS_FLT_INVIS: - incl = ows->nset.invis_incl; - excl = ows->nset.invis_excl; - break; - - case PHG_ARGS_FLT_PICK: - incl = ws->in_ws.devs.pick[dev_id - 1].filter.incl; - excl = ws->in_ws.devs.pick[dev_id - 1].filter.excl; - break; - - default: - /* TODO: Other filter types */ - ret->err = ERR2006; - break; - } - - if (!ret->err) { - incl_count = phg_nset_num_names_get(incl); - excl_count = phg_nset_num_names_get(excl); - ret->data.filter.incl.num_ints = incl_count; - ret->data.filter.excl.num_ints = excl_count; - if ((incl_count + excl_count) > 0) { - if (!PHG_SCRATCH_SPACE(&ws->scratch, - (incl_count + excl_count) * sizeof(Pint))) { - ret->err = ERR900; - ret->data.filter.incl.num_ints = 0; - ret->data.filter.excl.num_ints = 0; - } - else { - ret->data.filter.incl.ints = (Pint *) ws->scratch.buf; - ret->data.filter.excl.ints = - &ret->data.filter.incl.ints[incl_count]; - phg_nset_names_get(incl, - ret->data.filter.incl.num_ints, - ret->data.filter.incl.ints); - phg_nset_names_get(excl, - ret->data.filter.excl.num_ints, - ret->data.filter.excl.ints); - } + Nameset incl; + Nameset excl; + int incl_count; + int excl_count; + Ws_output_ws *ows = &ws->out_ws; + + ret->err = 0; + switch (type) { + case PHG_ARGS_FLT_INVIS: + incl = ows->nset.invis_incl; + excl = ows->nset.invis_excl; + break; + + case PHG_ARGS_FLT_PICK: + incl = ws->in_ws.devs.pick[dev_id - 1].filter.incl; + excl = ws->in_ws.devs.pick[dev_id - 1].filter.excl; + break; + + default: + /* TODO: Other filter types */ + ret->err = ERR2006; + break; + } + + if (!ret->err) { + incl_count = phg_nset_num_names_get(incl); + excl_count = phg_nset_num_names_get(excl); + ret->data.filter.incl.num_ints = incl_count; + ret->data.filter.excl.num_ints = excl_count; + if ((incl_count + excl_count) > 0) { + if (!PHG_SCRATCH_SPACE(&ws->scratch, + (incl_count + excl_count) * sizeof(Pint))) { + ret->err = ERR900; + ret->data.filter.incl.num_ints = 0; + ret->data.filter.excl.num_ints = 0; } - } + else { + ret->data.filter.incl.ints = (Pint *) ws->scratch.buf; + ret->data.filter.excl.ints = + &ret->data.filter.incl.ints[incl_count]; + phg_nset_names_get(incl, + ret->data.filter.incl.num_ints, + ret->data.filter.incl.ints); + phg_nset_names_get(excl, + ret->data.filter.excl.num_ints, + ret->data.filter.excl.ints); + } + } + } } diff --git a/src/libphigs/ws/wstx_ini.c b/src/libphigs/ws/wstx_ini.c index 3748036..f4990db 100644 --- a/src/libphigs/ws/wstx_ini.c +++ b/src/libphigs/ws/wstx_ini.c @@ -39,8 +39,8 @@ /******************************************************************************* * init_output_ws_dt * - * DESCR: Helper initialization function for output ws dt - * RETURNS: N/A + * DESCR: Helper initialization function for output ws dt + * RETURNS: N/A */ static void init_output_ws_dt( @@ -63,9 +63,9 @@ static void init_output_ws_dt( case PWST_HCOPY_TRUE_PDF: case PWST_HCOPY_TRUE_SVG: case PWST_HCOPY_TRUE_OBJ: - wsdt->default_colour_model = PMODEL_RGB; - wsdt->has_double_buffer = FALSE; - break; + wsdt->default_colour_model = PMODEL_RGB; //FIXME what about RGBA + wsdt->has_double_buffer = FALSE; + break; case PWST_OUTPUT_TRUE_DB: case PWST_OUTIN_TRUE_DB: wsdt->default_colour_model = PMODEL_RGB; @@ -78,10 +78,12 @@ static void init_output_ws_dt( } /* Set foreground colour */ - fg.type = PMODEL_RGB; + fg.type = PMODEL_RGBA; fg.val.general.x = 1.0; fg.val.general.y = 1.0; fg.val.general.z = 1.0; + fg.val.general.a = 1.0; + /* FIXME: how to implement transparency here ? */ /* Setup default attribute bundles */ wsdt->num_predefined_polyline_indices = WST_MIN_PREDEF_LINE_REPS; @@ -113,6 +115,7 @@ static void init_output_ws_dt( memcpy(&wsdt->default_interior_bundle_table[0].colr, &fg, sizeof(Pgcolr)); + wsdt->default_interior_bundle_table[0].refl_eqn = PREFL_AMB_DIFF; wsdt->default_interior_bundle_table[0].shad_meth = PSD_COLOUR; wsdt->default_interior_bundle_table[0].refl_props.ambient_coef = 1.0; @@ -139,8 +142,8 @@ static void init_output_ws_dt( /******************************************************************************* * init_views * - * DESCR: Helper function to initialize default views - * RETURNS: N/A + * DESCR: Helper function to initialize default views + * RETURNS: N/A */ static void init_views( diff --git a/src/libphigs/ws/wsx.c b/src/libphigs/ws/wsx.c index 6ddd7cf..e813490 100644 --- a/src/libphigs/ws/wsx.c +++ b/src/libphigs/ws/wsx.c @@ -301,6 +301,7 @@ int phg_wsx_setup_tool_nodisp( background.val.general.x = (float) red / 65535.0; background.val.general.y = (float) green / 65535.0; background.val.general.z = (float) blue / 65535.0; + background.val.general.a = 1.0; glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint *)&(ws->fbuf)); diff --git a/src/libphigs/ws/wsx_util.c b/src/libphigs/ws/wsx_util.c index 17aecbb..4fe0e5f 100644 --- a/src/libphigs/ws/wsx_util.c +++ b/src/libphigs/ws/wsx_util.c @@ -297,6 +297,7 @@ void phg_wsx_pixel_colour( gcolr->val.general.x = (float) color.red / 65535.0; gcolr->val.general.y = (float) color.green / 65535.0; gcolr->val.general.z = (float) color.blue / 65535.0; + gcolr->val.general.z = 1.0; // FIXME } /******************************************************************************* diff --git a/src/libphigs/wsgl/wsgl.c b/src/libphigs/wsgl/wsgl.c index b972a44..c84e0ba 100644 --- a/src/libphigs/wsgl/wsgl.c +++ b/src/libphigs/wsgl/wsgl.c @@ -1,24 +1,24 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include @@ -46,15 +46,18 @@ #include "private/sofas3P.h" short int wsgl_use_shaders = 1; -#define LOG_INT(DATA) \ - css_print_eltype(ELMT_HEAD(DATA)->elementType); \ - printf(":\tSIZE: %d\t", ELMT_HEAD(DATA)->length); \ - printf("CONTENT: %d\n", PHG_INT(DATA)); +short int wsgl_vert_shader_version = 120; +short int wsgl_frag_shader_version = 120; + +#define LOG_INT(DATA) \ + css_print_eltype(ELMT_HEAD(DATA)->elementType); \ + printf(":\tSIZE: %d\t", ELMT_HEAD(DATA)->length); \ + printf("CONTENT: %d\n", PHG_INT(DATA)); -#define LOG_FLOAT(DATA) \ - css_print_eltype(ELMT_HEAD(DATA)->elementType); \ - printf(":\tSIZE: %d\t", ELMT_HEAD(DATA)->length); \ - printf("CONTENT: %f\n", PHG_FLOAT(DATA)); +#define LOG_FLOAT(DATA) \ + css_print_eltype(ELMT_HEAD(DATA)->elementType); \ + printf(":\tSIZE: %d\t", ELMT_HEAD(DATA)->length); \ + printf("CONTENT: %f\n", PHG_FLOAT(DATA)); /******************************************************************************* * wsgl_init @@ -82,11 +85,12 @@ int wsgl_init( return FALSE; } #ifdef DEBUG - printf("wsgl_init: background color type %d (%f %f %f)\n", + printf("wsgl_init: background color type %d (%f %f %f %f)\n", background->type, background->val.general.x, background->val.general.y, - background->val.general.z + background->val.general.z, + background->val.general.a ); #endif phg_nset_init(&wsgl->cur_struct.ast.asf_nameset, @@ -210,16 +214,21 @@ void wsgl_clear( wsgl->background.val.general.x = gcolr.val.general.x; wsgl->background.val.general.y = gcolr.val.general.y; wsgl->background.val.general.z = gcolr.val.general.z; + wsgl->background.val.general.a = gcolr.val.general.a; } else { wsgl->background.val.general.x = 0.; wsgl->background.val.general.y = 0.; wsgl->background.val.general.z = 0.; + wsgl->background.val.general.a = 1.; #ifdef DEBUG printf("INFO: background color index 0 not defined. Using default black.\n"); #endif } #ifdef DEBUG - printf("wsgl_setup_background: Setting background to (%f %f %f)\n", gcolr.val.general.x,gcolr.val.general.y,gcolr.val.general.z); + printf("wsgl_setup_background: Setting background to (%f %f %f %f)\n", + gcolr.val.general.x,gcolr.val.general.y,gcolr.val.general.z, + gcolr.val.general.a + ); #endif if (ws->drawable_id != 0){ glXMakeContextCurrent(ws->display, ws->drawable_id, ws->drawable_id, ws->glx_context); @@ -243,6 +252,7 @@ void wsgl_clear( #endif glFlush(); } + glDepthMask (GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -312,26 +322,30 @@ void wsgl_flush( if (wsgl->win_changed) { wsgl->win_changed = 0; } - clear_flag = 1; } if (wsgl->hlhsr_changed) { - if (wsgl->hlhsr_mode == PHIGS_HLHSR_MODE_ZBUFF) { + switch (wsgl->hlhsr_mode){ + case PHIGS_HLHSR_MODE_NONE: +#ifdef DEBUG + printf("Disable z-buffer\n"); +#endif + glDisable(GL_DEPTH_TEST); + glDepthMask (GL_TRUE); + glDepthFunc(GL_LESS); + break; + case PHIGS_HLHSR_MODE_ZBUFF: #ifdef DEBUG printf("Enable z-buffer\n"); #endif + glDepthMask (GL_TRUE); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glAlphaFunc (GL_GREATER, 0.1); + glAlphaFunc (GL_GREATER, 0.01); glEnable(GL_ALPHA_TEST); - } - else if (wsgl->hlhsr_mode == PHIGS_HLHSR_MODE_NONE) { -#ifdef DEBUG - printf("Disable z-buffer\n"); -#endif - glDisable(GL_DEPTH_TEST); + break; } wsgl->hlhsr_changed = 0; } @@ -339,12 +353,13 @@ void wsgl_flush( glClearColor(wsgl->background.val.general.x, wsgl->background.val.general.y, wsgl->background.val.general.z, - 0.0); + wsgl->background.val.general.a); #ifdef DEBUG - printf("wsgl: clear to background color %f %f %f\n", + printf("wsgl: clear to background color %f %f %f %f\n", wsgl->background.val.general.x, wsgl->background.val.general.y, - wsgl->background.val.general.z + wsgl->background.val.general.z, + wsgl->background.val.general.a ); #endif if (clear_flag) { @@ -389,6 +404,8 @@ static void init_rendering_state( wsgl->cur_struct.ast.anno_char_up_vec.delta_y = 1.0; wsgl->cur_struct.ast.disting_mode = PDISTING_YES; wsgl->cur_struct.ast.cull_mode = PCULL_NONE; + wsgl->cur_struct.ast.alpha_channel = 1.0; + wsgl->cur_struct.ast.color_model= PMODEL_RGB; wsgl_set_edge_ind(ws, &wsgl->cur_struct.ast.bundl_group, 0); wsgl_set_edge_ind(ws, &wsgl->cur_struct.ast.indiv_group, 0); wsgl_set_int_ind(ws, &wsgl->cur_struct.ast.bundl_group, 0); @@ -427,6 +444,7 @@ void wsgl_begin_rendering( if (ws->drawable_id != 0){ glXMakeContextCurrent(ws->display, ws->drawable_id, ws->drawable_id, ws->glx_context); } + glDepthMask (GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); init_rendering_state(ws); } @@ -606,7 +624,6 @@ void wsgl_begin_structure( phg_mat_copy(wsgl->cur_struct.global_tran, wsgl->composite_tran); phg_mat_identity(wsgl->cur_struct.local_tran); wsgl_set_clip_ind(ws, 0); - wsgl_set_alpha_channel(ws, 1.0); wsgl_update_modelview(ws); if (wsgl->render_mode == WS_RENDER_MODE_SELECT) { @@ -635,28 +652,28 @@ void wsgl_end_structure( printf("End structure element: %d\n", wsgl->cur_struct.id); #endif - stack_pop(wsgl->struct_stack, (caddr_t) &wsgl->cur_struct); - wsgl_update_hlhsr_id(ws); - wsgl_update_projection(ws); - wsgl_update_modelview(ws); - wsgl_update_light_src_state(ws); + stack_pop(wsgl->struct_stack, (caddr_t) &wsgl->cur_struct); + wsgl_update_hlhsr_id(ws); + wsgl_update_projection(ws); + wsgl_update_modelview(ws); + wsgl_update_light_src_state(ws); #ifdef DEBUG - printf("Pop: id = %d, offset = %d\n", - wsgl->cur_struct.id, - wsgl->cur_struct.offset); - printf("View:\n"); - phg_mat_print(wsgl->cur_struct.view_rep.map_matrix); - printf("\n"); + printf("Pop: id = %d, offset = %d\n", + wsgl->cur_struct.id, + wsgl->cur_struct.offset); + printf("View:\n"); + phg_mat_print(wsgl->cur_struct.view_rep.map_matrix); + printf("\n"); #endif - if (wsgl->render_mode == WS_RENDER_MODE_SELECT) { + if (wsgl->render_mode == WS_RENDER_MODE_SELECT) { #ifdef DEBUG - printf("\tPop name\n"); + printf("\tPop name\n"); #endif - glPopName(); - glPopName(); - } + glPopName(); + glPopName(); + } } /******************************************************************************* @@ -720,18 +737,43 @@ void wsgl_render_element( phg_get_colr_ind(ws, &wsgl->cur_struct.ast.indiv_group.int_bundle.colr, PHG_INT(el)); +#ifdef DEBUGA + printf("Col Indx %d type %d alpha %f\n", + PHG_INT(el), + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.type, + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.val.general.a + ); +#endif break; case PELEM_INT_COLR: memcpy(&wsgl->cur_struct.ast.indiv_group.int_bundle.colr, ELMT_CONTENT(el), sizeof(Pgcolr)); +#ifdef DEBUGA + printf("Setting INT COLR type %d colors %f %f %f %f\n", + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.type, + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.val.general.x, + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.val.general.y, + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.val.general.z, + wsgl->cur_struct.ast.indiv_group.int_bundle.colr.val.general.a + ); +#endif break; case PELEM_BACK_INT_COLR: memcpy(&wsgl->cur_struct.ast.indiv_group.int_bundle.back_colr, ELMT_CONTENT(el), sizeof(Pgcolr)); +#ifdef DEBUGA + printf("Setting BACK COLR type %d colors %f %f %f %f\n", + wsgl->cur_struct.ast.indiv_group.int_bundle.back_colr.type, + wsgl->cur_struct.ast.indiv_group.int_bundle.back_colr.val.general.x, + wsgl->cur_struct.ast.indiv_group.int_bundle.back_colr.val.general.y, + wsgl->cur_struct.ast.indiv_group.int_bundle.back_colr.val.general.z, + wsgl->cur_struct.ast.indiv_group.int_bundle.back_colr.val.general.a + ); +#endif break; case PELEM_INT_STYLE: @@ -761,6 +803,13 @@ void wsgl_render_element( phg_get_colr_ind(ws, &wsgl->cur_struct.ast.indiv_group.edge_bundle.colr, PHG_INT(el)); +#ifdef DEBUGA + printf("Edge Col Indx %d type %d alpha %f\n", + PHG_INT(el), + wsgl->cur_struct.ast.indiv_group.edge_bundle.colr.type, + wsgl->cur_struct.ast.indiv_group.edge_bundle.colr.val.general.a + ); +#endif break; case PELEM_EDGE_COLR: @@ -778,8 +827,7 @@ void wsgl_render_element( break; case PELEM_EDGE_FLAG: - wsgl->cur_struct.ast.indiv_group.edge_bundle.flag = - (Pedge_flag) PHG_INT(el); + wsgl->cur_struct.ast.indiv_group.edge_bundle.flag = (Pedge_flag) PHG_INT(el); break; case PELEM_MARKER_IND: @@ -790,6 +838,13 @@ void wsgl_render_element( phg_get_colr_ind(ws, &wsgl->cur_struct.ast.indiv_group.marker_bundle.colr, PHG_INT(el)); +#ifdef DEBUGA + printf("Marker Col Indx %d type %d alpha %f\n", + PHG_INT(el), + wsgl->cur_struct.ast.indiv_group.marker_bundle.colr.type, + wsgl->cur_struct.ast.indiv_group.marker_bundle.colr.val.general.a + ); +#endif break; case PELEM_MARKER_COLR: @@ -814,6 +869,13 @@ void wsgl_render_element( phg_get_colr_ind(ws, &wsgl->cur_struct.ast.indiv_group.text_bundle.colr, PHG_INT(el)); +#ifdef DEBUGA + printf("Text Col Indx %d type %d alpha %f\n", + PHG_INT(el), + wsgl->cur_struct.ast.indiv_group.text_bundle.colr.type, + wsgl->cur_struct.ast.indiv_group.text_bundle.colr.val.general.a + ); +#endif break; case PELEM_TEXT_COLR: @@ -877,6 +939,13 @@ void wsgl_render_element( phg_get_colr_ind(ws, &wsgl->cur_struct.ast.indiv_group.line_bundle.colr, PHG_INT(el)); +#ifdef DEBUGA + printf("Line Col Indx %d type %d alpha %f\n", + PHG_INT(el), + wsgl->cur_struct.ast.indiv_group.line_bundle.colr.type, + wsgl->cur_struct.ast.indiv_group.line_bundle.colr.val.general.a + ); +#endif } break; @@ -894,7 +963,7 @@ void wsgl_render_element( wsgl->cur_struct.ast.indiv_group.line_bundle.type = PHG_INT(el); break; - case PELEM_FILL_AREA: + case PELEM_FILL_AREA: if (check_draw_primitive(ws)) { if (wsgl_get_int_style(&wsgl->cur_struct.ast) != PSTYLE_EMPTY) { wsgl_fill_area(ws, ELMT_CONTENT(el), &wsgl->cur_struct.ast); @@ -931,7 +1000,7 @@ void wsgl_render_element( case PELEM_FILL_AREA3: if (check_draw_primitive(ws)) { style = wsgl_get_int_style(&wsgl->cur_struct.ast); - if (wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON && wsgl->hlhsr_mode > 0) { + if ((wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON || wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON_NZ) && wsgl->hlhsr_mode > 0) { if (style == PSTYLE_EMPTY || style == PSTYLE_HOLLOW) { wsgl_clear_area3(ws, ELMT_CONTENT(el), &wsgl->cur_struct.ast); } @@ -970,7 +1039,7 @@ void wsgl_render_element( case PELEM_FILL_AREA_SET3: if (check_draw_primitive(ws)) { style = wsgl_get_int_style(&wsgl->cur_struct.ast); - if (wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON && wsgl->hlhsr_mode > 0) { + if ((wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON || wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON_NZ) && wsgl->hlhsr_mode > 0) { if (style == PSTYLE_EMPTY || style == PSTYLE_HOLLOW) { wsgl_clear_area_set3(ws, ELMT_CONTENT(el), @@ -989,7 +1058,7 @@ void wsgl_render_element( case PELEM_FILL_AREA_SET_DATA: if (check_draw_primitive(ws)) { style = wsgl_get_int_style(&wsgl->cur_struct.ast); - if (wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON && wsgl->hlhsr_mode > 0) { + if ((wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON || wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON_NZ) && wsgl->hlhsr_mode > 0) { if (style == PSTYLE_EMPTY || style == PSTYLE_HOLLOW) { wsgl_clear_area_set_data(ws, ELMT_CONTENT(el), @@ -1032,7 +1101,7 @@ void wsgl_render_element( case PELEM_FILL_AREA_SET3_DATA: if (check_draw_primitive(ws)) { style = wsgl_get_int_style(&wsgl->cur_struct.ast); - if (wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON && wsgl->hlhsr_mode > 0) { + if ((wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON || wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON_NZ) && wsgl->hlhsr_mode > 0) { if (style == PSTYLE_EMPTY || style == PSTYLE_HOLLOW) { wsgl_clear_area_set3_data(ws, ELMT_CONTENT(el), @@ -1075,12 +1144,10 @@ void wsgl_render_element( case PELEM_SET_OF_FILL_AREA_SET3_DATA: if (check_draw_primitive(ws)) { style = wsgl_get_int_style(&wsgl->cur_struct.ast); - if (wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON && wsgl->hlhsr_mode > 0) { - if (style == PSTYLE_EMPTY || style == PSTYLE_HOLLOW) { - wsgl_set_of_clear_area_set3_data(ws, - ELMT_CONTENT(el), - &wsgl->cur_struct.ast); - } + if ((wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON || wsgl->cur_struct.hlhsr_id == PHIGS_HLHSR_ID_ON_NZ) && wsgl->hlhsr_mode > 0) { + wsgl_set_of_clear_area_set3_data(ws, + ELMT_CONTENT(el), + &wsgl->cur_struct.ast); } if (style != PSTYLE_EMPTY) { if (wsgl->cur_struct.ast.cull_mode != PCULL_BACKFACE) { @@ -1260,7 +1327,8 @@ void wsgl_render_element( break; case PELEM_ALPHA_CHANNEL: - wsgl_set_alpha_channel(ws, PHG_FLOAT(el)); + wsgl->cur_struct.ast.alpha_channel = PHG_FLOAT(el); + wsgl->cur_struct.ast.color_model = PMODEL_RGBA; break; default: diff --git a/src/libphigs/wsgl/wsgl_attr.c b/src/libphigs/wsgl/wsgl_attr.c index 5755702..7e6e4ba 100644 --- a/src/libphigs/wsgl/wsgl_attr.c +++ b/src/libphigs/wsgl/wsgl_attr.c @@ -1,24 +1,24 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include @@ -45,8 +45,8 @@ extern GLint alpha_channel; /******************************************************************************* * wsgl_set_matrix * - * DESCR: Setup matrix - * RETURNS: N/A + * DESCR: Setup matrix + * RETURNS: N/A */ static void wsgl_set_matrix( @@ -109,8 +109,8 @@ static void wsgl_set_projection_matrix( /******************************************************************************* * wsgl_update_projection * - * DESCR: Update projection matrix - * RETURNS: N/A + * DESCR: Update projection matrix + * RETURNS: N/A */ void wsgl_update_projection( Ws *ws @@ -127,36 +127,25 @@ void wsgl_update_projection( phg_mat_mul(wsgl->model_tran, wsgl->pick_tran, wsgl->cur_struct.view_rep.map_matrix); -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - wsgl_set_projection_matrix(wsgl->model_tran); - } else { - wsgl_set_matrix(wsgl->model_tran, FALSE); - } - } - else { -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - wsgl_set_projection_matrix(wsgl->cur_struct.view_rep.map_matrix); - } else { - wsgl_set_matrix(wsgl->cur_struct.view_rep.map_matrix, FALSE); - } + if (wsgl_use_shaders){ + wsgl_set_projection_matrix(wsgl->model_tran); + } else { + wsgl_set_matrix(wsgl->model_tran, FALSE); + } + } else { + if (wsgl_use_shaders){ + wsgl_set_projection_matrix(wsgl->cur_struct.view_rep.map_matrix); + } else { + wsgl_set_matrix(wsgl->cur_struct.view_rep.map_matrix, FALSE); + } } } /******************************************************************************* * wsgl_update_modelview * - * DESCR: Update modelview matrix - * RETURNS: N/A + * DESCR: Update modelview matrix + * RETURNS: N/A */ void wsgl_update_modelview( @@ -181,23 +170,18 @@ void wsgl_update_modelview( phg_mat_mul(wsgl->model_tran, wsgl->cur_struct.view_rep.ori_matrix, wsgl->composite_tran); -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - wsgl_set_model_view_matrix(wsgl->model_tran); - } else { - wsgl_set_matrix(wsgl->model_tran, FALSE); - } + if (wsgl_use_shaders){ + wsgl_set_model_view_matrix(wsgl->model_tran); + } else { + wsgl_set_matrix(wsgl->model_tran, FALSE); + } } /******************************************************************************* * wsgl_set_view_ind * - * DESCR: Setup view - * RETURNS: N/A + * DESCR: Setup view + * RETURNS: N/A */ void wsgl_set_view_ind( Ws *ws, @@ -224,8 +208,8 @@ void wsgl_set_view_ind( /******************************************************************************* * wsgl_set_clip_ind * - * DESCR: Setup clip index - * RETURNS: N/A + * DESCR: Setup clip index + * RETURNS: N/A */ void wsgl_set_clip_ind( @@ -235,13 +219,9 @@ void wsgl_set_clip_ind( { Phg_ret ret; Wsgl_handle wsgl = ws->render_context; -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glUniform1i(clipping_ind, ind); + if (wsgl_use_shaders){ + glUniform1i(clipping_ind, ind); + if (! wsgl_use_shaders){ if (ind == 1) { glEnable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE1); @@ -253,33 +233,14 @@ void wsgl_set_clip_ind( glDisable(GL_CLIP_PLANE1); } } -} - -/******************************************************************************* - * wsgl_set_alpha_channel - * - * DESCR: Setup alpha channel - * RETURNS: N/A - */ -void wsgl_set_alpha_channel( - Ws *ws, - Pfloat alpha - ) -{ - Phg_ret ret; - Wsgl_handle wsgl = ws->render_context; -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) glUniform1f(alpha_channel, alpha); -#else - if (wsgl_use_shaders) glUniform1f(alpha_channel, alpha); -#endif + } } /******************************************************************************* * wsgl_set_clip_vol3 * - * DESCR: Setup view - * RETURNS: N/A + * DESCR: Setup view + * RETURNS: N/A */ void wsgl_set_clip_vol3( Ws *ws, @@ -295,62 +256,71 @@ void wsgl_set_clip_vol3( Ppoint3 nn1, pt1; /* second plane if any */ Ppoint3 vol3, point3, pwc; Pmatrix3 vrc2wc, unity; - -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - /* invert to transform from VRC to WC */ - op = int_data[0]; - num = int_data[1]; - list = (Phalf_space3 *)(&int_data[2]); - if (1 == num || 2 ==num){ - glUniform1i(num_clip_planes, num); - /* first plane */ - volume0 = list[0]; - /* take a local copy of the data */ - nn0.x = volume0.norm.delta_x; - nn0.y = volume0.norm.delta_y; - nn0.z = volume0.norm.delta_z; - - pt0.x = volume0.point.x; - pt0.y = volume0.point.y; - pt0.z = volume0.point.z; - - glUniform4f(plane0, nn0.x, nn0.y, nn0.z, 0.); - GLdouble eqn0[4] = {nn0.x, nn0.y, nn0.z, 0.}; - glClipPlane(GL_CLIP_PLANE0, eqn0); - glUniform4f(point0, pt0.x, pt0.y, pt0.z, 0.); - if (2 ==num){ - /* first plane */ - volume1 = list[1]; - /* take a local copy of the data */ - nn1.x = volume1.norm.delta_x; - nn1.y = volume1.norm.delta_y; - nn1.z = volume1.norm.delta_z; - - pt1.x = volume1.point.x; - pt1.y = volume1.point.y; - pt1.z = volume1.point.z; - - glUniform4f(plane1, nn1.x, nn1.y, nn1.z, 0.); - GLdouble eqn1[4] = {nn1.x, nn1.y, nn1.z, 0.}; - glClipPlane(GL_CLIP_PLANE1, eqn1); - glUniform4f(point1, pt1.x, pt1.y, pt1.z, 0.); - } - } else { - glUniform1i(num_clip_planes, 0); /* ignore the call */ + // FIXME check against what the standard says + op = int_data[0]; + num = int_data[1]; + list = (Phalf_space3 *)(&int_data[2]); + if (num >=1 && num <=2){ + /* invert to transform from VRC to WC */ + /* first plane */ + volume0 = list[0]; + /* take a local copy of the data */ + nn0.x = volume0.norm.delta_x; + nn0.y = volume0.norm.delta_y; + nn0.z = volume0.norm.delta_z; + + pt0.x = volume0.point.x; + pt0.y = volume0.point.y; + pt0.z = volume0.point.z; + + glUniform4f(plane0, nn0.x, nn0.y, nn0.z, 0.); + glUniform4f(point0, pt0.x, pt0.y, pt0.z, 0.); + if (2 ==num){ + /* first plane */ + volume1 = list[1]; + /* take a local copy of the data */ + nn1.x = volume1.norm.delta_x; + nn1.y = volume1.norm.delta_y; + nn1.z = volume1.norm.delta_z; + + pt1.x = volume1.point.x; + pt1.y = volume1.point.y; + pt1.z = volume1.point.z; + + glUniform4f(plane1, nn1.x, nn1.y, nn1.z, 0.); + glUniform4f(point1, pt1.x, pt1.y, pt1.z, 0.); + } + }; + if (wsgl_use_shaders) { + glUniform1i(num_clip_planes, num); + if (num >= 1){ + glUniform4f(plane0, nn0.x, nn0.y, nn0.z, 0.); + glUniform4f(point0, pt0.x, pt0.y, pt0.z, 0.); + if (num == 2){ + glUniform4f(plane1, nn1.x, nn1.y, nn1.z, 0.); + glUniform4f(point1, pt1.x, pt1.y, pt1.z, 0.); } + } else { + glUniform1i(num_clip_planes, 0); /* ignore the call */ + return; } + } else { + if (num >1){ + GLdouble eqn0[4] = {nn0.x, nn0.y, nn0.z, 0.}; + glClipPlane(GL_CLIP_PLANE0, eqn0); + if (num == 2){ + GLdouble eqn1[4] = {nn1.x, nn1.y, nn1.z, 0.}; + glClipPlane(GL_CLIP_PLANE1, eqn1); + } + } + } } /******************************************************************************* * wsgl_update_hlhsr_id * - * DESCR: Update depth buffer checking flag - * RETURNS: N/A + * DESCR: Update depth buffer checking flag + * RETURNS: N/A */ void wsgl_update_hlhsr_id( Ws *ws @@ -365,6 +335,14 @@ void wsgl_update_hlhsr_id( case PHIGS_HLHSR_ID_ON: glDepthFunc(GL_LESS); + glDepthMask(GL_TRUE); + glEnable(GL_DEPTH_TEST); + break; + + case PHIGS_HLHSR_ID_ON_NZ: + glDepthFunc(GL_ALWAYS); + glDepthMask(GL_FALSE); + glEnable(GL_DEPTH_TEST); break; default: @@ -375,8 +353,8 @@ void wsgl_update_hlhsr_id( /******************************************************************************* * wsgl_set_asf * - * DESCR: Setup asf - * RETURNS: N/A + * DESCR: Setup asf + * RETURNS: N/A */ void wsgl_set_asf( Ws_attr_st *ast, @@ -396,35 +374,61 @@ void wsgl_set_asf( /******************************************************************************* * wsgl_set_colr * - * DESCR: Set colour value - * RETURNS: N/A + * DESCR: Set colour value + * RETURNS: N/A */ void wsgl_set_colr( Pint colr_type, Pcoval *colr ) { + int* crash = 0; +#ifdef DEBUGA + printf("wsgl_set_colr: setting color of type %d\n", colr_type); +#endif switch(colr_type) { case PINDIRECT: glIndexi(colr->ind); break; case PMODEL_RGB: -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red, - colr->direct.rgb.green, - colr->direct.rgb.blue, - 1.0); - } else { - glColor3f(colr->direct.rgb.red, + if (wsgl_use_shaders) { + glVertexAttrib4f(vCOLOR, + colr->direct.rgb.red, + colr->direct.rgb.green, + colr->direct.rgb.blue, + 1.0); + } else { + glColor4f(colr->direct.rgb.red, colr->direct.rgb.green, - colr->direct.rgb.blue); + colr->direct.rgb.blue, + 1.0); + } + break; + + case PMODEL_RGBA: + if (wsgl_use_shaders){ + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red, + colr->direct.rgba.green, + colr->direct.rgba.blue, + colr->direct.rgba.alpha); + } else { +#ifdef DEBUGA + printf("DEBUG wsgl_set_colr: Color model rgba, %f %f %f %f\n", + colr->direct.rgba.red, + colr->direct.rgba.green, + colr->direct.rgba.blue, + colr->direct.rgba.alpha); + if (colr->direct.rgba.alpha <= 0 || colr->direct.rgba.alpha > 1.) { + printf("Alpha value out of bounds. Crashing.\n"); + *crash = 1; + } +#endif + glColor4f(colr->direct.rgba.red, + colr->direct.rgba.green, + colr->direct.rgba.blue, + colr->direct.rgba.alpha); } break; @@ -436,8 +440,8 @@ void wsgl_set_colr( /******************************************************************************* * wsgl_set_gcolr * - * DESCR: Set colour - * RETURNS: N/A + * DESCR: Set colour + * RETURNS: N/A */ void wsgl_set_gcolr( Pgcolr *gcolr @@ -449,21 +453,40 @@ void wsgl_set_gcolr( break; case PMODEL_RGB: -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) + if (wsgl_use_shaders) { + glVertexAttrib4f(vCOLOR, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + 1.0); + } else { + glColor4f(gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + 1.0); + } + break; + + case PMODEL_RGBA: + if (wsgl_use_shaders) { +#ifdef DEBUGA + printf("wsgl_set_gcolr setting %f %f %f %f\n", + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a + ); #endif - { - glVertexAttrib4f(vCOLOR, - gcolr->val.general.x, - gcolr->val.general.y, - gcolr->val.general.z, - 1.0); - } else { - glColor3f(gcolr->val.general.x, + glVertexAttrib4f(vCOLOR, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a); + } else { + glColor4f(gcolr->val.general.x, gcolr->val.general.y, - gcolr->val.general.z); + gcolr->val.general.z, + gcolr->val.general.a); } break; @@ -472,26 +495,82 @@ void wsgl_set_gcolr( } } +/******************************************************************************* + * wsgl_convert_gcolr + * + * DESCR: convert gcolr to target model + * RETURNS: N/A + */ +void wsgl_convert_gcolr( + Pgcolr *gcolr, + int model + ){ + switch (gcolr->type){ + case PINDIRECT: + break; + case PMODEL_RGB: + if (model == PMODEL_RGBA){ + gcolr->val.general.a = 1.0; + gcolr->type = PMODEL_RGBA; + } + break; + case PMODEL_RGBA: + gcolr->type = PMODEL_RGB; + break; + default: + break; + } +} + /******************************************************************************* * wsgl_colr_from_gcolr * - * DESCR: Get colour value from Pgcolr - * RETURNS: N/A + * DESCR: Get colour value from Pgcolr + * RETURNS: N/A */ void wsgl_colr_from_gcolr( Pcoval *colr, - Pgcolr *gcolr + Pgcolr *gcolr, + Pint mode ) { + /* mode is the global color mode */ + + + colr->direct.rgba.alpha = 1.0; + + /* check the type of the given color */ switch(gcolr->type) { case PINDIRECT: colr->ind = gcolr->val.ind; break; case PMODEL_RGB: - colr->direct.rgb.red = gcolr->val.general.x; - colr->direct.rgb.green = gcolr->val.general.y; - colr->direct.rgb.blue = gcolr->val.general.z; + if (mode == PMODEL_RGB){ + colr->direct.rgb.red = gcolr->val.general.x; + colr->direct.rgb.green = gcolr->val.general.y; + colr->direct.rgb.blue = gcolr->val.general.z; + } else { + /* have RGB but want rbga */ + colr->direct.rgba.red = gcolr->val.general.x; + colr->direct.rgba.green = gcolr->val.general.y; + colr->direct.rgba.blue = gcolr->val.general.z; + colr->direct.rgba.alpha = 1.0; + } + break; + + case PMODEL_RGBA: + if (mode == PMODEL_RGBA){ + colr->direct.rgba.red = gcolr->val.general.x; + colr->direct.rgba.green = gcolr->val.general.y; + colr->direct.rgba.blue = gcolr->val.general.z; + colr->direct.rgba.alpha = gcolr->val.general.a; + } else { + /* have RGBA but want RGB */ + colr->direct.rgb.red = gcolr->val.general.x; + colr->direct.rgb.green = gcolr->val.general.y; + colr->direct.rgb.blue = gcolr->val.general.z; + } break; default: @@ -502,8 +581,8 @@ void wsgl_colr_from_gcolr( /******************************************************************************* * wsgl_set_line_ind * - * DESCR: Setup line index - * RETURNS: N/A + * DESCR: Setup line index + * RETURNS: N/A */ void wsgl_set_line_ind( Ws *ws, @@ -528,8 +607,8 @@ void wsgl_set_line_ind( /******************************************************************************* * wsgl_setup_line_attr * - * DESCR: Setup line attributes - * RETURNS: N/A + * DESCR: Setup line attributes + * RETURNS: N/A */ void wsgl_setup_line_attr( Ws_attr_st *ast @@ -577,15 +656,10 @@ void wsgl_setup_line_attr( else { glLineWidth(ast->bundl_group.line_bundle.width); } -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glEnable(GL_LINE_SMOOTH); - glUniform1i(shading_mode, 0); - } else { + if (wsgl_use_shaders){ + glEnable(GL_LINE_SMOOTH); + glUniform1i(shading_mode, 0); + } else { glDisable(GL_LIGHTING); } } @@ -593,8 +667,8 @@ void wsgl_setup_line_attr( /******************************************************************************* * wsgl_set_int_ind * - * DESCR: Setup interior index - * RETURNS: N/A + * DESCR: Setup interior index + * RETURNS: N/A */ void wsgl_set_int_ind( Ws *ws, @@ -619,8 +693,8 @@ void wsgl_set_int_ind( /******************************************************************************* * wsgl_get_int_colr * - * DESCR: Get interior colour - * RETURNS: Pointer to interiour colour + * DESCR: Get interior colour + * RETURNS: Pointer to interiour colour */ Pgcolr* wsgl_get_int_colr( Ws_attr_st *ast @@ -630,9 +704,27 @@ Pgcolr* wsgl_get_int_colr( if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_INT_COLR_IND)) { gcolr = &ast->indiv_group.int_bundle.colr; +#ifdef DEBUGA + printf("gcolr from nameset %d colors %f %f %f %f\n", + gcolr->type, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a + ); +#endif } else { gcolr = &ast->bundl_group.int_bundle.colr; +#ifdef DEBUGA + printf("gcolr from bundle %d colors %f %f %f %f\n", + gcolr->type, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a + ); +#endif } return gcolr; } @@ -640,8 +732,8 @@ Pgcolr* wsgl_get_int_colr( /******************************************************************************* * wsgl_get_int_style * - * DESCR: Get interior style - * RETURNS: Interiour style + * DESCR: Get interior style + * RETURNS: Interiour style */ Pint_style wsgl_get_int_style( Ws_attr_st *ast @@ -662,8 +754,8 @@ Pint_style wsgl_get_int_style( /******************************************************************************* * wsgl_setup_int_style * - * DESCR: Setup interior style - * RETURNS: N/A + * DESCR: Setup interior style + * RETURNS: N/A */ void wsgl_setup_int_style( Pint_style style @@ -695,8 +787,8 @@ void wsgl_setup_int_style( /******************************************************************************* * wsgl_setup_int_attr_nocol * - * DESCR: Setup interior attributes without color - * RETURNS: N/A + * DESCR: Setup interior attributes without color + * RETURNS: N/A */ void wsgl_setup_int_attr_nocol( Ws *ws, @@ -745,19 +837,14 @@ void wsgl_setup_int_attr_nocol( wsgl->dev_st.int_shad_meth = shad_meth; } -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - if (wsgl->cur_struct.lighting) { - glUniform1i(shading_mode, 1); - } - else { - glUniform1i(shading_mode, 0); - } - } else { + if (wsgl_use_shaders){ + if (wsgl->cur_struct.lighting) { + glUniform1i(shading_mode, 1); + } + else { + glUniform1i(shading_mode, 0); + } + } else { if (wsgl->cur_struct.lighting) { glEnable(GL_LIGHTING); } @@ -765,14 +852,14 @@ void wsgl_setup_int_attr_nocol( glDisable(GL_LIGHTING); } } - // glCullFace(GL_BACK); + glCullFace(GL_BACK); } /******************************************************************************* * wsgl_setup_int_attr * - * DESCR: Setup interior attributes - * RETURNS: N/A + * DESCR: Setup interior attributes + * RETURNS: N/A */ void wsgl_setup_int_attr( Ws *ws, @@ -786,8 +873,8 @@ void wsgl_setup_int_attr( /******************************************************************************* * wsgl_set_edge_ind * - * DESCR: Setup edge index - * RETURNS: N/A + * DESCR: Setup edge index + * RETURNS: N/A */ void wsgl_set_edge_ind( Ws *ws, @@ -812,8 +899,8 @@ void wsgl_set_edge_ind( /******************************************************************************* * wsgl_get_edge_flag * - * DESCR: Get edge flag - * RETURNS: Edge flag + * DESCR: Get edge flag + * RETURNS: Edge flag */ Pedge_flag wsgl_get_edge_flag( Ws_attr_st *ast @@ -833,8 +920,8 @@ Pedge_flag wsgl_get_edge_flag( /******************************************************************************* * wsgl_get_edge_width * - * DESCR: Get edge width - * RETURNS: Edge width + * DESCR: Get edge width + * RETURNS: Edge width */ Pfloat wsgl_get_edge_width( Ws_attr_st *ast @@ -855,8 +942,8 @@ Pfloat wsgl_get_edge_width( /******************************************************************************* * wsgl_setup_edge_attr * - * DESCR: Setup edge attributes - * RETURNS: N/A + * DESCR: Setup edge attributes + * RETURNS: N/A */ void wsgl_setup_edge_attr( Ws_attr_st *ast @@ -901,14 +988,9 @@ void wsgl_setup_edge_attr( glDisable(GL_LINE_STIPPLE); break; } -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glUniform1i(shading_mode, 0); - } else { + if (wsgl_use_shaders) { + glUniform1i(shading_mode, 0); + } else { glDisable(GL_LIGHTING); } } @@ -916,8 +998,8 @@ void wsgl_setup_edge_attr( /******************************************************************************* * wsgl_set_marker_ind * - * DESCR: Setup marker index - * RETURNS: N/A + * DESCR: Setup marker index + * RETURNS: N/A */ void wsgl_set_marker_ind( Ws *ws, @@ -942,8 +1024,8 @@ void wsgl_set_marker_ind( /******************************************************************************* * wsgl_setup_marker_attr * - * DESCR: Setup marker attributes - * RETURNS: N/A + * DESCR: Setup marker attributes + * RETURNS: N/A */ void wsgl_setup_marker_attr( Ws_attr_st *ast, @@ -972,23 +1054,18 @@ void wsgl_setup_marker_attr( else { *size = ast->bundl_group.marker_bundle.size; } -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glUniform1i(shading_mode, 0); - } else { - glDisable(GL_LIGHTING); - } + if (wsgl_use_shaders){ + glUniform1i(shading_mode, 0); + } else { + glDisable(GL_LIGHTING); + } } /******************************************************************************* * wsgl_setup_background * - * DESCR: Setup background colour - * RETURNS: N/A + * DESCR: Setup background colour + * RETURNS: N/A */ void wsgl_setup_background( Ws *ws @@ -997,21 +1074,26 @@ void wsgl_setup_background( Wsgl_handle wsgl = ws->render_context; glDisable(GL_POLYGON_STIPPLE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glVertexAttrib4f(vCOLOR, - wsgl->background.val.general.x, - wsgl->background.val.general.y, - wsgl->background.val.general.z, - 1.0); + if (wsgl_use_shaders) { + glVertexAttrib4f(vCOLOR, + wsgl->background.val.general.x, + wsgl->background.val.general.y, + wsgl->background.val.general.z, + wsgl->background.val.general.a); + } else { + if (ws->current_colour_model == PMODEL_RGBA){ + glColor4f(wsgl->background.val.general.x, + wsgl->background.val.general.y, + wsgl->background.val.general.z, + wsgl->background.val.general.a + ); } else { - glColor3f(wsgl->background.val.general.x, - wsgl->background.val.general.y, - wsgl->background.val.general.z); + glColor4f(wsgl->background.val.general.x, + wsgl->background.val.general.y, + wsgl->background.val.general.z, + 1.0 + ); + } } /* Need to restore polygon mode */ wsgl->dev_st.int_style = -1; @@ -1020,8 +1102,8 @@ void wsgl_setup_background( /******************************************************************************* * wsgl_set_text_ind * - * DESCR: Setup text index - * RETURNS: N/A + * DESCR: Setup text index + * RETURNS: N/A */ void wsgl_set_text_ind( Ws *ws, @@ -1046,8 +1128,8 @@ void wsgl_set_text_ind( /******************************************************************************* * wsgl_get_text_prec * - * DESCR: Get text precision - * RETURNS: Text precision + * DESCR: Get text precision + * RETURNS: Text precision */ Ptext_prec wsgl_get_text_prec( Ws_attr_st *ast @@ -1068,8 +1150,8 @@ Ptext_prec wsgl_get_text_prec( /******************************************************************************* * wsgl_setup_text_attr * - * DESCR: Setup text attributes - * RETURNS: N/A + * DESCR: Setup text attributes + * RETURNS: N/A */ void wsgl_setup_text_attr( @@ -1108,26 +1190,21 @@ void wsgl_setup_text_attr( *char_expan = ast->bundl_group.text_bundle.char_expan; } -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) -#else - if (wsgl_use_shaders) -#endif - { - glUniform1i(shading_mode, 0); - } - else - { - glDisable(GL_LIGHTING); - glLineWidth(2.0); - } + if (wsgl_use_shaders){ + glUniform1i(shading_mode, 0); + } + else + { + glDisable(GL_LIGHTING); + glLineWidth(2.0); + } } /******************************************************************************* * wsgl_get_char_space * - * DESCR: Get char spacing - * RETURNS: Character spacing + * DESCR: Get char spacing + * RETURNS: Character spacing */ Pfloat wsgl_get_char_space( Ws_attr_st *ast @@ -1148,8 +1225,8 @@ Pfloat wsgl_get_char_space( /******************************************************************************* * wsgl_add_names_set * - * DESCR: Add names to nameset - * RETURNS: N/A + * DESCR: Add names to nameset + * RETURNS: N/A */ void wsgl_add_names_set( Ws *ws, @@ -1171,8 +1248,8 @@ void wsgl_add_names_set( /******************************************************************************* * wsgl_remove_names_set * - * DESCR: Remove names from nameset - * RETURNS: N/A + * DESCR: Remove names from nameset + * RETURNS: N/A */ void wsgl_remove_names_set( Ws *ws, diff --git a/src/libphigs/wsgl/wsgl_extattr.c b/src/libphigs/wsgl/wsgl_extattr.c index b545cf0..b56489f 100644 --- a/src/libphigs/wsgl/wsgl_extattr.c +++ b/src/libphigs/wsgl/wsgl_extattr.c @@ -1,24 +1,24 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2014 Surplus Users Ham Society -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -****************************************************************************** -* Changes: Copyright (C) 2022-2023 CERN -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2014 Surplus Users Ham Society + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ****************************************************************************** + * Changes: Copyright (C) 2022-2023 CERN + ******************************************************************************/ #include #include @@ -53,19 +53,35 @@ Pgcolr* wsgl_get_back_int_colr( if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_BACK_INT_COLR)) { gcolr = &ast->indiv_group.int_bundle.back_colr; - } - else { +#ifdef DEBUGA + printf("gcolr back from nameset %d colors %f %f %f %f\n", + gcolr->type, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a + ); +#endif + } else { gcolr = &ast->bundl_group.int_bundle.back_colr; +#ifdef DEBUGA + printf("gcolr back from bundle %d colors %f %f %f %f\n", + gcolr->type, + gcolr->val.general.x, + gcolr->val.general.y, + gcolr->val.general.z, + gcolr->val.general.a + ); +#endif } - return gcolr; } /******************************************************************************* * wsgl_setup_back_int_attr_nocol * - * DESCR: Setup backface interior attributes without color - * RETURNS: N/A + * DESCR: Setup backface interior attributes without color + * RETURNS: N/A */ void wsgl_setup_back_int_attr_nocol( @@ -100,14 +116,14 @@ void wsgl_setup_back_int_attr_nocol( glPolygonStipple(wsgl_hatch_tbl[style_ind - 1]); wsgl->dev_st.int_style_ind = style_ind; } - + if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_BACK_INT_SHAD_METH)) { shad_meth = ast->indiv_group.int_bundle.back_shad_meth; } else { shad_meth = ast->bundl_group.int_bundle.back_shad_meth; } - + if (shad_meth != wsgl->dev_st.int_shad_meth) { if (shad_meth == PSD_NONE) { glShadeModel(GL_FLAT); @@ -116,29 +132,21 @@ void wsgl_setup_back_int_attr_nocol( } wsgl->dev_st.int_shad_meth = shad_meth; } - + if (wsgl->cur_struct.lighting) { -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) { -#else if (wsgl_use_shaders) { -#endif glUniform1i(shading_mode, 1); } else { glEnable(GL_LIGHTING); } } else { -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) { -#else - if (wsgl_use_shaders) { -#endif - glUniform1i(shading_mode, 0); - } else { - glDisable(GL_LIGHTING); - } + if (wsgl_use_shaders) { + glUniform1i(shading_mode, 0); + } else { + glDisable(GL_LIGHTING); + } } - // glCullFace(GL_FRONT); + glCullFace(GL_FRONT); } /******************************************************************************* @@ -149,105 +157,149 @@ void wsgl_setup_back_int_attr_nocol( * RETURNS: N/A */ void wsgl_setup_int_refl_props( - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ) + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ) { - Pint refl_eqn; - Prefl_props *refl_props; - + Pint refl_eqn; + Prefl_props *refl_props; + #ifdef DEBUGLIGHT - printf("Setup int refl_props called.\n"); + printf("Setup int refl_props called.\n"); #endif - if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_INT_REFL_EQN)) { - refl_eqn = ast->indiv_group.int_bundle.refl_eqn; - } - else { - refl_eqn = ast->bundl_group.int_bundle.refl_eqn; - } - - if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_REFL_PROPS)) { - refl_props = &ast->indiv_group.int_bundle.refl_props; - } - else { - refl_props = &ast->bundl_group.int_bundle.refl_props; - } - - switch (refl_eqn) { - case PREFL_AMBIENT: - if (colr_type == PMODEL_RGB) { - glColorMaterial(GL_FRONT, GL_AMBIENT); - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red * refl_props->ambient_coef, - colr->direct.rgb.green * refl_props->ambient_coef, - colr->direct.rgb.blue * refl_props->ambient_coef, - 1.0); - } - - glColorMaterial(GL_FRONT, GL_DIFFUSE); - glVertexAttrib4f(vCOLOR, 0.0, 0.0, 0.0, 1.0); - - glColorMaterial(GL_FRONT, GL_SPECULAR); - glVertexAttrib4f(vCOLOR,0.0, 0.0, 0.0, 1.0); - break; - - case PREFL_AMB_DIFF: - if (colr_type == PMODEL_RGB) { - glColorMaterial(GL_FRONT, GL_AMBIENT); - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red * refl_props->ambient_coef, - colr->direct.rgb.green * refl_props->ambient_coef, - colr->direct.rgb.blue * refl_props->ambient_coef, - 1.0); - - glColorMaterial(GL_FRONT, GL_DIFFUSE); - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red * refl_props->diffuse_coef, - colr->direct.rgb.green * refl_props->diffuse_coef, - colr->direct.rgb.blue * refl_props->diffuse_coef, - 1.0); - } - - glColorMaterial(GL_FRONT, GL_SPECULAR); - glVertexAttrib4f(vCOLOR,0.0, 0.0, 0.0, 1.0); - break; - - case PREFL_AMB_DIFF_SPEC: - if (colr_type == PMODEL_RGB) { - glColorMaterial(GL_FRONT, GL_AMBIENT); - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red * refl_props->ambient_coef, - colr->direct.rgb.green * refl_props->ambient_coef, - colr->direct.rgb.blue * refl_props->ambient_coef, - 1.0); - - glColorMaterial(GL_FRONT, GL_DIFFUSE); - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red * refl_props->diffuse_coef, - colr->direct.rgb.green * refl_props->diffuse_coef, - colr->direct.rgb.blue * refl_props->diffuse_coef, - 1.0); - - glColorMaterial(GL_FRONT, GL_SPECULAR); - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red * refl_props->specular_coef, - colr->direct.rgb.green * refl_props->specular_coef, - colr->direct.rgb.blue * refl_props->specular_coef, - 1.0); - } - break; - - default: - break; - } + if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_INT_REFL_EQN)) { + refl_eqn = ast->indiv_group.int_bundle.refl_eqn; + } + else { + refl_eqn = ast->bundl_group.int_bundle.refl_eqn; + } + + if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_REFL_PROPS)) { + refl_props = &ast->indiv_group.int_bundle.refl_props; + } + else { + refl_props = &ast->bundl_group.int_bundle.refl_props; + } + + switch (refl_eqn) { + case PREFL_AMBIENT: + if (colr_type == PMODEL_RGB) { + glColorMaterial(GL_FRONT, GL_AMBIENT); + glVertexAttrib3f(vCOLOR, + colr->direct.rgb.red * refl_props->ambient_coef, + colr->direct.rgb.green * refl_props->ambient_coef, + colr->direct.rgb.blue * refl_props->ambient_coef); + } + if (colr_type == PMODEL_RGBA) { + glColorMaterial(GL_FRONT, GL_AMBIENT); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->ambient_coef, + colr->direct.rgba.green * refl_props->ambient_coef, + colr->direct.rgba.blue * refl_props->ambient_coef, + colr->direct.rgba.alpha); // FIXME: is this correct? + } + + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glVertexAttrib4f(vCOLOR, 0.0, 0.0, 0.0, 1.0); + + glColorMaterial(GL_FRONT, GL_SPECULAR); + glVertexAttrib4f(vCOLOR,0.0, 0.0, 0.0, 1.0); + break; + + case PREFL_AMB_DIFF: + if (colr_type == PMODEL_RGB) { + glColorMaterial(GL_FRONT, GL_AMBIENT); + glVertexAttrib3f(vCOLOR, + colr->direct.rgb.red * refl_props->ambient_coef, + colr->direct.rgb.green * refl_props->ambient_coef, + colr->direct.rgb.blue * refl_props->ambient_coef + ); + + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glVertexAttrib3f(vCOLOR, + colr->direct.rgb.red * refl_props->diffuse_coef, + colr->direct.rgb.green * refl_props->diffuse_coef, + colr->direct.rgb.blue * refl_props->diffuse_coef + ); + } + if (colr_type == PMODEL_RGBA) { + glColorMaterial(GL_FRONT, GL_AMBIENT); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->ambient_coef, + colr->direct.rgba.green * refl_props->ambient_coef, + colr->direct.rgba.blue * refl_props->ambient_coef, + colr->direct.rgba.alpha); + + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->diffuse_coef, + colr->direct.rgba.green * refl_props->diffuse_coef, + colr->direct.rgba.blue * refl_props->diffuse_coef, + colr->direct.rgba.alpha); + } + + glColorMaterial(GL_FRONT, GL_SPECULAR); + glVertexAttrib4f(vCOLOR,0.0, 0.0, 0.0, 1.0); + break; + + case PREFL_AMB_DIFF_SPEC: + if (colr_type == PMODEL_RGB) { + glColorMaterial(GL_FRONT, GL_AMBIENT); + glVertexAttrib3f(vCOLOR, + colr->direct.rgb.red * refl_props->ambient_coef, + colr->direct.rgb.green * refl_props->ambient_coef, + colr->direct.rgb.blue * refl_props->ambient_coef + ); + + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glVertexAttrib3f(vCOLOR, + colr->direct.rgb.red * refl_props->diffuse_coef, + colr->direct.rgb.green * refl_props->diffuse_coef, + colr->direct.rgb.blue * refl_props->diffuse_coef + ); + + glColorMaterial(GL_FRONT, GL_SPECULAR); + glVertexAttrib3f(vCOLOR, + colr->direct.rgb.red * refl_props->specular_coef, + colr->direct.rgb.green * refl_props->specular_coef, + colr->direct.rgb.blue * refl_props->specular_coef + ); + } + if (colr_type == PMODEL_RGBA) { + glColorMaterial(GL_FRONT, GL_AMBIENT); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->ambient_coef, + colr->direct.rgba.green * refl_props->ambient_coef, + colr->direct.rgba.blue * refl_props->ambient_coef, + colr->direct.rgba.alpha); + + glColorMaterial(GL_FRONT, GL_DIFFUSE); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->diffuse_coef, + colr->direct.rgba.green * refl_props->diffuse_coef, + colr->direct.rgba.blue * refl_props->diffuse_coef, + colr->direct.rgba.alpha); + + glColorMaterial(GL_FRONT, GL_SPECULAR); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->specular_coef, + colr->direct.rgba.green * refl_props->specular_coef, + colr->direct.rgba.blue * refl_props->specular_coef, + colr->direct.rgba.alpha); + } + break; + + default: + break; + } } /******************************************************************************* * wsgl_setup_back_int_refl_props * * DESCR: Setup backface surface reflection and colour properties - * NOTES: Make sure to enable GL_COLOR_MATERIAL before use + * NOTES: Make sure to enable GL_COLOR_MATERIAL before use * RETURNS: N/A */ void wsgl_setup_back_int_refl_props( @@ -260,7 +312,7 @@ void wsgl_setup_back_int_refl_props( Prefl_props *refl_props; #ifdef DEBUGLIGHT - printf("Setup back int refl_props called.\n"); + printf("Setup back int refl_props called.\n"); #endif if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_BACK_INT_REFL_EQN)) { @@ -282,11 +334,19 @@ void wsgl_setup_back_int_refl_props( case PREFL_AMBIENT: if (colr_type == PMODEL_RGB) { glColorMaterial(GL_BACK, GL_AMBIENT); - glVertexAttrib4f(vCOLOR, + glVertexAttrib3f(vCOLOR, colr->direct.rgb.red * refl_props->ambient_coef, colr->direct.rgb.green * refl_props->ambient_coef, - colr->direct.rgb.blue * refl_props->ambient_coef, - 1.0); + colr->direct.rgb.blue * refl_props->ambient_coef + ); + } + if (colr_type == PMODEL_RGBA) { + glColorMaterial(GL_BACK, GL_AMBIENT); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->ambient_coef, + colr->direct.rgba.green * refl_props->ambient_coef, + colr->direct.rgba.blue * refl_props->ambient_coef, + colr->direct.rgba.alpha * refl_props->ambient_coef); } glColorMaterial(GL_BACK, GL_DIFFUSE); @@ -299,18 +359,33 @@ void wsgl_setup_back_int_refl_props( case PREFL_AMB_DIFF: if (colr_type == PMODEL_RGB) { glColorMaterial(GL_BACK, GL_AMBIENT); - glVertexAttrib4f(vCOLOR, + glVertexAttrib3f(vCOLOR, colr->direct.rgb.red * refl_props->ambient_coef, colr->direct.rgb.green * refl_props->ambient_coef, - colr->direct.rgb.blue * refl_props->ambient_coef, - 1.0); + colr->direct.rgb.blue * refl_props->ambient_coef + ); glColorMaterial(GL_BACK, GL_DIFFUSE); - glVertexAttrib4f(vCOLOR, + glVertexAttrib3f(vCOLOR, colr->direct.rgb.red * refl_props->diffuse_coef, colr->direct.rgb.green * refl_props->diffuse_coef, - colr->direct.rgb.blue * refl_props->diffuse_coef, - 1.0); + colr->direct.rgb.blue * refl_props->diffuse_coef + ); + } + if (colr_type == PMODEL_RGBA) { + glColorMaterial(GL_BACK, GL_AMBIENT); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->ambient_coef, + colr->direct.rgba.green * refl_props->ambient_coef, + colr->direct.rgba.blue * refl_props->ambient_coef, + colr->direct.rgba.alpha); + + glColorMaterial(GL_BACK, GL_DIFFUSE); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->diffuse_coef, + colr->direct.rgba.green * refl_props->diffuse_coef, + colr->direct.rgba.blue * refl_props->diffuse_coef, + colr->direct.rgba.alpha); } glColorMaterial(GL_BACK, GL_SPECULAR); @@ -320,25 +395,47 @@ void wsgl_setup_back_int_refl_props( case PREFL_AMB_DIFF_SPEC: if (colr_type == PMODEL_RGB) { glColorMaterial(GL_BACK, GL_AMBIENT); - glVertexAttrib4f(vCOLOR, + glVertexAttrib3f(vCOLOR, colr->direct.rgb.red * refl_props->ambient_coef, colr->direct.rgb.green * refl_props->ambient_coef, - colr->direct.rgb.blue * refl_props->ambient_coef, - 1.0); + colr->direct.rgb.blue * refl_props->ambient_coef + ); glColorMaterial(GL_BACK, GL_DIFFUSE); - glVertexAttrib4f(vCOLOR, + glVertexAttrib3f(vCOLOR, colr->direct.rgb.red * refl_props->diffuse_coef, colr->direct.rgb.green * refl_props->diffuse_coef, - colr->direct.rgb.blue * refl_props->diffuse_coef, - 1.0); + colr->direct.rgb.blue * refl_props->diffuse_coef + ); glColorMaterial(GL_BACK, GL_SPECULAR); - glVertexAttrib4f(vCOLOR, + glVertexAttrib3f(vCOLOR, colr->direct.rgb.red * refl_props->specular_coef, colr->direct.rgb.green * refl_props->specular_coef, - colr->direct.rgb.blue * refl_props->specular_coef, - 1.0); + colr->direct.rgb.blue * refl_props->specular_coef + ); + } + if (colr_type == PMODEL_RGBA) { + glColorMaterial(GL_BACK, GL_AMBIENT); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->ambient_coef, + colr->direct.rgba.green * refl_props->ambient_coef, + colr->direct.rgba.blue * refl_props->ambient_coef, + colr->direct.rgba.alpha); + + glColorMaterial(GL_BACK, GL_DIFFUSE); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->diffuse_coef, + colr->direct.rgba.green * refl_props->diffuse_coef, + colr->direct.rgba.blue * refl_props->diffuse_coef, + colr->direct.rgba.alpha); + + glColorMaterial(GL_BACK, GL_SPECULAR); + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red * refl_props->specular_coef, + colr->direct.rgba.green * refl_props->specular_coef, + colr->direct.rgba.blue * refl_props->specular_coef, + colr->direct.rgba.alpha); } break; @@ -350,29 +447,29 @@ void wsgl_setup_back_int_refl_props( /******************************************************************************* * wsgl_setup_int_reflectance_model * - * DESCR: + * DESCR: * RETURNS: N/A */ void wsgl_setup_int_reflectance_model( - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ) + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ) { - Pint refl_model; - Prefl_props *refl_props; - GLfloat ambient[4]; - GLfloat diffuse[4]; - GLfloat specular[4]; - - if (phg_nset_name_is_set(&ast->asf_nameset, - (Pint) PASPECT_INT_REFL_MODEL)) { - refl_model = ast->indiv_group.int_bundle.refl_model; - } - else { - refl_model = ast->bundl_group.int_bundle.refl_model; - } + Pint refl_model; + Prefl_props *refl_props; + GLfloat ambient[4]; + GLfloat diffuse[4]; + GLfloat specular[4]; + + if (phg_nset_name_is_set(&ast->asf_nameset, + (Pint) PASPECT_INT_REFL_MODEL)) { + refl_model = ast->indiv_group.int_bundle.refl_model; + } + else { + refl_model = ast->bundl_group.int_bundle.refl_model; + } if (phg_nset_name_is_set(&ast->asf_nameset, (Pint) PASPECT_REFL_PROPS)) { refl_props = &ast->indiv_group.int_bundle.refl_props; @@ -381,125 +478,165 @@ void wsgl_setup_int_reflectance_model( refl_props = &ast->bundl_group.int_bundle.refl_props; } - switch (refl_model) { - case PREFL_AMBIENT: + if (wsgl_use_shaders) glUniform1i(shading_mode, 1); + + switch (refl_model) { + case PREFL_AMBIENT: #ifdef DEBUGLIGHT - printf("Reflectance model, Ambient\n"); -#endif -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) glUniform1i(shading_mode, 1); -#else - if (wsgl_use_shaders) glUniform1i(shading_mode, 1); + printf("Reflectance model, Ambient\n"); #endif - if (colr_type == PMODEL_RGB) { - ambient[0] = colr->direct.rgb.red * refl_props->ambient_coef; - ambient[1] = colr->direct.rgb.green * refl_props->ambient_coef; - ambient[2] = colr->direct.rgb.blue * refl_props->ambient_coef; - ambient[3] = 1.0; - - diffuse[0] = 0.0; - diffuse[1] = 0.0; - diffuse[2] = 0.0; - diffuse[3] = 1.0; - - specular[0] = 0.0; - specular[1] = 0.0; - specular[2] = 0.0; - specular[3] = 1.0; - } - break; - - case PREFL_AMB_DIFF: + if (colr_type == PMODEL_RGB) { + ambient[0] = colr->direct.rgb.red * refl_props->ambient_coef; + ambient[1] = colr->direct.rgb.green * refl_props->ambient_coef; + ambient[2] = colr->direct.rgb.blue * refl_props->ambient_coef; + ambient[3] = 1.0; + + diffuse[0] = 0.0; + diffuse[1] = 0.0; + diffuse[2] = 0.0; + diffuse[3] = 1.0; + + specular[0] = 0.0; + specular[1] = 0.0; + specular[2] = 0.0; + specular[3] = 1.0; + } + if (colr_type == PMODEL_RGBA) { + ambient[0] = colr->direct.rgba.red * refl_props->ambient_coef; + ambient[1] = colr->direct.rgba.green * refl_props->ambient_coef; + ambient[2] = colr->direct.rgba.blue * refl_props->ambient_coef; + ambient[3] = colr->direct.rgba.alpha * refl_props->ambient_coef; + + diffuse[0] = 0.0; + diffuse[1] = 0.0; + diffuse[2] = 0.0; + diffuse[3] = 1.0; + + specular[0] = 0.0; + specular[1] = 0.0; + specular[2] = 0.0; + specular[3] = 1.0; + } + break; + + case PREFL_AMB_DIFF: #ifdef DEBUGLIGHT - printf("Reflectance model, AMB_DIFF\n"); + printf("Reflectance model, AMB_DIFF\n"); #endif - if (colr_type == PMODEL_RGB) { -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) glUniform1i(shading_mode, 1); -#else - if (wsgl_use_shaders) glUniform1i(shading_mode, 1); -#endif - ambient[0] = colr->direct.rgb.red * refl_props->ambient_coef; - ambient[1] = colr->direct.rgb.green * refl_props->ambient_coef; - ambient[2] = colr->direct.rgb.blue * refl_props->ambient_coef; - ambient[3] = 1.0; - - diffuse[0] = colr->direct.rgb.red * refl_props->diffuse_coef; - diffuse[1] = colr->direct.rgb.green * refl_props->diffuse_coef; - diffuse[2] = colr->direct.rgb.blue * refl_props->diffuse_coef; - diffuse[3] = 1.0; - - specular[0] = 0.0; - specular[1] = 0.0; - specular[2] = 0.0; - specular[3] = 1.0; - } - break; - - case PREFL_AMB_DIFF_SPEC: + if (colr_type == PMODEL_RGB) { + ambient[0] = colr->direct.rgb.red * refl_props->ambient_coef; + ambient[1] = colr->direct.rgb.green * refl_props->ambient_coef; + ambient[2] = colr->direct.rgb.blue * refl_props->ambient_coef; + ambient[3] = 1.0; + + diffuse[0] = colr->direct.rgb.red * refl_props->diffuse_coef; + diffuse[1] = colr->direct.rgb.green * refl_props->diffuse_coef; + diffuse[2] = colr->direct.rgb.blue * refl_props->diffuse_coef; + diffuse[3] = 1.0; + + specular[0] = 0.0; + specular[1] = 0.0; + specular[2] = 0.0; + specular[3] = 1.0; + } + if (colr_type == PMODEL_RGBA) { + ambient[0] = colr->direct.rgba.red * refl_props->ambient_coef; + ambient[1] = colr->direct.rgba.green * refl_props->ambient_coef; + ambient[2] = colr->direct.rgba.blue * refl_props->ambient_coef; + ambient[3] = colr->direct.rgba.alpha * refl_props->ambient_coef; + + diffuse[0] = colr->direct.rgba.red * refl_props->diffuse_coef; + diffuse[1] = colr->direct.rgba.green * refl_props->diffuse_coef; + diffuse[2] = colr->direct.rgba.blue * refl_props->diffuse_coef; + diffuse[3] = colr->direct.rgba.alpha * refl_props->diffuse_coef; + + specular[0] = 0.0; + specular[1] = 0.0; + specular[2] = 0.0; + specular[3] = 1.0; + } + break; + + case PREFL_AMB_DIFF_SPEC: #ifdef DEBUGLIGHT - printf("Reflectance model, AMB_DIFF_SPEC\n"); + printf("Reflectance model, AMB_DIFF_SPEC\n"); #endif - if (colr_type == PMODEL_RGB) { -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) glUniform1i(shading_mode, 1); -#else - if (wsgl_use_shaders) glUniform1i(shading_mode, 1); -#endif - ambient[0] = colr->direct.rgb.red * refl_props->ambient_coef; - ambient[1] = colr->direct.rgb.green * refl_props->ambient_coef; - ambient[2] = colr->direct.rgb.blue * refl_props->ambient_coef; - ambient[3] = 1.0; - - diffuse[0] = colr->direct.rgb.red * refl_props->diffuse_coef; - diffuse[1] = colr->direct.rgb.green * refl_props->diffuse_coef; - diffuse[2] = colr->direct.rgb.blue * refl_props->diffuse_coef; - diffuse[3] = 1.0; - - specular[0] = colr->direct.rgb.red * refl_props->specular_coef; - specular[1] = colr->direct.rgb.green * refl_props->specular_coef; - specular[2] = colr->direct.rgb.blue * refl_props->specular_coef; - specular[3] = 1.0; - } + if (colr_type == PMODEL_RGB) { + ambient[0] = colr->direct.rgb.red * refl_props->ambient_coef; + ambient[1] = colr->direct.rgb.green * refl_props->ambient_coef; + ambient[2] = colr->direct.rgb.blue * refl_props->ambient_coef; + ambient[3] = 1.0; + + diffuse[0] = colr->direct.rgb.red * refl_props->diffuse_coef; + diffuse[1] = colr->direct.rgb.green * refl_props->diffuse_coef; + diffuse[2] = colr->direct.rgb.blue * refl_props->diffuse_coef; + diffuse[3] = 1.0; + + specular[0] = colr->direct.rgb.red * refl_props->specular_coef; + specular[1] = colr->direct.rgb.green * refl_props->specular_coef; + specular[2] = colr->direct.rgb.blue * refl_props->specular_coef; + specular[3] = 1.0; + } + if (colr_type == PMODEL_RGBA) { + ambient[0] = colr->direct.rgba.red * refl_props->ambient_coef; + ambient[1] = colr->direct.rgba.green * refl_props->ambient_coef; + ambient[2] = colr->direct.rgba.blue * refl_props->ambient_coef; + ambient[3] = colr->direct.rgba.alpha * refl_props->ambient_coef; + + diffuse[0] = colr->direct.rgba.red * refl_props->diffuse_coef; + diffuse[1] = colr->direct.rgba.green * refl_props->diffuse_coef; + diffuse[2] = colr->direct.rgba.blue * refl_props->diffuse_coef; + diffuse[3] = colr->direct.rgba.alpha * refl_props->diffuse_coef; + + specular[0] = colr->direct.rgba.red * refl_props->specular_coef; + specular[1] = colr->direct.rgba.green * refl_props->specular_coef; + specular[2] = colr->direct.rgba.blue * refl_props->specular_coef; + specular[3] = colr->direct.rgba.alpha * refl_props->specular_coef; + } #ifdef DEBUGLIGHT - else printf("Reflectance model, color type is not RGB %d \n", colr_type); + else printf("Reflectance model, color type is not RGB %d \n", colr_type); #endif - break; + break; - default: + default: #ifdef DEBUGLIGHT - printf("Reflectance model, DEFAULT\n"); -#endif - memset(ambient, 0.0, sizeof(Pfloat) * 3); - memset(diffuse, 0.0, sizeof(Pfloat) * 3); - memset(specular, 0.0, sizeof(Pfloat) * 3); -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) glUniform1i(shading_mode, 0); -#else - if (wsgl_use_shaders) glUniform1i(shading_mode, 0); + printf("Reflectance model, DEFAULT\n"); #endif - break; - } + memset(ambient, 0.0, sizeof(Pfloat) * 3); + memset(diffuse, 0.0, sizeof(Pfloat) * 3); + memset(specular, 0.0, sizeof(Pfloat) * 3); + if (wsgl_use_shaders) glUniform1i(shading_mode, 0); + break; + } -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects) { -#else - if (wsgl_use_shaders) { -#endif - glVertexAttrib4f(vCOLOR, - colr->direct.rgb.red, - colr->direct.rgb.green, - colr->direct.rgb.blue, - 1.0); - glUniform4fv(vAmbient, 1, ambient); - glUniform4fv(vDiffuse, 1, diffuse); - glUniform4fv(vSpecular, 1, specular); - } else { - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); - } - } + if (wsgl_use_shaders) { + switch (colr_type){ + case PMODEL_RGB: + glVertexAttrib4f(vCOLOR, + colr->direct.rgb.red, + colr->direct.rgb.green, + colr->direct.rgb.blue, + 1.0); + break; + case PMODEL_RGBA: + glVertexAttrib4f(vCOLOR, + colr->direct.rgba.red, + colr->direct.rgba.green, + colr->direct.rgba.blue, + colr->direct.rgba.alpha); + break; + default: + break; + } + glUniform4fv(vAmbient, 1, ambient); + glUniform4fv(vDiffuse, 1, diffuse); + glUniform4fv(vSpecular, 1, specular); + } else { + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); + } +} /******************************************************************************* * wsgl_setup_int_colr @@ -509,30 +646,36 @@ void wsgl_setup_int_reflectance_model( */ int wsgl_setup_int_colr( - Ws *ws, - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ) + Ws *ws, + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ) { - int lighting; - - Wsgl_handle wsgl = ws->render_context; + int lighting; - if (wsgl->cur_struct.lighting) { + Wsgl_handle wsgl = ws->render_context; + if (wsgl->cur_struct.lighting) { #ifdef DEBUGLIGHT - printf("Setup int color\n"); + printf("wsgl_setup_int_colr: Setup int color\n"); #endif - wsgl_setup_int_refl_props(colr_type, colr, ast); - wsgl_setup_int_reflectance_model(colr_type, colr, ast); - lighting = TRUE; - } - else { - wsgl_set_colr(colr_type, colr); - lighting = FALSE; - } - - return lighting; + wsgl_setup_int_refl_props(colr_type, colr, ast); + wsgl_setup_int_reflectance_model(colr_type, colr, ast); + lighting = TRUE; + } + else { +#ifdef DEBUGA + printf("wsgl_setup_int_colr: Setting colr_type %d, %f %f %f %f\n", + colr->direct.rgba.red, + colr->direct.rgba.green, + colr->direct.rgba.blue, + colr->direct.rgba.alpha); +#endif + wsgl_set_colr(colr_type, colr); + lighting = FALSE; + } + + return lighting; } /******************************************************************************* @@ -543,18 +686,22 @@ int wsgl_setup_int_colr( */ int wsgl_setup_int_attr_plus( - Ws *ws, - Ws_attr_st *ast - ) + Ws *ws, + Ws_attr_st *ast + ) { - Pcoval colr; + Pcoval colr; + Pgcolr *gcolr; #ifdef DEBUGLIGHT - printf("Setup int color plus\n"); + printf("Setup int color plus\n"); #endif - wsgl_setup_int_attr_nocol(ws, ast); - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); - return wsgl_setup_int_colr(ws, PMODEL_RGB, &colr, ast); + wsgl_setup_int_attr_nocol(ws, ast); + gcolr = wsgl_get_int_colr(ast); + wsgl_convert_gcolr(gcolr, ws->current_colour_model); + wsgl_colr_from_gcolr(&colr, gcolr, ws->current_colour_model); + // return wsgl_setup_int_colr(ws, ws->acurrent_colour_model, &colr, ast); + return wsgl_setup_int_colr(ws, gcolr->type, &colr, ast); } /******************************************************************************* @@ -565,30 +712,30 @@ int wsgl_setup_int_attr_plus( */ int wsgl_setup_back_int_colr( - Ws *ws, - Pint colr_type, - Pcoval *colr, - Ws_attr_st *ast - ) + Ws *ws, + Pint colr_type, + Pcoval *colr, + Ws_attr_st *ast + ) { - int lighting; + int lighting; - Wsgl_handle wsgl = ws->render_context; + Wsgl_handle wsgl = ws->render_context; - if (wsgl->cur_struct.lighting) { + if (wsgl->cur_struct.lighting) { #ifdef DEBUGLIGHT - printf("Setup back int color\n"); + printf("Setup back int color\n"); #endif - wsgl_setup_back_int_refl_props(colr_type, colr, ast); - wsgl_setup_int_reflectance_model(colr_type, colr, ast); - lighting = TRUE; - } - else { - wsgl_set_colr(colr_type, colr); - lighting = FALSE; - } - - return lighting; + wsgl_setup_back_int_refl_props(colr_type, colr, ast); + wsgl_setup_int_reflectance_model(colr_type, colr, ast); + lighting = TRUE; + } + else { + wsgl_set_colr(colr_type, colr); + lighting = FALSE; + } + + return lighting; } /******************************************************************************* @@ -598,17 +745,20 @@ int wsgl_setup_back_int_colr( * RETURNS: Lighting state */ - int wsgl_setup_back_int_attr_plus( - Ws *ws, - Ws_attr_st *ast - ) - { - Pcoval colr; +int wsgl_setup_back_int_attr_plus( + Ws *ws, + Ws_attr_st *ast + ) +{ + Pcoval colr; + Pgcolr *gcolr; #ifdef DEBUGLIGHT - printf("Setup back int color plus\n"); + printf("Setup back int color plus\n"); #endif - wsgl_setup_back_int_attr_nocol(ws, ast); - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); - return wsgl_setup_back_int_colr(ws, PMODEL_RGB, &colr, ast); - } + wsgl_setup_back_int_attr_nocol(ws, ast); + gcolr = wsgl_get_back_int_colr(ast); + wsgl_convert_gcolr(gcolr, ws->current_colour_model); + wsgl_colr_from_gcolr(&colr, gcolr, ws->current_colour_model); + return wsgl_setup_back_int_colr(ws, gcolr->type , &colr, ast); +} diff --git a/src/libphigs/wsgl/wsgl_fasd3fill.c b/src/libphigs/wsgl/wsgl_fasd3fill.c index e0d2498..b8853a3 100644 --- a/src/libphigs/wsgl/wsgl_fasd3fill.c +++ b/src/libphigs/wsgl/wsgl_fasd3fill.c @@ -328,6 +328,7 @@ void wsgl_fill_area_set3_data_front( Pcoval colr; Pvec3 norm; Pint colr_type; + Pgcolr *gcolr; fasd3.edata = &edata; fasd3.vdata = &vdata; @@ -337,7 +338,6 @@ void wsgl_fill_area_set3_data_front( glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_LINE); wsgl_setup_int_attr_nocol(ws, ast); - switch (fasd3.vflag) { case PVERT_COORD: if (fasd3.fflag == PFACET_COLOUR_NORMAL) { @@ -364,7 +364,7 @@ void wsgl_fill_area_set3_data_front( } else if (fasd3.fflag == PFACET_NORMAL) { colr_type = wsgl_get_int_colr(ast)->type; - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, colr_type, &colr, ast); glNormal3f(fasd3.fdata.norm.delta_x, fasd3.fdata.norm.delta_y, @@ -403,9 +403,18 @@ void wsgl_fill_area_set3_data_front( } } else { - colr_type = wsgl_get_int_colr(ast)->type; - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); - wsgl_setup_int_colr(ws, colr_type, &colr, ast); + gcolr = wsgl_get_int_colr(ast); + wsgl_colr_from_gcolr(&colr, gcolr, ws->current_colour_model); + wsgl_setup_int_colr(ws, gcolr->type, &colr, ast); +#ifdef DEBUGA + printf("fasd3fill: Setup color type %d: %f %f %f %f\n", + gcolr->type, + colr.direct.rgba.red, + colr.direct.rgba.green, + colr.direct.rgba.blue, + colr.direct.rgba.alpha + ); +#endif fasd3_normal3(&norm, &fasd3); glNormal3f(norm.delta_x, norm.delta_y, norm.delta_z); wsgl_set_current_normal(norm.delta_x, norm.delta_y, norm.delta_z); @@ -483,7 +492,7 @@ void wsgl_fill_area_set3_data_front( } else { colr_type = wsgl_get_int_colr(ast)->type; - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, colr_type, &colr, ast); for (i = 0; i < fasd3.nfa; i++) { priv_fill_area3_ptnorms(fasd3.vdata->num_vertices, @@ -578,7 +587,7 @@ void wsgl_fill_area_set3_data_back( } else if (fasd3.fflag == PFACET_NORMAL) { colr_type = wsgl_get_back_int_colr(ast)->type; - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, colr_type, &colr, ast); glNormal3f(fasd3.fdata.norm.delta_x, fasd3.fdata.norm.delta_y, @@ -618,7 +627,7 @@ void wsgl_fill_area_set3_data_back( } else { colr_type = wsgl_get_back_int_colr(ast)->type; - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, colr_type, &colr, ast); fasd3_normal3(&norm, &fasd3); glNormal3f(norm.delta_x, norm.delta_y, norm.delta_z); @@ -697,7 +706,7 @@ void wsgl_fill_area_set3_data_back( } else { colr_type = wsgl_get_back_int_colr(ast)->type; - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, colr_type, &colr, ast); for (i = 0; i < fasd3.nfa; i++) { priv_fill_area3_ptnorms(fasd3.vdata->num_vertices, diff --git a/src/libphigs/wsgl/wsgl_fasdfill.c b/src/libphigs/wsgl/wsgl_fasdfill.c index 31bb0bf..73371ee 100644 --- a/src/libphigs/wsgl/wsgl_fasdfill.c +++ b/src/libphigs/wsgl/wsgl_fasdfill.c @@ -358,7 +358,7 @@ void wsgl_fill_area_set_data_front( } } else if (fasd3.fflag == PFACET_NORMAL) { - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, fasd3.colr_type, &colr, ast); glNormal3f(fasd3.fdata.norm.delta_x, fasd3.fdata.norm.delta_y, @@ -393,7 +393,7 @@ void wsgl_fill_area_set_data_front( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, fasd3.colr_type, &colr, ast); fasd3_normal3(&norm, &fasd3); glNormal3f(norm.delta_x, norm.delta_y, norm.delta_z); @@ -466,7 +466,7 @@ void wsgl_fill_area_set_data_front( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, fasd3.colr_type, &colr, ast); for (i = 0; i < fasd3.nfa; i++) { priv_fill_area_ptnorms(fasd3.vdata->num_vertices, @@ -559,7 +559,7 @@ void wsgl_fill_area_set_data_back( } } else if (fasd3.fflag == PFACET_NORMAL) { - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, fasd3.colr_type, &colr, ast); glNormal3f(fasd3.fdata.norm.delta_x, fasd3.fdata.norm.delta_y, @@ -598,7 +598,7 @@ void wsgl_fill_area_set_data_back( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, fasd3.colr_type, &colr, ast); fasd3_normal3(&norm, &fasd3); glNormal3f(norm.delta_x, norm.delta_y, norm.delta_z); @@ -676,7 +676,7 @@ void wsgl_fill_area_set_data_back( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, fasd3.colr_type, &colr, ast); for (i = 0; i < fasd3.nfa; i++) { priv_fill_area_ptnorms(fasd3.vdata->num_vertices, diff --git a/src/libphigs/wsgl/wsgl_light.c b/src/libphigs/wsgl/wsgl_light.c index b844995..2ffe0ea 100644 --- a/src/libphigs/wsgl/wsgl_light.c +++ b/src/libphigs/wsgl/wsgl_light.c @@ -95,11 +95,7 @@ static void setup_ambient_light( #ifdef DEBUGL printf("Ambient light: %f %f %f\n", amb[0], amb[1], amb[2]); #endif -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects){ -#else if (wsgl_use_shaders){ -#endif #ifdef DEBUGL printf("Ambient light Using shaders %d\n", ind); #endif @@ -183,11 +179,7 @@ static void setup_directional_light( dif[0], dif[1], dif[2], pos[0], pos[1], pos[2]); #endif -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects){ -#else if (wsgl_use_shaders){ -#endif #ifdef DEBUGL printf("Directional light Using shaders %d\n", ind); #endif @@ -286,11 +278,7 @@ static void setup_positional_light( pos[0], pos[1], pos[2], coef[0], coef[1]); #endif -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects){ -#else if (wsgl_use_shaders){ -#endif #ifdef DEBUGL printf("Positional light Using shaders %d\n", ind); #endif @@ -352,8 +340,8 @@ static void setup_positional_light( } } else { id = get_light_id(ind); - glLightfv(id, GL_DIFFUSE, dif); glLightfv(id, GL_POSITION, pos); + glLightfv(id, GL_SPECULAR, dif); glEnable(id); } } @@ -419,11 +407,7 @@ void wsgl_update_light_src_state( } } } else { -#ifdef GLEW - if (wsgl_use_shaders && GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects){ -#else if (wsgl_use_shaders){ -#endif switch (i){ case 1: glUniform1i(lightSource0, 0); @@ -452,11 +436,7 @@ void wsgl_update_light_src_state( } } } -#ifdef GLEW - if (!wsgl_use_shaders || !GLEW_ARB_vertex_shader || !GLEW_ARB_fragment_shader || !GLEW_ARB_shader_objects) glPopMatrix(); -#else if (!wsgl_use_shaders) glPopMatrix(); -#endif } /******************************************************************************* diff --git a/src/libphigs/wsgl/wsgl_marker.c b/src/libphigs/wsgl/wsgl_marker.c index a7ae8bc..59a4e9d 100644 --- a/src/libphigs/wsgl/wsgl_marker.c +++ b/src/libphigs/wsgl/wsgl_marker.c @@ -34,26 +34,34 @@ #define PI 3.1415926535897932384626433832795 /******************************************************************************* - * wsgl_marker_dot + * wsgl_marker_line_loop * * DESCR: Draw marker dots helper function * RETURNS: N/A */ -static void wsgl_marker_dot( - Ppoint_list *point_list, - Pfloat scale - ) +static void wsgl_marker_line_loop( + Pint n, + Ppoint_list *point_list, + Pfloat scale + ) { - int i; - - glPointSize(scale); - glBegin(GL_POINTS); - for (i = 0; i < point_list->num_points; i++) { - glVertex2f(point_list->points[i].x, - point_list->points[i].y); - } - glEnd(); + int i, j; + + float alpha, dalpha; + glLineWidth(1.0); + glDisable(GL_LINE_STIPPLE); + dalpha = 2.0*PI/(float)n; + glBegin(GL_LINE_LOOP); + for (i = 0; i < point_list->num_points; i++) { + alpha = dalpha/2.0; + for (j = 0; j < n; j++){ + glVertex2f(point_list->points[i].x + scale*cos(alpha), + point_list->points[i].y + scale*sin(alpha)); + alpha += dalpha; + } + } + glEnd(); } /******************************************************************************* @@ -219,7 +227,7 @@ void wsgl_polymarker( wsgl_setup_marker_attr(ast, &type, &size); switch (type) { case PMARKER_DOT: - wsgl_marker_dot(&point_list, size); + wsgl_marker_polygon(40, &point_list, size); break; case PMARKER_PLUS: @@ -235,7 +243,7 @@ void wsgl_polymarker( break; case PMARKER_CIRCLE: - wsgl_marker_polygon(40, &point_list, size); + wsgl_marker_line_loop(40, &point_list, size); break; case PMARKER_TRIANG: @@ -294,7 +302,7 @@ void wsgl_polymarker3( wsgl_setup_marker_attr(ast, &type, &size); switch (type) { case PMARKER_DOT: - wsgl_marker_dot(&plist, size); + wsgl_marker_polygon(40, &plist, size); break; case PMARKER_PLUS: @@ -310,7 +318,7 @@ void wsgl_polymarker3( break; case PMARKER_CIRCLE: - wsgl_marker_polygon(40, &plist, size); + wsgl_marker_line_loop(40, &plist, size); break; case PMARKER_TRIANG: diff --git a/src/libphigs/wsgl/wsgl_shaders.c b/src/libphigs/wsgl/wsgl_shaders.c index 7e1c5ea..4b8745c 100644 --- a/src/libphigs/wsgl/wsgl_shaders.c +++ b/src/libphigs/wsgl/wsgl_shaders.c @@ -1,22 +1,22 @@ /****************************************************************************** -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER -* -* This file is part of Open PHIGS -* Copyright (C) 2022-2023 CERN -* -* Open PHIGS is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License as published by -* the Free Software Foundation, either version 2.1 of the License, or -* (at your option) any later version. -* -* Open PHIGS 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 Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with Open PHIGS. If not, see . -******************************************************************************/ + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER + * + * This file is part of Open PHIGS + * Copyright (C) 2022-2023 CERN + * + * Open PHIGS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * Open PHIGS 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Open PHIGS. If not, see . + ******************************************************************************/ #include #include #include @@ -42,7 +42,6 @@ GLint plane1, point1; GLint shading_mode; GLint vAmbient, vDiffuse, vSpecular, vPositional; GLint ModelViewMatrix, ProjectionMatrix; -GLint alpha_channel; GLint lightSource0, lightSourceTyp0, lightSourceCol0, lightSourcePos0, lightSourceCoef0; GLint lightSource1, lightSourceTyp1, lightSourceCol1, lightSourcePos1, lightSourceCoef1; GLint lightSource2, lightSourceTyp2, lightSourceCol2, lightSourcePos2, lightSourceCoef2; @@ -51,298 +50,13 @@ GLint lightSource4, lightSourceTyp4, lightSourceCol4, lightSourcePos4, lightSour GLint lightSource5, lightSourceTyp5, lightSourceCol5, lightSourcePos5, lightSourceCoef5; GLint lightSource6, lightSourceTyp6, lightSourceCol6, lightSourcePos6, lightSourceCoef6; -static const char* vertex_shader_text_130 = -"#version 130\n" -"in vec4 vColor;\n" -"out vec4 Color;\n" -"out vec4 Normal;\n" -"out float gl_ClipDistance[6];\n" -"uniform mat4 ModelViewMatrix;\n" -"uniform mat4 ProjectionMatrix;\n" -"uniform int num_clip_planes;\n" -"uniform int clipping_ind;\n" -"uniform vec4 plane0;\n" -"uniform vec4 point0;\n" -"uniform vec4 plane1;\n" -"uniform vec4 point1;\n" -"float distance;\n" -"void main()\n" -"{\n" -" Color = vColor;\n" -" Normal = normalize(ModelViewMatrix * vec4(gl_Normal, 1));\n" -" gl_Position = ProjectionMatrix * ModelViewMatrix * gl_Vertex;\n" -" if (clipping_ind > 0) {\n" -" if (num_clip_planes == 1) {\n" -" gl_ClipDistance[0] = dot(gl_Vertex-point0, plane0);\n" -" } else if (num_clip_planes == 2) {\n" -" gl_ClipDistance[0] = dot(gl_Vertex-point0, plane0);\n" -" gl_ClipDistance[1] = -dot(gl_Vertex-point1, plane1);\n" -" } else {\n" -" gl_ClipDistance[0] = 1.0;\n" -" gl_ClipDistance[1] = 1.0;\n" -" }\n" -" } else {\n" -" gl_ClipDistance[0] = 1.0;\n" -" gl_ClipDistance[1] = 1.0;\n" -" }\n" -"}\n"; - -static const char* fragment_shader_text_130 = -"#version 130\n" -"uniform int ShadingMode;\n" -"uniform vec4 vAmbient;\n" -"uniform vec4 vDiffuse;\n" -"uniform vec4 vSpecular;\n" -"\n" -"uniform int lightSource0;\n" -"uniform int lightSourceTyp0;\n" -"uniform vec4 lightSourceCol0;\n" -"uniform vec4 lightSourcePos0;\n" -"uniform vec4 lightSourceCoef0;\n" -"\n" -"uniform int lightSource1;\n" -"uniform int lightSourceTyp1;\n" -"uniform vec4 lightSourceCol1;\n" -"uniform vec4 lightSourcePos1;\n" -"uniform vec4 lightSourceCoef1;\n" -"\n" -"uniform int lightSource2;\n" -"uniform int lightSourceTyp2;\n" -"uniform vec4 lightSourceCol2;\n" -"uniform vec4 lightSourcePos2;\n" -"uniform vec4 lightSourceCoef2;\n" -"\n" -"uniform int lightSource3;\n" -"uniform int lightSourceTyp3;\n" -"uniform vec4 lightSourceCol3;\n" -"uniform vec4 lightSourcePos3;\n" -"uniform vec4 lightSourceCoef3;\n" -"\n" -"uniform int lightSource4;\n" -"uniform int lightSourceTyp4;\n" -"uniform vec4 lightSourceCol4;\n" -"uniform vec4 lightSourcePos4;\n" -"uniform vec4 lightSourceCoef4;\n" -"\n" -"uniform int lightSource5;\n" -"uniform int lightSourceTyp5;\n" -"uniform vec4 lightSourceCol5;\n" -"uniform vec4 lightSourcePos5;\n" -"uniform vec4 lightSourceCoef5;\n" -"\n" -"uniform int lightSource6;\n" -"uniform int lightSourceTyp6;\n" -"uniform vec4 lightSourceCol6;\n" -"uniform vec4 lightSourcePos6;\n" -"uniform vec4 lightSourceCoef6;\n" -"uniform float alpha_channel;\n" -"\n" -"in vec4 Color;\n" -"in vec4 Normal;\n" -"out vec4 FragColor;\n" -"\n" -"vec4 getLight(int type, vec4 color, vec4 pos, vec4 coef){\n" -" vec4 light;\n" -" float refl = 0.0;\n" -" float angle = Normal.x*pos.x+Normal.y*pos.y+Normal.z*pos.z;\n" -" float lennorm = sqrt(Normal.x*Normal.x+Normal.y*Normal.y+Normal.z*Normal.z);\n" -" float lenpos = sqrt(pos.x*pos.x+pos.y*pos.y+pos.z*pos.z);\n" -" if (lennorm == 0.0) lennorm = 1.0;\n" -" if (lenpos == 0.0) lenpos = 1.0;\n" -" angle = max(angle/lennorm/lenpos, 0.0);\n" -" switch (type) {\n" -" case 1:\n" -" light = color * vAmbient;\n" -" break;\n" -" case 2:\n" -" light = color * vDiffuse * angle;\n" -" break;\n" -" case 3:\n" -" refl = coef.x * pow(angle, coef.y);\n" -" light = vSpecular * vec4(refl, refl, refl, 1.0);\n" -" break;\n" -" default:\n" -" light = vec4(0.5, 0.0, 0.0, 1.0);\n" -" break;\n" -" };\n" -" return light;\n" -"}\n" -"void main()\n" -"{\n" -" int i;\n" -" if (ShadingMode > 0) {\n" -" int n = 0;\n" -" FragColor = vec4(0., 0., 0, 1.);\n" -" for (i=0; i<7; i++){\n" -" switch (i) {\n" -" case 0:\n" -" if (lightSource0 > 0){ FragColor += getLight(lightSourceTyp0, lightSourceCol0, lightSourcePos0, lightSourceCoef0);n += 1;};\n" -" break;\n" -" case 1:\n" -" if (lightSource1 > 0){ FragColor += getLight(lightSourceTyp1, lightSourceCol1, lightSourcePos1, lightSourceCoef1);n += 1;};\n" -" break;\n" -" case 2:\n" -" if (lightSource2 > 0){ FragColor += getLight(lightSourceTyp2, lightSourceCol2, lightSourcePos2, lightSourceCoef2);n += 1;};\n" -" break;\n" -" case 3:\n" -" if (lightSource3 > 0){ FragColor += getLight(lightSourceTyp3, lightSourceCol3, lightSourcePos3, lightSourceCoef3);n += 1;};\n" -" break;\n" -" case 4:\n" -" if (lightSource4 > 0){ FragColor += getLight(lightSourceTyp4, lightSourceCol4, lightSourcePos4, lightSourceCoef4);n += 1;};\n" -" break;\n" -" case 5:\n" -" if (lightSource5 > 0){ FragColor += getLight(lightSourceTyp5, lightSourceCol5, lightSourcePos5, lightSourceCoef5);n += 1;};\n" -" break;\n" -" case 6:\n" -" if (lightSource6 > 0){ FragColor += getLight(lightSourceTyp6, lightSourceCol6, lightSourcePos6, lightSourceCoef6);n += 1;};\n" -" break;\n" -" default:\n" -" break;\n" -" };\n" -" };\n" -" if (n > 0){\n" -" FragColor = min(FragColor, vec4(1., 1., 1., 1.));" -" } else { FragColor = Color;};\n" -" } else {\n" -" FragColor = Color;\n" -" };\n" -" FragColor.a = alpha_channel;\n" -"}\n"; - -static const char* vertex_shader_text_120 = -"#version 120\n" -"uniform mat4 ModelViewMatrix;\n" -"uniform mat4 ProjectionMatrix;\n" -"attribute vec4 vColor;\n" -"varying vec4 Color;\n" -"varying vec4 Normal;\n" -"uniform int num_clip_planes;\n" -"uniform int clipping_ind;\n" -"uniform vec4 plane0;\n" -"uniform vec4 point0;\n" -"uniform vec4 plane1;\n" -"uniform vec4 point1;\n" -"void main()\n" -"{\n" -" Color = vColor;\n" -" Normal = normalize(ModelViewMatrix * vec4(gl_Normal, 1));\n" -" gl_Position = ProjectionMatrix * ModelViewMatrix * gl_Vertex;\n" -" if ((num_clip_planes >0 ) && (clipping_ind > 0)) {\n" -" gl_ClipVertex = transpose(ModelViewMatrix) * gl_Vertex;\n" -" };\n" -"}\n"; +/* version 1.20 vertex and fragment shaders */ +#include "private/vs120.h" +#include "private/fs120.h" -static const char* fragment_shader_text_120 = -"#version 120\n" -"uniform int ShadingMode;\n" -"uniform vec4 vAmbient;\n" -"uniform vec4 vDiffuse;\n" -"uniform vec4 vSpecular;\n" -"\n" -"uniform int lightSource0;\n" -"uniform int lightSourceTyp0;\n" -"uniform vec4 lightSourceCol0;\n" -"uniform vec4 lightSourcePos0;\n" -"uniform vec4 lightSourceCoef0;\n" -"\n" -"uniform int lightSource1;\n" -"uniform int lightSourceTyp1;\n" -"uniform vec4 lightSourceCol1;\n" -"uniform vec4 lightSourcePos1;\n" -"uniform vec4 lightSourceCoef1;\n" -"\n" -"uniform int lightSource2;\n" -"uniform int lightSourceTyp2;\n" -"uniform vec4 lightSourceCol2;\n" -"uniform vec4 lightSourcePos2;\n" -"uniform vec4 lightSourceCoef2;\n" -"\n" -"uniform int lightSource3;\n" -"uniform int lightSourceTyp3;\n" -"uniform vec4 lightSourceCol3;\n" -"uniform vec4 lightSourcePos3;\n" -"uniform vec4 lightSourceCoef3;\n" -"\n" -"uniform int lightSource4;\n" -"uniform int lightSourceTyp4;\n" -"uniform vec4 lightSourceCol4;\n" -"uniform vec4 lightSourcePos4;\n" -"uniform vec4 lightSourceCoef4;\n" -"\n" -"uniform int lightSource5;\n" -"uniform int lightSourceTyp5;\n" -"uniform vec4 lightSourceCol5;\n" -"uniform vec4 lightSourcePos5;\n" -"uniform vec4 lightSourceCoef5;\n" -"\n" -"uniform int lightSource6;\n" -"uniform int lightSourceTyp6;\n" -"uniform vec4 lightSourceCol6;\n" -"uniform vec4 lightSourcePos6;\n" -"uniform vec4 lightSourceCoef6;\n" -"uniform float alpha_channel;\n" -"varying vec4 Normal;\n" -"varying vec4 Color;\n" -"\n" -"vec4 getLight(int type, vec4 color, vec4 pos, vec4 coef){\n" -" vec4 light;\n" -" float refl = 0.0;\n" -" float angle = Normal.x*pos.x+Normal.y*pos.y+Normal.z*pos.z;\n" -" float lennorm = sqrt(Normal.x*Normal.x+Normal.y*Normal.y+Normal.z*Normal.z);\n" -" float lenpos = sqrt(pos.x*pos.x+pos.y*pos.y+pos.z*pos.z);\n" -" if (lennorm == 0.0) lennorm = 1.0;\n" -" if (lenpos == 0.0) lenpos = 1.0;\n" -" angle = max(angle/lennorm/lenpos, 0.0);\n" -" light = vec4(0.5, 0.0, 0.0, 1.0);\n" -" if (type == 1) {\n" -" light = color * vAmbient;\n" -" };\n" -" if (type == 2) {\n" -" light = color * vDiffuse * angle;\n" -" };\n" -" if (type == 3) {\n" -" refl = coef.x * pow(angle, coef.y);\n" -" light = vSpecular * vec4(refl, refl, refl, 1.0);\n" -" };\n" -" return light;\n" -"}\n" -"void main()\n" -"{\n" -" int i;\n" -" if (ShadingMode > 0) {\n" -" int n = 0;\n" -" gl_FragColor = vec4(0., 0., 0, 1.);\n" -" for (i=0; i<7; i++){\n" -" if (i==0) {\n" -" if (lightSource0 > 0){ gl_FragColor += getLight(lightSourceTyp0, lightSourceCol0, lightSourcePos0, lightSourceCoef0);n += 1;};\n" -" }" -" if (i==1) {\n" -" if (lightSource1 > 0){ gl_FragColor += getLight(lightSourceTyp1, lightSourceCol1, lightSourcePos1, lightSourceCoef1);n += 1;};\n" -" }" -" if (i==2) {\n" -" if (lightSource2 > 0){ gl_FragColor += getLight(lightSourceTyp2, lightSourceCol2, lightSourcePos2, lightSourceCoef2);n += 1;};\n" -" }" -" if (i==3) {\n" -" if (lightSource3 > 0){ gl_FragColor += getLight(lightSourceTyp3, lightSourceCol3, lightSourcePos3, lightSourceCoef3);n += 1;};\n" -" }" -" if (i==4) {\n" -" if (lightSource4 > 0){ gl_FragColor += getLight(lightSourceTyp4, lightSourceCol4, lightSourcePos4, lightSourceCoef4);n += 1;};\n" -" }" -" if (i==5) {\n" -" if (lightSource5 > 0){ gl_FragColor += getLight(lightSourceTyp5, lightSourceCol5, lightSourcePos5, lightSourceCoef5);n += 1;};\n" -" }" -" if (i==6) {\n" -" if (lightSource6 > 0){ gl_FragColor += getLight(lightSourceTyp6, lightSourceCol6, lightSourcePos6, lightSourceCoef6);n += 1;};\n" -" }" -" };\n" -" if (n > 0){\n" -" gl_FragColor = min(gl_FragColor, vec4(1., 1., 1., 1.));" -" } else { gl_FragColor = Color;};\n" -" } else {\n" -" gl_FragColor = Color;\n" -" };\n" -" gl_FragColor.a = alpha_channel;\n" -"}\n"; +/* version 1.30 vertex and fragment shaders */ +#include "private/vs130.h" +#include "private/fs130.h" /******************************************************************************* * wsgl_shaders @@ -360,60 +74,79 @@ void wsgl_shaders(Ws * ws){ } #ifdef GLEW #ifdef DEBUG - printf("DEBUG: Shaders: initialising GLEW\n"); + printf("DEBUG: Shaders: initialising GLEW\n"); #endif err = glewInit(); if (GLEW_OK != err){ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); abort(); } + if (! (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader && GLEW_ARB_shader_objects)) wsgl_use_shaders = 0; #endif -#ifdef GLEW - if (! wsgl_use_shaders || !GLEW_ARB_vertex_shader ||! GLEW_ARB_fragment_shader ||! GLEW_ARB_shader_objects) { -#else - if (! wsgl_use_shaders) { -#endif - fprintf(stderr, "WARNING: Shaders are not available or not wanted.\nSome functionality will not work, e.g. clipping\n"); + + if (! wsgl_use_shaders) { + fprintf(stderr, "WARNING: Shaders are not available or not wanted.\nSome functionality will not work, e.g. clipping\n"); glUseProgram(0); } else { char NewerVersion[] = "1.30"; const char * ShaderVersion = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION); const char * Vendor = (const char *) glGetString(GL_VENDOR); const char * Renderer = (const char *) glGetString(GL_RENDERER); - printf("INFO: Shader version is %s.\n", ShaderVersion); - printf("INFO Vendor: %s, card: %s\n", Vendor, Renderer); + printf("INFO: Hardware Shader version is %s.\n", ShaderVersion); + printf("INFO: Hardware Vendor: %s, card: %s\n", Vendor, Renderer); /* There is a bug somewhere when V3D driver (like on Raspberry-Pi) are used. Rendering works fine but then the program crashes with a segfault when the OpenGL window is clicked. For now, we switch off the use of shaders if this driver is detected. - */ + */ if (0 == strncmp(Renderer,"V3D", 3)){ - printf("WARNING: Detected V3D driver. Because of a bug shaders will be switched off\n"); - wsgl_use_shaders = 0; - return; + printf("WARNING: Detected V3D driver.\n"); + printf("WARNING: Because of a bug please switch off shaders via the configuration file\n"); } - vertex_shader = glCreateShader(GL_VERTEX_SHADER); - fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); if (strcmp(ShaderVersion, NewerVersion) < 0 ){ - printf("WARNING: Shader version is %s Using version 1.20 for shaders\n", ShaderVersion); - glShaderSource(vertex_shader, 1, &vertex_shader_text_120, NULL); - glShaderSource(fragment_shader, 1, &fragment_shader_text_120, NULL); + printf("[WARNING] Shader version is %s\n", ShaderVersion); + printf("Detected NVIDIA card. Recommend 1.20 for vertex and fragment shaders\n"); } else { if (strcmp(Vendor, "NVIDIA Corporation") == 0){ - printf("Detected NVIDIA card. Using 1.30 for vertex and fragment shaders\n"); - glShaderSource(vertex_shader, 1, &vertex_shader_text_130, NULL); - glShaderSource(fragment_shader, 1, &fragment_shader_text_130, NULL); + printf("Detected NVIDIA card. Recommend 1.30 for vertex and fragment shaders\n"); } else if (strcmp(Vendor, "Intel") == 0) { - printf("Detected Intel card. Using 1.20 for vertex and 1.30 for fragment shader\n"); - glShaderSource(vertex_shader, 1, &vertex_shader_text_120, NULL); - glShaderSource(fragment_shader, 1, &fragment_shader_text_130, NULL); + printf("Detected Intel card. Recommend to use 1.20 for vertex and 1.30 for fragment shader\n"); } else { - printf("Unknown vendor card. Trying 1.30 for vertex and 1.30 for fragment shader\n"); - printf("Please report any problems.\n"); - glShaderSource(vertex_shader, 1, &vertex_shader_text_130, NULL); - glShaderSource(fragment_shader, 1, &fragment_shader_text_130, NULL); + printf("Unknown vendor card. Recommend to try 1.30 for vertex and 1.30 for fragment shader\n"); + printf("If that does not work, use 1.20 or switch off shaders via the configuration file\n"); } } + printf("[INFO] Using shader version %d for vertex shader\n", wsgl_vert_shader_version); + printf("[INFO] Using shader version %d for fragment shader\n", wsgl_frag_shader_version); + vertex_shader = glCreateShader(GL_VERTEX_SHADER); + fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); + switch (wsgl_vert_shader_version){ + case 120: + glShaderSource(vertex_shader, 1, &vertex_shader_text_120, NULL); + break; + case 130: + glShaderSource(vertex_shader, 1, &vertex_shader_text_130, NULL); + break; + default: + printf("[ERROR] Unsupported vertex shader version %d\n", wsgl_vert_shader_version); + printf("[ERROR] Please use one of 120 or 130\n"); + abort(); + break; + } + switch (wsgl_frag_shader_version){ + case 120: + glShaderSource(fragment_shader, 1, &fragment_shader_text_120, NULL); + break; + case 130: + glShaderSource(fragment_shader, 1, &fragment_shader_text_130, NULL); + break; + default: + printf("[ERROR]Unsupported fragment shader version %d\n", wsgl_frag_shader_version); + printf("[ERROR] Please use one of 120 or 130\n"); + abort(); + break; + } + // compile vertex shader glCompileShader(vertex_shader); glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &result); @@ -444,8 +177,6 @@ void wsgl_shaders(Ws * ws){ vPositional = glGetUniformLocation(ws->program, "vPositional"); // set some default color glVertexAttrib4f(vCOLOR, 0.5, 0.5, 0.5, 1.0); - alpha_channel = glGetUniformLocation(ws->program, "alpha_channel"); - glUniform1f(alpha_channel, 1.0); // init clipping num_clip_planes = glGetUniformLocation(ws->program, "num_clip_planes"); clipping_ind = glGetUniformLocation(ws->program, "clipping_ind"); diff --git a/src/libphigs/wsgl/wsgl_sofas3fill.c b/src/libphigs/wsgl/wsgl_sofas3fill.c index 2f2fa61..2ecfbf3 100644 --- a/src/libphigs/wsgl/wsgl_sofas3fill.c +++ b/src/libphigs/wsgl/wsgl_sofas3fill.c @@ -381,7 +381,7 @@ void wsgl_set_of_fill_area_set3_data_front( } } else if (sofas3.fflag == PFACET_NORMAL) { - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, sofas3.colr_type, &colr, ast); for (i = 0; i < sofas3.num_sets; i++) { num_lists = sofas3_num_vlists(&sofas3); @@ -417,7 +417,7 @@ void wsgl_set_of_fill_area_set3_data_front( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, sofas3.colr_type, &colr, ast); for (i = 0; i < sofas3.num_sets; i++) { num_lists = sofas3_num_vlists(&sofas3); @@ -489,7 +489,7 @@ void wsgl_set_of_fill_area_set3_data_front( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_int_colr(ast), ws->current_colour_model); wsgl_setup_int_colr(ws, sofas3.colr_type, &colr, ast); for (i = 0; i < sofas3.num_sets; i++) { num_lists = sofas3_num_vlists(&sofas3); @@ -574,7 +574,7 @@ void wsgl_set_of_fill_area_set3_data_back( } } else if (sofas3.fflag == PFACET_NORMAL) { - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, sofas3.colr_type, &colr, ast); for (i = 0; i < sofas3.num_sets; i++) { num_lists = sofas3_num_vlists(&sofas3); @@ -610,7 +610,7 @@ void wsgl_set_of_fill_area_set3_data_back( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, sofas3.colr_type, &colr, ast); for (i = 0; i < sofas3.num_sets; i++) { num_lists = sofas3_num_vlists(&sofas3); @@ -682,7 +682,7 @@ void wsgl_set_of_fill_area_set3_data_back( } } else { - wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast)); + wsgl_colr_from_gcolr(&colr, wsgl_get_back_int_colr(ast), ws->current_colour_model); wsgl_setup_back_int_colr(ws, sofas3.colr_type, &colr, ast); for (i = 0; i < sofas3.num_sets; i++) { num_lists = sofas3_num_vlists(&sofas3); diff --git a/src/test_c/test_c1.c b/src/test_c/test_c1.c index 0aed23b..e4a0706 100644 --- a/src/test_c/test_c1.c +++ b/src/test_c/test_c1.c @@ -138,16 +138,17 @@ int main(int argc, char *argv[]) view_index = atoi(argv[1]); printf("Use view: %d\n", view_index); } - - green.type = PMODEL_RGB; + green.type = PMODEL_RGBA; green.val.general.x = 0.0; green.val.general.y = 1.0; green.val.general.z = 0.0; + green.val.general.a = 1.0; - yellow.type = PMODEL_RGB; + yellow.type = PMODEL_RGBA; yellow.val.general.x = 1.0; yellow.val.general.y = 1.0; yellow.val.general.z = 0.0; + yellow.val.general.a = 1.0; popen_phigs(NULL, 0); @@ -173,6 +174,7 @@ int main(int argc, char *argv[]) pset_edgewidth(EDGE_WIDTH); pset_edgetype(PLINE_SOLID); pset_int_colr_ind(0); + // pset_back_int_colr_ind(0); pset_int_style(FILL_STYLE); pset_int_style_ind(FILL_STYLE_IND); pset_marker_type(PMARKER_CROSS); @@ -185,6 +187,7 @@ int main(int argc, char *argv[]) pset_local_tran3(rot3, PTYPE_REPLACE); pset_local_tran3(tran3, PTYPE_POSTCONCAT); pset_int_colr_ind(1); + // pset_back_int_colr_ind(1); pexec_struct(0); tvec3.delta_z += SPACE; ptranslate3(&tvec3, &errnum, tran3); @@ -193,12 +196,14 @@ int main(int argc, char *argv[]) plabel(10); pset_local_tran3(tran3, PTYPE_POSTCONCAT); pset_int_colr_ind(2); + // pset_back_int_colr_ind(2); plabel(20); pexec_struct(0); plabel(30); pclose_struct(); popen_ws(0, NULL, PWST_OUTPUT_TRUE_DB); + pset_colr_model(0, PMODEL_RGBA); vp.x_min = VP_X0; vp.x_max = VP_X1; vp.y_min = VP_Y0; @@ -215,33 +220,43 @@ int main(int argc, char *argv[]) pset_ws_win3(0, &win); pset_hlhsr_mode(0, PHIGS_HLHSR_MODE_ZBUFF); - col_rep.rgb.red = 0.0; - col_rep.rgb.green = 0.25; - col_rep.rgb.blue = 0.25; + col_rep.rgba.red = 0.0; + col_rep.rgba.green = 0.25; + col_rep.rgba.blue = 0.25; + col_rep.rgba.alpha = 1.0; pset_colr_rep(0, 0, &col_rep); - col_rep.rgb.red = 0.0; - col_rep.rgb.green = 0.5; - col_rep.rgb.blue = 0.5; + col_rep.rgba.red = 0.0; + col_rep.rgba.green = 0.5; + col_rep.rgba.blue = 0.5; + col_rep.rgba.alpha = 0.5; pset_colr_rep(0, 1, &col_rep); - col_rep.rgb.red = 0.0; - col_rep.rgb.green = 1.0; - col_rep.rgb.blue = 1.0; + col_rep.rgba.red = 0.0; + col_rep.rgba.green = 1.0; + col_rep.rgba.blue = 1.0; + col_rep.rgba.alpha = 1.0; pset_colr_rep(0, 2, &col_rep); - col_rep.rgb.red = 1.0; - col_rep.rgb.green = 1.0; - col_rep.rgb.blue = 1.0; + col_rep.rgba.red = 1.0; + col_rep.rgba.green = 1.0; + col_rep.rgba.blue = 1.0; + col_rep.rgba.alpha = 0.25; pset_colr_rep(0, 3, &col_rep); - col_rep.rgb.red = 1.0; - col_rep.rgb.green = 0.0; - col_rep.rgb.blue = 0.0; + col_rep.rgba.red = 1.0; + col_rep.rgba.green = 0.0; + col_rep.rgba.blue = 0.0; + col_rep.rgba.alpha = 0.2; pset_colr_rep(0, 4, &col_rep); pset_disp_upd_st(0, PDEFER_BNIL, PMODE_UQUM); + pxset_color_map(0); ppost_struct(0, 1, 0); +#ifdef DEBUG + Struct_handle structp = CSS_STRUCT_EXISTS(PHG_CSS, 1); + phg_css_print_struct(structp, 0); +#endif pupd_ws(0, PFLAG_PERFORM); XSelectInput(PHG_WSID(0)->display, @@ -290,6 +305,7 @@ int main(int argc, char *argv[]) pset_local_tran3(tran3, PTYPE_POSTCONCAT); poffset_elem_ptr(1); pset_int_colr_ind(4); + // pset_back_int_colr_ind(4); #if 0 pset_elem_ptr(0); //pdel_elem_range(19, 20); @@ -307,6 +323,7 @@ int main(int argc, char *argv[]) //pset_hlhsr_id(PHIGS_HLHSR_ID_OFF); pset_int_style(FILL_STYLE); pset_int_colr(&green); + pset_back_int_colr(&green); pset_edge_colr(&yellow); pcopy_all_elems_struct(0); pclose_struct(); diff --git a/src/test_c/test_c3.c b/src/test_c/test_c3.c index 72fb147..a7d37b6 100644 --- a/src/test_c/test_c3.c +++ b/src/test_c/test_c3.c @@ -157,6 +157,7 @@ void init_scene(void) pset_edgewidth(EDGE_WIDTH); pset_edgetype(PLINE_SOLID); pset_int_colr(&dark); + pset_back_int_colr(&dark); //us pset_int_style(FILL_STYLE); pset_int_style_ind(FILL_STYLE_IND); pset_marker_type(PMARKER_CROSS); @@ -516,6 +517,7 @@ int main(void) print_size(PWST_OUTIN_TRUE_DB); popen_ws(WS_1, NULL, PWST_OUTIN_TRUE_DB); + pset_colr_model(WS_1, PMODEL_RGB); pset_ws_win(WS_1, &win); pset_invis_filter(WS_1, &invis_filter); diff --git a/src/test_f/test_f4.f b/src/test_f/test_f4.f index f823e48..cde8100 100644 --- a/src/test_f/test_f4.f +++ b/src/test_f/test_f4.f @@ -211,7 +211,7 @@ SUBROUTINE KYSABL(iwk) DATA COLB / 0., 1., 0., 0., 1., 0., 1., 1., 0., 0., 1., 0.50/ INTEGER IWK - REAL CSPEC(3) + REAL CSPEC(4) IWK1 = IWK CALL POPST (NSGSAB) * Set color table @@ -220,7 +220,8 @@ SUBROUTINE KYSABL(iwk) CSPEC(1) = COLR(I) CSPEC(2) = COLG(I) CSPEC(3) = COLB(I) - CALL PSCR (IWK1,I,3,CSPEC) + CSPEC(4) = 1. + CALL PSCR (IWK1,I,4,CSPEC) 11 CONTINUE IBLACK=1 IWHIT=2 @@ -275,6 +276,11 @@ PROGRAM DRAWLINE CALL POPPH(0, 1) CALL POPWK(IWK, 0, 3) +* Set color model to PRGBA + CALL PSCM(IWK, PRGBA) +* Re-Pre-define colors FIXME: maybe have a different workstation type + CALL PXSCM(IWK) + CALL KYSABL(IWK) C Buisy loop diff --git a/src/test_f/test_f5.f b/src/test_f/test_f5.f index 072da56..3809965 100644 --- a/src/test_f/test_f5.f +++ b/src/test_f/test_f5.f @@ -97,7 +97,7 @@ PROGRAM MARKERSELECT PARAMETER (NMARKS=8, NMSIZS=8) INTEGER MARKER, ISIZE, MARKRS(NMARKS) - DATA MARKRS/2, 3, 4, 5, 6, 7, 8, 9 / + DATA MARKRS/1, 2, 3, 4, 5, 6, 7, 8/ INTEGER PICKAB PARAMETER (PICKAB=98) @@ -152,6 +152,7 @@ PROGRAM MARKERSELECT DX = 1./(FLOAT(NMSIZS)+1.) DO I = 1, NMARKS MARKER = MARKRS(I) + print*,"Defining marker:", i, marker Y = 1. - FLOAT(I) * DY DO ISIZE = 1, NMSIZS X = 0.05 + FLOAT(ISIZE-1) * DX @@ -205,8 +206,8 @@ PROGRAM MARKERSELECT SELMRK=PP(1,1) CALL PSEDM (EDITMO) CALL PUWK (IWKMK,1) - MKIND = PP(2,1) / 100 - MKSIZ = PP(2,1) - 100 * MKIND + MKIND = PP(2,1) / 400 + MKSIZ = PP(2,1) - 400 * MKIND PRINT*, "Selected marker ", mkind, " with size ", mksiz ENDIF 99 CALL PUWK(IWKMK,1) diff --git a/src/tools/create_shader_include_files.py b/src/tools/create_shader_include_files.py new file mode 100644 index 0000000..e013078 --- /dev/null +++ b/src/tools/create_shader_include_files.py @@ -0,0 +1,12 @@ +import sys + +with open(sys.argv[1], 'r') as f: + content = f.read() + +name = sys.argv[2] +print('/* auto-generated DO NOT EDIT */') +print(f'static const char* {name} =') +for line in content.splitlines(): + escaped = line.replace('\\', '\\\\').replace('"', '\\"') + print(f' "{escaped}\\n"') +print(';')