Advanced coding question

Miscellaneous Forums/General Discussion/Advanced coding question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

I want to use this function in sdl to copy a list of rectangle areas to the front buffer in a fast way. However I don't know how best to use the sdl function. I have access to the function.


However I am not sure if i should pass a bank of sequential x,y,w,h values, or instead somehow point to this structure:

    Type SDL_Rect
        Field x@@, y@@
        Field w@@, h@@
        
        Method Fill( from@ Ptr )
            MemCopy( GetPtr( ), from, SizeOf( Self ) )
        End Method
        
        Method GetPtr@ Ptr( )
            Return Varptr x
        End Method
        
        Method SetPosition( _x%, _y% )
            x = IntShort(_x)
            y = IntShort(_y)
        End Method
        
        Method GetPosition( _x% Var, _y% Var )
            _x = ShortInt(x)
            _y = ShortInt(y)
        End Method
    End Type
    
    Type SDL_Color
        Field r@
        Field g@
        Field b@
        Field unused@   ' O_o
        
        Method GetPtr@ Ptr( )
            Return Varptr r
        End Method
    End Type

    Type SDL_PixelFormat
        Field palette@ Ptr
        Field BitsPerPixel@
        Field BytesPerPixel@
        Field RLoss@
        Field GLoss@
        Field BLoss@
        Field ALoss@
        Field Rshift@
        Field Gshift@
        Field Bshift@
        Field Ashift@
        Field Rmask%
        Field Gmask%
        Field Bmask%
        Field Amask%
        Field colorkey%
        Field alpha@
        
        Method Fill( from@ Ptr )
            MemCopy( GetPtr( ), from, SizeOf( Self ) )
        End Method
        
        Method GetPtr@ Ptr( )
            Return Varptr palette
        End Method
    End Type


The docs for SDL_UpdateRects() says only this:


Name
SDL_UpdateRects -- Makes sure the given list of rectangles is updated on the given screen.

Synopsis
void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);


Description
Makes sure the given list of rectangles is updated on the given screen. The rectangles must all be confined within the screen boundaries (no clipping is done).

This function should not be called while screen is locked.

Note: It is adviced to call this function only once per frame, since each call has some processing overhead. This is no restriction since you can pass any number of rectangles each time.

The rectangles are not automatically merged or checked for overlap. In general, the programmer can use his knowledge about his particular rectangles to merge them in an efficient way, to avoid overdraw.