[SDL] Video Rendering with SDL_Overlay

Shane M. Walton walton at tcni.com
Tue Apr 4 11:24:16 PDT 2006


Yunwei,

I would be glad to hand over a function that I wrote to blit RGB images with
a known constant color background to the YV12 YUV format.  It works pretty
well with the SDL_Surface created by the SDL_ttf library.

You should be able to draw a line in RGB format and blit it as well.  The
function takes in the following: SDL_Overlay, SDL_Surface, x offset, and a y
offset.

Now that I am thinking of it, I didn't really put in any boundary checking,
but wouldn't be too hard to add.

Shane

> -----Original Message-----
> From: sdl-bounces+swalton75=cox.net at libsdl.org [mailto:sdl-
> bounces+swalton75=cox.net at libsdl.org] On Behalf Of yunwei at cogeco.ca
> Sent: Tuesday, April 04, 2006 1:27 PM
> To: sdl at libsdl.org
> Subject: [SDL] Video Rendering with SDL_Overlay
> 
> Hi,
> 
> It seems that the following post by Shane Walton on 2003-10-28 didnot get
> much attention. Since I am having the same
> question, I re-post it here. Hopefully some experts can help me.
> Basically, the question is how to draw graphics (for
> example, lines) on Video Overlay (for example, YUVOverlay). I know that I
> can work at the pixel level of the YUVOverlay,
> but are there other efficient ways to do that, for example, to use some
> graphic libraries to create the lines and then
> output the video and the lines together?
> 
> Thanks.
> Yunwei
> 
> 
> [SDL] Video Rendering with SDL_Overlay
> Shane Walton sdl at libsdl.org
> Tue Oct 28 20:17:01 2003
> 
> 
> Previous message: [SDL] SDL on FreeBSD
> Next message: [SDL] SDL Library Documentation
> Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 
> --------------------------------------------------------------------------
> ------
> 
> First, thanks for making such an easy to use API vs.
> understanding how the Xv extension works.
> 
> A system that I work with draws multiple video streams
> from host memory to the screen.  It was brought to my
> attention that the Xv/SDL_Overlay would be the most
> efficient way to put UYVY packed data on the video
> card.
> 
> My question is... what is the correct way to draw data
> over the overlay?  The data may be bitmaps, font,
> lines, arcs, etc.  Here is an example of the basic
> algorithm:
> 
> while (1)
> {
>    LockSurface(pSurface)
>    LockOverlay(pOverlay)
> 
>    FrameSync(frame) // wait for video frame
> 
>    copy(frame, pOverlay->pixels[0])
> 
>    UnlockOverlay(pOverlay)
>    UnlockSurface(pSurface)
> }
> 
> If I wanted to draw a "t" breaking the screen into
> four quadrants, how should I go about this?  I tried
> using SDL_FillRect() with a rectangle with width an
> height of one to make a line and then do a
> SDL_UpdateRect() only on the portion that I just drew
> the lines.  It would look something like this:
> 
> while (1)
> {
>    LockSurface(pSurface)
>    LockOverlay(pOverlay)
> 
>    FrameSync(frame) // wait for video frame
> 
>    copy(frame, pOverlay->pixels[0])
> 
>    // draw horizontal line
>    SDL_FillRect(pSurface, rect, color)
>    SDL_UpdateRect(pSurface, rect)
> 
>    // draw vertical line
>    SDL_FillRect(pSurface, rect, color)
>    SDL_UpdateRect(pSurface, rect)
> 
>    UnlockOverlay(pOverlay)
>    UnlockSurface(pSurface)
> }
> 
> Am I doing this at the correct time?  I moved the line
> drawing methods outside the locking mechanisms and it
> doesn't seem to make any difference.  I also notice
> that the overhead starts increasing with just a few
> lines.  I will need to draw more complicated data on
> the video overlay and am concerned that the overhead
> will compound.
> 
> What I would really like to do is draw this overlay
> once and have it be blitted automatically until I
> choose to change it.  Any thoughts, corrections, or
> just good advice is welcome.  Thanks.
> 
> Regards,
> 
> Shane
> 
> =====
> Regards,
> 
> Shane M. Walton, Software Engineer
> Digital System Resources, Inc.
> dsrelist at yahoo.com
> 
> __________________________________
> Do you Yahoo!?
> Exclusive Video Premiere - Britney Spears
> http://launch.yahoo.com/promos/britneyspears/
> 
> 
> 
> 
> --------------------------------------------------------------------------
> ------
> 
> 
> Previous message: [SDL] SDL on FreeBSD
> Next message: [SDL] SDL Library Documentation
> Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list