Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8324 in orxonox.OLD for trunk/src/lib/gui/gl/glgui_cursor.cc


Ignore:
Timestamp:
Jun 12, 2006, 12:40:57 AM (18 years ago)
Author:
bensch
Message:

trunk: Texture-Sequence is initialized smoothly now in the GLGuiCursor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/glgui_cursor.cc

    r8312 r8324  
    2020#include "glgui_handler.h"
    2121#include "color.h"
    22 #include "texture_sequence.h"
    23 #include "loading/resource_manager.h" // HACK
    2422
    2523namespace OrxGui
     
    6765    this->color = 0.0f;
    6866
    69     this->seq = new TextureSequence();
    70     this->seq->loadImageSeries(ResourceManager::getInstance()->getDataDir() + "/maps/reap_mouse/reap_mouse_##.tif", 0, 49);
     67    this->resize();
     68  }
    7169
    72     this->resize();
     70  /**
     71   * @brief Loads an Image-Series onto the Cursor.
     72   * @param imageNameSubstitue The Prefix of the Image
     73   * @param from From which image
     74   * @param to To which image
     75   * @return true on success.
     76   *
     77   * @see TextureSequence:: loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to)
     78   */
     79  bool GLGuiCursor::loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to)
     80  {
     81    this->backMaterial().setDiffuse(1.0, 1.0, 1.0);
     82    return this->seq.loadImageSeries(imageNameSubstitue, from, to);
    7383  }
    7484
    7585  void GLGuiCursor::tick(float dt)
    7686  {
    77     this->frameNumber += 25.0*dt;
    78     if (frameNumber >= this->seq->getFrameCount())
    79       frameNumber = 0.0;
    80 
    81     this->color += dt*10.0;
    82     if (this->color > 360.0)
    83       this->color -= 360.0;
    84     Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
    85     this->backMaterial().setDiffuse(color.x, color.y, color.z);
    86 
     87    if (!this->seq.empty())
     88    {
     89      this->frameNumber += 25.0*dt;
     90      if (frameNumber >= this->seq.getFrameCount())
     91        frameNumber = 0.0;
     92    }
     93    else
     94    {
     95      this->color += dt*10.0;
     96      if (this->color > 360.0)
     97        this->color -= 360.0;
     98      Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
     99      this->backMaterial().setDiffuse(color.x, color.y, color.z);
     100    }
    87101    //if (this->movement != Vector2D())
    88102    {
     
    110124  {
    111125    this->beginDraw();
    112     // HACK
    113     glActiveTexture(GL_TEXTURE0);
    114     glEnable(GL_TEXTURE_2D);
    115     glBindTexture(GL_TEXTURE_2D, this->seq->getFrameTexture((int)frameNumber));
    116     glColor3f(1,1,1);
    117     glEnable(GL_BLEND);
    118     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     126
     127    this->backMaterial().select();
     128    if (!this->seq.empty())
     129      glBindTexture(GL_TEXTURE_2D, this->seq.getFrameTexture((int)frameNumber));
    119130    this->drawRect(this->backRect());
    120131
     
    123134  }
    124135
     136  /**
     137   * @brief processes Events from the EventHandler.
     138   * @param event the Event to process.
     139   */
    125140  void GLGuiCursor::process(const Event& event)
    126141  {
Note: See TracChangeset for help on using the changeset viewer.