GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
Loading...
Searching...
No Matches
gsd_prim.c
Go to the documentation of this file.
1/*!
2 \file lib/ogsf/gsd_prim.c
3
4 \brief OGSF library - primitive drawing functions (lower level functions)
5
6 GRASS OpenGL gsurf OGSF Library
7
8 SPDX-FileCopyrightText: 1999-2008, 2018 GRASS Development Team
9 SPDX-License-Identifier: GPL-2.0-or-later
10
11 \author Bill Brown USACERL (January 1993)
12 \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
13 \author Support for framebuffer objects by Huidae Cho <grass4u gmail.com>
14 (July 2018)
15 */
16
17#include <stdlib.h>
18#include <string.h>
19
20#include <grass/config.h>
21
22#if defined(OPENGL_X11)
23#include <GL/gl.h>
24#include <GL/glu.h>
25#include <GL/glx.h>
26#elif defined(OPENGL_AQUA)
27#include <OpenGL/gl.h>
28#include <OpenGL/glu.h>
29#if defined(OPENGL_AGL)
30#include <AGL/agl.h>
31#endif
32#elif defined(OPENGL_WINDOWS)
33#include <GL/gl.h>
34#include <GL/glu.h>
35#include <wingdi.h>
36#endif
37
38#include <grass/gis.h>
39#include <grass/ogsf.h>
40#include <grass/glocale.h>
41
42#define USE_GL_NORMALIZE
43
44#define RED_MASK 0x000000FF
45#define GRN_MASK 0x0000FF00
46#define BLU_MASK 0x00FF0000
47#define ALP_MASK 0xFF000000
48
49#define INT_TO_RED(i, r) (r = (i & RED_MASK))
50#define INT_TO_GRN(i, g) (g = (i & GRN_MASK) >> 8)
51#define INT_TO_BLU(i, b) (b = (i & BLU_MASK) >> 16)
52#define INT_TO_ALP(i, a) (a = (i & ALP_MASK) >> 24)
53
54#define MAX_OBJS 64
55/* ^ TMP - move to gstypes */
56
57/* define border width (pixels) for viewport check */
58#define border 15
59
60static GLuint ObjList[MAX_OBJS];
61static int numobjs = 0;
62
63static int Shade;
64
65static float ogl_light_amb[MAX_LIGHTS][4];
66static float ogl_light_diff[MAX_LIGHTS][4];
67static float ogl_light_spec[MAX_LIGHTS][4];
68static float ogl_light_pos[MAX_LIGHTS][4];
69static float ogl_mat_amb[4];
70static float ogl_mat_diff[4];
71static float ogl_mat_spec[4];
72static float ogl_mat_emis[4];
73static float ogl_mat_shin;
74
75/*!
76 \brief Mostly for flushing drawing commands across a network
77
78 glFlush doesn't block, so if blocking is desired use glFinish.
79 */
80void gsd_flush(void)
81{
82 glFlush();
83
84 return;
85}
86
87/*!
88 \brief Set color mode
89
90 Call glColorMaterial before enabling the GL_COLOR_MATERIAL
91
92 \param cm color mode value
93 */
95{
96 switch (cm) {
97 case CM_COLOR:
98
101
102 break;
103 case CM_EMISSION:
104
108
109 break;
110 case CM_DIFFUSE:
111
115
116 break;
117 case CM_AD:
118
122
123 break;
124 case CM_NULL:
125
126 /* OGLXXX
127 * lmcolor: if LMC_NULL, use:
128 * glDisable(GL_COLOR_MATERIAL);
129 * LMC_NULL: use glDisable(GL_COLOR_MATERIAL);
130 */
133
134 break;
135 default:
136
138 break;
139 }
140
141 return;
142}
143
144/*!
145 \brief Print color mode to stderr
146 */
148{
149 GLint mat;
150
152 G_message(_("Color Material: %d"), mat);
153
154 return;
155}
156
157/*!
158 \brief ADD
159
160 \param x,y
161 \param rad
162 */
163void gsd_circ(float x, float y, float rad)
164{
166
168 glPushMatrix();
169 glTranslatef(x, y, 0.);
170 gluDisk(qobj, 0., rad, 32, 1);
171 glPopMatrix();
173
174 return;
175}
176
177/*!
178 \brief ADD
179
180 \param x,y,z
181 \param rad
182 */
183void gsd_disc(float x, float y, float z, float rad)
184{
186
188 glPushMatrix();
189 glTranslatef(x, y, z);
190 gluDisk(qobj, 0., rad, 32, 1);
191 glPopMatrix();
193
194 return;
195}
196
197/*!
198 \brief ADD
199
200 \param center center-point
201 \param siz size value
202 */
203void gsd_sphere(float *center, float siz)
204{
205 static int first = 1;
206 static GLUquadricObj *QOsphere;
207
208 if (first) {
210
211 if (QOsphere) {
212 gluQuadricNormals(QOsphere, GLU_SMOOTH); /* default */
213 gluQuadricTexture(QOsphere, GL_FALSE); /* default */
216 }
217
218 first = 0;
219 }
220
221 glPushMatrix();
222 glTranslatef(center[0], center[1], center[2]);
223 gluSphere(QOsphere, (double)siz, 24, 24);
224 glPopMatrix();
225
226 return;
227}
228
229/*!
230 \brief Write out z-mask
231
232 Enable or disable writing into the depth buffer
233
234 \param n Specifies whether the depth buffer is enabled for
235 writing
236 */
237void gsd_zwritemask(unsigned long n)
238{
239 /* OGLXXX glDepthMask is boolean only */
241
242 return;
243}
244
245/*!
246 \brief ADD
247
248 \param n
249 */
250void gsd_backface(int n)
251{
254
255 return;
256}
257
258/*!
259 \brief Set width of rasterized lines
260
261 \param n line width
262 */
263void gsd_linewidth(short n)
264{
265 glLineWidth((GLfloat)(n));
266
267 return;
268}
269
270/*!
271 \brief ADD
272 */
274{
276
277 return;
278}
279
280/*!
281 \brief ADD
282 */
284{
285 glEnd();
286
287 return;
288}
289
290/*!
291 \brief ADD
292 */
293void gsd_bgntmesh(void)
294{
296
297 return;
298}
299
300/*!
301 \brief ADD
302 */
303void gsd_endtmesh(void)
304{
305 glEnd();
306
307 return;
308}
309
310/*!
311 \brief ADD
312 */
314{
316
317 return;
318}
319
320/*!
321 \brief ADD
322 */
324{
325 glEnd();
326
327 return;
328}
329
330/*!
331 \brief ADD
332 */
333void gsd_bgntfan(void)
334{
336
337 return;
338}
339
340/*!
341 \brief ADD
342 */
343void gsd_endtfan(void)
344{
345 glEnd();
346
347 return;
348}
349
350/*!
351 \brief ADD
352 */
354{
355 /* OGLXXX
356 * swaptmesh not supported, maybe glBegin(GL_TRIANGLE_FAN)
357 * swaptmesh()
358 */
359
360 /*DELETED*/;
361
362 return;
363}
364
365/*!
366 \brief Delimit the vertices of a primitive or a group of like primitives
367 */
369{
370 /* OGLXXX
371 * special cases for polygons:
372 * independent quads: use GL_QUADS
373 * independent triangles: use GL_TRIANGLES
374 */
376
377 return;
378}
379
380/*!
381 \brief Delimit the vertices of a primitive or a group of like primitives
382 */
384{
385 glEnd();
386
387 return;
388}
389
390/*!
391 \brief Begin line
392 */
393void gsd_bgnline(void)
394{
395 /* OGLXXX for multiple, independent line segments: use GL_LINES */
397 return;
398}
399
400/*!
401 \brief End line
402 */
403void gsd_endline(void)
404{
405 glEnd();
406
407 return;
408}
409
410/*!
411 \brief Set shaded model
412
413 \param shade non-zero for GL_SMOOTH otherwise GL_FLAT
414 */
416{
417 Shade = shade;
418
419 if (shade) {
421 }
422 else {
424 }
425
426 return;
427}
428
429/*!
430 \brief Get shaded model
431
432 \return shade
433 */
435{
436 return (Shade);
437}
438
439/*!
440 \brief Draw to the front and back buffers
441 */
443{
444#if !defined(OPENGL_FBO)
445 /* OGLXXX bothbuffer: other possibilities include GL_FRONT, GL_BACK */
447#endif
448 return;
449}
450
451/*!
452 \brief Draw to the front buffer
453 */
455{
456#if !defined(OPENGL_FBO)
457 /* OGLXXX frontbuffer: other possibilities include GL_FRONT_AND_BACK */
459#endif
460 return;
461}
462
463/*!
464 \brief Draw to the back buffer
465 */
467{
468#if !defined(OPENGL_FBO)
469 /* OGLXXX backbuffer: other possibilities include GL_FRONT_AND_BACK */
471#endif
472 return;
473}
474
475/*!
476 \brief Swap buffers
477 */
479{
480#if !defined(OPENGL_FBO)
481 /* OGLXXX swapbuffers: copy the back buffer to the front;
482 * the back buffer becomes undefined afterward */
483#if defined(OPENGL_X11)
485#elif defined(OPENGL_AGL)
487#elif defined(OPENGL_WINDOWS)
489#endif
490#endif
491 return;
492}
493
494/*!
495 \brief Pop the current matrix stack
496 */
498{
499 glPopMatrix();
500
501 return;
502}
503
504/*!
505 \brief Push the current matrix stack
506 */
508{
509 glPushMatrix();
510
511 return;
512}
513
514/*!
515 \brief Multiply the current matrix by a general scaling matrix
516
517 \param xs x scale value
518 \param ys y scale value
519 \param zs z scale value
520 */
521void gsd_scale(float xs, float ys, float zs)
522{
523 glScalef(xs, ys, zs);
524
525 return;
526}
527
528/*!
529 \brief Multiply the current matrix by a translation matrix
530
531 \param dx x translation value
532 \param dy y translation value
533 \param dz z translation value
534 */
535void gsd_translate(float dx, float dy, float dz)
536{
537 glTranslatef(dx, dy, dz);
538
539 return;
540}
541
542/*!
543 \brief Get viewport
544
545 \param[out] window
546 \param viewport
547 \param modelMatrix model matrix
548 \param projMatrix projection matrix
549 */
550void gsd_getwindow(int *window, int *viewport, double *modelMatrix,
551 double *projMatrix)
552{
554 gsd_do_scale(1);
555
560
561 window[0] = viewport[1] + viewport[3] + border;
562 window[1] = viewport[1] - border;
563 window[2] = viewport[0] - border;
564 window[3] = viewport[0] + viewport[2] + border;
565
566 return;
567}
568
569/*!
570 \brief ADD
571
572 \param pt
573 \param window
574 \param viewport
575 \param doubleMatrix
576 \param projMatrix
577
578 \return 0
579 \return 1
580 */
581int gsd_checkpoint(float pt[4], int window[4], int viewport[4],
582 double modelMatrix[16], double projMatrix[16])
583{
584 GLdouble fx, fy, fz;
585
587 projMatrix, viewport, &fx, &fy, &fz);
588
589 if (fx < window[2] || fx > window[3] || fy < window[1] || fy > window[0])
590 return 1;
591 else
592 return 0;
593}
594
595/*!
596 \brief ADD
597
598 \param angle
599 \param axis
600 */
601void gsd_rot(float angle, char axis)
602{
603 GLfloat x;
604 GLfloat y;
605 GLfloat z;
606
607 switch (axis) {
608 case 'x':
609 case 'X':
610
611 x = 1.0;
612 y = 0.0;
613 z = 0.0;
614
615 break;
616 case 'y':
617 case 'Y':
618
619 x = 0.0;
620 y = 1.0;
621 z = 0.0;
622
623 break;
624 case 'z':
625 case 'Z':
626
627 x = 0.0;
628 y = 0.0;
629 z = 1.0;
630
631 break;
632 default:
633
634 G_warning(_("gsd_rot(): %c is an invalid axis "
635 "specification. Rotation ignored. "
636 "Please advise GRASS developers of this error"),
637 axis);
638 return;
639 }
640
641 glRotatef((GLfloat)angle, x, y, z);
642
643 return;
644}
645
646/*!
647 \brief Set the current normal vector & specify vertex
648
649 \param norm normal vector
650 \param col color value
651 \param pt point (model coordinates)
652 */
653void gsd_litvert_func(float *norm, unsigned long col, float *pt)
654{
655 glNormal3fv(norm);
658
659 return;
660}
661
662/*!
663 \brief ADD
664
665 \param norm
666 \param col [unused]
667 \param pt
668 */
669void gsd_litvert_func2(float *norm, unsigned long col G_UNUSED, float *pt)
670{
671 glNormal3fv(norm);
673
674 return;
675}
676
677/*!
678 \brief ADD
679
680 \param pt
681 */
682void gsd_vert_func(float *pt)
683{
685
686 return;
687}
688
689/*!
690 \brief Set current color
691
692 \param col color value
693 */
694void gsd_color_func(unsigned int col)
695{
696 GLbyte r, g, b, a;
697
698 /* OGLXXX
699 * cpack: if argument is not a variable
700 * might need to be:
701 * glColor4b(($1)&0xff, ($1)>>8&0xff, ($1)>>16&0xff, ($1)>>24&0xff)
702 */
703 INT_TO_RED(col, r);
704 INT_TO_GRN(col, g);
705 INT_TO_BLU(col, b);
706 INT_TO_ALP(col, a);
707 glColor4ub(r, g, b, a);
708
709 return;
710}
711
712/*!
713 \brief Initialize model light
714 */
716{
717
719
720 /* normal vector renormalization */
721#ifdef USE_GL_NORMALIZE
722 {
724 }
725#endif
726
727 /* OGLXXX
728 * Ambient:
729 * If this is a light model lmdef, then use
730 * glLightModelf and GL_LIGHT_MODEL_AMBIENT.
731 * Include ALPHA parameter with ambient
732 */
733
734 /* Default is front face lighting, infinite viewer
735 */
736 ogl_mat_amb[0] = 0.1;
737 ogl_mat_amb[1] = 0.1;
738 ogl_mat_amb[2] = 0.1;
739 ogl_mat_amb[3] = 1.0;
740
741 ogl_mat_diff[0] = 0.8;
742 ogl_mat_diff[1] = 0.8;
743 ogl_mat_diff[2] = 0.8;
744 ogl_mat_diff[3] = 0.8;
745
746 ogl_mat_spec[0] = 0.8;
747 ogl_mat_spec[1] = 0.8;
748 ogl_mat_spec[2] = 0.8;
749 ogl_mat_spec[3] = 0.8;
750
751 ogl_mat_emis[0] = 0.0;
752 ogl_mat_emis[1] = 0.0;
753 ogl_mat_emis[2] = 0.0;
754 ogl_mat_emis[3] = 0.0;
755
756 ogl_mat_shin = 25.0;
757
758 /* OGLXXX
759 * attenuation: see glLightf man page: (ignored for infinite lights)
760 * Add GL_LINEAR_ATTENUATION.
761 sgi_lmodel[0] = GL_CONSTANT_ATTENUATION;
762 sgi_lmodel[1] = 1.0;
763 sgi_lmodel[2] = 0.0;
764 sgi_lmodel[3] = ;
765 */
766
767 /* OGLXXX
768 * lmdef other possibilities include:
769 * glLightf(light, pname, *params);
770 * glLightModelf(pname, param);
771 * Check list numbering.
772 * Translate params as needed.
773 */
779
780 /* OGLXXX lmbind: check object numbering. */
781 /* OGLXXX
782 * lmbind: check object numbering.
783 * Use GL_FRONT in call to glMaterialf.
784 * Use GL_FRONT in call to glMaterialf.
785 if(1) {glCallList(1); glEnable(LMODEL);} else glDisable(LMODEL);
786 if(1) {glCallList(1); glEnable(GL_FRONT);} else glDisable(GL_FRONT);
787 */
788
789 return;
790}
791
792/*!
793 \brief Set material
794
795 \param set_shin,set_emis flags
796 \param sh,em should be 0. - 1.
797 \param emcolor packed colors to use for emission
798 */
799void gsd_set_material(int set_shin, int set_emis, float sh, float em,
800 int emcolor)
801{
802 if (set_shin) {
803 ogl_mat_spec[0] = sh;
804 ogl_mat_spec[1] = sh;
805 ogl_mat_spec[2] = sh;
806 ogl_mat_spec[3] = sh;
807
809
810 ogl_mat_shin = 60. + (int)(sh * 68.);
811
813 }
814
815 if (set_emis) {
816 ogl_mat_emis[0] = (em * (emcolor & 0x0000FF)) / 255.;
817 ogl_mat_emis[1] = (em * ((emcolor & 0x00FF00) >> 8)) / 255.;
818 ogl_mat_emis[2] = (em * ((emcolor & 0xFF0000) >> 16)) / 255.;
819
821 }
822
823 return;
824}
825
826/*!
827 \brief Define light
828
829 \param num light id (starts with 1)
830 \param vals position(x,y,z,w), color, ambientm, emission
831 */
832void gsd_deflight(int num, struct lightdefs *vals)
833{
834 if (num > 0 && num <= MAX_LIGHTS) {
835 ogl_light_pos[num - 1][0] = vals->position[X];
836 ogl_light_pos[num - 1][1] = vals->position[Y];
837 ogl_light_pos[num - 1][2] = vals->position[Z];
838 ogl_light_pos[num - 1][3] = vals->position[W];
839
840 glLightfv(GL_LIGHT0 + num, GL_POSITION, ogl_light_pos[num - 1]);
841
842 ogl_light_diff[num - 1][0] = vals->color[0];
843 ogl_light_diff[num - 1][1] = vals->color[1];
844 ogl_light_diff[num - 1][2] = vals->color[2];
845 ogl_light_diff[num - 1][3] = .3;
846
847 glLightfv(GL_LIGHT0 + num, GL_DIFFUSE, ogl_light_diff[num - 1]);
848
849 ogl_light_amb[num - 1][0] = vals->ambient[0];
850 ogl_light_amb[num - 1][1] = vals->ambient[1];
851 ogl_light_amb[num - 1][2] = vals->ambient[2];
852 ogl_light_amb[num - 1][3] = .3;
853
854 glLightfv(GL_LIGHT0 + num, GL_AMBIENT, ogl_light_amb[num - 1]);
855
856 ogl_light_spec[num - 1][0] = vals->color[0];
857 ogl_light_spec[num - 1][1] = vals->color[1];
858 ogl_light_spec[num - 1][2] = vals->color[2];
859 ogl_light_spec[num - 1][3] = .3;
860
861 glLightfv(GL_LIGHT0 + num, GL_SPECULAR, ogl_light_spec[num - 1]);
862 }
863
864 return;
865}
866
867/*!
868 \brief Switch light on/off
869
870 \param num
871 \param on 1 for 'on', 0 turns them off
872 */
873void gsd_switchlight(int num, int on)
874{
875 short defin;
876
877 defin = on ? num : 0;
878
879 if (defin) {
880 glEnable(GL_LIGHT0 + num);
881 }
882 else {
883 glDisable(GL_LIGHT0 + num);
884 }
885
886 return;
887}
888
889/*!
890 \brief Get image of current GL screen
891
892 \param pixbuf data buffer
893 \param[out] xsize,ysize picture dimension
894
895 \return 0 on failure
896 \return 1 on success
897 */
898int gsd_getimage(unsigned char **pixbuf, unsigned int *xsize,
899 unsigned int *ysize)
900{
901 GLuint l, r, b, t;
902
903 /* OGLXXX
904 * get GL_VIEWPORT:
905 * You can probably do better than this.
906 */
907 GLint tmp[4];
908
910 l = tmp[0];
911 r = tmp[0] + tmp[2] - 1;
912 b = tmp[1];
913 t = tmp[1] + tmp[3] - 1;
914
915 *xsize = r - l + 1;
916 *ysize = t - b + 1;
917
918 if (!*xsize || !*ysize)
919 return (0);
920
921 *pixbuf =
922 (unsigned char *)G_malloc((*xsize) * (*ysize) * 4); /* G_fatal_error */
923
924 if (!*pixbuf)
925 return (0);
926
927#if !defined(OPENGL_FBO)
929#endif
930
931 /* OGLXXX lrectread: see man page for glReadPixels */
932 glReadPixels(l, b, (r) - (l) + 1, (t) - (b) + 1, GL_RGBA, GL_UNSIGNED_BYTE,
933 *pixbuf);
934
935 return (1);
936}
937
938/*!
939 \brief Get viewpoint
940
941 \param tmp
942 \param num
943
944 \return 1
945 */
946int gsd_getViewport(GLint tmp[4], GLint num[2])
947{
948
949 /* Save current viewport to tmp */
952
953 return (1);
954}
955
956/*!
957 \brief Write view
958
959 \param pixbuf data buffer
960 \param xsize,ysize picture dimension
961
962 \return 0 on failure
963 \return 1 on success
964 */
965int gsd_writeView(unsigned char **pixbuf, unsigned int xsize,
966 unsigned int ysize)
967{
968
969 /* Malloc Buffer for image */
970 *pixbuf = (unsigned char *)G_malloc(xsize * ysize * 4); /* G_fatal_error */
971 if (!*pixbuf) {
972 return (0);
973 }
974
975#if !defined(OPENGL_FBO)
976 /* Read image buffer */
978#endif
979
980 /* Read Pixels into Buffer */
982 return (1);
983}
984
985/*!
986 \brief Specify pixel arithmetic
987
988 \param yesno turn on/off
989 */
991{
992 if (yesno) {
995 }
996 else {
999 }
1000
1001 return;
1002}
1003
1004/*!
1005 \brief Define clip plane
1006
1007 \param num
1008 \param params
1009 */
1010void gsd_def_clipplane(int num, double *params)
1011{
1012 int wason = 0;
1013
1014 /* OGLXXX see man page for glClipPlane equation */
1015 if (glIsEnabled(GL_CLIP_PLANE0 + (num))) {
1016 wason = 1;
1017 }
1018
1019 glClipPlane(GL_CLIP_PLANE0 + (num), params);
1020
1021 if (wason) {
1022 glEnable(GL_CLIP_PLANE0 + (num));
1023 }
1024 else {
1025 glDisable(GL_CLIP_PLANE0 + (num));
1026 }
1027
1028 return;
1029}
1030
1031/*!
1032 \brief Set clip plane
1033
1034 \param num
1035 \param able
1036 */
1037void gsd_set_clipplane(int num, int able)
1038{
1039 /* OGLXXX see man page for glClipPlane equation */
1040 if (able) {
1041 glEnable(GL_CLIP_PLANE0 + (num));
1042 }
1043 else {
1044 glDisable(GL_CLIP_PLANE0 + (num));
1045 }
1046
1047 return;
1048}
1049
1050/*!
1051 \brief Finish
1052
1053 Does nothing, only called from src.contrib/GMSL/NVIZ2.2/src/glwrappers.c
1054 */
1055void gsd_finish(void)
1056{
1057 return;
1058}
1059
1060/*!
1061 \brief Set the viewport
1062
1063 <i>l</i>, <i>b</i> specify the lower left corner of the viewport
1064 rectangle, in pixels.
1065
1066 <i>r</i>, <i>t</i> specify the width and height of the viewport.
1067
1068 \param l left
1069 \param r right
1070 \param b bottom
1071 \param t top
1072 */
1073void gsd_viewport(int l, int r, int b, int t)
1074{
1075 /* Screencoord */
1076 glViewport(l, b, r, t);
1077
1078 return;
1079}
1080
1081/*!
1082 \brief ADD
1083
1084 First time called, gets a bunch of objects, then hands them back
1085 when needed
1086
1087 \return -1 on failure
1088 \return number of objects
1089 */
1091{
1092 int i;
1093
1094 if (numobjs) {
1095 if (numobjs < MAX_OBJS) {
1096 numobjs++;
1097
1098 return (numobjs);
1099 }
1100
1101 return (-1);
1102 }
1103 else {
1104 ObjList[0] = glGenLists(MAX_OBJS);
1105
1106 for (i = 1; i < MAX_OBJS; i++) {
1107 ObjList[i] = ObjList[0] + i;
1108 }
1109 numobjs = 1;
1110
1111 return (numobjs);
1112 }
1113}
1114
1115/*!
1116 \brief ADD
1117
1118 \param listno
1119 \param do_draw
1120 */
1122{
1123 if (do_draw) {
1125 }
1126 else {
1127 glNewList(ObjList[listno], GL_COMPILE);
1128 }
1129
1130 return;
1131}
1132
1133/*!
1134 \brief End list
1135 */
1136void gsd_endlist(void)
1137{
1138 glEndList();
1139
1140 return;
1141}
1142
1143/*!
1144 \brief Delete list
1145
1146 \param listno
1147 \param range [unused]
1148 */
1150{
1151 unsigned int i;
1152
1153 for (i = 1; i < MAX_OBJS; i++) {
1154 if (i == listno) {
1155 glDeleteLists(ObjList[i], 1);
1156 numobjs--;
1157 if (numobjs < 1)
1158 numobjs = 1;
1159 return;
1160 }
1161 }
1162}
1163
1164/*!
1165 \brief ADD
1166
1167 \param listno
1168 */
1170{
1171 glCallList(ObjList[listno]);
1172
1173 return;
1174}
1175
1176/*!
1177 \brief ADD
1178
1179 \param listno [unused]
1180 */
1182{
1183 int i;
1184
1186 for (i = 1; i < MAX_OBJS; i++) {
1187 glCallList(ObjList[i]);
1188 glFlush();
1189 }
1190 gsd_popmatrix();
1191
1193
1194 return;
1195}
void G_warning(const char *,...) __attribute__((format(printf
#define G_malloc(n)
Definition defs/gis.h:136
void G_message(const char *,...) __attribute__((format(printf
void gsd_do_scale(int)
Set current scale.
Definition gsd_views.c:351
void gsd_call_label(void)
Call display list and draw defined labels – called from gsd_prim (gsd_call_lists)
Definition gsd_label.c:115
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition gis.h:43
#define _(str)
Definition glocale.h:10
void gsd_set_clipplane(int num, int able)
Set clip plane.
Definition gsd_prim.c:1037
void gsd_endlist(void)
End list.
Definition gsd_prim.c:1136
void gsd_viewport(int l, int r, int b, int t)
Set the viewport.
Definition gsd_prim.c:1073
void gsd_endtstrip(void)
ADD.
Definition gsd_prim.c:323
void gsd_endtfan(void)
ADD.
Definition gsd_prim.c:343
void gsd_endtmesh(void)
ADD.
Definition gsd_prim.c:303
void gsd_swaptmesh(void)
ADD.
Definition gsd_prim.c:353
void gsd_backface(int n)
ADD.
Definition gsd_prim.c:250
void gsd_pushmatrix(void)
Push the current matrix stack.
Definition gsd_prim.c:507
int gsd_getViewport(GLint tmp[4], GLint num[2])
Get viewpoint.
Definition gsd_prim.c:946
void gsd_calllist(int listno)
ADD.
Definition gsd_prim.c:1169
void gsd_zwritemask(unsigned long n)
Write out z-mask.
Definition gsd_prim.c:237
void gsd_deflight(int num, struct lightdefs *vals)
Define light.
Definition gsd_prim.c:832
void gsd_vert_func(float *pt)
ADD.
Definition gsd_prim.c:682
void gsd_bgnqstrip(void)
ADD.
Definition gsd_prim.c:273
void gsd_switchlight(int num, int on)
Switch light on/off.
Definition gsd_prim.c:873
#define INT_TO_GRN(i, g)
Definition gsd_prim.c:50
void gsd_litvert_func(float *norm, unsigned long col, float *pt)
Set the current normal vector & specify vertex.
Definition gsd_prim.c:653
#define border
Definition gsd_prim.c:58
void gsd_colormode(int cm)
Set color mode.
Definition gsd_prim.c:94
void gsd_bgnpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
Definition gsd_prim.c:368
int gsd_writeView(unsigned char **pixbuf, unsigned int xsize, unsigned int ysize)
Write view.
Definition gsd_prim.c:965
void gsd_bgntstrip(void)
ADD.
Definition gsd_prim.c:313
void gsd_blend(int yesno)
Specify pixel arithmetic.
Definition gsd_prim.c:990
void gsd_init_lightmodel(void)
Initialize model light.
Definition gsd_prim.c:715
int gsd_getshademodel(void)
Get shaded model.
Definition gsd_prim.c:434
void gsd_bgnlist(int listno, int do_draw)
ADD.
Definition gsd_prim.c:1121
int gsd_makelist(void)
ADD.
Definition gsd_prim.c:1090
void gsd_swapbuffers(void)
Swap buffers.
Definition gsd_prim.c:478
void gsd_endqstrip(void)
ADD.
Definition gsd_prim.c:283
void gsd_sphere(float *center, float siz)
ADD.
Definition gsd_prim.c:203
void show_colormode(void)
Print color mode to stderr.
Definition gsd_prim.c:147
#define INT_TO_RED(i, r)
Definition gsd_prim.c:49
int gsd_getimage(unsigned char **pixbuf, unsigned int *xsize, unsigned int *ysize)
Get image of current GL screen.
Definition gsd_prim.c:898
#define INT_TO_BLU(i, b)
Definition gsd_prim.c:51
void gsd_backbuffer(void)
Draw to the back buffer.
Definition gsd_prim.c:466
#define MAX_OBJS
Definition gsd_prim.c:54
void gsd_popmatrix(void)
Pop the current matrix stack.
Definition gsd_prim.c:497
void gsd_flush(void)
Mostly for flushing drawing commands across a network.
Definition gsd_prim.c:80
void gsd_def_clipplane(int num, double *params)
Define clip plane.
Definition gsd_prim.c:1010
void gsd_endline(void)
End line.
Definition gsd_prim.c:403
void gsd_finish(void)
Finish.
Definition gsd_prim.c:1055
void gsd_calllists(int listno)
ADD.
Definition gsd_prim.c:1181
void gsd_circ(float x, float y, float rad)
ADD.
Definition gsd_prim.c:163
void gsd_bgntfan(void)
ADD.
Definition gsd_prim.c:333
void gsd_deletelist(GLuint listno, int range)
Delete list.
Definition gsd_prim.c:1149
int gsd_checkpoint(float pt[4], int window[4], int viewport[4], double modelMatrix[16], double projMatrix[16])
ADD.
Definition gsd_prim.c:581
void gsd_rot(float angle, char axis)
ADD.
Definition gsd_prim.c:601
void gsd_bgnline(void)
Begin line.
Definition gsd_prim.c:393
void gsd_scale(float xs, float ys, float zs)
Multiply the current matrix by a general scaling matrix.
Definition gsd_prim.c:521
void gsd_translate(float dx, float dy, float dz)
Multiply the current matrix by a translation matrix.
Definition gsd_prim.c:535
void gsd_bgntmesh(void)
ADD.
Definition gsd_prim.c:293
void gsd_disc(float x, float y, float z, float rad)
ADD.
Definition gsd_prim.c:183
void gsd_getwindow(int *window, int *viewport, double *modelMatrix, double *projMatrix)
Get viewport.
Definition gsd_prim.c:550
#define INT_TO_ALP(i, a)
Definition gsd_prim.c:52
void gsd_litvert_func2(float *norm, unsigned long col, float *pt)
ADD.
Definition gsd_prim.c:669
void gsd_color_func(unsigned int col)
Set current color.
Definition gsd_prim.c:694
void gsd_shademodel(int shade)
Set shaded model.
Definition gsd_prim.c:415
void gsd_bothbuffers(void)
Draw to the front and back buffers.
Definition gsd_prim.c:442
void gsd_frontbuffer(void)
Draw to the front buffer.
Definition gsd_prim.c:454
void gsd_endpolygon(void)
Delimit the vertices of a primitive or a group of like primitives.
Definition gsd_prim.c:383
void gsd_linewidth(short n)
Set width of rasterized lines.
Definition gsd_prim.c:263
void gsd_set_material(int set_shin, int set_emis, float sh, float em, int emcolor)
Set material.
Definition gsd_prim.c:799
float g
Definition named_colr.c:7
OGSF header file (structures)
#define CM_DIFFUSE
Definition ogsf.h:152
#define X
Definition ogsf.h:141
#define CM_AD
Definition ogsf.h:154
#define CM_EMISSION
Definition ogsf.h:150
#define CM_NULL
Definition ogsf.h:155
#define Z
Definition ogsf.h:143
#define W
Definition ogsf.h:144
#define MAX_LIGHTS
Definition ogsf.h:47
#define Y
Definition ogsf.h:142
#define CM_COLOR
Definition ogsf.h:149
double b
Definition r_raster.c:37
double l
Definition r_raster.c:37
double t
Definition r_raster.c:37
double r
Definition r_raster.c:37
float ambient[3]
R, G, B.
Definition ogsf.h:535
float position[4]
X, Y, Z, (1=local/0=inf)
Definition ogsf.h:529
float color[3]
R, G, B.
Definition ogsf.h:532
#define x