Skip to content

Commit 6c98653

Browse files
Merge pull request #23 from schwicke/wayland
Improved support for Wayland
2 parents 7d93626 + f4f61fc commit 6c98653

File tree

11 files changed

+115
-94
lines changed

11 files changed

+115
-94
lines changed

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.9)
1+
CMAKE_MINIMUM_REQUIRED(VERSION 3.9...3.31)
22
PROJECT(PHIGS)
33

44
if (APPLE)
@@ -9,6 +9,8 @@ if (APPLE)
99
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-ld_classic,-dead_strip")
1010
endif()
1111

12+
set(OPENGL_GL_PREFERENCE "GLVND")
13+
1214
# Choose between Epoxy or GLEW
1315
if (USE_GLEW)
1416
set(USE_GLEW ON)

src/libphigs/ws/wstx_ini.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ int init_devices(
319319
idt->strokes[i].record.pets.pet_r1.unused = 0;
320320
idt->strokes[i].record.buffer_size = 100;
321321
idt->strokes[i].record.init_pos = 1;
322-
idt->strokes[i].type = WST_LOC_TYPE_POINTER_BUTTON_1;
322+
idt->strokes[i].type = WST_STROKE_TYPE_POINTER_BUTTON_1;
323323
}
324324
/* Default pick */
325325
idt->num_devs.pick = WST_MAX_NUM_PICK_DEVS;
@@ -328,7 +328,7 @@ int init_devices(
328328
idt->picks[i].num_pets = 1;
329329
idt->picks[i].pets[0] = 1;
330330
idt->picks[i].record.pets.pet_r1.unused = 0;
331-
idt->picks[i].type = WST_LOC_TYPE_POINTER_BUTTON_1;
331+
idt->picks[i].type = WST_PICK_TYPE_POINTER_BUTTON_1;
332332
}
333333
/* Default valuator */
334334
idt->num_devs.val = WST_MAX_NUM_VALUATOR_DEVS;

src/libphigs/ws/wsx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ int phg_wsx_setup_tool_nodisp(
302302
background.val.general.y = (float) green / 65535.0;
303303
background.val.general.z = (float) blue / 65535.0;
304304

305-
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &(ws->fbuf));
305+
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint *)&(ws->fbuf));
306306

307307
if (!wsgl_init(ws, &background, NUM_SELECTABLE_STRUCTS)) {
308308
ERR_BUF(ws->erh, ERR900);

src/libphigs/wsgl/wsgl.c

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ short int wsgl_use_shaders = 1;
5959
/*******************************************************************************
6060
* wsgl_init
6161
*
62-
* DESCR: Initialize renderer
63-
* RETURNS: Non zero or zero on error
62+
* DESCR: Initialize renderer
63+
* RETURNS: Non zero or zero on error
6464
*/
6565

6666
int wsgl_init(
@@ -118,8 +118,8 @@ int wsgl_init(
118118
/*******************************************************************************
119119
* wsgl_close
120120
*
121-
* DESCR: Close
122-
* RETURNS: N/A
121+
* DESCR: Close
122+
* RETURNS: N/A
123123
*/
124124

125125
void wsgl_close(
@@ -135,8 +135,8 @@ void wsgl_close(
135135
/*******************************************************************************
136136
* wsgl_set_window
137137
*
138-
* DESCR: Set render window coordinates
139-
* RETURNS: N/A
138+
* DESCR: Set render window coordinates
139+
* RETURNS: N/A
140140
*/
141141
void wsgl_set_window(
142142
Ws *ws,
@@ -152,8 +152,8 @@ void wsgl_set_window(
152152
/*******************************************************************************
153153
* wsgl_set_viewport
154154
*
155-
* DESCR: Set render window viewport
156-
* RETURNS: N/A
155+
* DESCR: Set render window viewport
156+
* RETURNS: N/A
157157
*/
158158
void wsgl_set_viewport(
159159
Ws *ws,
@@ -172,8 +172,8 @@ void wsgl_set_viewport(
172172
/*******************************************************************************
173173
* wsgl_set_hlhsr_mode
174174
*
175-
* DESCR: Set render depth mode
176-
* RETURNS: N/A
175+
* DESCR: Set render depth mode
176+
* RETURNS: N/A
177177
*/
178178
void wsgl_set_hlhsr_mode(
179179
Ws *ws,
@@ -189,8 +189,8 @@ void wsgl_set_hlhsr_mode(
189189
/*******************************************************************************
190190
* wsgl_clear
191191
*
192-
* DESCR: Clear render window
193-
* RETURNS: N/A
192+
* DESCR: Clear render window
193+
* RETURNS: N/A
194194
*/
195195
void wsgl_clear(
196196
Ws *ws
@@ -202,7 +202,9 @@ void wsgl_clear(
202202
Phg_ret ret;
203203
Pgcolr gcolr;
204204
Wsgl_handle wsgl = ws->render_context;
205-
/* try to get the background color from the color table entry for this ws */
205+
char buffer[6];
206+
char * xdg_session_type;
207+
/* Try to get the background color from the color table entry for this ws */
206208
phg_wsb_inq_LUT_entry(ws, 0, PINQ_REALIZED, PHG_ARGS_COREP, &ret, &gcolr, NULL);
207209
if (ret.err == 0) {
208210
wsgl->background.val.general.x = gcolr.val.general.x;
@@ -223,8 +225,13 @@ void wsgl_clear(
223225
glXMakeContextCurrent(ws->display, ws->drawable_id, ws->drawable_id, ws->glx_context);
224226
}
225227
wsgl_clear_geometry();
226-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
227-
if (ws->has_double_buffer) {
228+
xdg_session_type = getenv("XDG_SESSION_TYPE");
229+
if (xdg_session_type){
230+
strncpy(buffer, xdg_session_type, 5);
231+
} else {
232+
strncpy(buffer, "unkwn", 5);
233+
}
234+
if (ws->has_double_buffer && ( 0==strncmp(buffer, "x11", 3) || (0==strncmp(buffer, "tty", 3)))) {
228235
#ifdef DEBUG
229236
printf("Swapping buffers in clear\n");
230237
#endif
@@ -236,13 +243,14 @@ void wsgl_clear(
236243
#endif
237244
glFlush();
238245
}
246+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
239247
}
240248

241249
/*******************************************************************************
242250
* wsgl_flush
243251
*
244-
* DESCR: Flush settings to render window
245-
* RETURNS: N/A
252+
* DESCR: Flush settings to render window
253+
* RETURNS: N/A
246254
*/
247255
void wsgl_flush(
248256
Ws *ws
@@ -347,8 +355,8 @@ void wsgl_flush(
347355
/*******************************************************************************
348356
* init_rendering_state
349357
*
350-
* DESCR: Initialize rendering state helper function
351-
* RETURNS: N/A
358+
* DESCR: Initialize rendering state helper function
359+
* RETURNS: N/A
352360
*/
353361
static void init_rendering_state(
354362
Ws *ws
@@ -396,8 +404,8 @@ static void init_rendering_state(
396404
/*******************************************************************************
397405
* wsgl_begin_rendering
398406
*
399-
* DESCR: Start a rendiering session for workstation
400-
* RETURNS: N/A
407+
* DESCR: Start a rendiering session for workstation
408+
* RETURNS: N/A
401409
*/
402410
void wsgl_begin_rendering(
403411
Ws *ws
@@ -426,8 +434,8 @@ void wsgl_begin_rendering(
426434
/*******************************************************************************
427435
* wsgl_end_rendering
428436
*
429-
* DESCR: End a rendiering session
430-
* RETURNS: N/A
437+
* DESCR: End a rendiering session
438+
* RETURNS: N/A
431439
*/
432440
void wsgl_end_rendering(
433441
Ws *ws
@@ -454,8 +462,8 @@ void wsgl_end_rendering(
454462
/*******************************************************************************
455463
* store_cur_struct
456464
*
457-
* DESCR: Store current structure information helper function
458-
* RETURNS: N/A
465+
* DESCR: Store current structure information helper function
466+
* RETURNS: N/A
459467
*/
460468

461469
static void store_cur_struct(
@@ -479,8 +487,8 @@ static void store_cur_struct(
479487
/*******************************************************************************
480488
* update_cur_struct
481489
*
482-
* DESCR: Update current structure information helper function
483-
* RETURNS: N/A
490+
* DESCR: Update current structure information helper function
491+
* RETURNS: N/A
484492
*/
485493
static void update_cur_struct(
486494
Ws *ws
@@ -545,8 +553,8 @@ static int check_draw_primitive(
545553
/*******************************************************************************
546554
* check_highlight_primitive
547555
*
548-
* DESCR: check if the current primitive is highlighted
549-
* RETURNS: N/A
556+
* DESCR: check if the current primitive is highlighted
557+
* RETURNS: N/A
550558
*/
551559
static int check_highlight_primitive(
552560
Ws *ws
@@ -575,8 +583,8 @@ static int check_highlight_primitive(
575583
/*******************************************************************************
576584
* wsgl_begin_structure
577585
*
578-
* DESCR: Mark the beginning of a new structure element
579-
* RETURNS: N/A
586+
* DESCR: Mark the beginning of a new structure element
587+
* RETURNS: N/A
580588
*/
581589
void wsgl_begin_structure(
582590
Ws *ws,
@@ -614,8 +622,8 @@ void wsgl_begin_structure(
614622
/*******************************************************************************
615623
* wsgl_end_structure
616624
*
617-
* DESCR: Mark the ending of a structure element
618-
* RETURNS: N/A
625+
* DESCR: Mark the ending of a structure element
626+
* RETURNS: N/A
619627
*/
620628
void wsgl_end_structure(
621629
Ws *ws
@@ -654,8 +662,8 @@ void wsgl_end_structure(
654662
/*******************************************************************************
655663
* wsgl_render_element
656664
*
657-
* DESCR: Render element to current workstation rendering window
658-
* RETURNS: N/A
665+
* DESCR: Render element to current workstation rendering window
666+
* RETURNS: N/A
659667
*/
660668
void wsgl_render_element(
661669
Ws *ws,
@@ -1373,16 +1381,9 @@ void wsgl_begin_pick(
13731381
printf("WSGL begin pick: set render mode to select\n");
13741382
printf("WSGL begin pick: buffer size is %d at %p\n", wsgl->select_size, (void*)wsgl->select_buf);
13751383
#endif
1376-
//glDisable(GL_CULL_FACE);
1377-
//glEnable(GL_DEPTH_TEST);
13781384
glRenderMode(GL_SELECT);
13791385
glInitNames();
1380-
/*
1381-
glMatrixMode(GL_PROJECTION);
1382-
glPushMatrix();
1383-
glLoadIdentity();
1384-
glMatrixMode(GL_MODELVIEW);
1385-
*/}
1386+
}
13861387

13871388
/*******************************************************************************
13881389
* wsgl_end_pick

src/test_f/test_f1.f

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ PROGRAM DRAWLINE
2828
REAL PXA(1:2)
2929
REAL PYA(1:2)
3030

31+
INTEGER IWK
32+
PARAMETER (IWK=1)
33+
3134
C Open PHIGS and a workstation
32-
CALL POPPH(0, 0)
33-
CALL POPWK(0, 0, 0)
35+
CALL POPPH(0, 1)
36+
CALL POPWK(IWK, 0, 3)
3437

3538
C Define line colour in workstation table
3639
COLR(1) = 1.0
3740
COLR(2) = 1.0
3841
COLR(3) = 0.0
39-
CALL PSCR(0, 1, 3, COLR)
42+
CALL PSCR(IWK, 1, 3, COLR)
4043

4144
C Open structure
4245
CALL POPST(0)
@@ -70,7 +73,7 @@ PROGRAM DRAWLINE
7073
CALL PCLST
7174

7275
C Post structure to workstation
73-
CALL PPOST(0, 0, 0.0)
76+
CALL PPOST(IWK, 0, 0.0)
7477

7578
C Buisy loop
7679
DO WHILE (1 .GT. 0)

src/test_f/test_f2.f

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ PROGRAM DRAWLINE
3030
REAL PL_y(2)
3131
REAL PL_z(2)
3232

33-
C Open PHIGS and a workstation
34-
CALL POPPH(0, 0)
35-
CALL POPWK(0, 0, 0)
33+
INTEGER IWK
34+
PARAMETER (IWK=1)
3635

37-
C Define line colour in workstation table
36+
C Open PHIGS and a workstation
37+
CALL POPPH(0, 1)
38+
CALL POPWK(IWK, 0, 3)
39+
40+
C Define line colour in workstation table
3841
COLR(1) = 1.0
3942
COLR(2) = 1.0
4043
COLR(3) = 0.0
41-
CALL PSCR(0, 1, 3, COLR)
44+
CALL PSCR(IWK, 1, 3, COLR)
4245

4346
C Open structure
4447
CALL POPST(0)
@@ -108,7 +111,7 @@ PROGRAM DRAWLINE
108111
CALL PCLST
109112

110113
C Post structure to workstation
111-
CALL PPOST(0, 0, 0.0)
114+
CALL PPOST(IWK, 0, 0.0)
112115

113116
C Buisy loop
114117
DO WHILE (1 .GT. 0)

src/test_f/test_f3.f

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -490,31 +490,33 @@ SUBROUTINE KYDELP (XORG, YORG, SCAL)
490490
END
491491

492492
PROGRAM DRAWLINE
493-
493+
494494
C Include PHIGS enumeration file
495495
INCLUDE 'phigsf77.h'
496-
497-
C Open PHIGS and a workstation
498-
CALL POPPH(0, 0)
499-
CALL POPWK(0, 0, 0)
500-
iwk1 = 0
501-
C init colors
502-
call initcols(iwk1)
503-
504-
496+
497+
INTEGER IWK
498+
PARAMETER (IWK=1)
499+
500+
C Open PHIGS and a workstation
501+
CALL POPPH(0, 1)
502+
CALL POPWK(IWK, 0, 3)
503+
504+
C Initialize colors
505+
CALL INITCOLS(IWK)
506+
505507
C Open structure
506508
CALL POPST(0)
507509
CALL KYDELP(0.3, 0.5, 1.)
508-
509-
C Close structure
510+
C
511+
C Close structure
510512
CALL PCLST
511-
513+
512514
C Post structure to workstation
513-
CALL PPOST(0, 0, 0.0)
514-
515+
CALL PPOST(IWK, 0, 0.0)
516+
515517
C Buisy loop
516518
DO WHILE (1 .GT. 0)
517519
END DO
518-
520+
519521
STOP
520522
END

src/test_f/test_f4.f

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,14 @@ PROGRAM DRAWLINE
268268
C Include PHIGS enumeration file
269269
INCLUDE 'phigsf77.h'
270270

271+
INTEGER IWK
272+
PARAMETER (IWK=1)
273+
271274
C Open PHIGS and a workstation
272275
CALL POPPH(0, 1)
273-
CALL POPWK(1, 0, 3)
276+
CALL POPWK(IWK, 0, 3)
274277

275-
CALL KYSABL(1)
278+
CALL KYSABL(IWK)
276279

277280
C Buisy loop
278281
DO WHILE (1 .GT. 0)

0 commit comments

Comments
 (0)