Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 具有YUV覆盖的多个SDL窗口_C_Linux_Sdl_X11 - Fatal编程技术网

C 具有YUV覆盖的多个SDL窗口

C 具有YUV覆盖的多个SDL窗口,c,linux,sdl,x11,C,Linux,Sdl,X11,有人知道如何创建两个Windows ans吗?它们都应该有自己的YUV覆盖层和SDL1.3库 这是可能的,还是我试图使用错误的策略 如果我尝试以下来源,我会收到一条错误消息: [!]无法创建本地覆盖,因为只有屏幕表面才支持YUV显示 #include <SDL/SDL.h> #include <stdio.h> #include <stdlib.h> static bool running = true; static SDL_Window* win_loc

有人知道如何创建两个Windows ans吗?它们都应该有自己的YUV覆盖层和SDL1.3库

这是可能的,还是我试图使用错误的策略

如果我尝试以下来源,我会收到一条错误消息: [!]无法创建本地覆盖,因为只有屏幕表面才支持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_窗口*win_本地;
静态SDL_窗口*win_远程;
int main(int argc,字符**argv){
//SDL_设置视频模式
if((SDL_Init(SDL_Init_视频)!=0))
{
printf(“[!]无法初始化SDL%s\n”,SDL_GetError());
出口(-1);
}
如果(!(win_local=SDL_CreateWindow(“本地视频”,0,0,640,480,显示SDL_窗口| SDL_窗口|无边界)))
{
printf(“[!]无法创建窗口%s\n”,SDL_GetError());
出口(-1);
}
如果(!(win_remote=SDL_CreateWindow(“远程视频”,700、0、640、480,显示SDL_窗口)))
{
printf(“[!]无法创建窗口%s\n”,SDL_GetError());
出口(-1);
}
SDL_表面*表面_局部;
SDL_表面*表面远程;
如果(!(surface\u local=SDL\u GetWindowSurface(win\u local)))
{
printf(“[!]无法获取本地曲面%s\n”,SDL_GetError());
出口(-1);
}
如果(!(surface\u remote=SDL\u GetWindowSurface(win\u remote)))
{
printf(“[!]无法获取远程表面%s”,SDL_GetError());
出口(-1);
}
SDL_覆盖*覆盖_本地;
SDL_Overlay*Overlay_remote;
如果(!(覆盖本地=SDL\U CreateYUVOverlay(640480,SDL\U IYUV\U覆盖,曲面本地)))
{
printf(“[!]无法创建本地覆盖%s\n”,SDL_GetError());
出口(-1);
}
//
//如果(!(覆盖远程=SDL\U CreateYUVOverlay(640480,SDL\U IYUV\U覆盖,曲面远程)))
//  {
//printf(“[!]无法创建远程覆盖%s\n”,SDL_GetError());
//出口(-1);
//  }
SDL_事件;
(跑步时)
{
while(SDL_事件和事件))
{
开关(事件类型)
{
案例SDL_按键关闭:
if(event.key.keysym.sym==SDLK\u ESCAPE)
运行=错误;
打破
案例SDL_退出:
运行=错误;
打破
}
}
SDL_延迟(20);
}
//SDL_自由曲面(局部);
//SDL_自由曲面(远程);
SDL_(温_本地);
SDL_窗口(win_remote);
SDL_退出();
出口(0);
返回0;
}

SDL_CreateYUVOverlay
无法在多个窗口中正常工作,因为它不是1.3 API的一部分,而是为了与SDL 1.2反向兼容而保留的

我认为有三种可能的解决办法:

  • 在每个曲面的
    SDL\u CreateYUVOverlay
    之后调用
    SDL\u CreateWindow
    。你可能会避免这个错误,但我不确定它是否能正常工作

  • 看看如何做类似的事情

  • 使用OpenGL和着色器


  • SDL_CreateYUVOverlay
    无法在多个窗口中正常工作,因为它不是1.3 API的一部分,所以它与SDL 1.2完全兼容

    我认为有三种可能的解决办法:

  • 在每个曲面的
    SDL\u CreateYUVOverlay
    之后调用
    SDL\u CreateWindow
    。你可能会避免这个错误,但我不确定它是否能正常工作

  • 看看如何做类似的事情

  • 使用OpenGL和着色器