Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

SDL_gfx, YUV overlay, etc

Name: Anonymous 2012-02-06 11:51

Hi, I have problems drawing to SDL surface after I blited into it with SDL_DisplayYUVOverlay.

The purpose of the program is to display video and draw some simple shapes on top of it.

I have SDL_Overlay overlay tied to main screen  and I display it normally.
I have other screen, gui that I use like this

SDL_Surface *gui, *screen;
screen = SDL_SetVideoMode(width, height, 0, 0);
...
gui = SDL_CreateRGBSurface(0, screen->w, screen->h, 0, 0);
...

//rect is entire screen, bmp comes from ffmpeg
SDL_DisplayYUVOverlay(bmp, &rect);

//from SDL_gfx -- draw filled box
boxColor(gui, width/4, 0, 0, height/4, 0xff0000ff);
SDL_BlitSurface(gui, NULL, screen, &rect);

//update entire screen
SDL_UpdateRect(screen, 0, 0, 0, 0);


Video display works without problems. But after I blit the gui surface to screen and SDL_UpdateRects the video frame is replaced by the rectangle on black background, resulting in ugly flicker.

First I thought that default alpha of surface created by SDL_CreateRGBSurface is 1, but after adding
SDL_FillRect(gui, NULL, SDL_MapRGBA(gui->format, 0, 0, 0, 0));
nothing changed.

So, how to draw on top of video with SDL?

Name: Anonymous 2012-02-06 12:28

It appears you need to explicitly turn on alpha blending for a surface.
http://www.libsdl.org/docs/html/sdlcreatergbsurface.html

SDL_CreateRGBSurface(SDL_SRCALPHA, s->w, s->h, depth, rmask, gmask, bmask, amask);

or

SDL_SetAlpha(gui, SDL_SRCALPHA, alphaValue);

Use the source, Luke.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List