SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# src/sgecontrol.c

    00001 /*
    00002  * Copyright (c) 2007 Heiko Irrgang
    00003  *
    00004  * The license and distribution terms for this file may be
    00005  * found in the file COPYING in this distribution or at
    00006  * http://93-interactive.com/cms/products/software/sdl-game-engine/license/
    00007  */
    00008
    00009 #include <sge.h>
    00010
    00011 Uint32 sgeGlobalFPS=0;
    00012
    00013 SGETIMER sgeAddTimer(int ms, void *function) {
    00014         SGETIMER ret;
    00015         if ((ret=SDL_AddTimer(ms, function, NULL))==NULL) {
    00016                 sgeBailOut("Error adding timer %s\n", "" );
    00017         }
    00018         return ret;
    00019 }
    00020
    00021 static Uint32 sgeRedrawTimer(Uint32 interval, void *param) {
    00022         SDL_Event event;
    00023         SDL_UserEvent uevent;
    00024
    00025         uevent.type = SDL_USEREVENT;
    00026         uevent.code = SGEREDRAW;
    00027         uevent.data1 = NULL;
    00028         uevent.data2 = NULL;
    00029         event.type = SDL_USEREVENT;
    00030         event.user = uevent;
    00031         SDL_PushEvent (&event);
    00032         return interval;
    00033 }
    00034
    00035 SGETIMER sgeStartRedrawTimer(int fps) {
    00036         sgeGlobalFPS=fps;
    00037         return sgeAddTimer(1000/fps, sgeRedrawTimer);
    00038 }
    00039
    00040 void sgeStopRedrawTimer(SGETIMER sgetimer) {
    00041         sgeRemoveTimer(sgetimer);
    00042 }
    00043
    00044 Uint32 sgeGetFPS() {
    00045         return sgeGlobalFPS;
    00046 }
    00047

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines