Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ Some notes on differences with respect to other implementations.
Workstation numbers can be in the range from 0 to 99.

### Workstation types
* 0 PWST_OUTPUT_TRUE Output only on GL display
* 1 PWST_OUTIN_TRUE Input/Output on GL display
* 2 PWST_OUTPUT_TRUE_DB Output only on GL, buffered
* 3 PWST_OUTIN_TRUE_DB Input/Output on GL display, buffered
* 4 PWST_HCOPY_TRUE_TGA Hardcopy to file as TGA
* 5 PWST_HCOPY_TRUE_RGB_PNG Hardcopy to file as PNG RGB only
* 6 PWST_HCOPY_TRUE_RGBA_PNG Hardcopy to file as PNG with Alpha channel
* 7 PWST_HCOPY_TRUE_EPS Hardcopy to file as Encapsulated PostScript, no shaders
* 8 PWST_HCOPY_TRUE_PDF Hardcopy to file as PDF, no shaders
* 9 PWST_HCOPY_TRUE_SVG Hardcopy to file as SVG, no shaders
* 0 PWST_OUTPUT_TRUE Output only on GL display
* 1 PWST_OUTIN_TRUE Input/Output on GL display
* 2 PWST_OUTPUT_TRUE_DB Output only on GL, buffered
* 3 PWST_OUTIN_TRUE_DB Input/Output on GL display, buffered
* 4 PWST_HCOPY_TRUE_TGA Hardcopy to file as TGA
* 5 PWST_HCOPY_TRUE_RGB_PNG Hardcopy to file as PNG RGB only
* 6 PWST_HCOPY_TRUE_RGBA_PNG Hardcopy to file as PNG with Alpha channel
* 7 PWST_HCOPY_TRUE_EPS Hardcopy to file as Encapsulated PostScript, no shaders
* 8 PWST_HCOPY_TRUE_PDF Hardcopy to file as PDF, no shaders
* 9 PWST_HCOPY_TRUE_SVG Hardcopy to file as SVG, no shaders
* 10 PWST_HCOPY_TRUE_OBJ Export geometry as OBJ

Notes:
* There is no support for PostScript at the moment.
Expand Down
7 changes: 7 additions & 0 deletions phigs.def
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ 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

Workstation example for output obj
%wk 93 Workstation for hardcopy
%wg 2480 2480 0 0 1 Window width height px py border
%wp 0.0 1.0 0.0 1. position
%hs 1. scale factor for hardcopy
%bg 0. 0. 0. Background color R G B
5 changes: 3 additions & 2 deletions src/include/phigs/phigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Copyright (c) 1989, 1990, 1991 X Consortium
Copyright (c) 2014 Surplus Users Ham Society
Copyright (c) 2022-2023 CERN
Copyright (c) 2022-2025 CERN

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -163,7 +163,8 @@ typedef enum {
PCAT_PNGA,
PCAT_EPS,
PCAT_PDF,
PCAT_SVG
PCAT_SVG,
PCAT_OBJ
} Pws_cat;

typedef enum {
Expand Down
79 changes: 76 additions & 3 deletions src/include/phigs/private/wsglP.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This file is part of Open PHIGS
* Copyright (C) 2014 Surplus Users Ham Society
* (C) 2022-2023 CERN
* (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
Expand Down Expand Up @@ -119,6 +119,80 @@ typedef struct _Wsgl {
Ws_dev_st dev_st;
} Wsgl;

/* record geometry */
typedef enum {
GEOM_LINE,
GEOM_FACE
} GeomType;

typedef struct {
GeomType type;
int* indices;
int* norms;
int count;
} Geometry;

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 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
*/
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
*/
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
*/
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
*/
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
*/

void wsgl_export_obj(const char* filename, const char* title);
/*******************************************************************************
* wsgl_clear_geometry()
*
* DESCR: cleanup geometry records
* RETURNS: Non zero or zero on error
*/
void wsgl_clear_geometry();

/*******************************************************************************
* wsgl_init
*
Expand Down Expand Up @@ -1209,8 +1283,7 @@ void wsgl_anno_text_rel(
* DESCR: Initialise shaders
* RETURNS: N/A
*/

void wsgl_shaders(Ws * ws);
void wsgl_shaders(Ws * ws);

extern Phg_font *fnt_fonts[];
extern unsigned char *wsgl_hatch_tbl[];
Expand Down
3 changes: 2 additions & 1 deletion src/include/phigs/ws_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Copyright (c) 1989, 1990, 1991 X Consortium
Copyright (c) 2014 Surplus Users Ham Society
Copyright (c) 2022-2023 CERN
Copyright (c) 2022-2025 CERN

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -67,6 +67,7 @@ extern "C" {
#define PWST_HCOPY_TRUE_EPS 7
#define PWST_HCOPY_TRUE_PDF 8
#define PWST_HCOPY_TRUE_SVG 9
#define PWST_HCOPY_TRUE_OBJ 10

/* Default tables */
#define WST_MIN_PREDEF_LINE_REPS 1
Expand Down
1 change: 1 addition & 0 deletions src/libphigs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ SET(P_WSGL_SRCS
wsgl/wsgl_light.c
wsgl/wsgl_line.c
wsgl/wsgl_marker.c
wsgl/wsgl_obj.c
wsgl/wsgl_shaders.c
wsgl/wsgl_sofas3clear.c
wsgl/wsgl_sofas3edge.c
Expand Down
1 change: 1 addition & 0 deletions src/libphigs/c_binding/cb_lite.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void pinq_light_src_rep( ws_id, index, type, err_ind, rep)
dt->ws_category == PCAT_EPS ||
dt->ws_category == PCAT_PDF ||
dt->ws_category == PCAT_SVG ||
dt->ws_category == PCAT_OBJ ||
dt->ws_category == PCAT_OUTIN ||
dt->ws_category == PCAT_MO) ) {
*err_ind = ERR59;
Expand Down
1 change: 1 addition & 0 deletions src/libphigs/c_binding/cb_phg.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void popen_phigs(
phg_wst_add_ws_type(PCAT_EPS, 0);
phg_wst_add_ws_type(PCAT_PDF, 0);
phg_wst_add_ws_type(PCAT_SVG, 0);
phg_wst_add_ws_type(PCAT_OBJ, 0);

PHG_WS_LIST = (Ws_handle *) malloc(sizeof(Ws_handle) * MAX_NO_OPEN_WS);
if (PHG_WS_LIST == NULL) {
Expand Down
Loading
Loading