Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5344 in orxonox.OLD


Ignore:
Timestamp:
Oct 10, 2005, 12:39:21 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new Way to load and unload Text

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r5342 r5344  
    7777                  lib/graphics/light.cc \
    7878                  lib/graphics/shader.cc \
     79                  lib/graphics/text_engine/text.cc \
     80                  lib/graphics/text_engine/font.cc \
    7981                  lib/graphics/text_engine/text_engine.cc \
    8082                  lib/graphics/render2D/element_2d.cc \
     
    150152                 lib/graphics/light.h \
    151153                 lib/graphics/shader.h \
     154                 lib/graphics/text_engine/text.h \
     155                 lib/graphics/text_engine/font.h \
    152156                 lib/graphics/text_engine/text_engine.h \
    153157                 lib/lang/base_object.h \
  • trunk/src/Makefile.in

    r5342 r5344  
    7676        orxonox-p_node.$(OBJEXT) orxonox-null_parent.$(OBJEXT) \
    7777        orxonox-graphics_engine.$(OBJEXT) orxonox-light.$(OBJEXT) \
    78         orxonox-shader.$(OBJEXT) orxonox-text_engine.$(OBJEXT) \
     78        orxonox-shader.$(OBJEXT) orxonox-text.$(OBJEXT) \
     79        orxonox-font.$(OBJEXT) orxonox-text_engine.$(OBJEXT) \
    7980        orxonox-element_2d.$(OBJEXT) orxonox-render_2d.$(OBJEXT) \
    8081        orxonox-base_object.$(OBJEXT) orxonox-class_list.$(OBJEXT) \
     
    104105@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-factory.Po \
    105106@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-fast_factory.Po \
     107@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-font.Po \
    106108@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-game_loader.Po \
    107109@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-garbage_collector.Po \
     
    132134@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-test_entity.Po \
    133135@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-test_gun.Po \
     136@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-text.Po \
    134137@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-text_engine.Po \
    135138@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-track_manager.Po \
     
    337340                  lib/graphics/light.cc \
    338341                  lib/graphics/shader.cc \
     342                  lib/graphics/text_engine/text.cc \
     343                  lib/graphics/text_engine/font.cc \
    339344                  lib/graphics/text_engine/text_engine.cc \
    340345                  lib/graphics/render2D/element_2d.cc \
     
    410415                 lib/graphics/light.h \
    411416                 lib/graphics/shader.h \
     417                 lib/graphics/text_engine/text.h \
     418                 lib/graphics/text_engine/font.h \
    412419                 lib/graphics/text_engine/text_engine.h \
    413420                 lib/lang/base_object.h \
     
    518525@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-factory.Po@am__quote@
    519526@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-fast_factory.Po@am__quote@
     527@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-font.Po@am__quote@
    520528@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-game_loader.Po@am__quote@
    521529@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-garbage_collector.Po@am__quote@
     
    546554@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-test_entity.Po@am__quote@
    547555@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-test_gun.Po@am__quote@
     556@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-text.Po@am__quote@
    548557@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-text_engine.Po@am__quote@
    549558@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-track_manager.Po@am__quote@
     
    12441253@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    12451254@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-shader.obj `if test -f 'lib/graphics/shader.cc'; then $(CYGPATH_W) 'lib/graphics/shader.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/shader.cc'; fi`
     1255
     1256orxonox-text.o: lib/graphics/text_engine/text.cc
     1257@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-text.o -MD -MP -MF "$(DEPDIR)/orxonox-text.Tpo" -c -o orxonox-text.o `test -f 'lib/graphics/text_engine/text.cc' || echo '$(srcdir)/'`lib/graphics/text_engine/text.cc; \
     1258@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-text.Tpo" "$(DEPDIR)/orxonox-text.Po"; else rm -f "$(DEPDIR)/orxonox-text.Tpo"; exit 1; fi
     1259@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/text_engine/text.cc' object='orxonox-text.o' libtool=no @AMDEPBACKSLASH@
     1260@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-text.Po' tmpdepfile='$(DEPDIR)/orxonox-text.TPo' @AMDEPBACKSLASH@
     1261@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1262@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-text.o `test -f 'lib/graphics/text_engine/text.cc' || echo '$(srcdir)/'`lib/graphics/text_engine/text.cc
     1263
     1264orxonox-text.obj: lib/graphics/text_engine/text.cc
     1265@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-text.obj -MD -MP -MF "$(DEPDIR)/orxonox-text.Tpo" -c -o orxonox-text.obj `if test -f 'lib/graphics/text_engine/text.cc'; then $(CYGPATH_W) 'lib/graphics/text_engine/text.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/text_engine/text.cc'; fi`; \
     1266@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-text.Tpo" "$(DEPDIR)/orxonox-text.Po"; else rm -f "$(DEPDIR)/orxonox-text.Tpo"; exit 1; fi
     1267@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/text_engine/text.cc' object='orxonox-text.obj' libtool=no @AMDEPBACKSLASH@
     1268@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-text.Po' tmpdepfile='$(DEPDIR)/orxonox-text.TPo' @AMDEPBACKSLASH@
     1269@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1270@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-text.obj `if test -f 'lib/graphics/text_engine/text.cc'; then $(CYGPATH_W) 'lib/graphics/text_engine/text.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/text_engine/text.cc'; fi`
     1271
     1272orxonox-font.o: lib/graphics/text_engine/font.cc
     1273@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-font.o -MD -MP -MF "$(DEPDIR)/orxonox-font.Tpo" -c -o orxonox-font.o `test -f 'lib/graphics/text_engine/font.cc' || echo '$(srcdir)/'`lib/graphics/text_engine/font.cc; \
     1274@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-font.Tpo" "$(DEPDIR)/orxonox-font.Po"; else rm -f "$(DEPDIR)/orxonox-font.Tpo"; exit 1; fi
     1275@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/text_engine/font.cc' object='orxonox-font.o' libtool=no @AMDEPBACKSLASH@
     1276@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-font.Po' tmpdepfile='$(DEPDIR)/orxonox-font.TPo' @AMDEPBACKSLASH@
     1277@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1278@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-font.o `test -f 'lib/graphics/text_engine/font.cc' || echo '$(srcdir)/'`lib/graphics/text_engine/font.cc
     1279
     1280orxonox-font.obj: lib/graphics/text_engine/font.cc
     1281@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-font.obj -MD -MP -MF "$(DEPDIR)/orxonox-font.Tpo" -c -o orxonox-font.obj `if test -f 'lib/graphics/text_engine/font.cc'; then $(CYGPATH_W) 'lib/graphics/text_engine/font.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/text_engine/font.cc'; fi`; \
     1282@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-font.Tpo" "$(DEPDIR)/orxonox-font.Po"; else rm -f "$(DEPDIR)/orxonox-font.Tpo"; exit 1; fi
     1283@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/text_engine/font.cc' object='orxonox-font.obj' libtool=no @AMDEPBACKSLASH@
     1284@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-font.Po' tmpdepfile='$(DEPDIR)/orxonox-font.TPo' @AMDEPBACKSLASH@
     1285@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1286@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-font.obj `if test -f 'lib/graphics/text_engine/font.cc'; then $(CYGPATH_W) 'lib/graphics/text_engine/font.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/text_engine/font.cc'; fi`
    12461287
    12471288orxonox-text_engine.o: lib/graphics/text_engine/text_engine.cc
  • trunk/src/lib/graphics/graphics_engine.cc

    r5318 r5344  
    2727#include "ini_parser.h"
    2828#include "substring.h"
    29 
     29#include "text.h"
    3030
    3131using namespace std;
     
    564564if (this->geTextCFPS == NULL)
    565565{
    566   this->geTextCFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
     566  this->geTextCFPS = new Text("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
    567567  this->geTextCFPS->setName("curFPS");
    568568  this->geTextCFPS->setAlignment(TEXT_ALIGN_LEFT);
     
    571571if (this->geTextMaxFPS == NULL)
    572572{
    573       this->geTextMaxFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
     573      this->geTextMaxFPS = new Text("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
    574574      this->geTextMaxFPS->setName("MaxFPS");
    575575      this->geTextMaxFPS->setAlignment(TEXT_ALIGN_LEFT);
     
    578578if (this->geTextMinFPS == NULL)
    579579{
    580       this->geTextMinFPS = TextEngine::getInstance()->createText("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
     580      this->geTextMinFPS = new Text("fonts/arial_black.ttf", 15, TEXT_RENDER_DYNAMIC);
    581581      this->geTextMinFPS->setName("MinFPS");
    582582      this->geTextMinFPS->setAlignment(TEXT_ALIGN_LEFT);
  • trunk/src/lib/graphics/text_engine/font.h

    r5343 r5344  
    22 * @file font.h
    33 * brief Definition of the FONT-loading class
     4 *
     5 * !! IMPORTANT !! When using ttf fonts clear the license issues prior to
     6 * adding them to orxonox. This is really important, because we do not want
     7 * to offend anyone.
    48 */
    59
  • trunk/src/lib/graphics/text_engine/text.cc

    r5343 r5344  
    3838  if (fontFile != NULL)
    3939    this->setFont(fontFile, fontSize);
    40   this->setType(type);
    41 }
    42 
    43 /**
    44  *  creates a new Text Element
    45  * @param font the Font to render this text in
    46  * @param type The renderType to display this font in
    47  *
    48  * this constructor is private, because the user should initialize
    49  * a text with the TextEngine.
    50  */
    51 Text::Text(Font* font, TEXT_RENDER_TYPE type)
    52 {
    53   this->init();
    54 
    55   this->font = font;
    5640  this->setType(type);
    5741}
     
    8973
    9074/**
    91  * sets the Font of this Text to font
    92  * @param font the Font (normaly from the ResourceManager) to allocate to this Text
    93  */
    94 void Text::setFont(Font* font)
    95 {
    96   if (this->font != NULL)
    97     ResourceManager::getInstance()->unload(this->font);
    98   this->font = font;
    99 }
    100 
    101 /**
    10275 * sets the Font of this Text to font from fontFile
    10376 * @param fontFile the File to load the Font from.
     
    11184
    11285  tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize);
    113   if (tmpFont == NULL)
     86  if (tmpFont != NULL)
     87  {
     88    if (this->font != NULL)
     89      ResourceManager::getInstance()->unload(this->font);
     90    this->font = tmpFont;
     91  }
     92
     93  else
    11494  {
    11595    PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile);
    116     this->setFont(NULL);
    117   }
    118   else
    119     this->setFont(tmpFont);
     96    if (this->font != NULL)
     97      ResourceManager::getInstance()->unload(this->font);
     98    this->font = NULL;
     99  }
    120100}
    121101
  • trunk/src/lib/graphics/text_engine/text.h

    r5343 r5344  
    2424// FORWARD DECLARATION
    2525class Font;
    26 
    2726
    2827/**
     
    5756class Text : public Element2D
    5857{
    59   friend class TextEngine;
    6058  public:
    6159    Text(const char* fontFile, unsigned int fontSize = TEXT_DEFAULT_SIZE, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);
     
    8684
    8785  private:
    88     Text(Font* font = NULL, TEXT_RENDER_TYPE type = TEXT_RENDER_DYNAMIC);
    89     void setFont(Font* font);
    90 
    9186
    9287  private:
  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r5343 r5344  
    2323
    2424#include "text_engine.h"
     25#include "text.h"
     26#include "font.h"
    2527
    2628using namespace std;
     
    3436#include "class_list.h"
    3537
    36 #include "p_node.h"
    37 #include "vector.h"
    3838#include "debug.h"
    3939#include "list.h"
     
    126126
    127127/**
    128  *  creates a new Text with a certain font.
    129  * @see Font::Font
    130  * @see Text::Text
    131 */
    132 Text* TextEngine::createText(const char* fontFile, unsigned int fontSize, int textType)
    133 {
    134   Font* tmpFont;
    135   Text* newText;
    136   Vector tmpVec;
    137 
    138   tmpFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, &fontSize);
    139   if (!tmpFont)
    140     {
    141       PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile);
    142       return NULL;
    143     }
    144   else
    145     return new Text(tmpFont, TEXT_RENDER_DYNAMIC);
    146 }
    147 
    148 /**
    149128 *  outputs some nice Debug information
    150129
  • trunk/src/lib/graphics/text_engine/text_engine.h

    r5343 r5344  
    1818
    1919#include "base_object.h"
    20 #include "font.h"
    21 #include "text.h"
    2220
    2321#include "vector.h"
     
    2624class PNode;
    2725class Font;
     26class Text;
    2827
    2928///////////////////
     
    3736  /** @returns a Pointer to the only object of this Class */
    3837  inline static TextEngine* getInstance() { if (!singletonRef) singletonRef = new TextEngine();  return singletonRef; };
    39 
    40   Text* createText(const char* fontFile,
    41                    unsigned int fontSize = TEXT_DEFAULT_SIZE,
    42                    int textType = TEXT_RENDER_DYNAMIC);
    4338
    4439  void debug() const;
  • trunk/src/lib/shell/shell.cc

    r5335 r5344  
    2222
    2323
    24 #include "text_engine.h"
     24#include "text.h"
    2525#include "list.h"
    2626#include "graphics_engine.h"
     
    225225  for (unsigned int i = 0; i < bufferDisplaySize; i++)
    226226  {
    227     bufferText[i] = TextEngine::getInstance()->createText(this->fontFile, this->textSize, TEXT_RENDER_DYNAMIC);
     227    bufferText[i] = new Text(this->fontFile, this->textSize, TEXT_RENDER_DYNAMIC);
    228228    bufferText[i]->setColor(1, 0, 0);
    229229    bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
  • trunk/src/lib/shell/shell_input.h

    r5254 r5344  
    1010#define _SHELL_INPUT_H
    1111
    12 #include "text_engine.h"
     12#include "text.h"
    1313#include "event_listener.h"
    1414
  • trunk/src/util/resource_manager.cc

    r5335 r5344  
    3030#endif /* NO_TEXTURES */
    3131#ifndef NO_TEXT
    32 #include "text_engine.h"
     32#include "font.h"
     33#include "text.h" //!< @todo this should not be included here. -> make FONT independant of SIZE...
    3334#endif /* NO_TEXT */
    3435#ifndef NO_AUDIO
     
    359360              tmpResource->ttfSize = *(unsigned int*)param1;
    360361            else
    361               tmpResource->ttfSize = FONT_DEFAULT_SIZE;
     362              tmpResource->ttfSize = TEXT_DEFAULT_SIZE;
    362363
    363364          if(isFile(fullName))
     
    613614              if (param1 == NULL)
    614615                {
    615                   if (enumRes->ttfSize == FONT_DEFAULT_SIZE)
     616                  if (enumRes->ttfSize == TEXT_DEFAULT_SIZE)
    616617                    match = true;
    617618                }
  • trunk/src/util/track/track_manager.cc

    r5336 r5344  
    2424#include "stdincl.h"
    2525#include "list.h"
    26 #include "text_engine.h"
     26#include "text.h"
    2727#include "t_animation.h"
    2828
     
    380380  this->setBindSlave(this->trackNode);
    381381  // initializing the Text
    382   this->trackText = TextEngine::getInstance()->createText("fonts/earth.ttf", 30, TEXT_RENDER_DYNAMIC);
     382  this->trackText = new Text("fonts/earth.ttf", 30, TEXT_RENDER_DYNAMIC);
    383383  this->trackText->setAlignment(E2D_ALIGN_SCREEN_CENTER);
    384384  // initializing the Animation for the Text.
Note: See TracChangeset for help on using the changeset viewer.