Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4099 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
May 7, 2005, 2:55:23 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: glmis-refitted

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/glmenu/glmenu_imagescreen.cc

    r3729 r4099  
    2020
    2121#include "stdincl.h"
     22#include "graphics_engine.h"
    2223#include "material.h"
    2324
    2425using namespace std;
    25 
    26 GLMenuImageScreen* GLMenuImageScreen::singletonRef = 0;
    27 
    28 GLMenuImageScreen* GLMenuImageScreen::getInstance()
    29 {
    30   if(!singletonRef)
    31     singletonRef = new GLMenuImageScreen ();
    32   return singletonRef;
    33 }
    34 
    3526/**
    3627   \brief standard constructor
     
    4435}
    4536
    46 
    4737/**
    4838   \brief standard deconstructor
     
    5141GLMenuImageScreen::~GLMenuImageScreen()
    5242{
    53   if (this->backMat)
    54     delete this->backMat;
     43  delete this->backMat;
     44  delete barMat;
    5545}
    5646
     
    6050void GLMenuImageScreen::init ()
    6151{
    62   /*
    63   int w = 680;
    64   int h = 480;
    65 
    66   glViewport(0,0,w,h);
    67  
    68   glMatrixMode(GL_PROJECTION);
    69   glLoadIdentity();
    70   gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f);
    71   glMatrixMode(GL_MODELVIEW);
    72 
    73   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    74   glLoadIdentity();
    75   gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);
    76 
    77   // Bind the texture stored at the zero index of g_Texture[]
    78   //glBindTexture(GL_TEXTURE_2D, g_Texture[0]);
    79   */
    80 
    81  
    8252  // Select Our VU Meter Background Texture
    8353  this->backMat = new Material("load_screen");
    84   this->backMat->setDiffuseMap("pictures/load_screen.jpg");
     54  this->barMat = new Material("bar");
    8555  this->maxValue = 10;
    8656  this->currentValue = 0;
    87 
     57  this->setPosition(0,0);
     58  this->setScale(1,1);
     59  this->setBarPosScale( .55, .7, .3, .15);
    8860  // End of Background image code.
    8961}
    90 
    91 
    92 /**
    93    \brief function to innit screen with all attributes set
    94    \param name of the background-image file
    95    \param height of the ImageScreen
    96    \param width of the Image Screen
    97    \param x offset from (0, 0)
    98    \param y offset from (0, 0)
    99 
    100    GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height,
    101    right axis is right direction (=width)
    102 */
    103 void GLMenuImageScreen::init (char* backImageName, float height, float width,
    104                               float offsetX, float offsetY)
    105 {}
    106 
    107 
    108 /**
    109    \brief draws the ImageScreen to the screenbuffer
    110 */
    111 void GLMenuImageScreen::draw ()
    112 {
    113 
    114   glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    115 
    116   PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n",
    117          this->currentValue, this->maxValue);
    118 
    119   /* screen size */
    120   int screenWidth = 640;
    121   int screenHeight = 480;
    122  
    123   /* set image size */
    124   int imageWidth = 640;
    125   int imageHeight = 480;
    126  
    127   /* start pos of image */
    128   int offsetX = (screenWidth - imageWidth)/2;
    129   int offsetY = (screenHeight - imageHeight)/2;
    130  
    131   /* loadbar pos */
    132   int barX = 390;
    133   int barY = 50;
    134   int barWidth = 230;
    135   int barHeight = 30;
    136  
    137   float val = ((float)this->currentValue/(float)this->maxValue) * barWidth;
    138   if( val > (float)barWidth)
    139     val = (float)barWidth;
    140 
    141   glMatrixMode(GL_PROJECTION);
    142   glPushMatrix();
    143   glLoadIdentity();
    144   /* set up an ortho screen */
    145   glOrtho(0, screenWidth, 0, screenHeight, -1, 1);
    146   glMatrixMode(GL_MODELVIEW);
    147   glLoadIdentity();
    148   glPushMatrix();
    149 
    150   glEnable(GL_BLEND);
    151   glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT);
    152   glDisable(GL_LIGHTING);
    153 
    154   /* draw the progress bar */
    155   glBegin(GL_QUADS);
    156   glColor3f(0.96, 0.84, 0.34);
    157   glVertex2i(barX, barY);
    158   glVertex2i(barX + (int)val, barY);
    159   glVertex2i(barX + (int)val, barY + barHeight);
    160   glVertex2i(barX, barY + barHeight);
    161   glColor3f(1.0, 1.0, 1.0);
    162   glEnd();
    163 
    164   glBegin(GL_QUADS);
    165   glColor3f(0.0, 0.0, 0.0);
    166   glVertex2i(barX, barY);
    167   glVertex2i(barX + barWidth, barY);
    168   glVertex2i(barX + barWidth, barY + barHeight);
    169   glVertex2i(barX, barY + barHeight);
    170   glColor3f(1.0, 1.0, 1.0);
    171   glEnd();
    172 
    173   /* draw black border */
    174   glBegin(GL_QUADS);
    175   glColor3f(0.0, 0.0, 0.0);
    176   glVertex2i(barX-1, barY-1);
    177   glVertex2i(barX + barWidth +1, barY-1);
    178   glVertex2i(barX + barWidth+1, barY + barHeight+1);
    179   glVertex2i(barX - 1, barY + barHeight +1);
    180   glColor3f(1.0, 1.0, 1.0);
    181   glEnd();
    182 
    183   /* draw white border */
    184   glBegin(GL_QUADS);
    185   glColor3f(1.0, 1.0, 1.0);
    186   glVertex2i(barX-2, barY-2);
    187   glVertex2i(barX + barWidth +2, barY-2);
    188   glVertex2i(barX + barWidth+2, barY + barHeight+2);
    189   glVertex2i(barX - 2, barY + barHeight +2);
    190   glColor3f(1.0, 1.0, 1.0);
    191   glEnd();
    192 
    193   backMat->select();
    194   glBegin(GL_QUADS);
    195   glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY);
    196   glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY);
    197   glTexCoord2i(1, 1); glVertex2i(offsetX + imageWidth, offsetY + imageHeight);
    198   glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY + imageHeight);
    199   glEnd();
    200   glDisable(GL_TEXTURE_2D);
    201 
    202   glDisable(GL_BLEND);
    203   glPopMatrix();
    204   glMatrixMode(GL_PROJECTION);
    205   glPopMatrix();
    206   glPopAttrib();
    207 
    208   SDL_GL_SwapBuffers();             
    209 }
    210  
    21162
    21263/**
     
    21465    \param file name of the backgroun-image
    21566 */
    216 void GLMenuImageScreen::setBackImageName (char* backImageName)
    217 {}
     67void GLMenuImageScreen::setBackgroundImage (const char* backImageName)
     68{
     69  this->backMat->setDiffuseMap(backImageName);
     70}
    21871
    21972
    22073/**
    22174   \brief sets position of the ImageScreen
    222    \param x offset from (0, 0)
    223    \param y offset from (0, 0)
     75   \param x offset from the top left corner in percent(0-1) of the screensize
     76   \param y offset from the top left corner in percent(0-1) of the screensize
    22477*/
    22578void GLMenuImageScreen::setPosition(float offsetX, float offsetY)
    226 {}
     79{
     80  this->offsetX = offsetX;
     81  this->offsetY = offsetY;
     82}
    22783
    22884
    22985/*
    23086  \brief sets size of the ImageScreen
    231   \param height of the ImageScreen
    232   \param width of the Image Screen
    233 */
    234 void GLMenuImageScreen::setSize(float height, float width)
    235 {}
     87  \param scaleX the scaleing of the image into the x-direction (in percent (0-1))
     88  \param scaleY the scaleing of the image into the y-direction (in percent (0-1))
     89*/
     90void GLMenuImageScreen::setScale(float scaleX, float scaleY)
     91{
     92  this->scaleX = scaleX;
     93  this->scaleY = scaleY;
     94}
     95
     96/**
     97   \param barImage An image for the Bar
     98*/
     99void GLMenuImageScreen::setBarImage(const char* barImage)
     100{
     101  this->barMat->setDiffuseMap(barImage);
     102}
     103
     104/**
     105   \brief sets the Position and the Size of the bar
     106   \param barX The Position in the x-direction in percent of the screen (0-1)
     107   \param barY The Position in the y-direction in percent of the screen (0-1)
     108   \param barW The Size in the x-direction in percent of the screen (0-1)
     109   \param barH The Size in the y-direction in percent of the screen (0-1)
     110*/
     111void GLMenuImageScreen::setBarPosScale(float barX, float barY, float barW, float barH)
     112{
     113  this->barX = barX;
     114  this->barY = barY;
     115  this->barW = barW;
     116  this->barH = barH;
     117}
    236118
    237119
     
    285167  this->draw();
    286168}
     169
     170
     171
     172/**
     173   \brief draws the ImageScreen to the screenbuffer
     174*/
     175void GLMenuImageScreen::draw ()
     176{
     177  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     178
     179  PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n",
     180         this->currentValue, this->maxValue);
     181
     182  /* screen size */
     183  int screenWidth = GraphicsEngine::getInstance()->getResolutionX();
     184  int screenHeight = GraphicsEngine::getInstance()->getResolutionY();
     185 
     186  int imageWidth = (int)(screenWidth * this->scaleX);
     187  int imageHeight = (int)(screenHeight * this->scaleY);
     188
     189  int offsetX = (int)(this->offsetX * screenWidth);
     190  int offsetY = (int)(this->offsetY * screenHeight);
     191
     192  /* loadbar pos */
     193  int barX = (int)(this->barX *screenWidth);
     194  int barY = (int)(this->barY *screenHeight);
     195  int barW = (int)(this->barW *screenWidth);
     196  int barH = (int)(this->barH *screenHeight);
     197 
     198  int val = (int)(((float)this->currentValue/(float)this->maxValue)
     199                  * this->barW * (float)screenWidth);
     200  if( val > barW)
     201    val = barW;
     202
     203  printf(":::::::::::::::::::::%d %d %d %d %d\n", screenHeight, barY, barW, barH, val);
     204
     205  GraphicsEngine::enter2DMode();
     206
     207  /* draw the BackGround */
     208  backMat->select();
     209  glBegin(GL_TRIANGLE_STRIP);
     210  glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY + imageHeight);
     211  glTexCoord2i(1, 0); glVertex2i(offsetX +imageWidth, offsetY + imageHeight);
     212  glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY);
     213  glTexCoord2i(1, 1); glVertex2i(offsetX + imageWidth, offsetY);
     214  glEnd();
     215 
     216 
     217  /* draw the progress bar */
     218  barMat->select();
     219  glBegin(GL_TRIANGLE_STRIP);
     220  glColor3f(0.96, 0.84, 0.34);
     221  glTexCoord2i(0, 0); glVertex2i(barX, barY + barH);
     222  glTexCoord2i(1, 0); glVertex2i(barX + val, barY + barH);
     223  glTexCoord2i(0, 1); glVertex2i(barX, barY);
     224  glTexCoord2i(1, 1); glVertex2i(barX + val, barY);
     225  glEnd();
     226
     227  /*
     228    glBegin(GL_QUADS);
     229    glColor3f(0.0, 0.0, 0.0);
     230    glVertex2i(barX, barY);
     231    glVertex2i(barX + barWidth, barY);
     232    glVertex2i(barX + barWidth, barY + barHeight);
     233    glVertex2i(barX, barY + barHeight);
     234    glColor3f(1.0, 1.0, 1.0);
     235    glEnd();
     236   
     237    /* draw black border
     238    glBegin(GL_QUADS);
     239    glColor3f(0.0, 0.0, 0.0);
     240    glVertex2i(barX-1, barY-1);
     241    glVertex2i(barX + barWidth +1, barY-1);
     242    glVertex2i(barX + barWidth+1, barY + barHeight+1);
     243    glVertex2i(barX - 1, barY + barHeight +1);
     244    glColor3f(1.0, 1.0, 1.0);
     245    glEnd();
     246   
     247    /* draw white border /
     248    glBegin(GL_QUADS);
     249    glColor3f(1.0, 1.0, 1.0);
     250    glVertex2i(barX-2, barY-2);
     251    glVertex2i(barX + barWidth +2, barY-2);
     252    glVertex2i(barX + barWidth+2, barY + barHeight+2);
     253    glVertex2i(barX - 2, barY + barHeight +2);
     254    glColor3f(1.0, 1.0, 1.0);
     255    glEnd();
     256  */
     257
     258  GraphicsEngine::leave2DMode();
     259
     260  SDL_GL_SwapBuffers();             
     261}
     262 
     263
  • orxonox/trunk/src/glmenu/glmenu_imagescreen.h

    r3675 r4099  
    1515
    1616 private:
    17   GLMenuImageScreen ();
    1817
    1918 public:
     19  GLMenuImageScreen ();
    2020  virtual ~GLMenuImageScreen ();
    21  
    22   static GLMenuImageScreen* getInstance();
    23 
    24   static GLMenuImageScreen* singletonRef;
    2521
    2622  void init ();
    27   void init (char* backImageName, float height, float width,
    28              float offsetX, float offsetY);
    2923
    3024  void draw ();
    3125 
    32   void setBackImageName (char* backImageName);
    33   void setPosition (float offsetX, float offsetY);
    34   void setSize (float height, float width);
    35  
     26  void setBackgroundImage(const char* backImageName);
     27  void setPosition(float offsetX, float offsetY);
     28  void setScale (float scaleX, float scaleY);
     29
     30  void setBarImage(const char* barImage);
     31  void setBarPosScale(float barX, float barY, float barW, float barH);
     32
    3633  void setMaximum (int maxValue);
    3734  int getMaximum ();
     
    4239 private:
    4340  char* backImageName;       //!< the name of the file of the background image
    44   float height, width;       //!< hight and width of the image
     41  float scaleX, scaleY;      //!< hight and width of the image
    4542  float offsetX, offsetY;    //!< offset of the image from left and up
    4643  Material* backMat;         //!< Background Material.
     44  float barX, barY, barW, barH; //!< Position and Scale of the bar.
     45  Material* barMat;          //!< A Material for the Loading-Bar
    4746
    4847  /* progress bar values */
  • orxonox/trunk/src/story_entities/world.cc

    r4094 r4099  
    343343          if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) sky = (SkyBox*) created;
    344344          element = element->NextSiblingElement();
     345          glmis->step(); //! \todo temporary
    345346        }
    346347      PRINTF0("Done loading WorldEntities\n");
     
    826827 
    827828  //GLMenuImageScreen*
    828   this->glmis = GLMenuImageScreen::getInstance();
     829  this->glmis = new GLMenuImageScreen();
    829830  this->glmis->init();
     831  glmis->setBackgroundImage("pictures/load_screen.jpg");
    830832  this->glmis->setMaximum(8);
    831833  this->glmis->draw();
     
    843845  PRINTF(3)("World::releaseLoadScreen - start\n");
    844846  this->glmis->setValue(this->glmis->getMaximum());
    845   //SDL_Delay(500);
    846847  PRINTF(3)("World::releaseLoadScreen - end\n");
     848  delete this->glmis;
    847849}
    848850
Note: See TracChangeset for help on using the changeset viewer.