2011-08-22 14 views
1

誰も知っていますが、2つのWindows ansを作成するには、どちらもSDL 1.3ライブラリで独自のYUVオーバーレイを使用する必要がありますか?YUVオーバーレイを使用した複数のSDLウィンドウ

間違った戦略を使用する可能性がありますか?

私は、次のソースを試みた場合、私はエラーメッセージを得た:[!] は地元のオーバーレイ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; 
} 

答えて

1

SDL_CreateYUVOverlayスクリーン表面上に支持されていることでうまく動作しません。複数のウィンドウは、1.3 APIの一部ではないため、SDL 1.2との下位互換性のために残されていました。ただ、各表面についてSDL_CreateWindow

  1. コールSDL_CreateYUVOverlay

    は、私は三つの可能な解決策を参照してください。あなたはおそらくエラーを避けるでしょうが、正しく動作するかどうかはわかりません。

  2. SDL_CreateYUVOverlay is implemented using 1.3 APIを参照してください。同様の操作を行います。

  3. OpenGLとシェーダを使用します。

関連する問題