|
Atrinik Client 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00030 #include <global.h> 00031 00032 static Uint32 fps_lasttime; 00033 static Uint32 fps_current; 00035 static Uint32 fps_frames; 00036 00039 void fps_init() 00040 { 00041 fps_lasttime = SDL_GetTicks(); 00042 fps_current = fps_frames = 0; 00043 } 00044 00048 void fps_do() 00049 { 00050 fps_frames++; 00051 00052 if (fps_lasttime < SDL_GetTicks() - 1000) 00053 { 00054 fps_lasttime = SDL_GetTicks(); 00055 fps_current = fps_frames; 00056 fps_frames = 0; 00057 } 00058 } 00059 00063 void widget_show_fps(widgetdata *widget) 00064 { 00065 char buf[MAX_BUF]; 00066 00067 sprite_blt(Bitmaps[BITMAP_FPS], widget->x1, widget->y1, NULL, NULL); 00068 00069 snprintf(buf, sizeof(buf), "%d", fps_current); 00070 string_blt(ScreenSurface, FONT_ARIAL11, "fps:", widget->x1 + 5, widget->y1 + 4, COLOR_WHITE, 0, NULL); 00071 string_blt(ScreenSurface, FONT_ARIAL11, buf, widget->x1 + widget->wd - 5 - string_get_width(FONT_ARIAL11, buf, 0), widget->y1 + 4, COLOR_WHITE, 0, NULL); 00072 }
1.7.4