Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-23 19:48:13 +0000
committerStijn Buys <ingar@osirion.org>2008-02-23 19:48:13 +0000
commit27345ec20eebccd070287b89cdefb4e4381af5cf (patch)
treef9895df6737052287e6a8d83de0416d7cba26f2b /src/client
parent5c734fe66e9ace93c03937adc2fc56336fb474fb (diff)
sv_framerate and cl_framerate
Diffstat (limited to 'src/client')
-rw-r--r--src/client/chat.cc8
-rw-r--r--src/client/client.cc39
2 files changed, 27 insertions, 20 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index 4e7416f..8d5e94c 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -73,9 +73,11 @@ void draw()
// draw the console input
gl::enable(GL_TEXTURE_2D);
- gl::color(0.0f, 1.0f, 0.0f, 1.0f);
- draw_text(CHARWIDTH , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), "Say:");
-
+ gl::color(1.0f, 1.0f, 1.0f, 1.0f);
+ draw_text(CHARWIDTH , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), "say");
+ gl::color(0.0f, 1.0f, .0f, 1.0f);
+ draw_text(CHARWIDTH*4 , 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), ":");
+
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
draw_text(CHARWIDTH*6, 4 + CHARHEIGHT * (MAXNOTIFYLINES+1), (*history_pos));
diff --git a/src/client/client.cc b/src/client/client.cc
index 33b3a04..a25b958 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -23,6 +23,8 @@
namespace client
{
+core::Cvar *cl_framerate = 0;
+
//--- private definition ------------------------------------------
/// client application implementation
class Client : public core::Application
@@ -90,6 +92,7 @@ void Client::init()
// client variables
core::Cvar::get("cl_name", "Player", core::Cvar::Archive);
core::Cvar::get("cl_color", "1.0 1.0 1.0", core::Cvar::Archive);
+ cl_framerate = core::Cvar::get("cl_framerate", "0");
// initialize SDL, but do not initialize any subsystems
SDL_Init(0);
@@ -115,28 +118,30 @@ void Client::run()
{
con_print << "Running client..." << std::endl;
- Uint32 chrono = SDL_GetTicks();
+
+
+ Uint32 client_framerate = (Uint32)(1000/120);
+ Uint32 elapsed = 0;
while (true) {
- Uint32 current = SDL_GetTicks();
+ if (cl_framerate->value())
+ client_framerate = (Uint32) (1000.0f / cl_framerate->value());
- // overflow protection ~49 days
- if (current < chrono) {
- chrono = current;
- }
+ Uint32 chrono = SDL_GetTicks();
- // run a core frame
- float seconds = ((float)(current - chrono)) / 1000.0f;
- core::Application::frame(seconds);
-
- // run a video frame
- video::frame(seconds);
+ core::Application::frame((float)elapsed / 1000.0f);
+ video::frame((float)elapsed / 1000.0f);
+ input::frame((float)elapsed / 1000.0f);
- // process input
- input::frame(seconds);
-
- // update the main loop chronometer
- chrono = current;
+ // sleep
+ Uint32 current = SDL_GetTicks();
+
+ elapsed = current - chrono;
+
+ if (elapsed < client_framerate) {
+ SDL_Delay(client_framerate - elapsed);
+ elapsed = client_framerate;
+ }
}
}