Funkey Function!

This is a discussion on Funkey Function! within the C++ Programming forums, part of the General Programming Boards category; Ok, I have a weird function. Here it is: void Slock(SDL_Surface *screen) //1 { if ( SDL_MUSTLOCK(screen) ) //2 { ...

  1. #1
    Shadow12345
    Guest

    Funkey Function!

    Ok, I have a weird function. Here it is:

    void Slock(SDL_Surface *screen) //1
    {
    if ( SDL_MUSTLOCK(screen) ) //2
    {
    if (SDL_LockSurface(screen) < 0 ) //3
    {
    return;
    }
    }
    }

    1) Slock is called when the screen must be locked so it can be drawn on

    2) SDL_MUSTLOCK(surface, in this case 'screen') determines if the screen does in fact need to be locked (it may already be locked or not require being locked in order to be drawn on)

    3) If SDL_MUSTLOCK determines that the screen must be locked it then goes to the next if statement which says if SDL_LockSurface(screen) is an error then return. It doesn't seem SDL_LockSurface is ever actually called though, so I don't see how it can test if it is an error or not

    Ok, this is kinda weird so any help will be great. By the way all the SDL functions return less than zero (< 0) when it is an error.
    If someone can attempt to explain to me why it is set up the way it is I will be very happy. By the way this source code actually works, it is from a SDL tutorial online I am just trying to understand it.

    thanks in advanced
    Last edited by Shadow12345; 04-19-2002 at 11:14 AM.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    3) If SDL_MUSTLOCK determines that the screen must be locked it then goes to the next if statement which says if SDL_LockSurface(screen) is an error then return. It doesn't seem SDL_LockSurface is ever actually called though, so I don't see how it can test if it is an error or not
    things that are functions inside of if statements are called, then checked, ( i think )

    its the same with the message box thing:

    Code:
    if( MessageBox(NULL, "Click Ok", "Ok", MB_OK) == ID_OK )
    {
         MessageBox(NULL, "You clicked OK", "YAY", MB_OK);
    }
    (something like that)

  3. #3
    Shadow12345
    Guest
    Yeah I think you are right, that seems to be the only logical explanation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21