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