How To Draw Frames Per Second

This beginner level how to draws the frame rate to the screen. Seeing this output gives you an understanding the game loop.

howtodrawframespersecond

Level

Beginner

Read these first

How To Draw Simple Text

Details

Displaying the framerate in your game window can be useful for debugging or general game loop information. To DrawFramerate simply pass in the X and Y location of where you want the text to be displayed in the game window.

The Text API shows other methods for drawing the framerate to the screen.

Source Code Widget

  • program HowToDrawFramesPerSecond;
    uses SwinGame,sgTypes;
    
    procedure Main();
    
    begin
        OpenGraphicsWindow('Draw Framerate' ,400 ,300 );
        repeat
            ProcessEvents();
            ClearScreen(ColorWhite );
            DrawFramerate(10 ,8 );
            RefreshScreen();
        
        until WindowCloseRequested();
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
    
        open_graphics_window("Draw Framerate" ,400 ,300 );
        do 
        {
            process_events();
            clear_screen(color_white );
            draw_framerate(10 ,8 );
            refresh_screen();
        }
        while ( ! (window_close_requested() ) );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon


Possibilities