Changeset 7216 in orxonox.OLD for branches/std/src/lib/graphics
- Timestamp:
- Mar 12, 2006, 8:54:30 AM (19 years ago)
- Location:
- branches/std/src/lib/graphics
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/lib/graphics/effects/fog_effect.cc
r7193 r7216 126 126 * @param mode the mode character 127 127 */ 128 GLint FogEffect:: charToFogMode(const char*mode)128 GLint FogEffect::stringToFogMode(const std::string& mode) 129 129 { 130 if( !strcmp( "GL_LINEAR", mode))130 if(mode == "GL_LINEAR") 131 131 return GL_LINEAR; 132 else if( !strcmp("GL_EXP", mode))132 else if(mode == "GL_EXP") 133 133 return GL_EXP; 134 else if( !strcmp("GL_EXP2", mode))134 else if(mode == "GL_EXP2" ) 135 135 return GL_EXP2; 136 136 else -
branches/std/src/lib/graphics/effects/fog_effect.h
r7107 r7216 26 26 virtual bool deactivate(); 27 27 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); } 29 29 inline void setFogDensity(float density) { this->fogDensity = density; } 30 30 inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; } … … 33 33 34 34 private: 35 GLint charToFogMode(const char*mode);35 GLint stringToFogMode(const std::string& mode); 36 36 37 37 -
branches/std/src/lib/graphics/effects/lense_flare.cc
r7193 r7216 147 147 * 7th: Texture of the third burst 148 148 */ 149 void LenseFlare::addFlare(const char*textureName)149 void LenseFlare::addFlare(const std::string& textureName) 150 150 { 151 151 if( this->flares.size() > LF_MAX_FLARES) … … 159 159 bb->setSize(50, 50); 160 160 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()); 162 162 163 163 // the first flare belongs to the light source … … 167 167 bb->setVisibility(true); 168 168 } 169 PRINTF( 0)("Finished adding\n", textureName);169 PRINTF(4)("Finished adding\n"); 170 170 } 171 171 -
branches/std/src/lib/graphics/effects/lense_flare.h
r7015 r7216 39 39 virtual void tick(float dt); 40 40 41 void addFlare(const char*textureName);41 void addFlare(const std::string& textureName); 42 42 43 43 -
branches/std/src/lib/graphics/render2D/billboard.cc
r7193 r7216 78 78 void Billboard::loadParams(const TiXmlElement* root) 79 79 { 80 LoadParam(root, "texture", this , Billboard, setTexture)80 LoadParam(root, "texture", this->material, Material, setDiffuseMap) 81 81 .describe("the texture-file to load onto the Billboard"); 82 82 … … 100 100 * @param textureFile The texture-file to load onto the crosshair 101 101 */ 102 void Billboard::setTexture(const char*textureFile)102 void Billboard::setTexture(const std::string& textureFile) 103 103 { 104 104 this->material->setDiffuseMap(textureFile); -
branches/std/src/lib/graphics/render2D/billboard.h
r6815 r7216 30 30 31 31 void setSize(float sizeX, float sizeY); 32 void setTexture(const char*textureFile);32 void setTexture(const std::string& textureFile); 33 33 void attachTo(PNode* pnode); 34 34 -
branches/std/src/lib/graphics/render2D/element_2d.cc
r7199 r7216 180 180 * @param alignment the alignment @see loadParams 181 181 */ 182 void Element2D::setAlignment(const char*alignment)183 { 184 if ( !strcmp(alignment, "center"))182 void Element2D::setAlignment(const std::string& alignment) 183 { 184 if (alignment == "center") 185 185 this->setAlignment(E2D_ALIGN_CENTER); 186 else if ( !strcmp(alignment, "left"))186 else if (alignment == "left") 187 187 this->setAlignment(E2D_ALIGN_LEFT); 188 else if ( !strcmp(alignment, "right"))188 else if (alignment == "right") 189 189 this->setAlignment(E2D_ALIGN_RIGHT); 190 else if ( !strcmp(alignment, "screen-center"))190 else if (alignment == "screen-center") 191 191 this->setAlignment(E2D_ALIGN_SCREEN_CENTER); 192 192 } … … 213 213 /** 214 214 * 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 */ 217 void Element2D::setLayer(const std::string& layer) 218 218 { 219 219 this->setLayer(Element2D::charToLayer2D(layer)); … … 235 235 * @param bindNode the name of the Node (should be existing) 236 236 */ 237 void Element2D::setBindNode(const char*bindNode)237 void Element2D::setBindNode(const std::string& bindNode) 238 238 { 239 239 const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE)); … … 572 572 * @param childName the name of the child to add to this PNode 573 573 */ 574 void Element2D::addChild2D (const char*childName)574 void Element2D::addChild2D (const std::string& childName) 575 575 { 576 576 Element2D* childNode = dynamic_cast<Element2D*>(ClassList::getObject(childName, CL_ELEMENT_2D)); … … 651 651 * @param parentName the name of the Parent to set to this Element2D 652 652 */ 653 void Element2D::setParent2D (const char*parentName)653 void Element2D::setParent2D (const std::string& parentName) 654 654 { 655 655 Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D)); … … 658 658 else 659 659 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()); 661 661 } 662 662 … … 704 704 * @param bias the speed to iterate to this new Positions 705 705 */ 706 void Element2D::setParentSoft2D(const char*parentName, float bias)706 void Element2D::setParentSoft2D(const std::string& parentName, float bias) 707 707 { 708 708 Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D)); … … 724 724 * @param parentMode a String representing this parentingMode 725 725 */ 726 void Element2D::setParentMode2D (const char*parentingMode)726 void Element2D::setParentMode2D (const std::string& parentingMode) 727 727 { 728 728 this->setParentMode2D(Element2D::charToParentingMode2D(parentingMode)); … … 1093 1093 * @return the int corresponding to the named parentingMode 1094 1094 */ 1095 E2D_PARENT_MODE Element2D::charToParentingMode2D(const char*parentingMode)1096 { 1097 if ( !strcmp(parentingMode, "local-rotate"))1095 E2D_PARENT_MODE Element2D::charToParentingMode2D(const std::string& parentingMode) 1096 { 1097 if (parentingMode == "local-rotate") 1098 1098 return (E2D_PARENT_LOCAL_ROTATE); 1099 else if ( !strcmp(parentingMode, "rotate-movement"))1099 else if (parentingMode == "rotate-movement") 1100 1100 return (E2D_PARENT_ROTATE_MOVEMENT); 1101 else if ( !strcmp(parentingMode, "movement"))1101 else if (parentingMode == "movement") 1102 1102 return (E2D_PARENT_MOVEMENT); 1103 else if ( !strcmp(parentingMode, "all"))1103 else if (parentingMode == "all") 1104 1104 return (E2D_PARENT_ALL); 1105 else if ( !strcmp(parentingMode, "rotate-and-move"))1105 else if (parentingMode == "rotate-and-move") 1106 1106 return (E2D_PARENT_ROTATE_AND_MOVE); 1107 1107 } … … 1139 1139 * @returns the E2D_LAYER on success, E2D_DEFAULT_LAYER on error. 1140 1140 */ 1141 E2D_LAYER Element2D::charToLayer2D(const char*layer)1142 { 1143 if ( !strcmp(layer, "top"))1141 E2D_LAYER Element2D::charToLayer2D(const std::string& layer) 1142 { 1143 if (layer =="top") 1144 1144 return (E2D_LAYER_TOP); 1145 else if ( !strcmp(layer, "medium"))1145 else if (layer == "medium") 1146 1146 return (E2D_LAYER_MEDIUM); 1147 else if ( !strcmp(layer, "bottom"))1147 else if (layer == "bottom") 1148 1148 return (E2D_LAYER_BOTTOM); 1149 else if ( !strcmp(layer, "below-all"))1149 else if (layer == "below-all") 1150 1150 return (E2D_LAYER_BELOW_ALL); 1151 1151 else -
branches/std/src/lib/graphics/render2D/element_2d.h
r7052 r7216 102 102 /** @param alignment the new Alignment of the 2D-Element */ 103 103 inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; }; 104 void setAlignment(const char*alignment);104 void setAlignment(const std::string& alignment); 105 105 inline E2D_ALIGNMENT getAlignment() const { return this->alignment; }; 106 106 107 107 // LAYERING // 108 108 void setLayer(E2D_LAYER layer); 109 void setLayer(const char*layer);109 void setLayer(const std::string& layer); 110 110 /** @returns the Layer this Element is drawn to */ 111 111 inline E2D_LAYER getLayer() const { return this->layer; }; … … 121 121 /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */ 122 122 inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; }; 123 void setBindNode(const char*bindNode);123 void setBindNode(const std::string& bindNode); 124 124 inline const PNode* getBindNode() const { return this->bindNode; }; 125 125 … … 181 181 182 182 void addChild2D (Element2D* child); 183 void addChild2D (const char*childName);183 void addChild2D (const std::string& childName); 184 184 void removeChild2D (Element2D* child); 185 185 void remove2D(); … … 187 187 /** @param parent the new parent of this Element2D */ 188 188 void setParent2D (Element2D* parent) { parent->addChild2D(this); }; 189 void setParent2D (const char*parentName);189 void setParent2D (const std::string& parentName); 190 190 /** @returns the parent of this Element2D */ 191 191 inline Element2D* getParent2D () const { return this->parent; }; … … 194 194 195 195 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); 197 197 198 198 void setParentMode2D (E2D_PARENT_MODE parentMode); 199 void setParentMode2D (const char*parentingMode);199 void setParentMode2D (const std::string& parentingMode); 200 200 /** @returns the Parenting mode of this node */ 201 201 int getParentMode2D() const { return this->parentMode; }; … … 213 213 // helper functions // 214 214 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); 216 216 217 217 static const char* layer2DToChar(E2D_LAYER layer); 218 static E2D_LAYER charToLayer2D(const char*layer);218 static E2D_LAYER charToLayer2D(const std::string& layer); 219 219 220 220 private: -
branches/std/src/lib/graphics/text_engine/text.cc
r7207 r7216 50 50 if (this->font != NULL && this->font != Font::getDefaultFont()) 51 51 ResourceManager::getInstance()->unload(this->font); 52 53 if (this->text)54 delete[] this->text;55 52 } 56 53 … … 64 61 // initialize this Text 65 62 this->font = NULL; 66 this->text = NULL; 67 this->externText = NULL; 63 this->text = ""; 68 64 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 69 65 this->blending = TEXT_DEFAULT_BLENDING; 70 66 this->color = TEXT_DEFAULT_COLOR; 71 67 this->setSize(TEXT_DEFAULT_SIZE); 72 this->setText( NULL);68 this->setText(""); 73 69 } 74 70 … … 104 100 * @param text the new text to set 105 101 */ 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 } 102 void Text::setText(const std::string& text) 103 { 104 this->text = text; 131 105 132 106 // setting up the Text-Width if DYNAMIC … … 138 112 139 113 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()) 144 115 { 145 while (*tmpText != '\0')116 for (unsigned int i = 0; i < this->text.size(); i++) 146 117 { 147 if(glyphArray[ *tmpText] != NULL)118 if(glyphArray[this->text[i]] != NULL) 148 119 { 149 width += glyphArray[ *tmpText]->advance;120 width += glyphArray[this->text[i]]->advance; 150 121 } 151 tmpText++;152 122 } 153 123 this->setSizeX2D(width *this->getSizeY2D()); … … 190 160 glBindTexture(GL_TEXTURE_2D, Font::getDefaultFont()->getTexture()); 191 161 } 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())) 196 163 { 197 164 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); … … 201 168 202 169 glBegin(GL_QUADS); 203 while (likely(*tmpText != '\0'))170 for (unsigned int i = 0; i < this->text.size(); i++) 204 171 { 205 if(likely((tmpGlyph = glyphArray[ *tmpText]) != NULL))172 if(likely((tmpGlyph = glyphArray[this->text[i]]) != NULL)) 206 173 { 207 174 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); … … 219 186 posX += tmpGlyph->advance * this->getSizeY2D(); 220 187 } 221 ++tmpText;222 188 } 223 189 glEnd(); … … 232 198 void Text::debug() const 233 199 { 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()); 238 201 239 202 if (this->getBindNode()) -
branches/std/src/lib/graphics/text_engine/text.h
r7207 r7216 45 45 void setFont(const std::string& fontFile, unsigned int renderSize); 46 46 47 void setText(const char* text, bool isExtern = false);47 void setText(const std::string& text); 48 48 49 49 /** @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; }; 51 51 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 52 52 inline void setBlending(float blending) { this->blending = blending; }; … … 69 69 Font* font; //!< Font of this text 70 70 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 73 72 Vector color; //!< The color of the font. 74 73 float blending; //!< The blending intensity.
Note: See TracChangeset
for help on using the changeset viewer.