Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3070 in orxonox.OLD for orxonox/trunk/importer/material.cc


Ignore:
Timestamp:
Dec 3, 2004, 8:22:38 PM (21 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: ability to readIn BMP files for the diffuse-color-Texture

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/importer/material.cc

    r3069 r3070  
    8484  setShininess(2.0);
    8585  setTransparency(0.0);
     86
     87  diffuseTextureSet = false;
     88  ambientTextureSet = false;
     89  specularTextureSet = false;
     90
    8691 
    8792}
     
    243248  setTransparency (atof(tr));
    244249}
     250
     251// MAPPING //
     252
     253/**
     254   \brief Sets the Materials Diffuse Map
     255   \param dMap the Name of the Image to Use
     256*/
     257void Material::setDiffuseMap(char* dMap)
     258{
     259  if (verbose>=2)
     260    printf ("setting Diffuse Map %s\n", dMap);
     261
     262  diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
     263
     264}
     265
     266/**
     267   \brief Sets the Materials Ambient Map
     268   \param aMap the Name of the Image to Use
     269*/
     270void Material::setAmbientMap(char* aMap)
     271{
     272  SDL_Surface* ambientMap;
     273
     274}
     275
     276/**
     277   \brief Sets the Materials Specular Map
     278   \param sMap the Name of the Image to Use
     279*/
     280void Material::setSpecularMap(char* sMap)
     281{
     282  SDL_Surface* specularMap;
     283
     284}
     285
     286/**
     287   \brief Sets the Materials Bumpiness
     288   \param bump the Name of the Image to Use
     289*/
     290void Material::setBump(char* bump)
     291{
     292
     293}
     294
     295/**
     296   \brief reads in a Windows BMP-file, and imports it to openGL.
     297   \param bmpName The name of the Image to load.
     298   \param texture A pointer to the Texture which should be read to.
     299*/
     300bool Material::loadBMP (char* bmpName, GLuint* texture)
     301{
     302  SDL_Surface* map;
     303  if (map = SDL_LoadBMP(bmpName))
     304    {
     305
     306      glGenTextures( 1, texture );
     307      /* Typical Texture Generation Using Data From The Bitmap */
     308      glBindTexture( GL_TEXTURE_2D, *texture );
     309     
     310      /* Generate The Texture */
     311      glTexImage2D( GL_TEXTURE_2D, 0, 3, map->w,
     312                    map->h, 0, GL_BGR,
     313                    GL_UNSIGNED_BYTE, map->pixels );
     314     
     315      /* Linear Filtering */
     316      glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
     317      glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
     318      if ( map )
     319        SDL_FreeSurface( map );
     320
     321      return true;
     322    }
     323  else
     324    return false;
     325}
     326
     327
     328
    245329
    246330/**
     
    294378  else if (illumModel >= 2)
    295379    glShadeModel(GL_SMOOTH);
    296 }
     380
     381  if (diffuseTextureSet)
     382    glBindTexture(GL_TEXTURE_2D, diffuseTexture);
     383 
     384}
Note: See TracChangeset for help on using the changeset viewer.