Index: orxonox/trunk/src/glmenu/glmenu_imagescreen.cc
===================================================================
--- orxonox/trunk/src/glmenu/glmenu_imagescreen.cc	(revision 3729)
+++ orxonox/trunk/src/glmenu/glmenu_imagescreen.cc	(revision 4099)
@@ -20,17 +20,8 @@
 
 #include "stdincl.h"
+#include "graphics_engine.h"
 #include "material.h"
 
 using namespace std;
-
-GLMenuImageScreen* GLMenuImageScreen::singletonRef = 0;
-
-GLMenuImageScreen* GLMenuImageScreen::getInstance()
-{
-  if(!singletonRef)
-    singletonRef = new GLMenuImageScreen ();
-  return singletonRef;
-}
-
 /**
    \brief standard constructor
@@ -44,5 +35,4 @@
 }
 
-
 /**
    \brief standard deconstructor
@@ -51,6 +41,6 @@
 GLMenuImageScreen::~GLMenuImageScreen() 
 {
-  if (this->backMat)
-    delete this->backMat;
+  delete this->backMat;
+  delete barMat;
 }
 
@@ -60,153 +50,14 @@
 void GLMenuImageScreen::init ()
 {
-  /*
-  int w = 680;
-  int h = 480;
-
-  glViewport(0,0,w,h);
-  
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity(); 
-  gluPerspective(45.0f,(GLfloat)w/(GLfloat)h, .5f ,150.0f);
-  glMatrixMode(GL_MODELVIEW); 
-
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  glLoadIdentity();
-  gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);
-
-  // Bind the texture stored at the zero index of g_Texture[]
-  //glBindTexture(GL_TEXTURE_2D, g_Texture[0]);
-  */
-
-  
   // Select Our VU Meter Background Texture
   this->backMat = new Material("load_screen");
-  this->backMat->setDiffuseMap("pictures/load_screen.jpg");
+  this->barMat = new Material("bar");
   this->maxValue = 10;
   this->currentValue = 0;
-
+  this->setPosition(0,0);
+  this->setScale(1,1);
+  this->setBarPosScale( .55, .7, .3, .15);
   // End of Background image code.
 }
-
-
-/**
-   \brief function to innit screen with all attributes set
-   \param name of the background-image file
-   \param height of the ImageScreen
-   \param width of the Image Screen
-   \param x offset from (0, 0)
-   \param y offset from (0, 0)
-
-   GLMenu uses its own coordinating system: upper left corner is (0, 0). x-axis is down=height, 
-   right axis is right direction (=width)
-*/
-void GLMenuImageScreen::init (char* backImageName, float height, float width, 
-			      float offsetX, float offsetY)
-{}
-
-
-/**
-   \brief draws the ImageScreen to the screenbuffer
-*/
-void GLMenuImageScreen::draw ()
-{
-
-  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
-
-  PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n", 
-	 this->currentValue, this->maxValue);
-
-  /* screen size */
-  int screenWidth = 640;
-  int screenHeight = 480;
-  
-  /* set image size */
-  int imageWidth = 640;
-  int imageHeight = 480;
-  
-  /* start pos of image */
-  int offsetX = (screenWidth - imageWidth)/2;
-  int offsetY = (screenHeight - imageHeight)/2;
-  
-  /* loadbar pos */
-  int barX = 390;
-  int barY = 50;
-  int barWidth = 230;
-  int barHeight = 30;
-  
-  float val = ((float)this->currentValue/(float)this->maxValue) * barWidth;
-  if( val > (float)barWidth)
-    val = (float)barWidth;
-
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  /* set up an ortho screen */
-  glOrtho(0, screenWidth, 0, screenHeight, -1, 1); 
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-  glPushMatrix();
-
-  glEnable(GL_BLEND);
-  glPushAttrib(GL_LIGHTING_BIT | GL_TRANSFORM_BIT);
-  glDisable(GL_LIGHTING);
-
-  /* draw the progress bar */
-  glBegin(GL_QUADS);
-  glColor3f(0.96, 0.84, 0.34);
-  glVertex2i(barX, barY);
-  glVertex2i(barX + (int)val, barY);
-  glVertex2i(barX + (int)val, barY + barHeight);
-  glVertex2i(barX, barY + barHeight);
-  glColor3f(1.0, 1.0, 1.0);
-  glEnd();
-
-  glBegin(GL_QUADS);
-  glColor3f(0.0, 0.0, 0.0);
-  glVertex2i(barX, barY);
-  glVertex2i(barX + barWidth, barY);
-  glVertex2i(barX + barWidth, barY + barHeight);
-  glVertex2i(barX, barY + barHeight);
-  glColor3f(1.0, 1.0, 1.0);
-  glEnd();
-
-  /* draw black border */
-  glBegin(GL_QUADS);
-  glColor3f(0.0, 0.0, 0.0);
-  glVertex2i(barX-1, barY-1);
-  glVertex2i(barX + barWidth +1, barY-1);
-  glVertex2i(barX + barWidth+1, barY + barHeight+1);
-  glVertex2i(barX - 1, barY + barHeight +1);
-  glColor3f(1.0, 1.0, 1.0);
-  glEnd();
-
-  /* draw white border */
-  glBegin(GL_QUADS);
-  glColor3f(1.0, 1.0, 1.0);
-  glVertex2i(barX-2, barY-2);
-  glVertex2i(barX + barWidth +2, barY-2);
-  glVertex2i(barX + barWidth+2, barY + barHeight+2);
-  glVertex2i(barX - 2, barY + barHeight +2);
-  glColor3f(1.0, 1.0, 1.0);
-  glEnd();
-
-  backMat->select();
-  glBegin(GL_QUADS);
-  glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY);
-  glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY);
-  glTexCoord2i(1, 1); glVertex2i(offsetX + imageWidth, offsetY + imageHeight);
-  glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY + imageHeight);
-  glEnd();
-  glDisable(GL_TEXTURE_2D);
-
-  glDisable(GL_BLEND);
-  glPopMatrix();
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glPopAttrib();
-
-  SDL_GL_SwapBuffers();              
-}
- 
 
 /** 
@@ -214,24 +65,55 @@
     \param file name of the backgroun-image
  */
-void GLMenuImageScreen::setBackImageName (char* backImageName)
-{}
+void GLMenuImageScreen::setBackgroundImage (const char* backImageName)
+{
+  this->backMat->setDiffuseMap(backImageName);
+}
 
 
 /**
    \brief sets position of the ImageScreen
-   \param x offset from (0, 0)
-   \param y offset from (0, 0)
+   \param x offset from the top left corner in percent(0-1) of the screensize
+   \param y offset from the top left corner in percent(0-1) of the screensize
 */
 void GLMenuImageScreen::setPosition(float offsetX, float offsetY)
-{}
+{
+  this->offsetX = offsetX;
+  this->offsetY = offsetY;
+}
 
 
 /*
   \brief sets size of the ImageScreen
-  \param height of the ImageScreen
-  \param width of the Image Screen
-*/
-void GLMenuImageScreen::setSize(float height, float width)
-{}
+  \param scaleX the scaleing of the image into the x-direction (in percent (0-1))
+  \param scaleY the scaleing of the image into the y-direction (in percent (0-1))
+*/
+void GLMenuImageScreen::setScale(float scaleX, float scaleY)
+{
+  this->scaleX = scaleX;
+  this->scaleY = scaleY;
+}
+
+/**
+   \param barImage An image for the Bar
+*/
+void GLMenuImageScreen::setBarImage(const char* barImage)
+{
+  this->barMat->setDiffuseMap(barImage);
+}
+
+/**
+   \brief sets the Position and the Size of the bar
+   \param barX The Position in the x-direction in percent of the screen (0-1)
+   \param barY The Position in the y-direction in percent of the screen (0-1)
+   \param barW The Size in the x-direction in percent of the screen (0-1)
+   \param barH The Size in the y-direction in percent of the screen (0-1)
+*/
+void GLMenuImageScreen::setBarPosScale(float barX, float barY, float barW, float barH)
+{
+  this->barX = barX;
+  this->barY = barY;
+  this->barW = barW;
+  this->barH = barH;
+}
 
 
@@ -285,2 +167,97 @@
   this->draw();
 }
+
+
+
+/**
+   \brief draws the ImageScreen to the screenbuffer
+*/
+void GLMenuImageScreen::draw ()
+{
+  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+
+  PRINTF(4)("GLMenuImagEscreen::draw() - drawing step %i/%i\n", 
+	 this->currentValue, this->maxValue);
+
+  /* screen size */
+  int screenWidth = GraphicsEngine::getInstance()->getResolutionX();
+  int screenHeight = GraphicsEngine::getInstance()->getResolutionY();
+  
+  int imageWidth = (int)(screenWidth * this->scaleX);
+  int imageHeight = (int)(screenHeight * this->scaleY);
+
+  int offsetX = (int)(this->offsetX * screenWidth);
+  int offsetY = (int)(this->offsetY * screenHeight);
+
+  /* loadbar pos */
+  int barX = (int)(this->barX *screenWidth);
+  int barY = (int)(this->barY *screenHeight);
+  int barW = (int)(this->barW *screenWidth);
+  int barH = (int)(this->barH *screenHeight);
+  
+  int val = (int)(((float)this->currentValue/(float)this->maxValue)
+		  * this->barW * (float)screenWidth);
+  if( val > barW)
+    val = barW;
+
+  printf(":::::::::::::::::::::%d %d %d %d %d\n", screenHeight, barY, barW, barH, val);
+
+  GraphicsEngine::enter2DMode();
+
+  /* draw the BackGround */
+  backMat->select();
+  glBegin(GL_TRIANGLE_STRIP);
+  glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY + imageHeight);
+  glTexCoord2i(1, 0); glVertex2i(offsetX +imageWidth, offsetY + imageHeight);
+  glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY);
+  glTexCoord2i(1, 1); glVertex2i(offsetX + imageWidth, offsetY);
+  glEnd();
+  
+  
+  /* draw the progress bar */
+  barMat->select();
+  glBegin(GL_TRIANGLE_STRIP);
+  glColor3f(0.96, 0.84, 0.34);
+  glTexCoord2i(0, 0); glVertex2i(barX, barY + barH);
+  glTexCoord2i(1, 0); glVertex2i(barX + val, barY + barH);
+  glTexCoord2i(0, 1); glVertex2i(barX, barY);
+  glTexCoord2i(1, 1); glVertex2i(barX + val, barY);
+  glEnd();
+
+  /*
+    glBegin(GL_QUADS);
+    glColor3f(0.0, 0.0, 0.0);
+    glVertex2i(barX, barY);
+    glVertex2i(barX + barWidth, barY);
+    glVertex2i(barX + barWidth, barY + barHeight);
+    glVertex2i(barX, barY + barHeight);
+    glColor3f(1.0, 1.0, 1.0);
+    glEnd();
+    
+    /* draw black border 
+    glBegin(GL_QUADS);
+    glColor3f(0.0, 0.0, 0.0);
+    glVertex2i(barX-1, barY-1);
+    glVertex2i(barX + barWidth +1, barY-1);
+    glVertex2i(barX + barWidth+1, barY + barHeight+1);
+    glVertex2i(barX - 1, barY + barHeight +1);
+    glColor3f(1.0, 1.0, 1.0);
+    glEnd();
+    
+    /* draw white border /
+    glBegin(GL_QUADS);
+    glColor3f(1.0, 1.0, 1.0);
+    glVertex2i(barX-2, barY-2);
+    glVertex2i(barX + barWidth +2, barY-2);
+    glVertex2i(barX + barWidth+2, barY + barHeight+2);
+    glVertex2i(barX - 2, barY + barHeight +2);
+    glColor3f(1.0, 1.0, 1.0);
+    glEnd();
+  */
+
+  GraphicsEngine::leave2DMode();
+
+  SDL_GL_SwapBuffers();              
+}
+ 
+
Index: orxonox/trunk/src/glmenu/glmenu_imagescreen.h
===================================================================
--- orxonox/trunk/src/glmenu/glmenu_imagescreen.h	(revision 3729)
+++ orxonox/trunk/src/glmenu/glmenu_imagescreen.h	(revision 4099)
@@ -15,23 +15,20 @@
 
  private:
-  GLMenuImageScreen ();
 
  public:
+  GLMenuImageScreen ();
   virtual ~GLMenuImageScreen ();
-  
-  static GLMenuImageScreen* getInstance();
-
-  static GLMenuImageScreen* singletonRef;
 
   void init ();
-  void init (char* backImageName, float height, float width, 
-	     float offsetX, float offsetY);
 
   void draw ();
   
-  void setBackImageName (char* backImageName);
-  void setPosition (float offsetX, float offsetY);
-  void setSize (float height, float width);
-  
+  void setBackgroundImage(const char* backImageName);
+  void setPosition(float offsetX, float offsetY);
+  void setScale (float scaleX, float scaleY);
+
+  void setBarImage(const char* barImage);
+  void setBarPosScale(float barX, float barY, float barW, float barH);
+
   void setMaximum (int maxValue);
   int getMaximum ();
@@ -42,7 +39,9 @@
  private:
   char* backImageName;       //!< the name of the file of the background image
-  float height, width;       //!< hight and width of the image
+  float scaleX, scaleY;      //!< hight and width of the image
   float offsetX, offsetY;    //!< offset of the image from left and up
   Material* backMat;         //!< Background Material.
+  float barX, barY, barW, barH; //!< Position and Scale of the bar.
+  Material* barMat;          //!< A Material for the Loading-Bar
 
   /* progress bar values */
