Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3790 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Apr 13, 2005, 12:33:07 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the textEngine back into the trunk.
merged with command:
svn merge -r 3681:HEAD branches/textEngine/ trunk/

conflicts in:
world.cc/h orxonox.cc NEWS
changed in favor of the trunk

Location:
orxonox/trunk/src/lib/graphics
Files:
1 deleted
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r3622 r3790  
    167167
    168168
     169/**
     170   \brief entering 2D Mode
     171   
     172   this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else
     173*/
     174void GraphicsEngine::enter2DMode(void)
     175{
     176  SDL_Surface *screen = SDL_GetVideoSurface();
     177 
     178  /* Note, there may be other things you need to change,
     179     depending on how you have your OpenGL state set up.
     180  */
     181  glPushAttrib(GL_ENABLE_BIT);
     182  glDisable(GL_DEPTH_TEST);
     183  glDisable(GL_CULL_FACE);
     184  glDisable(GL_LIGHTING);  // will be set back when leaving 2D-mode
     185  glEnable(GL_TEXTURE_2D);
     186
     187  /* This allows alpha blending of 2D textures with the scene */
     188  glEnable(GL_BLEND);
     189  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     190 
     191  glViewport(0, 0, screen->w, screen->h);
     192 
     193  glMatrixMode(GL_PROJECTION);
     194  glPushMatrix();
     195  glLoadIdentity();
     196 
     197  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
     198 
     199  glMatrixMode(GL_MODELVIEW);
     200  glPushMatrix();
     201  glLoadIdentity();
     202 
     203  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     204}
     205
     206/**
     207   \brief leaves the 2DMode again also \see Font::enter2DMode(void)
     208*/
     209void GraphicsEngine::leave2DMode(void)
     210{
     211  glMatrixMode(GL_MODELVIEW);
     212  glPopMatrix();
     213 
     214  glMatrixMode(GL_PROJECTION);
     215  glPopMatrix();
     216 
     217  glPopAttrib();
     218}
    169219
    170220
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r3619 r3790  
    2626  int setGLattribs(void);
    2727  int setResolution(int width, int height, int bpp);
     28  /** \returns the x resolution */
     29  inline int getResolutionX(void) {return this->resolutionX;}
     30  /** \returns the y resolution */
     31  inline int getResolutionY(void) {return this->resolutionY;}
     32  /** \returns the Bits Per Pixel */
     33  inline int getbbp(void) {return this->bitsPerPixel;}
    2834  int resolutionChanged(SDL_ResizeEvent* resizeInfo);
    2935  void listModes(void);
    3036
    3137  static bool texturesEnabled;
     38
     39  static void enter2DMode(void);
     40  static void leave2DMode(void);
    3241
    3342 private:
  • orxonox/trunk/src/lib/graphics/importer/material.cc

    r3672 r3790  
    3030using namespace std;
    3131
    32 
    33 /**
    34    \brief creates a default Material with no Name
    35    normally you call this to create a material List (for an obj-file) and then append with addMaterial()
    36 */
    37 Material::Material()
    38 {
    39   this->init();
    40  
    41   this->setName ("");
    42 }
    43 
    4432/**
    4533   \brief creates a Material.
     
    4836Material::Material (char* mtlName)
    4937{
    50   this->init();
    51  
    52   this->setName (mtlName);
     38   PRINTF(4)("initializing new Material.\n");
     39  this->nextMat = NULL;
     40  this->name ="";
     41  this->setIllum(3);
     42  this->setDiffuse(0,0,0);
     43  this->setAmbient(0,0,0);
     44  this->setSpecular(.5,.5,.5);
     45  this->setShininess(2.0);
     46  this->setTransparency(1.0);
     47
     48
     49  this->diffuseTexture = NULL;
     50  this->ambientTexture = NULL;
     51  this->specularTexture = NULL;
     52
     53  this->diffuseTextureSet = false;
     54  this->ambientTextureSet = false;
     55  this->specularTextureSet = false;
     56
     57  if (mtlName)
     58    this->setName (mtlName);
     59  else
     60    this->setName("");
    5361}
    5462
     
    8694
    8795/**
    88    \brief initializes a new Material with its default Values
    89 */
    90 void Material::init(void)
    91 {
    92   PRINTF(4)("initializing new Material.\n");
    93   this->nextMat = NULL;
    94   this->name ="";
    95   this->setIllum(3);
    96   this->setDiffuse(0,0,0);
    97   this->setAmbient(0,0,0);
    98   this->setSpecular(.5,.5,.5);
    99   this->setShininess(2.0);
    100   this->setTransparency(0.0);
    101 
    102 
    103   this->diffuseTexture = NULL;
    104   this->ambientTexture = NULL;
    105   this->specularTexture = NULL;
    106 
    107   this->diffuseTextureSet = false;
    108   this->ambientTextureSet = false;
    109   this->specularTextureSet = false;
    110 }
    111 
    112 /**
    11396   \brief Search for a Material called mtlName
    11497   \param mtlName the Name of the Material to search for
     
    151134  glMaterialf(GL_FRONT, GL_SHININESS, this->shininess);
    152135 
     136  // setting the transparency
     137  if (this->transparency == 1.0)
     138    {
     139      glDisable(GL_BLEND);
     140    }
     141  else
     142    {
     143      glEnable(GL_BLEND);
     144      glColor4f(1.0f, 1.0f, 1.0f, this->transparency);
     145      glBlendFunc(GL_SRC_ALPHA, GL_ONE);
     146    }
     147
    153148  // setting illumination Model
    154149  if (this->illumModel == 1) //! \todo make this work, if no vertex-normals are read.
  • orxonox/trunk/src/lib/graphics/importer/material.h

    r3590 r3790  
    2222{
    2323 public:
    24   Material ();
    25   Material (char* mtlName);
     24  Material (char* mtlName = "");
    2625  Material* addMaterial(char* mtlName);
    2726  ~Material ();
    28   void init(void);
    2927
    3028  Material* search(char* mtlName);
  • orxonox/trunk/src/lib/graphics/importer/texture.cc

    r3660 r3790  
    9898}
    9999
    100 #ifdef HAVE_SDL_SDL_IMAGE_H
     100#ifdef HAVE_SDL_IMAGE_H
    101101bool Texture::loadImage(const char* imageName)
    102102{
     
    118118            pImage->format = GL_RGB;
    119119          else if (pImage->bpp == 4)
    120             pImage->format = GL_RGBA;
    121          
     120            {
     121              pImage->format = GL_RGBA;
     122              SDL_SetAlpha(this->map, 0, 0);
     123            }
     124
    122125          if( !IMG_isPNG(SDL_RWFromFile(imageName, "rb")) && !IMG_isJPG(SDL_RWFromFile(imageName, "rb")))
    123126            for (int i=0;i<map->h * map->w *3;i+=3)
     
    146149
    147150
    148 #else /* HAVE_SDL_SDL_IMAGE_H */
     151#else /* HAVE_SDL_IMAGE_H */
    149152/**
    150153   \brief Makes the Programm ready to Read-in a texture-File
     
    832835
    833836}
    834 #endif /* HAVE_SDL_SDL_IMAGE_H */
     837#endif /* HAVE_SDL_IMAGE_H */
  • orxonox/trunk/src/lib/graphics/importer/texture.h

    r3660 r3790  
    1414#include "debug.h"
    1515
    16 #ifdef HAVE_SDL_SDL_IMAGE_H
    17 #include <SDL/SDL_image.h>
     16#ifdef HAVE_SDL_IMAGE_H
     17#include <SDL_image.h>
    1818#else
    1919// IMAGE LIBS //
     
    2626#include <png.h>
    2727#endif /* HAVE_PNG_H */
    28 #endif /* HAVE_SDL_SDL_IMAGE_H */
     28#endif /* HAVE_SDL_IMAGE_H */
    2929
    3030//! A Class, that reads in Textures from different fileformats.
     
    5757
    5858  bool loadImage(const char* imageName);
    59 #ifndef HAVE_SDL_SDL_IMAGE_H
     59#ifndef HAVE_SDL_IMAGE_H
    6060
    6161  bool loadBMP (char* bmpName);
     
    7474
    7575};
    76 
    77 
    78 
    7976#endif /* _TEXTURE_H */
Note: See TracChangeset for help on using the changeset viewer.