这是创建纹理以渲染1280 * 720 [高清版]图像的正确方法吗?
我通过ffmpeg从RTSP服务器接收数据包,并解码并获取帧。
要渲染我,请按照以下步骤操作。
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
screen = SDL_CreateWindow("TEST APPLICATION", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 0, 0,
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
bmp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STREAMING, 1280, 720);
SDL_RenderSetLogicalSize(renderer, 1280, 720);
while (1)
{
Handling SDL Event. ->
for (;;) {
while ( SDL_PollEvent(&event))
switch (event.type) {
case SDL_QUIT:
case SDL_KEYDOWN:
SDL_Quit ();
exit (0);
break;
case DISPLAY_IMAGE:
SDL_UpdateYUVTexture(bmp, NULL, pFrame->data[0],
pFrame->linesize[0], pFrame->data[1],
pFrame->linesize[1],
pFrame->data[2], pFrame->linesize[2]);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, bmp, NULL, NULL);
SDL_RenderPresent(renderer);
break;
}
}
另外, 从其他一些主题,我将推动这样的事件:
SDL_Event event;
event.type = DISPLAY_IMAGE;
SDL_PushEvent (&event);
请告诉我这是否是正确的做法?