Sean You

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

4.8 Exercises

  1. Instead of using D3D10CreateDeviceAndSwapChain to create the device and swap chain at once, you can use D3D10CreateDevice and IDXGIFactory::CreateSwapChain to create the device and swap chain separately. In particular, this allows you to create several swap chains, which can be useful for applications that render into multiple windows (one swap chain is used for each window). To create an IDXGIFactory instance, use the CreateDXGIFactory function. To use the DXGI functions, you will need to link dxgi.lib to your project.

  2. Modify the previous exercise solution by disabling the Alt+Enter functionality to switch between full-screen and windowed mode; use the IDXGIFactory::MakeWindowAssociation method and specify the DXGI_MWA_NO_WINDOW_CHANGES flag so that DXGI does not monitor the message queue. Note that the IDXGIFactory::MakeWindowAssociation method needs to be called after IDXGIFactory::CreateSwapChain is called.

  3. Some systems have more than one adapter (video card), and the application may wish to let the user choose which one to use, instead of always using the default adapter. Use the IDXGIFactory::EnumAdapters method to determine how many adapters are on your system.

  4. For each adapter the system possesses, IDXGIFactory::EnumAdapters outputs a pointer to a filled out IDXGIAdapter interface. This interface can be used to query information about the adapter. Use the IDXGIAdapter::CheckInterfaceSupport method to see if the adapters on your system support Direct3D 10.

  5. An adapter has outputs associated with it (e.g., a monitor). You can use the IDXGIAdapter::EnumOutputs method to enumerate the outputs for a particular adapter. Use this method to determine the number of outputs for the default adapter.

  6. Each output has a list of supported display modes (DXGI_MODE_DESC) for a given pixel format. For each output (IDXGIOutput), show the width, height, and refresh rate of each display mode the output supports for the DXGI_FORMAT_R8G8B8A8_UNORM format using the IDXGIOutput::GetDisplayModeList method.

    The listing below shows example output for Exercises 3, 4, 5, and 6. It is useful to use the OutputDebugString function for quick output to the VC++ output window.

    *** NUM ADAPTERS = 1
    *** D3D10 SUPPORTED FOR ADAPTER 0
    *** NUM OUTPUTS FOR DEFAULT ADAPTER = 1
    ***WIDTH = 640 HEIGHT = 480 REFRESH = 60000/1000
    ***WIDTH = 640 HEIGHT = 480 REFRESH = 72000/1000
    ***WIDTH = 640 HEIGHT = 480 REFRESH = 75000/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 56250/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 56250/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 60000/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 60000/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 72188/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 72188/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 75000/1000
    ***WIDTH = 720 HEIGHT = 480 REFRESH = 75000/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 56250/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 56250/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 60000/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 60000/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 72188/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 72188/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 75000/1000
    ***WIDTH = 720 HEIGHT = 576 REFRESH = 75000/1000
    ***WIDTH = 800 HEIGHT = 600 REFRESH = 56250/1000
    ***WIDTH = 800 HEIGHT = 600 REFRESH = 60000/1000
    ***WIDTH = 800 HEIGHT = 600 REFRESH = 60000/1000
    ***WIDTH = 800 HEIGHT = 600 REFRESH = 72188/1000
    ***WIDTH = 800 HEIGHT = 600 REFRESH = 75000/1000
    ***WIDTH = 848 HEIGHT = 480 REFRESH = 60000/1000
    ***WIDTH = 848 HEIGHT = 480 REFRESH = 60000/1000
    ***WIDTH = 848 HEIGHT = 480 REFRESH = 70069/1000
    ***WIDTH = 848 HEIGHT = 480 REFRESH = 70069/1000
    ***WIDTH = 848 HEIGHT = 480 REFRESH = 75029/1000
    ***WIDTH = 848 HEIGHT = 480 REFRESH = 75029/1000
    ***WIDTH = 960 HEIGHT = 600 REFRESH = 60000/1000
    ***WIDTH = 960 HEIGHT = 600 REFRESH = 60000/1000
    ***WIDTH = 960 HEIGHT = 600 REFRESH = 70069/1000
    ***WIDTH = 960 HEIGHT = 600 REFRESH = 70069/1000
    ***WIDTH = 960 HEIGHT = 600 REFRESH = 75029/1000
    ***WIDTH = 960 HEIGHT = 600 REFRESH = 75029/1000
    ***WIDTH = 1024 HEIGHT = 768 REFRESH = 60000/1000
    ***WIDTH = 1024 HEIGHT = 768 REFRESH = 60000/1000
    ***WIDTH = 1024 HEIGHT = 768 REFRESH = 70069/1000
    ***WIDTH = 1024 HEIGHT = 768 REFRESH = 75029/1000
    ***WIDTH = 1152 HEIGHT = 864 REFRESH = 60000/1000
    ***WIDTH = 1152 HEIGHT = 864 REFRESH = 60000/1000
    ***WIDTH = 1152 HEIGHT = 864 REFRESH = 75000/1000
    ***WIDTH = 1280 HEIGHT = 720 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 720 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 720 REFRESH = 60000/1001
    ***WIDTH = 1280 HEIGHT = 768 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 768 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 800 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 800 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 960 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 960 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 1024 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 1024 REFRESH = 60000/1000
    ***WIDTH = 1280 HEIGHT = 1024 REFRESH = 75025/1000
    ***WIDTH = 1360 HEIGHT = 768 REFRESH = 60000/1000
    ***WIDTH = 1360 HEIGHT = 768 REFRESH = 60000/1000
    ***WIDTH = 1600 HEIGHT = 1200 REFRESH = 60000/1000
    
  7. Experiment with modifying the viewport settings to draw the scene into a subrectangle of the back buffer. For example, try:

    D3D10_VIEWPORT vp;
        vp.TopLeftX = 100;
        vp.TopLeftY = 100;
        vp.Width    = 400;
        vp.Height   = 300;
        vp.MinDepth = 0.0f;
        vp.MaxDepth = 1.0f;
    
posted on 2010-09-20 02:42  Sean You  阅读(296)  评论(0编辑  收藏  举报