Allink  v0.1
DrawFile.cpp
1 #include "../../include/Draw.h"
2 #include <unistd.h>
3 #include <setjmp.h>
4 
5 #ifdef __glut_h__
7  Shout("ReadConf");
8  FILE *ConfFile;
9  char cLine[256];
10  double Val[9];
11  if( (ConfFile = fopen("Draw.conf","r")) == 0 ){return;}
12  for(int k=0;!(fgets(cLine,256,ConfFile)==NULL);k++){
13  if(1 == sscanf(cLine,"Pre %lf",Val) )
14  pr = (int) Val[0];
15  else if(1 == sscanf(cLine,"Passo %lf",Val))
16  GridStep = (int)Val[0];
17  else if(1 == sscanf(cLine,"Box %lf",Val))
18  la = (int) Val[0];
19  else if(1 == sscanf(cLine,"Grid %lf",Val))
20  gr = (int) Val[0];
21  else if(3 == sscanf(cLine,"Offset %lf %lf %lf",Val,Val+1,Val+2)){
22  xp = Val[0];yp = Val[1];zp = Val[2];
23  }
24  else if(3 == sscanf(cLine,"Rotate %lf %lf %lf",Val,Val+1,Val+2)){
25  xa = Val[0];ya = Val[1];za = Val[2];
26  }
27  else if(3 == sscanf(cLine,"Sun %lf %lf %lf",Val,Val+1,Val+2)){
28  xf = Val[0];yf = Val[1];zf = Val[2];
29  }
30  else if(3 == sscanf(cLine,"Info %lf %lf %lf",Val,Val+1,Val+2)){
31  xi = Val[0];yi = Val[1];zi = Val[2];
32  }
33  else if(5 == sscanf(cLine,"Legend %lf %lf %lf %lf %lf",Val,Val+1,Val+2,Val+3,Val+4)){
34  xLeg = Val[0];yLeg = Val[1];zLeg = Val[2];dxLeg = Val[3];dyLeg = Val[4];
35  }
36  else if(3 == sscanf(cLine,"Background %lf %lf %lf",Val,Val+1,Val+2)){
37  Rback = Val[0];Gback = Val[1];Bback = Val[2];
38  }
39  else if(1 == sscanf(cLine,"Wheel %lf",Val)){
40  zw = Val[0];
41  }
42  else if(3 == sscanf(cLine,"GridEdge %lf %lf %lf",Val,Val+1,Val+2)){
43  GridEdge[0] = Val[0];GridEdge[1] = Val[1];GridEdge[2] = Val[2];
44  }
45  }
46  fclose(ConfFile);
47 }
48 #ifdef USE_TIFF
49 #include <tiff.h>
50 #include <tiffio.h>
51 int Draw::OpenImage(const char *FileName){
52  Shout("OpenImage");
53 // pixel = (GLubyte *)realloc(pixel,4*width*height*sizeof(*pixel));
54 // glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE,pixel);
55 // return 0;
56  TIFF *image;
57  uint16 photo=0, bps=0, spp=0, fillorder=0,resUnit=0;
58  uint32 ImWidth1=0,ImHeight1=0;
59  tsize_t stripSize;
60  int imageOffset=0, result=0;
61  int stripMax=0, stripCount=0;
62  float xRes=0,yRes=0;
63  // char *buffer, tempbyte;
64  uint32 *buffer=NULL;
65  int bufferSize=0, count=0;
66  int NPixel=0,Level=4;
67  if((image = TIFFOpen(FileName, "r")) == NULL){
68  fprintf(stderr, "Could not open incoming image\n");
69  return 0;
70  }
71  TIFFGetField(image, TIFFTAG_IMAGELENGTH, &ImHeight1);
72  TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &ImWidth1);
73  TIFFGetField(image, TIFFTAG_PHOTOMETRIC, &photo);
74  TIFFGetField(image, TIFFTAG_FILLORDER, &fillorder);
75  TIFFGetField(image, TIFFTAG_XRESOLUTION, &xRes);
76  TIFFGetField(image, TIFFTAG_YRESOLUTION, &yRes);
77  TIFFGetField(image, TIFFTAG_RESOLUTIONUNIT, &resUnit);
78  TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bps);
79  TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp);
80  stripSize = TIFFStripSize (image);
81  stripMax = TIFFNumberOfStrips (image);
82  imageOffset = 0;
83  bufferSize = TIFFNumberOfStrips (image) * stripSize;
84  ImHeight = (GLuint)ImHeight1;
85  ImWidth = (GLuint) ImWidth1;
86  NPixel = ImWidth*ImHeight*Level;
87  //sprintf(info,"width %d height %d photo %d fillorder %d Res (%lf %lf) ResUnit %d bit/sample %d sample/pixel %d stripSize %d stripMax %d bufferSize %d NPixel %d\n",ImWidth,ImHeight,photo,fillorder,xRes,yRes,resUnit,bps,spp,stripSize,stripMax,bufferSize,NPixel);
88  //buffer = (uint32 *) malloc(bufferSize);
89  buffer = (uint32 *)_TIFFmalloc(ImHeight1 * ImWidth1 * sizeof (uint32));
90  if(buffer == NULL){
91  fprintf(stderr, "Could not allocate enough memory for the uncompressed image\n");
92  return 0;
93  }
94  free(pixel);
95  pixel = NULL;
96  pixel = (GLubyte *)calloc(4*ImWidth*ImHeight,sizeof(*pixel));
97  if(!TIFFReadRGBAImage(image,ImWidth1,ImHeight1,buffer,1)){
98  //if(!TIFFReadRGBAImageOriented(image,ImWidth1,ImHeight1,buffer,ORIENTATION_TOPLEFT,0)){
99  _TIFFfree(buffer);
100  printf("The immage was not read\n");
101  throw "Corrupted TIFF file!";
102  }
103  for(int h=0; h<ImHeight; h++) {
104  for(int w=0; w<ImWidth; w++) {
105  pixel[(h*ImWidth+w)*4+0] = buffer[(h*ImWidth+w)] & 0x000000ff;
106  pixel[(h*ImWidth+w)*4+1] = ((buffer[(h*ImWidth+w)] >> 8 ) & 0x0000ff);
107  pixel[(h*ImWidth+w)*4+2] = ((buffer[(h*ImWidth+w)] >> 16 ) & 0x00ff);
108  pixel[(h*ImWidth+w)*4+3] = ((buffer[(h*ImWidth+w)] >> 24 ) & 0xff);
109  }
110  }
111  TIFFClose(image);
112  _TIFFfree(buffer);
113  return 1;
114 }
115 int Draw::WritePixel(){
116  Shout("WritePixel");
117  char cImage[160];
118  sprintf(cImage,"Image%05u.tif",Step);
119  TIFF *tif = TIFFOpen( cImage, "w");
120  if(tif) {
121  TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ImWidth);
122  TIFFSetField(tif, TIFFTAG_IMAGELENGTH, ImHeight);
123  TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
124  TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
125  TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
126  TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
127  TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
128  }
129  TIFFWriteEncodedStrip(tif, 0, pixel, ImWidth * ImHeight *4);
130  TIFFClose(tif);
131  return 0;
132 }
133 int Draw::Picture(){
134  Shout("Picture");
135  // mkOpenGLJPEGImage jpgScreen;
136  // jpgScreen.SetDebugMode(true);
137  // jpgScreen.GetOpenGLScreenImage(imageWidth, imageHeight);
138  // jpgScreen.SaveToFile("ScreenShot.jpg");
139  //GLubyte pixel[Resx][Resy][3];
140  // GLubyte *pixel=new GLubyte [Resx * Resy];
141  glutPostRedisplay();
142  char cImage[160];
143  sprintf(cImage,"Image%05u.tif",Step);
144  TIFF *tif = TIFFOpen( cImage, "w");
145  if(tif) {
146  TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WinWidth);
147  TIFFSetField(tif, TIFFTAG_IMAGELENGTH, WinHeight);
148  TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
149  //TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
150  TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
151  TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
152  TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
153  }
154  char * data = (char *) calloc(WinWidth * WinHeight*4,sizeof(char));
155  // pixel = (GLubyte *)realloc(pixel,3*width*height*sizeof(*pixel));
156  // glPixelStorei(GL_UNPACK_ALIGNMENT,1);
157  // glRasterPos3i(0,0,0);
158  // //glutUseLayer(GLUT_NORMAL);
159  // glReadPixels(-1,-1,width,height,GL_RGBA,GL_UNSIGNED_BYTE,pixel);
160  // glReadBuffer(GL_BACK);
161  // //glPixelStorei(GL_PACK_ALIGNMENT, 1);
162  glReadPixels(0, 0, WinWidth, WinHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
163  char * MonaSoMare = (char *) calloc(WinWidth * WinHeight*4,sizeof(char));
164  for(int l=0;l<4;l++)
165  for(int w = 0;w<WinWidth;w++)
166  for(int h=0;h<WinHeight;h++)
167  MonaSoMare[(h*WinWidth+w)*4+l] = data[( (WinHeight-h)*WinWidth+w)*4 + l];
168  TIFFWriteEncodedStrip(tif, 0,MonaSoMare, WinWidth * WinHeight *4);
169  TIFFClose(tif);
170  free(data);
171  free(MonaSoMare);
172  // //UINT *pixels=new UINT[nWidth * nHeight];
173  //glReadBuffer(GL_BACK_LEFT);
174  // //glReadPixels(0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,image);
175  //GL_COLOR_INDEX, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_RED, GL_GREEN, GL_BLUE,
176  //GL_ALPHA, GL_RGB, GL_RGBA, GL_LUMINANCE, and GL_LUMINANCE_ALPHA.
177  //GL_UNSIGNED_BYTE, GL_BYTE, GL_BITMAP, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, or GL_FLOAT.
178 }
179 #else
180 int Draw::OpenImage(const char *FileName){
181  printf("libtiff not supported\n");
182 }
184  printf("libtiff not supported\n");
185 }
187  printf("libtiff not supported\n");
188 }
189 #endif //USE_TIFF
190 #ifdef USE_PNG
191 #include <png.h>
192 #include <pngwriter.h>
194  char cImage[160];
195  sprintf(cImage,"Image%05u.png",Step);
196  pngwriter Image(ImWidth,ImHeight,1.0,cImage);
197  double Norm = 1./256.;
198  for(int w = 0;w<ImWidth;w++)
199  for(int h=0;h<ImHeight;h++){
200  double Color[3];
201  for(int l=0;l<3;l++){
202  Color[l] = Norm*pixel[(h*ImWidth+w)*4+l];
203  }
204  Image.plot(w,h,Color[0],Color[1],Color[2]);
205  }
206  Image.close();
207 }
208 int Draw::WritePng(){
209  Shout("WritePng");
210  int NLevel = 4;
211  png_byte color_type;
212  png_byte bit_depth;
213  png_structp png_ptr;
214  png_infop info_ptr;
215  int number_of_passes;
216  png_byte header[8]; // 8 is the maximum size that can be checked
217  char cImage[160];
218  sprintf(cImage,"Image%05u.png",Step);
219  png_bytep * row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * ImHeight);
220  for (int y=0; y<ImHeight; y++)
221  row_pointers[y] = (png_byte*) malloc(ImWidth);//info_ptr->rowbytes);
222  for (int y=0; y<ImHeight; y++) {
223  png_byte* row = row_pointers[y];
224  for (int x=0; x<ImWidth; x++) {
225  png_byte* ptr = &(row[x*4]);
226  for(int l=0;l<NLevel;l++)
227  ptr[l] = pixel[(y*ImWidth+x)*NLevel+l];
228  }
229  }
230  /* initialize stuff */
231  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
232  SigErr(!png_ptr,"[write_png_file] png_create_write_struct failed");
233  info_ptr = png_create_info_struct(png_ptr);
234  SigErr(!info_ptr,"[write_png_file] png_create_info_struct failed");
235  SigErr(setjmp(png_jmpbuf(png_ptr)),"[read_png_file] Error during init_io");
236  png_set_sig_bytes(png_ptr, 8);
237  // png_read_info(png_ptr, info_ptr);
238  color_type = 6;//info_ptr->color_type;
239  bit_depth = 8;//info_ptr->bit_depth;
240  // number_of_passes = png_set_interlace_handling(png_ptr);
241  //png_read_update_info(png_ptr, info_ptr);
242  FILE *fp = fopen(cImage, "wb");
243  SigErr(!fp,"[write_png_file] File %s could not be opened for writing",cImage);
244  SigErr(setjmp(png_jmpbuf(png_ptr)),"[write_png_file] Error during init_io");
245  /* setup libpng for using standard C fread() function
246  with our FILE pointer */
247  png_init_io(png_ptr, fp);
248  /* convert index color images to RGB images */
249  // if (color_type == PNG_COLOR_TYPE_PALETTE)
250  //png_set_palette_to_rgb (png_ptr);
251  /* convert 1-2-4 bits grayscale images to 8 bits
252  grayscale. */
253 // if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
254 // png_set_gray_1_2_4_to_8 (png_ptr);
255 
256 // if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
257 // png_set_tRNS_to_alpha (png_ptr);
258  /* write header */
259  SigErr(setjmp(png_jmpbuf(png_ptr)),"[write_png_file] Error during writing header");
260  png_set_IHDR(png_ptr, info_ptr, ImWidth, ImHeight,
261  bit_depth, color_type, PNG_INTERLACE_NONE,
262  PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
263  png_write_info(png_ptr, info_ptr);
264  /* write bytes */
265  SigErr(setjmp(png_jmpbuf(png_ptr)),"[write_png_file] Error during writing bytes");
266  png_write_image(png_ptr, row_pointers);
267  /* end write */
268  SigErr(setjmp(png_jmpbuf(png_ptr)),"[write_png_file] Error during end of write");
269  png_write_end(png_ptr, NULL);
270  /* cleanup heap allocation */
271  for (int y=0; y<ImHeight; y++) free(row_pointers[y]);
272  free(row_pointers);
273  fclose(fp);
274  return 0;
275 }
276 #else //USE_PNG
278  printf("Pngwriter not installed\n");
279 }
281  printf("Pngwriter not installed\n");
282 }
283 #endif
284 
286  Shout("ReadScript");
287  FILE *File2Read;
288  if((File2Read = fopen("DrawScript.dr","r"))==0){
289  return ;
290  }
291  glDeleteLists(ScriptList,1);
292  ScriptList = glGenLists(1);
293  glNewList(ScriptList,GL_COMPILE);
294  double Expand[3] = {Edge[0]*InvScaleUn,Edge[1]*InvScaleUn,Edge[2]*InvScaleUn};
295  double *From = (double *)calloc(3,sizeof(double));
296  double *To = (double *)calloc(3,sizeof(double));
297  double *Hue = (double *)calloc(5,sizeof(double));
298  char *cLine = (char *)calloc(265,sizeof(char));
299  for(int k=0;!(fgets(cLine,256,File2Read)==NULL);k++){
300  if(strncmp(cLine,"Line",4)==0){
301  fgets(cLine,256,File2Read);
302  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3,Hue+4);
303  fgets(cLine,256,File2Read);
304  sscanf(cLine,"%lf %lf %lf %lf %lf %lf\n",From,From+1,From+2,To,To+1,To+2);
305  glPushMatrix();
306  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
307  glLineWidth(Hue[4]);
308  glBegin(GL_LINES);
309  glNormal3f(0.,0.,1.);
310  glVertex3d(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
311  glVertex3d(To[0]*Expand[0],To[1]*Expand[1],To[2]*Expand[2]);
312  glEnd();
313  glPopMatrix();
314  }
315  else if(strncmp(cLine,"Curve",4)==0){
316  glPushMatrix();
317  glBegin(GL_LINE_STRIP);
318  fgets(cLine,256,File2Read);
319  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
320  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
321  glNormal3f(0.,0.,1.);
322  while(1==1) {
323  fpos_t FPos;
324  fgetpos(File2Read,&FPos);
325  if(fgets(cLine,256,File2Read)==0) break;
326  if(sscanf(cLine,"%lf %lf %lf\n",From,From+1,From+2)!=3){
327  fsetpos(File2Read,&FPos);
328  break;
329  }
330  glVertex3d(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
331  }
332  glEnd();
333  glPopMatrix();
334  }
335  else if(strncmp(cLine,"Polygon",4)==0){
336  glPushMatrix();
337  glBegin(GL_POLYGON);
338  fgets(cLine,256,File2Read);
339  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
340  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
341  glNormal3f(0.,0.,1.);
342  while(1==1) {
343  fpos_t FPos;
344  fgetpos(File2Read,&FPos);
345  if(fgets(cLine,256,File2Read)==0) break;
346  if(sscanf(cLine,"%lf %lf %lf\n",From,From+1,From+2)!=3){
347  fsetpos(File2Read,&FPos);
348  break;
349  }
350  glVertex3d(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
351  }
352  glEnd();
353  glPopMatrix();
354  }
355  else if(strncmp(cLine,"Arrow",4)==0){
356  fgets(cLine,256,File2Read);
357  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3,Hue+4);
358  fgets(cLine,256,File2Read);
359  sscanf(cLine,"%lf %lf %lf %lf %lf %lf\n",From,From+1,From+2,To,To+1,To+2);
360  glLineWidth(Hue[4]);
361  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
362  glPushMatrix();//Arrow
363  double Dist[3];
364  double Freccia[3] = {Expand[0],0.,0.};
365  double Axis[3];
366  for(int d=0;d<3;d++){
367  Dist[d] = (To[d] - From[d])*Expand[d];
368  }
369  double Length1 = sqrt( QUAD(Dist[0]) + QUAD(Dist[1]) + QUAD(Dist[2]) );
370  double Length2 = sqrt( QUAD(Expand[0]) );
371  for(int d=0;d<3;d++){
372  Axis[d] = .5*(Dist[d]/Length1 + Freccia[d]/Length2);
373  }
374  glTranslated(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
375  glRotatef(180.,Axis[0],Axis[1],Axis[2]);
376  glScaled(Length1/Length2,1.0,1.0);
377  glNormal3f(Dist[0],Dist[1],Dist[2]);
378  glCallList(Arrow);
379  glPopMatrix();//Arrow
380  }
381  else if(strncmp(cLine,"Sphere",6)==0){
382  fgets(cLine,256,File2Read);
383  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
384  fgets(cLine,256,File2Read);
385  sscanf(cLine,"%lf %lf %lf %lf %lf %lf\n",From,From+1,From+2,To,To+1,To+2);
386  glPushMatrix();
387  glTranslated(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
388  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
389  glutSolidSphere(To[0]*Expand[0],(int)To[1],(int)To[2]);
390  glPopMatrix();
391  }
392  else if(strncmp(cLine,"Cylinder",7)==0){
393  fgets(cLine,256,File2Read);
394  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
395  fgets(cLine,256,File2Read);
396  sscanf(cLine,"%lf %lf %lf %lf %lf %lf\n",From,From+1,From+2,To,To+1,To+2);
397  glPushMatrix();
398  glTranslated(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
399  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
400  glutSolidSphere(To[0]*Expand[0],(int)To[1],(int)To[2]);
401  glPopMatrix();
402  }
403  else if(strncmp(cLine,"Text",4)==0){
404  char *String = (char *)calloc(265,sizeof(char));
405  fgets(cLine,256,File2Read);
406  for(int c=0;c<strlen(cLine);c++)
407  String[c] = cLine[c];
408  // sscanf(cLine,"%s\n",String);
409  fgets(cLine,256,File2Read);
410  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
411  fgets(cLine,256,File2Read);
412  sscanf(cLine,"%lf %lf %lf %lf %lf %lf\n",From,From+1,From+2,To,To+1,To+2);
413  glPushMatrix();
414  glNormal3f(0.,0.,-1.);
415  glColor4f(Hue[0],Hue[1],Hue[2],Hue[3]);
416  glRasterPos3f(From[0]*Expand[0],From[1]*Expand[1],From[2]*Expand[2]);
417  for(int i=0;i<strlen(String);i++)
418  glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,String[i]);
419  glCallList(Point);
420  glPopMatrix();
421  free(String);
422  }
423  else if(strncmp(cLine,"Fog",3)==0){
424  GLuint filter;
425  GLuint fogMode[]= { GL_EXP, GL_EXP2, GL_LINEAR };
426  fgets(cLine,256,File2Read);
427  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
428  fgets(cLine,256,File2Read);
429  sscanf(cLine,"%lf %lf %lf %lf %lf %lf\n",From,From+1,From+2,To,To+1,To+2);
430  GLuint fogfilter = From[0] > 2. ? 0 : (int) From[0];
431  GLfloat fogColor[4]= {Hue[0], Hue[1], Hue[2], Hue[3]};
432  glFogi(GL_FOG_MODE, fogMode[fogfilter]);
433  glFogfv(GL_FOG_COLOR, fogColor);
434  glFogf(GL_FOG_DENSITY, From[1]);
435  glHint(GL_FOG_HINT, GL_DONT_CARE);
436  glFogf(GL_FOG_START, From[2]*Expand[2]);
437  glFogf(GL_FOG_END, To[2]*Expand[2]);
438  glEnable(GL_FOG);
439  }
440  else if(strncmp(cLine,"Background",10)==0){
441  fgets(cLine,256,File2Read);
442  sscanf(cLine,"%lf %lf %lf %lf\n",Hue,Hue+1,Hue+2,Hue+3);
443  glClearColor(Hue[0],Hue[1],Hue[2],Hue[3]);
444  }
445  }
446  glEndList();
447  fclose(File2Read);
448  free(From);
449  free(To);
450  free(Hue);
451  free(cLine);
452 }
453 #endif
GLfloat xp
Translation, wheel.
Definition: Draw.h:155
int GridEdge[3]
Number of lines per edge.
Definition: Draw.h:264
double InvScaleUn
Rescale the three orthogonal directions.
Definition: Draw.h:181
void ReadScript()
Reads and draw a script file.
Definition: DrawFile.cpp:285
GLuint Arrow
Refers to the list of a arrow.
Definition: Draw.h:206
GLfloat Rback
Background color.
Definition: Draw.h:155
int WritePngwriter()
Write a png file of the data in pixel (uses libpngwriter)
Definition: DrawFile.cpp:277
int Picture()
Write a tiff file of the data in pixel.
Definition: DrawFile.cpp:183
int WinHeight
Height of the window.
Definition: Draw.h:248
int gr
Puts/removes the grid.
Definition: Draw.h:218
int ImWidth
Width and height of the image.
Definition: Draw.h:153
int la
Puts/removes the box edges.
Definition: Draw.h:216
int OpenImage(const char *FileName)
Open a image to be store in pixel.
Definition: DrawFile.cpp:180
GLuint ScriptList
Refers to the list of the objects called by the script file.
Definition: Draw.h:202
GLfloat xLeg
Position of the legend.
Definition: Draw.h:155
int WritePng()
Write a png file of the data in pixel (not working)
Definition: DrawFile.cpp:280
int Step
Current step for the picture&#39;s name.
Definition: Draw.h:244
GLfloat xa
Angles.
Definition: Draw.h:155
GLfloat xf
Orientation of the light.
Definition: Draw.h:155
GLfloat dxLeg
Width of the legend.
Definition: Draw.h:155
GLfloat xi
Position of the info string.
Definition: Draw.h:155
double Edge[3]
Box size.
Definition: Draw.h:262
int WritePixel()
Boh.
Definition: DrawFile.cpp:186
int WinWidth
Width of the window.
Definition: Draw.h:246
int NLevel
Levels of the images data (usually 4=RGBA)
Definition: Draw.h:256
GLubyte * pixel
Principal image (always allocated)
Definition: Draw.h:270
void ReadConf()
Reads and applies external configurations.
Definition: DrawFile.cpp:6
double GridStep
Finess of the grid.
Definition: Draw.h:183