Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5380 in orxonox.OLD for branches/2d-recalc/src/lib/graphics


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/graphics
Files:
5 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
Note: See TracChangeset for help on using the changeset viewer.