Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5380 in orxonox.OLD


Ignore:
Timestamp:
Oct 15, 2005, 1:49:17 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: some 2d-adaptions

Location:
branches/2d-recalc/src/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2d-recalc/src/lib/graphics/graphics_engine.cc

    r5347 r5380  
    301301    glMatrixMode(GL_PROJECTION_MATRIX);
    302302    glLoadIdentity();
    303     glViewport(0,0,width,height);                                                   // Reset The Current Viewport
     303    glViewport(0,0,width,height);    // Reset The Current Viewport
    304304}
    305305
     
    421421  glLoadIdentity();
    422422
    423   glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
     423  glOrtho(0.0, 1, 1, 0.0, 0.0, 1.0);
    424424
    425425  glMatrixMode(GL_MODELVIEW);
     
    565565    this->geTextCFPS->setName("curFPS");
    566566    this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
    567     this->geTextCFPS->setAbsCoor2D(5, 15);
     567    this->geTextCFPS->setAbsCoor2Dpx(5, 15);
    568568  }
    569569  if (this->geTextMaxFPS == NULL)
     
    572572    this->geTextMaxFPS->setName("MaxFPS");
    573573    this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT);
    574     this->geTextMaxFPS->setAbsCoor2D(5, 40);
     574    this->geTextMaxFPS->setAbsCoor2Dpx(5, 40);
    575575  }
    576576  if (this->geTextMinFPS == NULL)
     
    579579    this->geTextMinFPS->setName("MinFPS");
    580580    this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
    581     this->geTextMinFPS->setAbsCoor2D(5, 65);
     581    this->geTextMinFPS->setAbsCoor2Dpx(5, 65);
    582582  }
    583583}
  • branches/2d-recalc/src/lib/graphics/render2D/element_2d.cc

    r5378 r5380  
    221221  else if (!strcmp(layer, "below-all"))
    222222    this->setLayer(E2D_BELOW_ALL);
     223}
     224
     225
     226void Element2D::setSize2Dpx(int x, int y)
     227{
     228  this->setSize2D((float)(x)/(float)GraphicsEngine::getInstance()->getResolutionX(), (float)(y)/(float)GraphicsEngine::getInstance()->getResolutionY());
     229}
     230
     231
     232void Element2D::setSizeX2Dpx(int x)
     233{
     234  this->setSizeX2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX());
     235}
     236
     237
     238void Element2D::setSizeY2Dpx(int y)
     239{
     240  this->setSizeY2D((float)y/(float)GraphicsEngine::getInstance()->getResolutionY());
     241}
     242
     243int Element2D::getSizeX2Dpx() const
     244{
     245  return (int)((float)this->getSizeX2D()*GraphicsEngine::getInstance()->getResolutionX());
     246}
     247
     248int Element2D::getSizeY2Dpx() const
     249{
     250  return (int)((float)this->getSizeY2D()*GraphicsEngine::getInstance()->getResolutionY());
    223251}
    224252
  • branches/2d-recalc/src/lib/graphics/render2D/element_2d.h

    r5378 r5380  
    100100
    101101    inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; };
     102    void setSize2Dpx(int x, int y);
    102103    inline void setSizeX2D(float x) { this->sizeX = x; };
     104    void setSizeX2Dpx(int x);
    103105    inline void setSizeY2D(float y) { this->sizeY = y; };
     106    void setSizeY2Dpx(int y);
    104107    inline float getSizeX2D() const { return this->sizeX; };
     108    int getSizeX2Dpx() const;
    105109    inline float getSizeY2D() const { return this->sizeY; };
     110    int getSizeY2Dpx() const;
    106111
    107112    // LIKE PNODE
  • branches/2d-recalc/src/lib/graphics/text_engine/text.cc

    r5376 r5380  
    2929/**
    3030 *  creates a new Text Element
     31 * @param textSize the size of the font to be displayed.
    3132 * @param fontFile the Font to render this text in
    3233 * @param type The renderType to display this font in
     
    3940    this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
    4041  this->setType(type);
    41   this->size = textSize;
     42  this->setSizeY2Dpx(textSize);
    4243}
    4344
     
    7172  this->blending = TEXT_DEFAULT_BLENDING;
    7273  this->color = TEXT_DEFAULT_COLOR;
    73   this->size = TEXT_DEFAULT_SIZE;
     74  this->setSizeY2Dpx(TEXT_DEFAULT_SIZE);
    7475  this->setType(TEXT_RENDER_DYNAMIC);
    7576
     
    250251          glBegin(GL_QUADS);
    251252          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[2]);
    252           glVertex2d(posX, - tmpGlyph->bearingY * this->size);
     253          glVertex2d(posX, - tmpGlyph->bearingY * this->getSizeY2D());
    253254          glTexCoord2f(tmpGlyph->texCoord[0], tmpGlyph->texCoord[3]);
    254           glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     255          glVertex2d(posX, (tmpGlyph->height - tmpGlyph->bearingY)*this->getSizeY2D());
    255256          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[3]);
    256           glVertex2d(posX+tmpGlyph->width*this->size, (tmpGlyph->height - tmpGlyph->bearingY)*this->size);
     257          glVertex2d(posX+tmpGlyph->width*this->getSizeY2D(), (tmpGlyph->height - tmpGlyph->bearingY)*this->getSizeY2D());
    257258          glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
    258           glVertex2d(posX+tmpGlyph->width*this->size, - tmpGlyph->bearingY*this->size);
     259          glVertex2d(posX+tmpGlyph->width*this->getSizeY2D(), - tmpGlyph->bearingY*this->getSizeY2D());
    259260          glEnd();
    260261          glEndList();
    261           posX += tmpGlyph->width*this->size;
     262          posX += tmpGlyph->width*this->getSizeY2D();
    262263        }
    263264        tmpText++;
     
    298299    PRINT(0)("=== TEXT: %s ===\n", this->externText);
    299300
    300   if (this->getBindNode())
    301     PRINT(0)("is bind to %s; ref=%p\n", this->getBindNode()->getName(), this->getBindNode());
    302301  PRINT(0)("Color: %0.2f %0.2f %0.2f\n", this->color.x, this->color.y, this->color.z);
    303302}
  • branches/2d-recalc/src/lib/graphics/text_engine/text.h

    r5378 r5380  
    5555  public:
    5656    Text(const char* fontFile, unsigned int fontSize = TEXT_DEFAULT_SIZE, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);
     57    Text(const char* fontFile, float fontSize);
    5758    ~Text();
    5859    void init();
     
    6970    void setColor(float r, float g, float b) { this->color = Vector(r, g, b); };
    7071    /** sets the Size of the Font */
    71     void setSize(float size) { this->size = size; };
    72     /** @returns the Size of the Text */
    73 //    void getSize(float &x, float& y) const { return this->size; };
     72    inline void setTextSize(unsigned int size) { this->setSizeY2Dpx(size); };
    7473
    7574    void setType(TEXT_RENDER_TYPE type);
     
    9291    Vector            color;          //!< The color of the font.
    9392    float             blending;       //!< The blending intensity.
    94     float             size;           //!< The size of the Font.
    9593
    9694  // placement in openGL
  • branches/2d-recalc/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc

    r5373 r5380  
    200200/**
    201201 *  draws the ImageScreen to the screenbuffer
     202 * @todo redesign this whole function, as it is deprecated.
    202203*/
    203204void GLMenuImageScreen::draw ()
     
    209210
    210211  /* screen size */
    211   int screenWidth = GraphicsEngine::getInstance()->getResolutionX();
    212   int screenHeight = GraphicsEngine::getInstance()->getResolutionY();
    213 
    214   int imageWidth = (int)(screenWidth * this->scaleX);
    215   int imageHeight = (int)(screenHeight * this->scaleY);
    216 
    217   int offsetX = (int)(this->offsetX * screenWidth);
    218   int offsetY = (int)(this->offsetY * screenHeight);
     212  float screenWidth = 1;//GraphicsEngine::getInstance()->getResolutionX();
     213  float screenHeight = 1;//GraphicsEngine::getInstance()->getResolutionY();
     214
     215  float imageWidth = (screenWidth * this->scaleX);
     216  float imageHeight = (screenHeight * this->scaleY);
     217
     218  float offsetX = (this->offsetX * screenWidth);
     219  float offsetY = (this->offsetY * screenHeight);
    219220
    220221  /* loadbar pos */
    221   int barX = (int)(this->barX *screenWidth);
    222   int barY = (int)(this->barY *screenHeight);
    223   int barW = (int)(this->barW *screenWidth);
    224   int barH = (int)(this->barH *screenHeight);
     222  float barX = (this->barX *screenWidth);
     223  float barY = (this->barY *screenHeight);
     224  float barW = (this->barW *screenWidth);
     225  float barH = (this->barH *screenHeight);
    225226
    226227  float val = (float)this->currentValue/(float)this->maxValue;
     
    234235  backMat->select();
    235236  glBegin(GL_TRIANGLE_STRIP);
    236   glTexCoord2i(0, 1); glVertex2i(offsetX, offsetY + imageHeight);
    237   glTexCoord2i(1, 1); glVertex2i(offsetX +imageWidth, offsetY + imageHeight);
    238   glTexCoord2i(0, 0); glVertex2i(offsetX, offsetY);
    239   glTexCoord2i(1, 0); glVertex2i(offsetX + imageWidth, offsetY);
     237  glTexCoord2i(0, 1); glVertex2f(offsetX, offsetY + imageHeight);
     238  glTexCoord2i(1, 1); glVertex2f(offsetX +imageWidth, offsetY + imageHeight);
     239  glTexCoord2i(0, 0); glVertex2f(offsetX, offsetY);
     240  glTexCoord2i(1, 0); glVertex2f(offsetX + imageWidth, offsetY);
    240241  glEnd();
    241242
     
    244245  glBegin(GL_LINE_LOOP);
    245246  glColor3f(1.0, 1.0, 1.0);
    246   glVertex2i(barX - 2, barY - 2);
    247   glVertex2i(barX + barW + 2, barY - 2);
    248   glVertex2i(barX + barW + 2, barY + barH + 2);
    249   glVertex2i(barX - 2, barY + barH + 2);
     247  glVertex2f(barX - .01, barY - .01);
     248  glVertex2f(barX + barW + .01, barY - .01);
     249  glVertex2f(barX + barW + .01, barY + barH + .01);
     250  glVertex2f(barX - .01, barY + barH + .01);
    250251  glColor3f(1.0, 1.0, 1.0);
    251252  glEnd();
     
    254255  barMat->select();
    255256  glBegin(GL_TRIANGLE_STRIP);
    256   glTexCoord2f(0,   1); glVertex2i(barX, barY + barH);
    257   glTexCoord2f(val, 1); glVertex2i(barX + (int)(val * this->barW * (float)screenWidth), barY + barH);
    258   glTexCoord2f(0,   0); glVertex2i(barX, barY);
    259   glTexCoord2f(val, 0); glVertex2i(barX + (int)(val * this->barW * (float)screenWidth), barY);
     257  glTexCoord2f(0,   1); glVertex2f(barX, barY + barH);
     258  glTexCoord2f(val, 1); glVertex2f(barX + (val * this->barW * (float)screenWidth), barY + barH);
     259  glTexCoord2f(0,   0); glVertex2f(barX, barY);
     260  glTexCoord2f(val, 0); glVertex2f(barX + (val * this->barW * (float)screenWidth), barY);
    260261  glEnd();
    261262
     
    263264    glBegin(GL_QUADS);
    264265    glColor3f(0.0, 0.0, 0.0);
    265     glVertex2i(barX, barY);
    266     glVertex2i(barX + barWidth, barY);
    267     glVertex2i(barX + barWidth, barY + barHeight);
    268     glVertex2i(barX, barY + barHeight);
     266    glVertex2f(barX, barY);
     267    glVertex2f(barX + barWidth, barY);
     268    glVertex2f(barX + barWidth, barY + barHeight);
     269    glVertex2f(barX, barY + barHeight);
    269270    glColor3f(1.0, 1.0, 1.0);
    270271    glEnd();
     
    273274    glBegin(GL_QUADS);
    274275    glColor3f(0.0, 0.0, 0.0);
    275     glVertex2i(barX-1, barY-1);
    276     glVertex2i(barX + barWidth +1, barY-1);
    277     glVertex2i(barX + barWidth+1, barY + barHeight+1);
    278     glVertex2i(barX - 1, barY + barHeight +1);
     276    glVertex2f(barX-1, barY-1);
     277    glVertex2f(barX + barWidth +1, barY-1);
     278    glVertex2f(barX + barWidth+1, barY + barHeight+1);
     279    glVertex2f(barX - 1, barY + barHeight +1);
    279280    glColor3f(1.0, 1.0, 1.0);
    280281    glEnd();
  • branches/2d-recalc/src/lib/shell/shell.cc

    r5377 r5380  
    8181  this->backgroundMaterial = new Material;
    8282  // Element2D and generals
    83   this->setAbsCoor2D(3, -400);
    84   this->textSize = 20;
    85   this->lineSpacing = 0;
     83  this->textSize = .001;
     84  this->lineSpacing = .001;
    8685  this->bActive = false;
    8786  this->fontFile = new char[strlen(SHELL_DEFAULT_FONT)+1];
     
    9392  this->setTextColor(SHELL_DEFAULT_TEXT_COLOR);
    9493  this->setBackgroundColor(SHELL_DEFAULT_BACKGROUND_COLOR);
    95 
     94  this->setRelCoor2D(0,-this->shellHeight, 0);
    9695  // register the shell at the ShellBuffer
    9796  ShellBuffer::getInstance()->registerShell(this);
     
    128127
    129128  EventHandler::getInstance()->setState(ES_SHELL);
    130   this->setRelCoorSoft2D(0, 0, 1, 5);
     129  this->setRelCoorSoft2D(0, 0, 0, 5);
    131130
    132131  tIterator<char>* bufferIT = ShellBuffer::getInstance()->getBuffer()->getIterator();
     
    250249  if (this->shellInput != NULL)
    251250  {
    252     this->shellInput->setSize(this->textSize);
     251    this->shellInput->setSizeY2D(this->textSize);
    253252    this->shellInput->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
    254253    this->shellInput->setBlending(this->textColor[3]);
    255     this->shellInput->setRelCoor2D(5, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);
     254    this->shellInput->setRelCoor2D(.005, (this->textSize + this->lineSpacing)*this->bufferDisplaySize + this->textSize);
    256255  }
    257256
     
    262261      if (this->bufferText[i] != NULL)
    263262      {
    264         this->bufferText[i]->setSize(this->textSize);
     263        this->bufferText[i]->setSizeY2D(this->textSize);
    265264        this->bufferText[i]->setColor(this->textColor[0], this->textColor[1], this->textColor[2]);
    266265        this->bufferText[i]->setBlending(this->textColor[3]);
     
    269268    }
    270269  }
    271   this->shellHeight = (this->textSize + this->lineSpacing) * (bufferDisplaySize+1);
    272 
     270  this->shellHeight = (float)(this->textSize + this->lineSpacing) * (bufferDisplaySize+1.0);
    273271}
    274272
     
    365363  */
    366364    lastText->setRelDir2D(-90);
    367     lastText->setRelDirSoft2D(0, 10);
    368     lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1000,0,0));
     365    lastText->setRelDirSoft2D(0, 1);
     366    lastText->setRelCoor2D(this->calculateLinePosition(0)- Vector(-1,0,0));
    369367    lastText->setRelCoorSoft2D(this->calculateLinePosition(0),10);
    370368
     
    478476
    479477  glTexCoord2f(1, 0);
    480   glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y  );
     478  glVertex2f(1 - this->getAbsCoor2D().x, this->getAbsCoor2D().y  );
    481479
    482480  glTexCoord2f(0, 1);
     
    484482
    485483  glTexCoord2f(1, 1);
    486   glVertex2f(GraphicsEngine::getInstance()->getResolutionX() - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
     484  glVertex2f(1 - this->getAbsCoor2D().x, this->getAbsCoor2D().y + this->shellHeight);
    487485
    488486  glEnd();
  • branches/2d-recalc/src/lib/shell/shell.h

    r5374 r5380  
    9292    // GENERAL
    9393    bool                     bActive;                //!< If the shell is active.
    94     unsigned int             shellHeight;            //!< The hight of the Shell in Pixels.
    95     unsigned int             lineSpacing;            //!< The Spacing between lines.
    96     unsigned int             textSize;               //!< The size of the text.
     94    float                    shellHeight;            //!< The hight of the Shell in Pixels.
     95    float                    lineSpacing;            //!< The Spacing between lines.
     96    float                    textSize;               //!< The size of the text.
    9797    float                    textColor[4];           //!< The text's color [r,g,b,a].
    9898    char*                    fontFile;               //!< The file containing the font.
Note: See TracChangeset for help on using the changeset viewer.