Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7216 in orxonox.OLD for branches/std/src/lib/graphics


Ignore:
Timestamp:
Mar 12, 2006, 8:54:30 AM (19 years ago)
Author:
bensch
Message:

orxonox/std:: compile and run again, with many more std::strings….

Location:
branches/std/src/lib/graphics
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/graphics/effects/fog_effect.cc

    r7193 r7216  
    126126 * @param mode the mode character
    127127 */
    128 GLint FogEffect::charToFogMode(const char* mode)
     128GLint FogEffect::stringToFogMode(const std::string& mode)
    129129{
    130   if( !strcmp( "GL_LINEAR", mode))
     130  if(mode == "GL_LINEAR")
    131131    return GL_LINEAR;
    132   else if( !strcmp("GL_EXP", mode))
     132  else if(mode == "GL_EXP")
    133133    return GL_EXP;
    134   else if(!strcmp("GL_EXP2", mode) )
     134  else if(mode == "GL_EXP2" )
    135135    return GL_EXP2;
    136136  else
  • branches/std/src/lib/graphics/effects/fog_effect.h

    r7107 r7216  
    2626    virtual bool deactivate();
    2727
    28     inline void setFogMode(const char* mode) { this->fogMode = this->charToFogMode(mode); }
     28    inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); }
    2929    inline void setFogDensity(float density) { this->fogDensity = density; }
    3030    inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; }
     
    3333
    3434  private:
    35     GLint charToFogMode(const char* mode);
     35    GLint stringToFogMode(const std::string& mode);
    3636
    3737
  • branches/std/src/lib/graphics/effects/lense_flare.cc

    r7193 r7216  
    147147 *  7th: Texture of the third burst
    148148 */
    149 void LenseFlare::addFlare(const char* textureName)
     149void LenseFlare::addFlare(const std::string& textureName)
    150150{
    151151  if( this->flares.size() > LF_MAX_FLARES)
     
    159159  bb->setSize(50, 50);
    160160  this->flares.push_back(bb);
    161   PRINTF(0)("Added a Lenseflare Billboard with texture %s\n", textureName);
     161  PRINTF(4)("Added a Lenseflare Billboard with texture %s\n", textureName.c_str());
    162162
    163163  // the first flare belongs to the light source
     
    167167    bb->setVisibility(true);
    168168  }
    169   PRINTF(0)("Finished adding\n", textureName);
     169  PRINTF(4)("Finished adding\n");
    170170}
    171171
  • branches/std/src/lib/graphics/effects/lense_flare.h

    r7015 r7216  
    3939    virtual void tick(float dt);
    4040
    41     void addFlare(const char* textureName);
     41    void addFlare(const std::string& textureName);
    4242
    4343
  • branches/std/src/lib/graphics/render2D/billboard.cc

    r7193 r7216  
    7878void Billboard::loadParams(const TiXmlElement* root)
    7979{
    80   LoadParam(root, "texture", this, Billboard, setTexture)
     80  LoadParam(root, "texture", this->material, Material, setDiffuseMap)
    8181      .describe("the texture-file to load onto the Billboard");
    8282
     
    100100 * @param textureFile The texture-file to load onto the crosshair
    101101 */
    102 void Billboard::setTexture(const char* textureFile)
     102void Billboard::setTexture(const std::string& textureFile)
    103103{
    104104  this->material->setDiffuseMap(textureFile);
  • branches/std/src/lib/graphics/render2D/billboard.h

    r6815 r7216  
    3030
    3131    void setSize(float sizeX, float sizeY);
    32     void setTexture(const char* textureFile);
     32    void setTexture(const std::string& textureFile);
    3333    void attachTo(PNode* pnode);
    3434
  • branches/std/src/lib/graphics/render2D/element_2d.cc

    r7199 r7216  
    180180 * @param alignment the alignment @see loadParams
    181181*/
    182 void Element2D::setAlignment(const char* alignment)
    183 {
    184   if (!strcmp(alignment, "center"))
     182void Element2D::setAlignment(const std::string& alignment)
     183{
     184  if (alignment == "center")
    185185    this->setAlignment(E2D_ALIGN_CENTER);
    186   else if (!strcmp(alignment, "left"))
     186  else if (alignment == "left")
    187187    this->setAlignment(E2D_ALIGN_LEFT);
    188   else if (!strcmp(alignment, "right"))
     188  else if (alignment == "right")
    189189    this->setAlignment(E2D_ALIGN_RIGHT);
    190   else if (!strcmp(alignment, "screen-center"))
     190  else if (alignment == "screen-center")
    191191    this->setAlignment(E2D_ALIGN_SCREEN_CENTER);
    192192}
     
    213213/**
    214214 * sets the layer onto which this 2D-element is projected to.
    215  * @param layer the layer @see loadParams @see Element2D::charToLayer2D(const char* layer)
    216  */
    217 void Element2D::setLayer(const char* layer)
     215 * @param layer the layer @see loadParams @see Element2D::charToLayer2D(const std::string& layer)
     216 */
     217void Element2D::setLayer(const std::string& layer)
    218218{
    219219  this->setLayer(Element2D::charToLayer2D(layer));
     
    235235 * @param bindNode the name of the Node (should be existing)
    236236 */
    237 void Element2D::setBindNode(const char* bindNode)
     237void Element2D::setBindNode(const std::string& bindNode)
    238238{
    239239  const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE));
     
    572572 * @param childName the name of the child to add to this PNode
    573573 */
    574 void Element2D::addChild2D (const char* childName)
     574void Element2D::addChild2D (const std::string& childName)
    575575{
    576576  Element2D* childNode = dynamic_cast<Element2D*>(ClassList::getObject(childName, CL_ELEMENT_2D));
     
    651651 * @param parentName the name of the Parent to set to this Element2D
    652652 */
    653 void Element2D::setParent2D (const char* parentName)
     653void Element2D::setParent2D (const std::string& parentName)
    654654{
    655655  Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D));
     
    658658  else
    659659    PRINTF(2)("Not Found Element2D's (%s::%s) new Parent by Name: %s\n",
    660                 this->getClassName(), this->getName(), parentName);
     660                this->getClassName(), this->getName(), parentName.c_str());
    661661}
    662662
     
    704704 * @param bias the speed to iterate to this new Positions
    705705 */
    706 void Element2D::setParentSoft2D(const char* parentName, float bias)
     706void Element2D::setParentSoft2D(const std::string& parentName, float bias)
    707707{
    708708  Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D));
     
    724724 * @param parentMode a String representing this parentingMode
    725725 */
    726 void Element2D::setParentMode2D (const char* parentingMode)
     726void Element2D::setParentMode2D (const std::string& parentingMode)
    727727{
    728728  this->setParentMode2D(Element2D::charToParentingMode2D(parentingMode));
     
    10931093 * @return the int corresponding to the named parentingMode
    10941094 */
    1095 E2D_PARENT_MODE Element2D::charToParentingMode2D(const char* parentingMode)
    1096 {
    1097   if (!strcmp(parentingMode, "local-rotate"))
     1095E2D_PARENT_MODE Element2D::charToParentingMode2D(const std::string& parentingMode)
     1096{
     1097  if (parentingMode == "local-rotate")
    10981098    return (E2D_PARENT_LOCAL_ROTATE);
    1099   else  if (!strcmp(parentingMode, "rotate-movement"))
     1099  else  if (parentingMode == "rotate-movement")
    11001100    return (E2D_PARENT_ROTATE_MOVEMENT);
    1101   else  if (!strcmp(parentingMode, "movement"))
     1101  else  if (parentingMode == "movement")
    11021102    return (E2D_PARENT_MOVEMENT);
    1103   else  if (!strcmp(parentingMode, "all"))
     1103  else  if (parentingMode == "all")
    11041104    return (E2D_PARENT_ALL);
    1105   else  if (!strcmp(parentingMode, "rotate-and-move"))
     1105  else  if (parentingMode == "rotate-and-move")
    11061106    return (E2D_PARENT_ROTATE_AND_MOVE);
    11071107}
     
    11391139 * @returns the E2D_LAYER on success, E2D_DEFAULT_LAYER on error.
    11401140 */
    1141 E2D_LAYER Element2D::charToLayer2D(const char* layer)
    1142 {
    1143   if (!strcmp(layer, "top"))
     1141E2D_LAYER Element2D::charToLayer2D(const std::string& layer)
     1142{
     1143  if (layer =="top")
    11441144    return (E2D_LAYER_TOP);
    1145   else  if (!strcmp(layer, "medium"))
     1145  else  if (layer == "medium")
    11461146    return (E2D_LAYER_MEDIUM);
    1147   else  if (!strcmp(layer, "bottom"))
     1147  else  if (layer == "bottom")
    11481148    return (E2D_LAYER_BOTTOM);
    1149   else  if (!strcmp(layer, "below-all"))
     1149  else  if (layer == "below-all")
    11501150    return (E2D_LAYER_BELOW_ALL);
    11511151  else
  • branches/std/src/lib/graphics/render2D/element_2d.h

    r7052 r7216  
    102102    /** @param alignment the new Alignment of the 2D-Element */
    103103    inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
    104     void setAlignment(const char* alignment);
     104    void setAlignment(const std::string& alignment);
    105105    inline E2D_ALIGNMENT getAlignment() const { return this->alignment; };
    106106
    107107    // LAYERING //
    108108    void setLayer(E2D_LAYER layer);
    109     void setLayer(const char* layer);
     109    void setLayer(const std::string& layer);
    110110    /** @returns the Layer this Element is drawn to */
    111111    inline E2D_LAYER getLayer() const { return this->layer; };
     
    121121    /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
    122122    inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; };
    123     void setBindNode(const char* bindNode);
     123    void setBindNode(const std::string& bindNode);
    124124    inline const PNode* getBindNode() const { return this->bindNode; };
    125125
     
    181181
    182182    void addChild2D (Element2D* child);
    183     void addChild2D (const char* childName);
     183    void addChild2D (const std::string& childName);
    184184    void removeChild2D (Element2D* child);
    185185    void remove2D();
     
    187187    /** @param parent the new parent of this Element2D */
    188188    void setParent2D (Element2D* parent) { parent->addChild2D(this); };
    189     void setParent2D (const char* parentName);
     189    void setParent2D (const std::string& parentName);
    190190    /** @returns the parent of this Element2D */
    191191    inline Element2D* getParent2D () const { return this->parent; };
     
    194194
    195195    void setParentSoft2D(Element2D* parentNode, float bias = 1.0);
    196     void setParentSoft2D(const char* parentName, float bias = 1.0);
     196    void setParentSoft2D(const std::string& parentName, float bias = 1.0);
    197197
    198198    void setParentMode2D (E2D_PARENT_MODE parentMode);
    199     void setParentMode2D (const char* parentingMode);
     199    void setParentMode2D (const std::string& parentingMode);
    200200    /** @returns the Parenting mode of this node */
    201201    int getParentMode2D() const { return this->parentMode; };
     
    213213    // helper functions //
    214214    static const char* parentingModeToChar2D(int parentingMode);
    215     static E2D_PARENT_MODE charToParentingMode2D(const char* parentingMode);
     215    static E2D_PARENT_MODE charToParentingMode2D(const std::string& parentingMode);
    216216
    217217    static const char* layer2DToChar(E2D_LAYER layer);
    218     static E2D_LAYER charToLayer2D(const char* layer);
     218    static E2D_LAYER charToLayer2D(const std::string& layer);
    219219
    220220  private:
  • branches/std/src/lib/graphics/text_engine/text.cc

    r7207 r7216  
    5050  if (this->font != NULL && this->font != Font::getDefaultFont())
    5151    ResourceManager::getInstance()->unload(this->font);
    52 
    53   if (this->text)
    54     delete[] this->text;
    5552}
    5653
     
    6461  // initialize this Text
    6562  this->font = NULL;
    66   this->text = NULL;
    67   this->externText = NULL;
     63  this->text = "";
    6864  this->setAlignment(TEXT_DEFAULT_ALIGNMENT);
    6965  this->blending = TEXT_DEFAULT_BLENDING;
    7066  this->color = TEXT_DEFAULT_COLOR;
    7167  this->setSize(TEXT_DEFAULT_SIZE);
    72   this->setText(NULL);
     68  this->setText("");
    7369}
    7470
     
    104100 * @param text the new text to set
    105101 */
    106 void Text::setText(const char* text, bool isExtern)
    107 {
    108   if (isExtern)
    109   {
    110     this->externText = text;
    111 
    112     if (unlikely(this->text != NULL))
    113     {
    114       delete[] this->text;
    115       this->text = NULL;
    116     }
    117   }
    118   else
    119   {
    120     this->externText = NULL;
    121     if (this->text)
    122       delete[] this->text;
    123     if (text != NULL)
    124     {
    125       this->text = new char[strlen(text)+1];
    126       strcpy(this->text, text);
    127     }
    128     else
    129       this->text = NULL;
    130   }
     102void Text::setText(const std::string& text)
     103{
     104  this->text = text;
    131105
    132106  // setting up the Text-Width if DYNAMIC
     
    138112
    139113    float width = 0;
    140     const char* tmpText = this->externText;
    141     if (this->externText == NULL)
    142       tmpText = this->text;
    143     if (tmpText != NULL)
     114    if (!this->text.empty())
    144115    {
    145       while (*tmpText != '\0')
     116      for (unsigned int i = 0; i < this->text.size(); i++)
    146117      {
    147         if(glyphArray[*tmpText] != NULL)
     118        if(glyphArray[this->text[i]] != NULL)
    148119        {
    149           width += glyphArray[*tmpText]->advance;
     120          width += glyphArray[this->text[i]]->advance;
    150121        }
    151         tmpText++;
    152122      }
    153123      this->setSizeX2D(width *this->getSizeY2D());
     
    190160    glBindTexture(GL_TEXTURE_2D, Font::getDefaultFont()->getTexture());
    191161  }
    192   const char* tmpText = this->externText;
    193   if (this->externText == NULL)
    194     tmpText = this->text;
    195   if (likely(tmpText != NULL))
     162  if (likely(!this->text.empty()))
    196163  {
    197164    glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0);
     
    201168
    202169    glBegin(GL_QUADS);
    203     while (likely(*tmpText != '\0'))
     170    for (unsigned int i = 0; i < this->text.size(); i++)
    204171    {
    205       if(likely((tmpGlyph = glyphArray[*tmpText]) != NULL))
     172      if(likely((tmpGlyph = glyphArray[this->text[i]]) != NULL))
    206173      {
    207174        glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]);
     
    219186        posX += tmpGlyph->advance * this->getSizeY2D();
    220187      }
    221       ++tmpText;
    222188    }
    223189    glEnd();
     
    232198void Text::debug() const
    233199{
    234   if (this->externText == NULL)
    235     PRINT(0)("=== TEXT: %s ===\n", this->text);
    236   else
    237     PRINT(0)("=== TEXT: %s ===\n", this->externText);
     200  PRINT(0)("=== TEXT: %s ===\n", this->text.c_str());
    238201
    239202  if (this->getBindNode())
  • branches/std/src/lib/graphics/text_engine/text.h

    r7207 r7216  
    4545    void setFont(const std::string& fontFile, unsigned int renderSize);
    4646
    47     void setText(const char* text, bool isExtern = false);
     47    void setText(const std::string& text);
    4848
    4949    /** @returns the String this Text displays */
    50     inline const char* getText() const { return (externText == NULL)?this->text:this->externText; };
     50    inline const std::string& getText() const { return this->text; };
    5151    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
    5252    inline void setBlending(float blending) { this->blending = blending; };
     
    6969    Font*             font;           //!< Font of this text
    7070
    71     char*             text;           //!< The text to display
    72     const char*       externText;     //!< the text to Display from an external Source.
     71    std::string       text;           //!< The text to display
    7372    Vector            color;          //!< The color of the font.
    7473    float             blending;       //!< The blending intensity.
Note: See TracChangeset for help on using the changeset viewer.