有谁知道,如何创建两个 Windows 和都应该有自己的带有 SDL 1.3 库的 YUV 叠加层?
有可能还是我尝试使用错误的策略?
如果我尝试以下来源,我收到一条错误消息: [!] 无法创建局部叠加 YUV 显示仅支持屏幕表面
#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
static bool running = true;
static SDL_Window* win_local;
static SDL_Window* win_remote;
int main(int argc, char** argv) {
// SDL_SetVideoMode
if((SDL_Init(SDL_INIT_VIDEO) != 0))
{
printf("[!] can't initialize SDL %s\n", SDL_GetError());
exit(-1);
}
if(!(win_local = SDL_CreateWindow("Local Video", 0, 0, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS)))
{
printf("[!] can't create Window %s\n", SDL_GetError());
exit(-1);
}
if(!(win_remote = SDL_CreateWindow("Remote Video", 700, 0, 640, 480, SDL_WINDOW_SHOWN)))
{
printf("[!] can't create Window %s\n", SDL_GetError());
exit(-1);
}
SDL_Surface* surface_local;
SDL_Surface* surface_remote;
if(!(surface_local = SDL_GetWindowSurface(win_local)))
{
printf("[!] can't get local surface %s\n", SDL_GetError());
exit(-1);
}
if(!(surface_remote = SDL_GetWindowSurface(win_remote)))
{
printf("[!] can't get remote surface %s", SDL_GetError());
exit(-1);
}
SDL_Overlay* overlay_local;
SDL_Overlay* overlay_remote;
if(!(overlay_local = SDL_CreateYUVOverlay(640, 480, SDL_IYUV_OVERLAY, surface_local)))
{
printf("[!] can't create local overlay %s\n", SDL_GetError());
exit(-1);
}
//
// if(!(overlay_remote = SDL_CreateYUVOverlay(640, 480, SDL_IYUV_OVERLAY, surface_remote)))
// {
// printf("[!] can't create remote overlay %s\n", SDL_GetError());
// exit(-1);
// }
SDL_Event event;
while(running)
{
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_ESCAPE)
running = false;
break;
case SDL_QUIT:
running = false;
break;
}
}
SDL_Delay(20);
}
//SDL_FreeSurface(local);
//SDL_FreeSurface(remote);
SDL_DestroyWindow(win_local);
SDL_DestroyWindow(win_remote);
SDL_Quit();
exit(0);
return 0;
}
最佳答案
SDL_CreateYUVOverlay
不能很好地用于多个窗口,因为它不是 1.3 API 的一部分,它是为了与 SDL 1.2 反向兼容而保留的。
我看到三种可能的解决方案:
在每个表面的
SDL_CreateWindow
之后调用SDL_CreateYUVOverlay
。您可能会避免该错误,但我不确定它是否会正常工作。看看如何SDL_CreateYUVOverlay is implemented using 1.3 API并做类似的事情。
使用 OpenGL 和着色器。
关于c - 带有 YUV 叠加的多个 SDL 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7145124/