Destroy X windows

Hello,
I’ve made a software grabing frames with my camera and displaying it in
a SDL YUV Overlay.
When I click on the x at the top of the X windows, it doesn’t turn it
off, and it continues to display frames.
What should I do to turn off when I clicked on the “destroy event”.
Thanks,
Fabrice.

Catch the relevant SDL_QUIT event and destroy the overlay, perhaps?
I’m not sure if SDL_Quit() would systematically destroy it or not,
though it seems like it should.

—> Drake WilsonOn Tue, May 25, 2004 at 02:44:50PM +1000, Fabrice Chinjoie wrote:

I’ve made a software grabing frames with my camera and displaying it in
a SDL YUV Overlay.
When I click on the x at the top of the X windows, it doesn’t turn it
off, and it continues to display frames.
What should I do to turn off when I clicked on the “destroy event”.

Could you tell me what is wrong with this? Even with atexit(SDLQuit) it
doesn’t work.
Thanks


FrameYUV=SDL_CreateYUVOverlay(width,height,SDL_YV12_OVERLAY,screen);

while(1)
  {
SDL_LockYUVOverlay(FrameYUV);

memcpy(FrameYUV->pixels[0],video.y,width*height);
memcpy(FrameYUV->pixels[1],video.u,width*height/4);
memcpy(FrameYUV->pixels[2],video.v,width*height/4);

SDL_DisplayYUVOverlay(FrameYUV,&disp);
SDL_UnlockYUVOverlay(FrameYUV);
  }
SDL_FreeYUVOverlay(FrameYUV);
SDL_Quit();

}

Drake Wilson wrote:>On Tue, May 25, 2004 at 02:44:50PM +1000, Fabrice Chinjoie wrote:

I’ve made a software grabing frames with my camera and displaying it in
a SDL YUV Overlay.
When I click on the x at the top of the X windows, it doesn’t turn it
off, and it continues to display frames.
What should I do to turn off when I clicked on the “destroy event”.

Catch the relevant SDL_QUIT event and destroy the overlay, perhaps?
I’m not sure if SDL_Quit() would systematically destroy it or not,
though it seems like it should.

—> Drake Wilson


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

You have a straight infinite loop; you’re not catching any events at
all. The SDL_QUIT event and the SDL_Quit() function are not the
same thing; the latter is what you call when you wish to deinitialize
SDL, and the former is the event that is sent to you when the user
tells your window to close – usually via the window manager, such as
by clicking the X button to which you refer.

Event loops are commonly constructed something like the following:

for (;:wink: {
{
SDL_Event ev;

while (SDL_PollEvent(&ev)) {
  /* process the event ev */
}

}

/* do some other processing here */
}

See the docs for the SDL event system, especially SDL_PollEvent()
and the SDL_Event structure.

—> Drake WilsonOn Tue, May 25, 2004 at 03:52:19PM +1000, Fabrice Chinjoie wrote:

Could you tell me what is wrong with this? Even with atexit(SDLQuit) it
doesn’t work.
Thanks


FrameYUV=SDL_CreateYUVOverlay(width,height,SDL_YV12_OVERLAY,screen);

while(1)
  {
SDL_LockYUVOverlay(FrameYUV);

memcpy(FrameYUV->pixels[0],video.y,width*height);
memcpy(FrameYUV->pixels[1],video.u,width*height/4);
memcpy(FrameYUV->pixels[2],video.v,width*height/4);

SDL_DisplayYUVOverlay(FrameYUV,&disp);
SDL_UnlockYUVOverlay(FrameYUV);
  }
SDL_FreeYUVOverlay(FrameYUV);
SDL_Quit();

}