1 /***************************************************************************** 2 * 3 * Elmer, A Finite Element Software for Multiphysical Problems 4 * 5 * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program (in file fem/GPL-2); if not, write to the 19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 *****************************************************************************/ 23 24 /******************************************************************************* 25 * 26 * Includes for X & OpenGL. 27 * 28 ******************************************************************************* 29 * 30 * Author: Juha Ruokolainen 31 * 32 * Address: CSC - IT Center for Science Ltd. 33 * Keilaranta 14, P.O. BOX 405 34 * 02101 Espoo, Finland 35 * Tel. +358 0 457 2723 36 * Telefax: +358 0 457 2302 37 * EMail: Juha.Ruokolainen@csc.fi 38 * 39 * Date: 26 Sep 1995 40 * 41 * Modified by: 42 * 43 * Date of modification: 44 * 45 * $Id: graphics.h,v 1.3 2005/05/31 11:28:14 vierinen Exp $ 46 * 47 * $Log: graphics.h,v $ 48 * Revision 1.3 2005/05/31 11:28:14 vierinen 49 * ads 50 * 51 * Revision 1.2 2005/05/31 10:39:03 vierinen 52 * apple? 53 * 54 * Revision 1.1.1.1 2005/05/31 06:29:21 vierinen 55 * ads 56 * 57 * Revision 1.4 2001/06/29 12:00:05 jpr 58 * *** empty log message *** 59 * 60 * Revision 1.3 2001/06/13 07:55:53 jpr 61 * *** empty log message *** 62 * 63 * Revision 1.2 1998/07/31 13:36:55 jpr 64 * 65 * Added id, started log. 66 * 67 * 68 ******************************************************************************/ 69 70 #include "../../config.h" 71 72 #ifndef MINGW32 73 74 #include <X11/X.h> 75 #include <X11/keysymdef.h> 76 #include "../glaux/glaux.h" 77 78 #else 79 80 #include <GL/glaux.h> 81 82 #endif 83 84 #include <GL/gl.h> 85 #include <GL/glu.h> 86 87 88 89 /* 90 * Material for lightning computations 91 */ 92 typedef struct material_s 93 { 94 struct material_s *Next; 95 96 char *Name; 97 98 int Changed; 99 100 float Shininess; 101 float Diffuse[4],Specular[4]; 102 } material_t; 103 104 /* 105 * 106 */ 107 typedef struct rgb_s 108 { 109 unsigned char r,g,b; 110 } rgb_t; 111 112 typedef struct colormap_s 113 { 114 struct colormap_s *Next; 115 116 char *Name; 117 118 int Changed; 119 120 rgb_t *Values; 121 int NumberOfEntries; 122 } colormap_t; 123 124 #ifdef MODULE_GRAPHICS 125 126 material_t DefaultMaterial = 127 { 128 NULL, NULL, TRUE, 20.0, { 0.8,0.8,0.8,1.0 }, { 0.0,0.0,0.0,1.0 } 129 }; 130 material_t DefaultEdgeMaterial = 131 { 132 NULL, NULL, TRUE, 20.0, { 0.8,0.8,0.8,1.0 }, { 0.0,0.0,0.0,1.0 } 133 }; 134 material_t def_mat = 135 { 136 NULL, NULL, TRUE, 20.0, { 0.8,0.8,0.8,1.0 }, { 0.0,0.0,0.0,1.0 } 137 }; 138 139 colormap_t DefaultColorMap = 140 { 141 NULL, NULL, TRUE, NULL, 0 142 }; 143 colormap_t def_map = 144 { 145 NULL, NULL, TRUE, NULL, 0 146 }; 147 148 colormap_t *ArrowColorMap = &DefaultColorMap, *MeshColorMap = &DefaultColorMap, 149 *ContourColorMap = &DefaultColorMap, *IsoSurfaceColorMap = &DefaultColorMap, 150 *SphereColorMap = &DefaultColorMap, *ParticleColorMap = &DefaultColorMap; 151 152 material_t *ArrowMaterial = &DefaultMaterial, *MeshMaterial = &DefaultMaterial, 153 *ContourMaterial = &DefaultMaterial, *IsoSurfaceMaterial = &DefaultMaterial, 154 *SphereMaterial = &DefaultMaterial, *ParticleMaterial = &DefaultMaterial; 155 156 #else 157 158 extern colormap_t DefaultColorMap,def_map; 159 160 extern colormap_t *ArrowColorMap,*MeshColorMap,*ContourColorMap, 161 *IsoSurfaceColorMap,*SphereColorMap,*ParticleColorMap; 162 163 extern material_t DefaultMaterial,DefaultEdgeMaterial,def_mat; 164 extern material_t *ArrowMaterial,*MeshMaterial,*ContourMaterial, 165 *IsoSurfaceMaterial,*SphereMaterial,*ParticleMaterial; 166 #endif 167 168 169 /* 170 * Try keeping direct softcalls to OpenGL in graphics module... 171 */ 172 #define GRA_FILL (GL_FILL) 173 #define GRA_LINE (GL_LINE) 174 175 #define GRA_POINTS (GL_POINTS) 176 #define GRA_LINES (GL_LINES) 177 #define GRA_QUADS (GL_QUADS) 178 #define GRA_TRIANGLES (GL_TRIANGLES) 179 180 #define gra_end() glEnd() 181 #define gra_begin( Mode ) glBegin( Mode ) 182 183 #define gra_lon() glEnable( GL_LIGHTING ) 184 #define gra_loff() glDisable( GL_LIGHTING ) 185 186 #define gra_beg_lines() { glDisable( GL_LIGHTING ); glBegin( GL_LINES ); } 187 #define gra_end_lines() { glEnd(); glEnable( GL_LIGHTING ); } 188 189 #define gra_line_width(a) glLineWidth(a) 190 191 #define gra_push_matrix() glPushMatrix() 192 #define gra_pop_matrix() glPopMatrix() 193 #define gra_mult_matrix(Matrix) glMultMatrixd( (GLdouble *)Matrix ) 194 #define gra_load_identity() glLoadIdentity() 195 196 #define gra_look_at(fx,fy,fz,tx,ty,tz,ux,uy,uz) gluLookAt(fx,fy,fz,tx,ty,tz,ux,uy,uz) 197 198 #define gra_polygon_mode( Mode ) glPolygonMode( GL_FRONT_AND_BACK, Mode ) 199 200 201