Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3770 in orxonox.OLD


Ignore:
Timestamp:
Apr 10, 2005, 11:52:05 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: textEngine rendering again

Location:
orxonox/branches/textEngine/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/textEngine/src/lib/graphics/font/text_engine.cc

    r3769 r3770  
    4545  // initialize this Text
    4646  this->bindNode = NULL;
     47  this->font = font;
    4748  this->text = NULL;
    4849  this->texture = 0;
    49   this->setType(TEXT_DYNAMIC);
     50  this->setType(type);
    5051  this->setPosition(0, 0);
    5152
     
    146147  glGetIntegerv(GL_VIEWPORT, viewPort);
    147148
    148   printf("rendering some Text\n");
    149   //enter2DMode();
     149  GraphicsEngine::enter2DMode();
    150150
    151151
     
    192192      glEnd();
    193193    }
    194   else //(if type & TEXT_DYNAMIC)
     194  else //(if type == TEXT_DYNAMIC)
    195195    {
    196196      Glyph** glyphArray = this->font->getGlyphArray();
     
    199199      glTranslatef(pos.x, pos.y, 0);
    200200
    201       printf("%d, %d\n", this->font->getFastTextureID(), glyphArray[65]->displayList);
     201      //      printf("%d, %d\n", this->font->getFastTextureID(), glyphArray[65]->displayList);
    202202      char* tmpText = this->text;
    203203      while (*tmpText != '\0')
     
    211211        }
    212212    }
    213   //leave2DMode();
     213  GraphicsEngine::leave2DMode();
    214214}
    215215
     
    400400  return rg;
    401401}
    402 
    403 /**
    404    \brief entering 2D Mode
    405    
    406    this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else
    407 */
    408 void Font::enter2DMode(void)
    409 {
    410   SDL_Surface *screen = SDL_GetVideoSurface();
    411  
    412   /* Note, there may be other things you need to change,
    413      depending on how you have your OpenGL state set up.
    414   */
    415   glPushAttrib(GL_ENABLE_BIT);
    416   glDisable(GL_DEPTH_TEST);
    417   glDisable(GL_CULL_FACE);
    418   glDisable(GL_LIGHTING);  // will be set back when leaving 2D-mode
    419   glEnable(GL_TEXTURE_2D);
    420 
    421   /* This allows alpha blending of 2D textures with the scene */
    422   glEnable(GL_BLEND);
    423   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    424  
    425   glViewport(0, 0, screen->w, screen->h);
    426  
    427   glMatrixMode(GL_PROJECTION);
    428   glPushMatrix();
    429   glLoadIdentity();
    430  
    431   glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
    432  
    433   glMatrixMode(GL_MODELVIEW);
    434   glPushMatrix();
    435   glLoadIdentity();
    436  
    437   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    438 }
    439 
    440 /**
    441    \brief leaves the 2DMode again also \see Font::enter2DMode(void)
    442 */
    443 void Font::leave2DMode(void)
    444 {
    445         glMatrixMode(GL_MODELVIEW);
    446         glPopMatrix();
    447 
    448         glMatrixMode(GL_PROJECTION);
    449         glPopMatrix();
    450 
    451         glPopAttrib();
    452 }
    453 
    454402
    455403GLuint Font::createFastTexture(void)
     
    874822
    875823  newText = new Text(tmpFont, TEXT_DYNAMIC);
     824  textList->add(newText);
     825
     826  return newText;
    876827}
    877828
  • orxonox/branches/textEngine/src/lib/graphics/font/text_engine.h

    r3769 r3770  
    170170  Glyph* getGlyphMetrics(Uint16 character);
    171171
    172   void enter2DMode(void);
    173   void leave2DMode(void);
    174 
    175 
    176172  GLuint createFastTexture();
    177173
  • orxonox/branches/textEngine/src/lib/graphics/graphics_engine.cc

    r3681 r3770  
    167167
    168168
     169/**
     170   \brief entering 2D Mode
     171   
     172   this is a GL-Projection-mode, that is orthogonal, for placing the font in fron of everything else
     173*/
     174void GraphicsEngine::enter2DMode(void)
     175{
     176  SDL_Surface *screen = SDL_GetVideoSurface();
     177 
     178  /* Note, there may be other things you need to change,
     179     depending on how you have your OpenGL state set up.
     180  */
     181  glPushAttrib(GL_ENABLE_BIT);
     182  glDisable(GL_DEPTH_TEST);
     183  glDisable(GL_CULL_FACE);
     184  glDisable(GL_LIGHTING);  // will be set back when leaving 2D-mode
     185  glEnable(GL_TEXTURE_2D);
     186
     187  /* This allows alpha blending of 2D textures with the scene */
     188  glEnable(GL_BLEND);
     189  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     190 
     191  glViewport(0, 0, screen->w, screen->h);
     192 
     193  glMatrixMode(GL_PROJECTION);
     194  glPushMatrix();
     195  glLoadIdentity();
     196 
     197  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
     198 
     199  glMatrixMode(GL_MODELVIEW);
     200  glPushMatrix();
     201  glLoadIdentity();
     202 
     203  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     204}
     205
     206/**
     207   \brief leaves the 2DMode again also \see Font::enter2DMode(void)
     208*/
     209void GraphicsEngine::leave2DMode(void)
     210{
     211  glMatrixMode(GL_MODELVIEW);
     212  glPopMatrix();
     213 
     214  glMatrixMode(GL_PROJECTION);
     215  glPopMatrix();
     216 
     217  glPopAttrib();
     218}
    169219
    170220
  • orxonox/branches/textEngine/src/lib/graphics/graphics_engine.h

    r3716 r3770  
    3737  static bool texturesEnabled;
    3838
     39  static void enter2DMode(void);
     40  static void leave2DMode(void);
     41
    3942 private:
    4043  GraphicsEngine();
  • orxonox/branches/textEngine/src/story_entities/world.cc

    r3769 r3770  
    350350            this->glmis->step();
    351351            this->testText = TextEngine::getInstance()->createText("fonts/earth.ttf");
     352            testText->setText("test");
     353            testText->setBindNode(tn);
    352354
    353355            break;
Note: See TracChangeset for help on using the changeset viewer.