Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Extras / CDTestFramework / AntTweakBar / src / TwDirect3D11.h
1 //  ---------------------------------------------------------------------------\r
2 //\r
3 //  @file       TwDirect3D11.h\r
4 //  @brief      Direct3D11 graphic functions\r
5 //  @author     Philippe Decaudin - http://www.antisphere.com\r
6 //  @license    This file is part of the AntTweakBar library.\r
7 //              For conditions of distribution and use, see License.txt\r
8 //\r
9 //  note:       Private header\r
10 //\r
11 //  ---------------------------------------------------------------------------\r
12 \r
13 \r
14 #if !defined ANT_TW_DIRECT3D11_INCLUDED\r
15 #define ANT_TW_DIRECT3D11_INCLUDED\r
16 \r
17 #include "TwGraph.h"\r
18 \r
19 //  ---------------------------------------------------------------------------\r
20 \r
21 class CTwGraphDirect3D11 : public ITwGraph\r
22 {\r
23 public:\r
24     virtual int                 Init();\r
25     virtual int                 Shut();\r
26     virtual void                BeginDraw(int _WndWidth, int _WndHeight);\r
27     virtual void                EndDraw();\r
28     virtual bool                IsDrawing();\r
29     virtual void                Restore();\r
30     virtual void                DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color0, color32 _Color1, bool _AntiAliased=false);\r
31     virtual void                DrawLine(int _X0, int _Y0, int _X1, int _Y1, color32 _Color, bool _AntiAliased=false) { DrawLine(_X0, _Y0, _X1, _Y1, _Color, _Color, _AntiAliased); }\r
32     virtual void                DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color00, color32 _Color10, color32 _Color01, color32 _Color11);\r
33     virtual void                DrawRect(int _X0, int _Y0, int _X1, int _Y1, color32 _Color) { DrawRect(_X0, _Y0, _X1, _Y1, _Color, _Color, _Color, _Color); }\r
34     virtual void                DrawTriangles(int _NumTriangles, int *_Vertices, color32 *_Colors, Cull _CullMode);\r
35 \r
36     virtual void *              NewTextObj();\r
37     virtual void                DeleteTextObj(void *_TextObj);\r
38     virtual void                BuildText(void *_TextObj, const std::string *_TextLines, color32 *_LineColors, color32 *_LineBgColors, int _NbLines, const CTexFont *_Font, int _Sep, int _BgWidth);\r
39     virtual void                DrawText(void *_TextObj, int _X, int _Y, color32 _Color, color32 _BgColor);\r
40 \r
41     virtual void                ChangeViewport(int _X0, int _Y0, int _Width, int _Height, int _OffsetX, int _OffsetY);\r
42     virtual void                RestoreViewport();\r
43     virtual void                SetScissor(int _X0, int _Y0, int _Width, int _Height);\r
44 \r
45 protected:\r
46     struct ID3D11Device *       m_D3DDev;\r
47     struct ID3D11DeviceContext *m_D3DDevImmContext;\r
48     unsigned int                m_D3DDevInitialRefCount;\r
49     bool                        m_Drawing;\r
50     const CTexFont *            m_FontTex;\r
51     struct ID3D11Texture2D *    m_FontD3DTex;\r
52     struct ID3D11ShaderResourceView *m_FontD3DTexRV;\r
53     int                         m_WndWidth;\r
54     int                         m_WndHeight;\r
55     int                         m_OffsetX;\r
56     int                         m_OffsetY;\r
57     void *                      m_ViewportInit;\r
58     RECT                        m_ViewportAndScissorRects[2];\r
59 \r
60     struct CLineRectVtx\r
61     {\r
62         float                   m_Pos[3];\r
63         color32                 m_Color;\r
64     };\r
65     struct CTextVtx\r
66     {\r
67         float                   m_Pos[3];\r
68         color32                 m_Color;\r
69         float                   m_UV[2];\r
70     };\r
71     struct CConstants\r
72     {\r
73         float                   m_Offset[4];\r
74         float                   m_CstColor[4];\r
75     };\r
76 \r
77     struct CTextObj\r
78     {\r
79         struct ID3D11Buffer *   m_TextVertexBuffer;\r
80         struct ID3D11Buffer *   m_BgVertexBuffer;\r
81         int                     m_NbTextVerts;\r
82         int                     m_NbBgVerts;\r
83         int                     m_TextVertexBufferSize;\r
84         int                     m_BgVertexBufferSize;\r
85         bool                    m_LineColors;\r
86         bool                    m_LineBgColors;\r
87     };\r
88 \r
89     struct CState11 *               m_State;\r
90     struct ID3D11DepthStencilState *m_DepthStencilState;\r
91     struct ID3D11BlendState *       m_BlendState;\r
92     struct ID3D11RasterizerState *  m_RasterState;\r
93     struct ID3D11RasterizerState *  m_RasterStateAntialiased;\r
94     struct ID3D11RasterizerState *  m_RasterStateMultisample;\r
95     struct ID3D11RasterizerState *  m_RasterStateCullCW;\r
96     struct ID3D11RasterizerState *  m_RasterStateCullCCW;\r
97 \r
98     struct ID3D11VertexShader *     m_LineRectVS;\r
99     struct ID3D11VertexShader *     m_LineRectCstColorVS;\r
100     struct ID3D11PixelShader *      m_LineRectPS;\r
101     struct ID3D11InputLayout *      m_LineRectVertexLayout;\r
102     struct ID3D11VertexShader *     m_TextVS;\r
103     struct ID3D11VertexShader *     m_TextCstColorVS;\r
104     struct ID3D11PixelShader *      m_TextPS;\r
105     struct ID3D11InputLayout *      m_TextVertexLayout;\r
106     struct ID3D11Buffer *           m_LineVertexBuffer;\r
107     struct ID3D11Buffer *           m_RectVertexBuffer;\r
108     struct ID3D11Buffer *           m_TrianglesVertexBuffer;\r
109     int                             m_TrianglesVertexBufferCount;\r
110     struct ID3D11Buffer *           m_ConstantBuffer;\r
111     struct ID3D11SamplerState *     m_SamplerState;\r
112 };\r
113 \r
114 //  ---------------------------------------------------------------------------\r
115 \r
116 \r
117 #endif // !defined ANT_TW_DIRECT3D11_INCLUDED\r