Thread: Dying on SDL_Flip.

  1. #1
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212

    Dying on SDL_Flip.

    It seems my SDL program dies whenever I flip pages.

    Code:
    screen = SDL_SetVideoMode(800, 600, 16, 
                              SDL_SWSURFACE | SDL_DOUBLEBUF);
    SDL_WM_SetCaption("Fight", NULL);
    ...
    SDL_Flip(screen);
    Am I doing something wrong? I haven't drawn anything on screen yet.

    nevermind, i figured it out. it was an unrelated pointer thing.
    Last edited by Brian; 11-16-2003 at 11:52 AM.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Not sure about SDL - I wrote my own flip code in assembly.

    Simply retrieve a pointer from DirectX to the buffer and primary surface.

    Code:
    push ds
    push esi
    push edi
    
    
    lds   esi,[SecondaryBuffer]
    les   edi,[PrimaryBuffer]
    mov ecx,[size]
    rep  movsd
    
    pop edi
    pop esi
    pop ds
    A faster way would be MMX except that MMX does not allow memory to memory transfers. Besides that the only faster way I know of is REP STOSQ which is only available on the Intel IA-64 Itanium CPU.
    Last edited by VirtualAce; 11-16-2003 at 05:15 PM.

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    31
    When not in fullscreen mode...
    you don't need SDL_DOUBLEBUFF
    you should'nt use SDL_Flip

    use SDL_UpdateRect

    *rummages for reference*

    God this book is small....

    Code:
    Prototype
    void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
    
    also
    
    void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);
    
    Ex.1 for a 800x600 window:
    
    SDL_UpdateRect(screen, 0, 0, 800, 600)
    
    Ex.2 for a 800x600 window:
    
    
    SDL_Rect rect;
    rect.x = 0;
    rect.y = 0;
    rect.w = 800;
    rect.h = 600;
    SDL_UpdateRects(screen, 1, &rect)
    Also, i suggest using macros for screen hieght/width because they are used so often... and its alot easier to change and... yeah.
    I never lie... except for right now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suspect my CMOS battery is dying
    By Mario F. in forum Tech Board
    Replies: 13
    Last Post: 05-01-2008, 07:06 AM
  2. Processes not dying
    By Elkvis in forum Linux Programming
    Replies: 12
    Last Post: 04-23-2008, 08:59 AM
  3. Spam Filters. ISP based email is dying.
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 03-05-2008, 12:05 PM
  4. The top 10 dead (or dying) computer skills
    By DISGUISED in forum A Brief History of Cprogramming.com
    Replies: 30
    Last Post: 06-14-2007, 11:17 PM
  5. Burner Dying
    By ober in forum Tech Board
    Replies: 0
    Last Post: 08-22-2005, 01:12 PM