/[usata]/usata2/src/usata.cpp
ViewVC logotype

Diff of /usata2/src/usata.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by skunix, Fri Dec 31 07:27:46 2004 UTC revision 1.13 by skunix, Sun Jan 2 06:34:43 2005 UTC
# Line 20  Line 20 
20  #include "log.hpp"  #include "log.hpp"
21  #include "texture.hpp"  #include "texture.hpp"
22  #include "scene-manager.hpp"  #include "scene-manager.hpp"
23  #include <stdexcept>  #include "exception_types.hpp"
24  #include <boost/format.hpp>  #include <boost/format.hpp>
25  #include <boost/filesystem/operations.hpp>  #include <boost/filesystem/operations.hpp>
26  #include <memory>  #include <memory>
# Line 28  Line 28 
28  namespace usata  namespace usata
29  {  {
30    
31    class Clocker
32    {
33            unsigned cnt;
34            unsigned int next;
35            public:
36                    bool try_next();
37                    void xsync();
38    };
39    
40    bool
41    Clocker::try_next()
42    {
43            if (system::time::get_ticks()>= next)
44            {
45                    next +=16;
46                    ++cnt;
47                    if (cnt >= 3)
48                    {
49                            cnt=0;
50                            ++next;
51                    }
52                    return true;
53            }
54    
55            return false;  
56    }
57    
58    void
59    Clocker::xsync()
60    {
61            next=system::time::get_ticks();
62            cnt=0;
63    }
64    
65    
66  namespace  namespace
67  {  {
68    
# Line 68  Usata::Usata() Line 103  Usata::Usata()
103  :       texture_manager(new TextureManager),  :       texture_manager(new TextureManager),
104          scene(new SceneManager)          scene(new SceneManager)
105  {  {
106                    
107  }  }
108    
109  Usata::~Usata()  Usata::~Usata()
# Line 106  Usata::setup_video() Line 141  Usata::setup_video()
141  }  }
142    
143  int  int
144    Usata::loop()
145    {
146            Clocker clock;
147            clock.xsync();
148            quit = false;
149    
150            unsigned int cnt=0;    
151    
152            while (!quit)
153            {
154                    while (clock.try_next())
155                            ++cnt;
156                    
157                    if (cnt > 60)
158                            quit=true;
159    
160            }
161    
162            return 0;
163    }
164    
165    int
166  Usata::run()  Usata::run()
167  {  {
168          log::BufferedStream logstream;          log::BufferedStream logstream;
# Line 119  Usata::run() Line 176  Usata::run()
176    
177          //texture_manager->get("atex");          //texture_manager->get("atex");
178    
179          return 0;          return loop();
180  }  }
181    
182    
183    
184  } // namespace usata  } // namespace usata

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26