Thread: SDL way to do this:

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    55

    SDL way to do this:

    Code:
    if (PeekMessage(&Msg, 0, 0, 0, PM_REMOVE)){
    	if (Msg.message == WM_QUIT) break;
    	TranslateMessage(&Msg);
    	DispatchMessage(&Msg);
    }
    I have that within a for that is showing frames of a video at a certain FPS... With that, the user can close the application whenever he wants... However, my whole application uses SDL, except for that. It would be a shame to be platform dependent just for that. Do you know how to do that with SDL?

  2. #2
    Registered User
    Join Date
    Apr 2007
    Location
    Sweden
    Posts
    41
    Code:
    SDL_Event ev;
    bool game_is_running = true;
    
    while (game_is_running) 
    {
        SDL_PollEvent(&ev);
    
        switch (ev.type)
        {               
            case SDL_QUIT:
            {
                game_is_running = false;
                break;
            }
        }
    }
    
    // cleanup before exiting goes here

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    Thanks a lot... It works really good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SDL and stdio.h
    By a.mlw.walker in forum C Programming
    Replies: 1
    Last Post: 02-06-2009, 07:45 AM
  2. Problems compiling this SDL app
    By Rider in forum C++ Programming
    Replies: 3
    Last Post: 03-27-2007, 12:22 PM
  3. SDL and MinGW Studio
    By Vicious in forum Tech Board
    Replies: 0
    Last Post: 07-30-2004, 09:59 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. sdl in c++
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-07-2002, 07:46 AM