GRASS Programmer's Manual
6.4.2(2012)
|
00001 00019 #include <stdlib.h> 00020 #include <string.h> 00021 00022 #include <grass/config.h> 00023 00024 #if defined(OPENGL_X11) || defined(OPENGL_WINDOWS) 00025 #include <GL/gl.h> 00026 #include <GL/glu.h> 00027 #elif defined(OPENGL_AQUA) 00028 #include <OpenGL/gl.h> 00029 #include <OpenGL/glu.h> 00030 #endif 00031 00032 #include <grass/gis.h> 00033 #include <grass/gstypes.h> 00034 #include <grass/glocale.h> 00035 00036 #define USE_GL_NORMALIZE 00037 00038 #define RED_MASK 0x000000FF 00039 #define GRN_MASK 0x0000FF00 00040 #define BLU_MASK 0x00FF0000 00041 #define ALP_MASK 0xFF000000 00042 00043 #define INT_TO_RED(i, r) (r = (i & RED_MASK)) 00044 #define INT_TO_GRN(i, g) (g = (i & GRN_MASK) >> 8) 00045 #define INT_TO_BLU(i, b) (b = (i & BLU_MASK) >> 16) 00046 #define INT_TO_ALP(i, a) (a = (i & ALP_MASK) >> 24) 00047 00048 #define MAX_OBJS 64 00049 /* ^ TMP - move to gstypes */ 00050 00051 /* define border width (pixels) for viewport check */ 00052 #define border 15 00053 00054 static GLuint ObjList[MAX_OBJS]; 00055 static int numobjs = 0; 00056 00057 static int Shade; 00058 00059 static float ogl_light_amb[MAX_LIGHTS][4]; 00060 static float ogl_light_diff[MAX_LIGHTS][4]; 00061 static float ogl_light_spec[MAX_LIGHTS][4]; 00062 static float ogl_light_pos[MAX_LIGHTS][4]; 00063 static float ogl_mat_amb[4]; 00064 static float ogl_mat_diff[4]; 00065 static float ogl_mat_spec[4]; 00066 static float ogl_mat_emis[4]; 00067 static float ogl_mat_shin; 00068 00074 void gsd_flush(void) 00075 { 00076 glFlush(); 00077 00078 return; 00079 } 00080 00088 void gsd_colormode(int cm) 00089 { 00090 switch (cm) { 00091 case CM_COLOR: 00092 00093 glDisable(GL_COLOR_MATERIAL); 00094 glDisable(GL_LIGHTING); 00095 00096 break; 00097 case CM_EMISSION: 00098 00099 glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); 00100 glEnable(GL_COLOR_MATERIAL); 00101 glEnable(GL_LIGHTING); 00102 00103 break; 00104 case CM_DIFFUSE: 00105 00106 glColorMaterial(GL_FRONT, GL_DIFFUSE); 00107 glEnable(GL_COLOR_MATERIAL); 00108 glEnable(GL_LIGHTING); 00109 00110 break; 00111 case CM_AD: 00112 00113 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); 00114 glEnable(GL_COLOR_MATERIAL); 00115 glEnable(GL_LIGHTING); 00116 00117 break; 00118 case CM_NULL: 00119 00120 /* OGLXXX 00121 * lmcolor: if LMC_NULL, use: 00122 * glDisable(GL_COLOR_MATERIAL); 00123 * LMC_NULL: use glDisable(GL_COLOR_MATERIAL); 00124 */ 00125 glDisable(GL_COLOR_MATERIAL); 00126 glEnable(GL_LIGHTING); 00127 00128 break; 00129 default: 00130 00131 glDisable(GL_COLOR_MATERIAL); 00132 break; 00133 } 00134 00135 return; 00136 } 00137 00141 void show_colormode(void) 00142 { 00143 GLint mat; 00144 00145 glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER, &mat); 00146 G_message(_("Color Material: %d"), mat); 00147 00148 return; 00149 } 00150 00157 void gsd_circ(float x, float y, float rad) 00158 { 00159 GLUquadricObj *qobj = gluNewQuadric(); 00160 00161 gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); 00162 glPushMatrix(); 00163 glTranslatef(x, y, 0.); 00164 gluDisk(qobj, 0., rad, 32, 1); 00165 glPopMatrix(); 00166 gluDeleteQuadric(qobj); 00167 00168 return; 00169 } 00170 00177 void gsd_disc(float x, float y, float z, float rad) 00178 { 00179 GLUquadricObj *qobj = gluNewQuadric(); 00180 00181 gluQuadricDrawStyle(qobj, GLU_FILL); 00182 glPushMatrix(); 00183 glTranslatef(x, y, z); 00184 gluDisk(qobj, 0., rad, 32, 1); 00185 glPopMatrix(); 00186 gluDeleteQuadric(qobj); 00187 00188 return; 00189 } 00190 00197 void gsd_sphere(float *center, float siz) 00198 { 00199 static int first = 1; 00200 static GLUquadricObj *QOsphere; 00201 00202 if (first) { 00203 QOsphere = gluNewQuadric(); 00204 00205 if (QOsphere) { 00206 gluQuadricNormals(QOsphere, GLU_SMOOTH); /* default */ 00207 gluQuadricTexture(QOsphere, GL_FALSE); /* default */ 00208 gluQuadricOrientation(QOsphere, GLU_OUTSIDE); /* default */ 00209 gluQuadricDrawStyle(QOsphere, GLU_FILL); 00210 } 00211 00212 first = 0; 00213 } 00214 00215 glPushMatrix(); 00216 glTranslatef(center[0], center[1], center[2]); 00217 gluSphere(QOsphere, (double)siz, 24, 24); 00218 glPopMatrix(); 00219 00220 return; 00221 } 00222 00231 void gsd_zwritemask(unsigned long n) 00232 { 00233 /* OGLXXX glDepthMask is boolean only */ 00234 glDepthMask((GLboolean) (n)); 00235 00236 return; 00237 } 00238 00244 void gsd_backface(int n) 00245 { 00246 glCullFace(GL_BACK); 00247 (n) ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE); 00248 00249 return; 00250 } 00251 00257 void gsd_linewidth(short n) 00258 { 00259 glLineWidth((GLfloat) (n)); 00260 00261 return; 00262 } 00263 00267 void gsd_bgnqstrip(void) 00268 { 00269 glBegin(GL_QUAD_STRIP); 00270 00271 return; 00272 } 00273 00277 void gsd_endqstrip(void) 00278 { 00279 glEnd(); 00280 00281 return; 00282 } 00283 00287 void gsd_bgntmesh(void) 00288 { 00289 glBegin(GL_TRIANGLE_STRIP); 00290 00291 return; 00292 } 00293 00297 void gsd_endtmesh(void) 00298 { 00299 glEnd(); 00300 00301 return; 00302 } 00303 00307 void gsd_bgntstrip(void) 00308 { 00309 glBegin(GL_TRIANGLE_STRIP); 00310 00311 return; 00312 } 00313 00317 void gsd_endtstrip(void) 00318 { 00319 glEnd(); 00320 00321 return; 00322 } 00323 00327 void gsd_bgntfan(void) 00328 { 00329 glBegin(GL_TRIANGLE_FAN); 00330 00331 return; 00332 } 00333 00337 void gsd_endtfan(void) 00338 { 00339 glEnd(); 00340 00341 return; 00342 } 00343 00347 void gsd_swaptmesh(void) 00348 { 00349 /* OGLXXX 00350 * swaptmesh not supported, maybe glBegin(GL_TRIANGLE_FAN) 00351 * swaptmesh() 00352 */ 00353 00354 /*DELETED*/; 00355 00356 return; 00357 } 00358 00362 void gsd_bgnpolygon(void) 00363 { 00364 /* OGLXXX 00365 * special cases for polygons: 00366 * independant quads: use GL_QUADS 00367 * independent triangles: use GL_TRIANGLES 00368 */ 00369 glBegin(GL_POLYGON); 00370 00371 return; 00372 } 00373 00377 void gsd_endpolygon(void) 00378 { 00379 glEnd(); 00380 00381 return; 00382 } 00383 00387 void gsd_bgnline(void) 00388 { 00389 /* OGLXXX for multiple, independent line segments: use GL_LINES */ 00390 glBegin(GL_LINE_STRIP); 00391 return; 00392 } 00393 00397 void gsd_endline(void) 00398 { 00399 glEnd(); 00400 00401 return; 00402 } 00403 00409 void gsd_shademodel(int bool) 00410 { 00411 Shade = bool; 00412 00413 if (bool) { 00414 glShadeModel(GL_SMOOTH); 00415 } 00416 else { 00417 glShadeModel(GL_FLAT); 00418 } 00419 00420 return; 00421 } 00422 00428 int gsd_getshademodel(void) 00429 { 00430 return (Shade); 00431 } 00432 00436 void gsd_bothbuffer(void) 00437 { 00438 /* OGLXXX frontbuffer: other possibilities include GL_FRONT_AND_BACK */ 00439 glDrawBuffer(GL_FRONT_AND_BACK); 00440 00441 return; 00442 } 00443 00450 void gsd_frontbuffer(int bool) 00451 { 00452 /* OGLXXX frontbuffer: other possibilities include GL_FRONT_AND_BACK */ 00453 glDrawBuffer((bool) ? GL_FRONT : GL_BACK); 00454 00455 return; 00456 } 00457 00464 void gsd_backbuffer(int bool) 00465 { 00466 /* OGLXXX backbuffer: other possibilities include GL_FRONT_AND_BACK */ 00467 glDrawBuffer((bool) ? GL_BACK : GL_FRONT); 00468 return; 00469 } 00470 00474 void gsd_swapbuffers(void) 00475 { 00476 /* OGLXXX swapbuffers: 00477 glXSwapBuffers(*display, window); 00478 replace display and window */ 00479 00480 Swap_func(); 00481 00482 return; 00483 } 00484 00488 void gsd_popmatrix(void) 00489 { 00490 glPopMatrix(); 00491 00492 return; 00493 } 00494 00498 void gsd_pushmatrix(void) 00499 { 00500 glPushMatrix(); 00501 00502 return; 00503 } 00504 00512 void gsd_scale(float xs, float ys, float zs) 00513 { 00514 glScalef(xs, ys, zs); 00515 00516 return; 00517 } 00518 00526 void gsd_translate(float dx, float dy, float dz) 00527 { 00528 glTranslatef(dx, dy, dz); 00529 00530 return; 00531 } 00532 00541 void gsd_getwindow(int *window, int *viewport, double *modelMatrix, 00542 double *projMatrix) 00543 { 00544 gsd_pushmatrix(); 00545 gsd_do_scale(1); 00546 00547 glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); 00548 glGetDoublev(GL_PROJECTION_MATRIX, projMatrix); 00549 glGetIntegerv(GL_VIEWPORT, viewport); 00550 gsd_popmatrix(); 00551 00552 window[0] = viewport[1] + viewport[3] + border; 00553 window[1] = viewport[1] - border; 00554 window[2] = viewport[0] - border; 00555 window[3] = viewport[0] + viewport[2] + border; 00556 00557 return; 00558 00559 } 00560 00573 int gsd_checkpoint(float pt[4], 00574 int window[4], 00575 int viewport[4], 00576 double modelMatrix[16], double projMatrix[16]) 00577 { 00578 GLdouble fx, fy, fz; 00579 00580 gluProject((GLdouble) pt[X], (GLdouble) pt[Y], (GLdouble) pt[Z], 00581 modelMatrix, projMatrix, viewport, &fx, &fy, &fz); 00582 00583 if (fx < window[2] || fx > window[3] 00584 || fy < window[1] || fy > window[0]) 00585 return 1; 00586 else 00587 return 0; 00588 00589 } 00590 00597 void gsd_rot(float angle, char axis) 00598 { 00599 GLfloat x; 00600 GLfloat y; 00601 GLfloat z; 00602 00603 switch (axis) { 00604 case 'x': 00605 case 'X': 00606 00607 x = 1.0; 00608 y = 0.0; 00609 z = 0.0; 00610 00611 break; 00612 case 'y': 00613 case 'Y': 00614 00615 x = 0.0; 00616 y = 1.0; 00617 z = 0.0; 00618 00619 break; 00620 case 'z': 00621 case 'Z': 00622 00623 x = 0.0; 00624 y = 0.0; 00625 z = 1.0; 00626 00627 break; 00628 default: 00629 00630 G_warning(_("gsd_rot(): %c is an invalid axis " 00631 "specification. Rotation ignored. " 00632 "Please advise GRASS developers of this error"), axis); 00633 return; 00634 } 00635 00636 glRotatef((GLfloat) angle, x, y, z); 00637 00638 return; 00639 } 00640 00648 void gsd_litvert_func(float *norm, unsigned long col, float *pt) 00649 { 00650 glNormal3fv(norm); 00651 gsd_color_func(col); 00652 glVertex3fv(pt); 00653 00654 return; 00655 } 00656 00664 void gsd_litvert_func2(float *norm, unsigned long col, float *pt) 00665 { 00666 glNormal3fv(norm); 00667 glVertex3fv(pt); 00668 00669 return; 00670 } 00671 00677 void gsd_vert_func(float *pt) 00678 { 00679 glVertex3fv(pt); 00680 00681 return; 00682 } 00683 00689 void gsd_color_func(unsigned int col) 00690 { 00691 GLbyte r, g, b, a; 00692 00693 /* OGLXXX 00694 * cpack: if argument is not a variable 00695 * might need to be: 00696 * glColor4b(($1)&0xff, ($1)>>8&0xff, ($1)>>16&0xff, ($1)>>24&0xff) 00697 */ 00698 INT_TO_RED(col, r); 00699 INT_TO_GRN(col, g); 00700 INT_TO_BLU(col, b); 00701 INT_TO_ALP(col, a); 00702 glColor4ub(r, g, b, a); 00703 00704 return; 00705 } 00706 00710 void gsd_init_lightmodel(void) 00711 { 00712 00713 glEnable(GL_LIGHTING); 00714 00715 /* normal vector renormalization */ 00716 #ifdef USE_GL_NORMALIZE 00717 { 00718 glEnable(GL_NORMALIZE); 00719 } 00720 #endif 00721 00722 /* OGLXXX 00723 * Ambient: 00724 * If this is a light model lmdef, then use 00725 * glLightModelf and GL_LIGHT_MODEL_AMBIENT. 00726 * Include ALPHA parameter with ambient 00727 */ 00728 00729 /* Default is front face lighting, infinite viewer 00730 */ 00731 ogl_mat_amb[0] = 0.1; 00732 ogl_mat_amb[1] = 0.1; 00733 ogl_mat_amb[2] = 0.1; 00734 ogl_mat_amb[3] = 1.0; 00735 00736 ogl_mat_diff[0] = 0.8; 00737 ogl_mat_diff[1] = 0.8; 00738 ogl_mat_diff[2] = 0.8; 00739 ogl_mat_diff[3] = 0.8; 00740 00741 ogl_mat_spec[0] = 0.8; 00742 ogl_mat_spec[1] = 0.8; 00743 ogl_mat_spec[2] = 0.8; 00744 ogl_mat_spec[3] = 0.8; 00745 00746 ogl_mat_emis[0] = 0.0; 00747 ogl_mat_emis[1] = 0.0; 00748 ogl_mat_emis[2] = 0.0; 00749 ogl_mat_emis[3] = 0.0; 00750 00751 ogl_mat_shin = 25.0; 00752 00753 /* OGLXXX 00754 * attenuation: see glLightf man page: (ignored for infinite lights) 00755 * Add GL_LINEAR_ATTENUATION. 00756 sgi_lmodel[0] = GL_CONSTANT_ATTENUATION; 00757 sgi_lmodel[1] = 1.0; 00758 sgi_lmodel[2] = 0.0; 00759 sgi_lmodel[3] = ; 00760 */ 00761 00762 /* OGLXXX 00763 * lmdef other possibilities include: 00764 * glLightf(light, pname, *params); 00765 * glLightModelf(pname, param); 00766 * Check list numbering. 00767 * Translate params as needed. 00768 */ 00769 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ogl_mat_amb); 00770 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ogl_mat_diff); 00771 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, ogl_mat_spec); 00772 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, ogl_mat_emis); 00773 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, ogl_mat_shin); 00774 00775 /* OGLXXX lmbind: check object numbering. */ 00776 /* OGLXXX 00777 * lmbind: check object numbering. 00778 * Use GL_FRONT in call to glMaterialf. 00779 * Use GL_FRONT in call to glMaterialf. 00780 if(1) {glCallList(1); glEnable(LMODEL);} else glDisable(LMODEL); 00781 if(1) {glCallList(1); glEnable(GL_FRONT);} else glDisable(GL_FRONT); 00782 */ 00783 00784 return; 00785 } 00786 00794 void gsd_set_material(int set_shin, int set_emis, float sh, float em, 00795 int emcolor) 00796 { 00797 if (set_shin) { 00798 ogl_mat_spec[0] = sh; 00799 ogl_mat_spec[1] = sh; 00800 ogl_mat_spec[2] = sh; 00801 ogl_mat_spec[3] = sh; 00802 00803 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, ogl_mat_spec); 00804 00805 ogl_mat_shin = 60. + (int)(sh * 68.); 00806 00807 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, ogl_mat_shin); 00808 } 00809 00810 if (set_emis) { 00811 ogl_mat_emis[0] = (em * (emcolor & 0x0000FF)) / 255.; 00812 ogl_mat_emis[1] = (em * ((emcolor & 0x00FF00) >> 8)) / 255.; 00813 ogl_mat_emis[2] = (em * ((emcolor & 0xFF0000) >> 16)) / 255.; 00814 00815 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, ogl_mat_emis); 00816 } 00817 00818 return; 00819 } 00820 00827 void gsd_deflight(int num, struct lightdefs *vals) 00828 { 00829 if (num > 0 && num <= MAX_LIGHTS) { 00830 ogl_light_pos[num - 1][0] = vals->position[X]; 00831 ogl_light_pos[num - 1][1] = vals->position[Y]; 00832 ogl_light_pos[num - 1][2] = vals->position[Z]; 00833 ogl_light_pos[num - 1][3] = vals->position[W]; 00834 00835 glLightfv(GL_LIGHT0 + num, GL_POSITION, ogl_light_pos[num - 1]); 00836 00837 ogl_light_diff[num - 1][0] = vals->color[0]; 00838 ogl_light_diff[num - 1][1] = vals->color[1]; 00839 ogl_light_diff[num - 1][2] = vals->color[2]; 00840 ogl_light_diff[num - 1][3] = .3; 00841 00842 glLightfv(GL_LIGHT0 + num, GL_DIFFUSE, ogl_light_diff[num - 1]); 00843 00844 ogl_light_amb[num - 1][0] = vals->ambient[0]; 00845 ogl_light_amb[num - 1][1] = vals->ambient[1]; 00846 ogl_light_amb[num - 1][2] = vals->ambient[2]; 00847 ogl_light_amb[num - 1][3] = .3; 00848 00849 glLightfv(GL_LIGHT0 + num, GL_AMBIENT, ogl_light_amb[num - 1]); 00850 00851 ogl_light_spec[num - 1][0] = vals->color[0]; 00852 ogl_light_spec[num - 1][1] = vals->color[1]; 00853 ogl_light_spec[num - 1][2] = vals->color[2]; 00854 ogl_light_spec[num - 1][3] = .3; 00855 00856 glLightfv(GL_LIGHT0 + num, GL_SPECULAR, ogl_light_spec[num - 1]); 00857 } 00858 00859 return; 00860 } 00861 00868 void gsd_switchlight(int num, int on) 00869 { 00870 short defin; 00871 00872 defin = on ? num : 0; 00873 00874 if (defin) { 00875 glEnable(GL_LIGHT0 + num); 00876 } 00877 else { 00878 glDisable(GL_LIGHT0 + num); 00879 } 00880 00881 return; 00882 } 00883 00893 int gsd_getimage(unsigned char **pixbuf, unsigned int *xsize, 00894 unsigned int *ysize) 00895 { 00896 GLuint l, r, b, t; 00897 00898 /* OGLXXX 00899 * get GL_VIEWPORT: 00900 * You can probably do better than this. 00901 */ 00902 GLint tmp[4]; 00903 00904 glGetIntegerv(GL_VIEWPORT, tmp); 00905 l = tmp[0]; 00906 r = tmp[0] + tmp[2] - 1; 00907 b = tmp[1]; 00908 t = tmp[1] + tmp[3] - 1; 00909 00910 *xsize = r - l + 1; 00911 *ysize = t - b + 1; 00912 00913 *pixbuf = (unsigned char *)G_malloc((*xsize) * (*ysize) * 4); /* G_fatal_error */ 00914 00915 if (!*pixbuf) 00916 return (0); 00917 00918 glReadBuffer(GL_FRONT); 00919 00920 /* OGLXXX lrectread: see man page for glReadPixels */ 00921 glReadPixels(l, b, (r) - (l) + 1, (t) - (b) + 1, GL_RGBA, 00922 GL_UNSIGNED_BYTE, *pixbuf); 00923 00924 return (1); 00925 } 00926 00935 int gsd_getViewport(GLint tmp[4], GLint num[2]) 00936 { 00937 00938 /* Save current viewport to tmp */ 00939 glGetIntegerv(GL_VIEWPORT, tmp); 00940 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, num); 00941 00942 return (1); 00943 } 00944 00951 int gsd_writeView(unsigned char **pixbuf, unsigned int xsize, 00952 unsigned int ysize) 00953 { 00954 00955 /* Malloc Buffer for image */ 00956 *pixbuf = (unsigned char *)G_malloc(xsize * ysize * 4); /* G_fatal_error */ 00957 if (!*pixbuf) { 00958 return (0); 00959 } 00960 00961 /* Read image buffer */ 00962 glReadBuffer(GL_FRONT); 00963 00964 /* Read Pixels into Buffer */ 00965 glReadPixels(0, 0, xsize, ysize, GL_RGBA, GL_UNSIGNED_BYTE, *pixbuf); 00966 return (1); 00967 } 00968 00974 void gsd_blend(int yesno) 00975 { 00976 if (yesno) { 00977 glEnable(GL_BLEND); 00978 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00979 } 00980 else { 00981 glDisable(GL_BLEND); 00982 glBlendFunc(GL_ONE, GL_ZERO); 00983 } 00984 00985 return; 00986 } 00987 00994 void gsd_def_clipplane(int num, double *params) 00995 { 00996 int wason = 0; 00997 00998 /* OGLXXX see man page for glClipPlane equation */ 00999 if (glIsEnabled(GL_CLIP_PLANE0 + (num))) { 01000 wason = 1; 01001 } 01002 01003 glClipPlane(GL_CLIP_PLANE0 + (num), params); 01004 01005 if (wason) { 01006 glEnable(GL_CLIP_PLANE0 + (num)); 01007 } 01008 else { 01009 glDisable(GL_CLIP_PLANE0 + (num)); 01010 } 01011 01012 return; 01013 } 01014 01021 void gsd_set_clipplane(int num, int able) 01022 { 01023 /* OGLXXX see man page for glClipPlane equation */ 01024 if (able) { 01025 glEnable(GL_CLIP_PLANE0 + (num)); 01026 } 01027 else { 01028 glDisable(GL_CLIP_PLANE0 + (num)); 01029 } 01030 01031 return; 01032 } 01033 01039 void gsd_finish(void) 01040 { 01041 return; 01042 } 01043 01057 void gsd_viewport(int l, int r, int b, int t) 01058 { 01059 /* Screencoord */ 01060 glViewport(l, b, r, t); 01061 01062 return; 01063 } 01064 01074 int gsd_makelist(void) 01075 { 01076 int i; 01077 01078 if (numobjs) { 01079 if (numobjs < MAX_OBJS) { 01080 numobjs++; 01081 01082 return (numobjs); 01083 } 01084 01085 return (-1); 01086 } 01087 else { 01088 ObjList[0] = glGenLists(MAX_OBJS); 01089 01090 for (i = 1; i < MAX_OBJS; i++) { 01091 ObjList[i] = ObjList[0] + i; 01092 } 01093 numobjs = 1; 01094 01095 return (numobjs); 01096 } 01097 01098 } 01099 01106 void gsd_bgnlist(int listno, int do_draw) 01107 { 01108 if (do_draw) { 01109 glNewList(ObjList[listno], GL_COMPILE_AND_EXECUTE); 01110 } 01111 else { 01112 glNewList(ObjList[listno], GL_COMPILE); 01113 } 01114 01115 return; 01116 } 01117 01121 void gsd_endlist(void) 01122 { 01123 glEndList(); 01124 01125 return; 01126 } 01127 01134 void gsd_deletelist(GLuint listno, int range) 01135 { 01136 unsigned int i; 01137 01138 for (i = 1; i < MAX_OBJS; i++) { 01139 if (i == listno) { 01140 glDeleteLists(ObjList[i], 1); 01141 numobjs--; 01142 if (numobjs < 1) 01143 numobjs = 1; 01144 return; 01145 } 01146 } 01147 } 01148 01154 void gsd_calllist(int listno) 01155 { 01156 glCallList(ObjList[listno]); 01157 01158 return; 01159 } 01160 01161 01167 void gsd_calllists(int listno) 01168 { 01169 int i; 01170 01171 gsd_pushmatrix(); 01172 for (i = 1; i < MAX_OBJS; i++) { 01173 glCallList(ObjList[i]); 01174 glFlush(); 01175 } 01176 gsd_popmatrix(); 01177 01178 gsd_call_label(); 01179 01180 return; 01181 }