Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3206 in orxonox.OLD


Ignore:
Timestamp:
Dec 17, 2004, 8:08:12 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new PRINTF() implemented in Material and Array

Location:
orxonox/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/debug.h

    r3205 r3206  
    99#define PRINTF1 \
    1010    if (verbose >= 1 ) \
    11      printf ("%s:%d:", __FILE__, __LINE__); \
    12      if (verbose >= 1) printf
     11        printf
    1312#else
    14 #define PRINTF1
     13#define PRINTF1 //
    1514#endif
    1615     
     
    1817#define PRINTF2 \
    1918     if (verbose >= 2 ) \
    20      printf ("%s:%d:", __FILE__, __LINE__); \
    21      if (verbose >= 2) printf
     19          printf
     20        
    2221#else
    23 #define PRINTF2
     22#define PRINTF2 //
    2423#endif
    2524     
     
    2726#define PRINTF3 \
    2827     if (verbose >= 3 ) \
    29      printf ("%s:%d:", __FILE__, __LINE__); \
    30      if (verbose >= 3) printf
     28        printf
    3129#else
    32 #define PRINTF3
     30#define PRINTF3 //
    3331#endif
    3432     
     
    3634#define PRINTF4 \
    3735     if (verbose >= 4 ) \
    38      printf ("%s:%d:", __FILE__, __LINE__); \
    39      if (verbose >= 4) printf
     36         printf
    4037#else
    41 #define PRINTF4
     38#define PRINTF4 //
    4239#endif
    4340     
    4441     
    4542#else 
    46 #define PRINTF(x)
     43#define PRINTF(x) //
    4744#endif
    4845
     46#define PRINTF0 \
     47    printf
    4948
    5049#endif /* _DEBUG_H */
  • orxonox/trunk/src/importer/array.cc

    r3195 r3206  
    3030Array::~Array()
    3131{
    32   if (verbose >= 2)
    33     printf("deleting array\n");
     32  PRINTF(2)("deleting array\n");
    3433  Entry* walker = this->firstEntry;
    3534  Entry* previous;
     
    5049void Array::initializeArray ()
    5150{
    52   if (verbose >= 2)
    53     printf ("crating new Array\n");
     51  PRINTF(2)("crating new Array\n");
    5452  this->firstEntry = new Entry;
    5553  this->firstEntry->next =NULL;
     
    6664void Array::finalizeArray (void)
    6765{
    68   if (verbose >= 3)
    69     printf ("Finalizing array. Length: %i\n", entryCount); 
     66  PRINTF(3)("Finalizing array. Length: %i\n", entryCount); 
    7067  //  if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
    71   if ((this->array = new GLfloat [this->entryCount]) == NULL)
    72     printf ("could not allocate %i data Blocks\n", this->entryCount);
     68  if (!(this->array = new GLfloat [this->entryCount]))
     69    PRINTF(1)("could not allocate %i data Blocks\n", this->entryCount);
    7370  Entry* walker = this->firstEntry;
    7471  for (int i=0; i<this->entryCount; i++)
     
    9087  if (!this->finalized)
    9188    {
    92       if (verbose >= 3)
    93         printf ("adding new Entry to Array: %f\n", entry);
     89      PRINTF(3)("adding new Entry to Array: %f\n", entry);
    9490     
    9591      this->currentEntry->value = entry;
     
    10096    }
    10197  else
    102     if (verbose >= 1)
    103       printf ("adding failed, because list has been finalized\n");
     98    PRINTF(1)("adding failed, because list has been finalized\n");
    10499}
    105100
     
    136131void Array::debug ()
    137132{
    138   printf ("entryCount=%i, address=%p\n", this->entryCount, this->array);
     133  PRINTF(0)("entryCount=%i, address=%p\n", this->entryCount, this->array);
    139134}
  • orxonox/trunk/src/importer/framework.cc

    r3205 r3206  
    6363  {
    6464    // If an error is found, display a message, kill the GL and SDL screens (if they were created) and exit
    65     printf("Could not initalize OpenGL :(\n\n");
     65    PRINTF(1)("Could not initalize OpenGL :(\n\n");
    6666    wHandler.KillGLWindow();
    6767    return 0;
    6868  }
    6969 
    70   printf ("%i, %i\n", wHandler.screen->w, wHandler.screen->h);
     70  PRINTF(2)("screensize: %i, %i\n", wHandler.screen->w, wHandler.screen->h);
    7171  if (argc>=3)
    7272    obj = new Object (argv[1], atof(argv[2]));
     
    125125      switch (event.type) {
    126126      case SDL_MOUSEMOTION:
    127         if (verbose >=3)
    128           printf("Mouse motion about %d,%d Pixels to (%d,%d).\n",
    129                  event.motion.xrel, event.motion.yrel,
    130                  event.motion.x, event.motion.y);
     127        PRINTF(3)("Mouse motion about %d,%d Pixels to (%d,%d).\n",
     128                  event.motion.xrel, event.motion.yrel,
     129                  event.motion.x, event.motion.y);
    131130        // TRACKBALL
    132131        if (mouse1Down)
  • orxonox/trunk/src/importer/material.cc

    r3195 r3206  
    7777  if (pName[0] == '\0')
    7878    {
    79       if (verbose >=3)
    80         printf("not Adding empty Path to the List.\n");
     79      PRINTF(3)("not Adding empty Path to the List.\n");
    8180      return;
    8281    }
     
    9190      if (status.st_mode & S_IFDIR)
    9291        {
    93           if (verbose >=2)
    94             printf ("Adding Path %s to the PathList.\n", pName);
     92          PRINTF(2)("Adding Path %s to the PathList.\n", pName);
    9593          PathList* tmpPathList = this;
    9694          while (tmpPathList->next)
     
    9997        }
    10098      else
    101         if (verbose >=1)
    102           printf ("You tried to add non-folder %s to a PathList.\n", tmpPName);
     99        PRINTF(2)("You tried to add non-folder %s to a PathList.\n", tmpPName);
    103100    }
    104101  else
    105     if (verbose >=1)
    106       printf ("You tried to add non-existing folder %s to a PathList.\n", tmpPName);
     102      PRINTF(2)("You tried to add non-existing folder %s to a PathList.\n", tmpPName);
    107103  delete []tmpPName;
    108104}
     
    135131Material::~Material()
    136132{
    137   if (verbose >= 2)
    138     printf ("delete Material %s.\n", this->name);
     133  PRINTF(2)("delete Material %s.\n", this->name);
    139134  if (this->name)
    140135    delete []this->name;
     
    152147Material* Material::addMaterial(char* mtlName)
    153148{
    154   if (verbose >=2)
    155     printf ("adding Material %s.\n", mtlName);
     149  PRINTF(2)("adding Material %s.\n", mtlName);
    156150   Material* tmpMat = this;
    157151  while (tmpMat->nextMat != NULL)
     
    169163void Material::init(void)
    170164{
    171   if (verbose >= 3)
    172     printf ("initializing new Material.\n");
     165  PRINTF(2)("initializing new Material.\n");
    173166  this->nextMat = NULL;
    174167  this->name ="";
     
    200193Material* Material::search (char* mtlName)
    201194{
    202   if (verbose >=3)
    203     printf ("Searching for material %s", mtlName);
     195  PRINTF(2)("Searching for material %s", mtlName);
    204196  Material* searcher = this;
    205197  while (searcher != NULL)
    206198    {
    207       if (verbose >= 3)
    208         printf (".");
     199      PRINTF(2)(".");
    209200      if (!strcmp (searcher->getName(), mtlName))
    210201        {
    211           if (verbose >= 3)
    212             printf ("found.\n");
     202          PRINTF(2)("found.\n");
    213203          return searcher;
    214204        }
    215205      searcher = searcher->nextMat;
    216206    }
    217   if (verbose >=3)
    218     printf ("not found\n");
     207  PRINTF(2)("not found\n");
    219208  return NULL;
    220209}
     
    258247void Material::setName (char* mtlName)
    259248{
     249  PRINTF(3)("setting Material Name to %s.\n", this->name);
    260250  this->name = new char [strlen(mtlName)+1];
    261251  strcpy(this->name, mtlName);
    262   if (verbose >= 3)
    263     printf("setting Material Name to %s.\n", this->name);
    264 
    265   //  printf ("adding new Material: %s, %p\n", this->getName(), this);
    266 
    267 }
     252}
     253
    268254/**
    269255   \returns The Name of The Material
     
    280266void Material::setIllum (int illum)
    281267{
    282   if (verbose >= 3)
    283     printf("setting illumModel of Material %s to %i\n", this->name, illum);
     268  PRINTF(3)("setting illumModel of Material %s to %i\n", this->name, illum);
    284269  this->illumModel = illum;
    285270  //  printf ("setting illumModel to: %i\n", illumModel);
     
    301286void Material::setDiffuse (float r, float g, float b)
    302287{
    303   if (verbose >= 3)
    304     printf ("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
     288  PRINTF(3)("setting Diffuse Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
    305289  this->diffuse[0] = r;
    306290  this->diffuse[1] = g;
     
    328312void Material::setAmbient (float r, float g, float b)
    329313{
    330   if (verbose >=3)
    331     printf ("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
     314  PRINTF(3)("setting Ambient Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
    332315  this->ambient[0] = r;
    333316  this->ambient[1] = g;
     
    354337void Material::setSpecular (float r, float g, float b)
    355338{
    356   if (verbose >= 3)
    357     printf ("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
     339  PRINTF(3)("setting Specular Color of Material %s to r=%f g=%f b=%f.\n", this->name, r, g, b);
    358340  this->specular[0] = r;
    359341  this->specular[1] = g;
     
    395377void Material::setTransparency (float trans)
    396378{
    397   if (verbose >= 3)
    398     printf ("setting Transparency of Material %s to %f.\n", this->name, trans);
     379  PRINTF(3)("setting Transparency of Material %s to %f.\n", this->name, trans);
    399380  this->transparency = trans;
    400381}
     
    439420        }
    440421      strcat(tmpName, texName);
    441       printf("%s\n", tmpName);
    442422      if (access (tmpName, F_OK) == 0)
    443423        return tmpName;
     
    460440void Material::setDiffuseMap(char* dMap)
    461441{
    462   if (verbose>=2)
    463     printf ("setting Diffuse Map %s\n", dMap);
     442  PRINTF(3)("setting Diffuse Map %s\n", dMap);
    464443
    465444  //  diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
     
    507486bool Material::loadTexToGL (Image* pImage, GLuint* texture)
    508487{
    509   if (verbose >=3)
    510     printf ("Loading texture to OpenGL-Environment.\n");
     488  PRINTF(2)("Loading texture to OpenGL-Environment.\n");
    511489  glGenTextures(1, texture);
    512490  glBindTexture(GL_TEXTURE_2D, *texture);
     
    534512      if(!map)
    535513        {
    536           printf("IMG_Load: %s\n", IMG_GetError());
     514          PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
    537515          return false;
    538516        }
     
    551529  else
    552530    {
    553       if (verbose >=1)
    554         printf ("Image not Found: %s\n", imgNameWithPath);
     531      PRINTF(1)("Image not Found: %s\n", imgNameWithPath);
    555532      return false;
    556533    }
     
    571548      if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".bmp", 4))
    572549        {
    573           if (verbose >=2)
    574             printf ("Requested bmp-image. Trying to Import.\n");
     550          PRINTF(3)("Requested bmp-image. Trying to Import.\n");
    575551          return this->loadBMP(imgNameWithPath, texture);
    576552        }
     
    578554      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".jpg", 4) || !strncmp(imgNameWithPath+strlen(imgNameWithPath)-5, ".jpg", 5))
    579555        {
    580           if (verbose >=2)
    581             printf ("Requested jpeg-image. Trying to Import\n");
     556          PRINTF(3)("Requested jpeg-image. Trying to Import\n");
    582557          return this->loadJPG(imgNameWithPath, texture);
    583558        }
    584559      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".tga", 4))
    585560        {
    586           if (verbose >=2)
    587             printf ("Requested tga-image. Trying to Import\n");
     561          PRINTF(3)("Requested tga-image. Trying to Import\n");
    588562          return this->loadTGA(imgNameWithPath, texture);
    589563        }
    590564      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".png", 4))
    591565        {
    592           if (verbose >=2)
    593             printf ("Requested png-image. Trying to Import\n");
     566          PRINTF(3)("Requested png-image. Trying to Import\n");
    594567          return this->loadPNG(imgNameWithPath, texture);
    595568        }
    596569      else
    597570        {
    598           if (verbose >=1)
    599             printf ("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imgNameWithPath);
     571          PRINTF(1)("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imgNameWithPath);
    600572          return false;
    601573        }
     
    603575  else
    604576    {
    605       if (verbose >=1)
    606         printf ("Image not Found: %s\n", imgNameWithPath);
     577      PRINTF(1)("Image not Found: %s\n", imgNameWithPath);
    607578      return false;
    608579    }
     
    627598  if ((file = fopen(bmpName, "rb"))==NULL)
    628599    {
    629       if (verbose >=1)
    630         printf("File Not Found : %s\n",bmpName);
     600      PRINTF(1)("File Not Found : %s\n",bmpName);
    631601      return false;
    632602    }
     
    637607  if ((i = fread(&pImage->width, 4, 1, file)) != 1)
    638608    {
    639       if (verbose >=1)
    640         printf("Error reading width from %s.\n", bmpName);
     609      PRINTF(1)("Error reading width from %s.\n", bmpName);
    641610      return false;
    642611    }
     
    644613  if ((i = fread(&pImage->height, 4, 1, file)) != 1)
    645614    {
    646       if (verbose>=1)
    647         printf("Error reading height from %s.\n", bmpName);
     615      PRINTF(1)("Error reading height from %s.\n", bmpName);
    648616      return false;
    649617    }
     
    655623  if ((fread(&planes, 2, 1, file)) != 1)
    656624    {
    657       if (verbose>=1)
    658         printf("Error reading planes from %s.\n", bmpName);
     625      PRINTF(1)("Error reading planes from %s.\n", bmpName);
    659626      return false;
    660627    }
    661628  if (planes != 1)
    662629    {
    663       if (verbose>=1)
    664         printf("Planes from %s is not 1: %u\n", bmpName, planes);
     630      PRINTF(1)("Planes from %s is not 1: %u\n", bmpName, planes);
    665631      return false;
    666632    }
     
    669635  if ((i = fread(&bpp, 2, 1, file)) != 1)
    670636    {
    671       if (verbose>=1)
    672         printf("Error reading bpp from %s.\n", bmpName);
     637      PRINTF(1)("Error reading bpp from %s.\n", bmpName);
    673638      return false;
    674639    }
    675640  if (bpp != 24)
    676641    {
    677       if (verbose>=1)
    678         printf("Bpp from %s is not 24: %u\n", bmpName, bpp);
     642      PRINTF(1)("Bpp from %s is not 24: %u\n", bmpName, bpp);
    679643      return false;
    680644    }
     
    687651  if (pImage->data == NULL)
    688652    {
    689       if (verbose>=1)
    690         printf("Error allocating memory for color-corrected image data");
     653      PRINTF(1)("Error allocating memory for color-corrected image data");
    691654      return false;     
    692655    }
     
    694657  if ((i = fread(pImage->data, size, 1, file)) != 1)
    695658    {
    696       if (verbose>=1)
    697         printf("Error reading image data from %s.\n", bmpName);
     659      PRINTF(1)("Error reading image data from %s.\n", bmpName);
    698660      return false;
    699661    }
     
    739701    {
    740702      // Display an error message saying the file was not found, then return NULL
    741       printf("Unable to load JPG File %s.\n", jpgName);
     703      PRINTF(1)("Unable to load JPG File %s.\n", jpgName);
    742704      return false;
    743705    }
     
    817779  return true;
    818780#else /* HAVE_JPEGLIB_H */
    819   if (verbose >=1)
    820     printf ("sorry, but you did not compile with jpeg-support.\nEither install SDL_image or jpeglib, and recompile to see the image\n");
     781  PRINTF(1)("sorry, but you did not compile with jpeg-support.\nEither install SDL_image or jpeglib, and recompile to see the image\n");
    821782  return false;
    822783#endif /* HAVE_JPEGLIB_H */
     
    844805  if(fTGA == NULL)
    845806    {
    846       printf("Error could not open texture file: %s\n", tgaName);
     807      PRINTF(1)("Error could not open texture file: %s\n", tgaName);
    847808      return false;
    848809    }
     
    850811  if(fread(&tgaHeader, sizeof(TGAHeader), 1, fTGA) == 0)
    851812    {
    852       printf("Error could not read file header of %s\n", tgaName);
     813      PRINTF(1)("Error could not read file header of %s\n", tgaName);
    853814      if(fTGA != NULL)
    854815        {
     
    872833  else
    873834    {
    874       printf("Error TGA file be type 2 or type 10\n");
     835      PRINTF(1)("Error TGA file be type 2 or type 10\n");
    875836      if (fTGA)
    876837        fclose(fTGA);
     
    901862  if(fread(header, sizeof(header), 1, fTGA) == 0)
    902863    {
    903       printf("Error could not read info header\n");
     864      PRINTF(1)("Error could not read info header\n");
    904865      return false;
    905866    }
     
    911872  if((pImage->width <= 0) || (pImage->height <= 0) || ((pImage->bpp != 24) && (pImage->bpp !=32)))
    912873    {
    913       printf("Error invalid texture information\n");
     874      PRINTF(1)("Error invalid texture information\n");
    914875      return false;
    915876    }
     
    930891  if(pImage->data == NULL)
    931892    {
    932       printf("Error could not allocate memory for image\n");
     893      PRINTF(1)("Error could not allocate memory for image\n");
    933894      return false;
    934895    }
     
    936897  if(fread(pImage->data, 1, imageSize, fTGA) != imageSize)
    937898    {
    938       printf("Error could not read image data\n");
     899      PRINTF(1)("Error could not read image data\n");
    939900      if(pImage->data != NULL)
    940901        {
     
    977938  if(fread(header, sizeof(header), 1, fTGA) == 0)
    978939    {
    979       printf("Error could not read info header\n");
     940      PRINTF(1)("Error could not read info header\n");
    980941      return false;
    981942    }
     
    993954  if((pImage->width <= 0) || (pImage->height <= 0) || ((pImage->bpp != 24) && (pImage->bpp !=32)))
    994955    {
    995       printf("Error Invalid pImage information\n");
     956      PRINTF(1)("Error Invalid pImage information\n");
    996957      return false;
    997958    }
     
    1003964  if(pImage->data == NULL)
    1004965    {
    1005       printf("Error could not allocate memory for image\n");
     966      PRINTF(1)("Error could not allocate memory for image\n");
    1006967      return false;
    1007968    }
     
    1013974      if(fread(&chunkheader, sizeof(GLubyte), 1, fTGA) == 0)
    1014975        {
    1015           printf("Error could not read RLE header\n");
     976          PRINTF(1)("Error could not read RLE header\n");
    1016977          if(pImage->data != NULL)
    1017978            {
     
    1031992              if(fread(colorbuffer, 1, bytesPerPixel, fTGA) != bytesPerPixel)
    1032993                {
    1033                   printf("Error could not read image data\n");
     994                  PRINTF(1)("Error could not read image data\n");
    1034995                  if(colorbuffer != NULL)
    1035996                    {
     
    10611022              if(currentpixel > pixelcount)     
    10621023                {
    1063                   printf("Error too many pixels read\n");
     1024                  PRINTF(1)("Error too many pixels read\n");
    10641025                  if(colorbuffer != NULL)
    10651026                    {
     
    10831044          if(fread(colorbuffer, 1, bytesPerPixel, fTGA) != bytesPerPixel) // Attempt to read following color values
    10841045            {
    1085               printf("Error could not read from file");
     1046              PRINTF(1)("Error could not read from file");
    10861047              if(colorbuffer != NULL)
    10871048                {
     
    11141075              if(currentpixel > pixelcount)
    11151076                {
    1116                   printf("Error too many pixels read\n");
     1077                  PRINTF(1)("Error too many pixels read\n");
    11171078                  if(colorbuffer != NULL)
    11181079                    {
     
    11671128  if (png_sig_cmp(PNG_header, 0, 8) != 0)
    11681129    {
    1169       if (verbose >=2)
    1170         printf ("Not Recognized as a pngFile\n");
     1130      PRINTF(2)("Not Recognized as a pngFile\n");
    11711131      fclose (PNG_file);
    11721132      return 0;
     
    12741234  return true;
    12751235#else /* HAVE_PNG_H */
    1276   if (verbose >=1)
    1277     printf ("sorry, but you did not compile with png-support.\nEither install SDL_image or libpng, and recompile to see the image\n");
     1236  PRINTF(1)("sorry, but you did not compile with png-support.\nEither install SDL_image or libpng, and recompile to see the image\n");
    12781237  return false;
    12791238#endif /* HAVE_PNG_H */
  • orxonox/trunk/src/importer/object.cc

    r3196 r3206  
    7474Object::~Object()
    7575{
    76   if (verbose >= 2)
    77     printf ("Deleting display Lists.\n");
     76  PRINTF(2)("Deleting display Lists.\n");
    7877  Group* walker = this->firstGroup;
    7978  while (walker != NULL)
     
    9291    delete []this->mtlFileName;
    9392
    94   if (verbose >=2)
    95     printf("Deleting Materials.\n");
     93  PRINTF(2)("Deleting Materials.\n");
    9694  if (this->material)
    9795    delete this->material;
Note: See TracChangeset for help on using the changeset viewer.