src/video/windowsrt/SDL_winrtrenderer.h
author David Ludwig <dludwig@pobox.com>
Tue, 08 Jan 2013 23:11:22 -0500
changeset 8384 bc7a52629e1e
parent 8375 e33eb49b7f42
child 8400 1315402d9028
permissions -rw-r--r--
WinRT: converted tabs to spaces in src/video/windowsrt/*
     1 #pragma once
     2 
     3 #include "DirectXHelper.h"
     4 #include "SDL.h"
     5 
     6 struct VertexPositionColor
     7 {
     8     DirectX::XMFLOAT3 pos;
     9     DirectX::XMFLOAT2 tex;
    10 };
    11 
    12 // Helper class that initializes DirectX APIs for 3D rendering.
    13 ref class SDL_winrtrenderer
    14 {
    15 internal:
    16     SDL_winrtrenderer();
    17 
    18 public:
    19     virtual ~SDL_winrtrenderer();
    20     virtual void Initialize(Windows::UI::Core::CoreWindow^ window);
    21     virtual void HandleDeviceLost();
    22     virtual void CreateDeviceResources();
    23     virtual void CreateWindowSizeDependentResources();
    24     virtual void UpdateForWindowSizeChange();
    25     virtual void Present();
    26     virtual float ConvertDipsToPixels(float dips);
    27 
    28 internal:
    29     virtual void Render(SDL_Surface * surface, SDL_Rect * rects, int numrects);
    30     void ResizeMainTexture(int w, int h);
    31 
    32 protected private:
    33     // Direct3D Objects.
    34     Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
    35     Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
    36     Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
    37     Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
    38     Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
    39     Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
    40     Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
    41     Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
    42     Microsoft::WRL::ComPtr<ID3D11Texture2D> m_mainTexture;
    43     Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_mainTextureResourceView;
    44     Microsoft::WRL::ComPtr<ID3D11SamplerState> m_mainSampler;
    45 
    46     // UpdateWindowSurface helper objects
    47     SDL_Surface * m_mainTextureHelperSurface;
    48 
    49     // Cached renderer properties.
    50     D3D_FEATURE_LEVEL m_featureLevel;
    51     Windows::Foundation::Size m_renderTargetSize;
    52     Windows::Foundation::Rect m_windowBounds;
    53     Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
    54     Windows::Graphics::Display::DisplayOrientations m_orientation;
    55     uint32 m_vertexCount;
    56 
    57     // Transform used for display orientation.
    58     DirectX::XMFLOAT4X4 m_orientationTransform3D;
    59 
    60     // Has the renderer finished loading?
    61     bool m_loadingComplete;
    62 };