Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3345 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Jan 5, 2005, 6:11:11 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: :loadscreen: now uses texture-class

Location:
orxonox/branches/parenting/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/parenting/src/debug.h

    r3212 r3345  
    33
    44#ifdef  DEBUG
     5extern int verbose;
    56#define PRINTF(x) \
    67           PRINTF ## x
  • orxonox/branches/parenting/src/importer/texture.cc

    r3344 r3345  
    137137  if (this->texture)
    138138    glDeleteTextures(1, &this->texture);
    139 }
    140 
    141 /**
    142    \returns The Texture-identifier number.
    143 */
    144 GLuint Texture::getTexture(void)
    145 {
    146     return this->texture;
    147139}
    148140
  • orxonox/branches/parenting/src/importer/texture.h

    r3344 r3345  
    7272  ~Texture(void);
    7373
    74   GLuint getTexture(void);
     74  inline GLuint getTexture(void) {return this->texture;} //!< \returns The textureID of this texture.
    7575  bool loadTexToGL (Image* pImage);
    7676
  • orxonox/branches/parenting/src/world.cc

    r3342 r3345  
    2727#include "null_parent.h"
    2828#include "helper_parent.h"
    29 
    30 #include <SDL/SDL_image.h>
     29#include "importer/texture.h"
    3130
    3231using namespace std;
     
    156155  glMatrixMode(GL_MODELVIEW);
    157156
    158 
    159   SDL_Surface *pBitmap[1];
    160   unsigned int textureArray[1];
    161   char *strFileName = "orx_tex.bmp";
    162   int textureID = 0;
    163  
    164   pBitmap[0] = SDL_LoadBMP (strFileName);
    165   if( pBitmap[0] == NULL)
    166     return;
    167  
    168   if(pBitmap[0] == NULL)                                // If we can't load the file, quit!
    169     {
    170       printf (" Failed loading %s\n", strFileName);
    171       SDL_Quit ();
    172     }
    173   glGenTextures(1, &textureArray[textureID]);
    174   /* Bind the texture to the texture arrays index and init the texture */
    175   glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);
    176  
    177   /* Rearrange the pixelData since openGL has a different pixel orientation */
    178   int width  = pBitmap[0]->w;
    179   int height = pBitmap[0]->h;
    180   unsigned char * data = (unsigned char *)(pBitmap[0]->pixels);
    181   unsigned char * newData = new unsigned char[width * height * 3];
    182   int channels = 3; /* RGB channel number*/
    183  
    184   int bytesPerPixel = pBitmap[0]->format->BytesPerPixel;
    185  
    186   /* this is the real swapping algorithm */
    187   for( int i = 0 ; i < (height / 2) ; ++i )
    188     for( int j = 0 ; j < width * bytesPerPixel; j += bytesPerPixel )
    189       for(int k = 0; k < bytesPerPixel; ++k)
    190         swap( data[ (i * width * bytesPerPixel) + j + k], data[ ( (height - i - 1) * width * bytesPerPixel ) + j + k]);
    191  
    192   // the following lines extract R,G and B values from any bitmap
    193  
    194   for(int i = 0; i < (width * height); ++i)
    195     {
    196       byte r,g,b;
    197       Uint32 pixel_value = 0;     
    198       /* the following loop extracts the pixel (however wide it is 8,16,24 or 32) and
    199          creates a long with all these bytes taken together.
    200       */
    201      
    202       for(int j = bytesPerPixel - 1 ; j >= 0; --j)
    203         {
    204           pixel_value = pixel_value << 8;
    205           pixel_value = pixel_value | data[ (i * bytesPerPixel) + j ];
    206         }                                                             
    207      
    208       SDL_GetRGB(pixel_value, pBitmap[0]->format, (Uint8 *)&r, (Uint8 *)&g, (Uint8 *)&b);
    209      
    210       newData[(i * channels) + 0] = r;
    211       newData[(i * channels) + 1] = g;
    212       newData[(i * channels) + 2] = b;
    213    
    214       pixel_value = 0;
    215     }
    216  
    217   /* Build Mipmaps (builds different versions of the picture for distances - looks better) */
    218   gluBuild2DMipmaps (GL_TEXTURE_2D, 3, pBitmap[0]->w, pBitmap[0]->h, GL_RGB, GL_UNSIGNED_BYTE, newData);
    219   glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);   
    220   glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    221 
    222   delete [] newData;   
    223   SDL_FreeSurface(pBitmap[0]);
    224 
     157  Texture* loadScreenTexture = new Texture();
     158  loadScreenTexture->loadImage("orx_tex.bmp");
    225159
    226160  /* ------------painten */
     
    268202  SDL_GL_SwapBuffers();                   
    269203
    270   glDisable (GL_TEXTURE_2D);
    271   glDeleteTextures (1, &textureArray[textureID]);
     204  delete loadScreenTexture;
    272205  SDL_Delay (1000);
    273206  printf ("World::displayLoadScreen - end\n");
Note: See TracChangeset for help on using the changeset viewer.