2

iOSアプリケーションにSDL 2を使用しようとしています。libSDL2.a をビルドして、プロジェクトに追加します。また、アプリケーション プロジェクトにすべてのヘッダーを追加しています。初期化のために、私は次のコードを使用しています:

/* initialize SDL */ 
if (SDL_Init(SDL_INIT_VIDEO) < 0) { 
        fatalError("Could not initialize SDL"); 
} 
window = SDL_CreateWindow(NULL, 0, 0, m_curScreenResolutions.deviceScreenResolution.size.height, 
                              m_curScreenResolutions.deviceScreenResolution.size.width, 
                              SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | 
                              SDL_WINDOW_BORDERLESS); 

    renderer = SDL_CreateRenderer(window, -1, 0);

そして、画像を描画するために次のコードを使用します:

struct displayImage 
{ 
    float x, y;                
    SDL_Texture *texture; 
    long width, height; 

}; 

SDL_Rect srcRect; 
    SDL_Rect dstRect; 

    for (int i = 0; i < [m_imagesForDisplaying count]; i++) 
    { 
        NSValue *value = [m_imagesForDisplaying objectAtIndex:i]; 
        displayImage preImage; 
        [value getValue:&preImage]; 

        srcRect.x = 0; 
        srcRect.y = 0; 
        srcRect.w = preImage.width; 
        srcRect.h = preImage.height; 

        dstRect.w = preImage.width; 
        dstRect.h = preImage.height; 
        dstRect.x = preImage.x; 
        dstRect.y = preImage.y; 
        SDL_RenderCopy(inputRenderer, preImage.texture, &srcRect, &dstRect); 
    } 
    /* update screen */ 
    SDL_RenderPresent(inputRenderer);

写真は完全に描画されますが、描画後、プログラムでオブジェクトを追加しても、iOS ネイティブ オブジェクト ( UIViewUIButtonなど) やアプリケーション UI が表示されません。SDL のウィンドウ + レンダラーの作成後に UIKit コントロールを追加しようとしています。たとえば、UIKit コントロールを追加するには、UIView次のコードを使用します。

UIView* newView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
newView.backgroundColor = [UIColor yellowColor]; 
[self.view addSubView:newView];

self は UIViewController です。

次に、コードを使用して取得しようとUIWindowSDL_SysWMinfoます。

// Retrieve SDL's root UIViewController (iOS only!) 
// This function is completely NOT guaranteed to work in the future. 
// Use it at your own risk! 
UIViewController * GetSDLViewController(SDL_Window * sdlWindow) 
{ 
    SDL_SysWMinfo systemWindowInfo; 
    SDL_VERSION(&systemWindowInfo.version); 
    if ( ! SDL_GetWindowWMInfo(sdlWindow, &systemWindowInfo)) { 
        // consider doing some kind of error handling here 
        return nil; 
    } 
    UIWindow * appWindow = systemWindowInfo.info.uikit.window; 
    UIViewController * rootViewController = appWindow.rootViewController; 
    return rootViewController; 
} 

しかし、初期化しようとするとSDL_SysWMinfo、巣の問題があります: https://docs.google.com/open?id=0B1IEde1HB7cUSVE1NGpVNDRHTUU

誰にもアイデアはありますか?

4

0 に答える 0