bool
DeviceManagerDx::CreateCompositorDevices()
{
  MOZ_ASSERT(ProcessOwnsCompositor());

  FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
  MOZ_ASSERT(d3d11.IsEnabled());

  if (!LoadD3D11()) {
    return false;
  }

  CreateCompositorDevice(d3d11);

  if (!d3d11.IsEnabled()) {
    MOZ_ASSERT(!mCompositorDevice);
    ReleaseD3D11();
    return false;
  }

  // We leak these everywhere and we need them our entire runtime anyway, let's
  // leak it here as well. We keep the pointer to sD3D11CreateDeviceFn around
  // as well for D2D1 and device resets.
  mD3D11Module.disown();

  MOZ_ASSERT(mCompositorDevice);
  return d3d11.IsEnabled();
}
Beispiel #2
0
i32 CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPSTR /*lpCmdLine*/, i32 /*nCmdShow*/ ) {

    // the window we'll be rendering to
    SDL_Window* window = nullptr;

    // initialize SDL
    i32 result = SDL_Init( SDL_INIT_VIDEO );
    if ( result < 0 ) {
        //printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
        return EXIT_FAILURE;
    }

    // create window

    /*SDL_DisplayMode displayMode;
    SDL_GetDesktopDisplayMode(0, &displayMode);*/

    const u32 Width = 1366;
    const u32 Height = 768;

    window = SDL_CreateWindow(
        "D3D11 Test",
        SDL_WINDOWPOS_UNDEFINED,
        SDL_WINDOWPOS_UNDEFINED,
        Width, Height,
        SDL_WINDOW_SHOWN |
        SDL_WINDOW_FULLSCREEN_DESKTOP );
    if ( window == nullptr ) {
        //printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
        return EXIT_FAILURE;
    }

    SDL_SysWMinfo wmInfo;
    SDL_VERSION( &wmInfo.version );
    SDL_GetWindowWMInfo( window, &wmInfo );
    if ( FAILED( InitializeD3D11( wmInfo.info.win.window, Width, Height ) ) )
        return EXIT_FAILURE;

    if ( FAILED( CreateObject() ) )
        return EXIT_FAILURE;

    bool quit = false;

    // while application is running
    while ( !quit ) {
        SDL_Event e;

        // handle events on queue
        while ( SDL_PollEvent( &e ) ) {
            switch ( e.type ) {
            case SDL_KEYUP:
                switch ( e.key.keysym.sym ) {
                case SDLK_F11:
                    if ( SDL_GetWindowFlags( window ) & SDL_WINDOW_FULLSCREEN_DESKTOP )
                        SDL_SetWindowFullscreen( window, 0 );
                    else
                        SDL_SetWindowFullscreen( window, SDL_WINDOW_FULLSCREEN_DESKTOP );
                    break;
                case SDLK_ESCAPE:
                    quit = true;
                    break;
                }
                break;
            case SDL_QUIT:
                quit = true;
                break;
            }
        }
        Rotate();
        RenderScene();
    }

    // destroy window
    ReleaseD3D11();
    SDL_DestroyWindow( window );

    // quit SDL subsystems
    SDL_Quit();

    return EXIT_SUCCESS;
}