1 //
2 //   Copyright 2015 Pixar
3 //
4 //   Licensed under the Apache License, Version 2.0 (the "Apache License")
5 //   with the following modification; you may not use this file except in
6 //   compliance with the Apache License and the following modification to it:
7 //   Section 6. Trademarks. is deleted and replaced with:
8 //
9 //   6. Trademarks. This License does not grant permission to use the trade
10 //      names, trademarks, service marks, or product names of the Licensor
11 //      and its affiliates, except as required to comply with Section 4(c) of
12 //      the License and to reproduce the content of the NOTICE file.
13 //
14 //   You may obtain a copy of the Apache License at
15 //
16 //       http://www.apache.org/licenses/LICENSE-2.0
17 //
18 //   Unless required by applicable law or agreed to in writing, software
19 //   distributed under the Apache License with the above modification is
20 //   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 //   KIND, either express or implied. See the Apache License for the specific
22 //   language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef OPENSUBDIV_EXAMPLES_D3D11_CONTROL_MESH_DISPLAY_H
26 #define OPENSUBDIV_EXAMPLES_D3D11_CONTROL_MESH_DISPLAY_H
27 
28 #include <d3d11.h>
29 #include <opensubdiv/far/topologyLevel.h>
30 
31 class D3D11ControlMeshDisplay {
32 public:
33     D3D11ControlMeshDisplay(ID3D11DeviceContext *deviceContext);
34     ~D3D11ControlMeshDisplay();
35 
36     void Draw(ID3D11Buffer *buffer, int stride,
37               const float *modelViewProjectionMatrix);
38 
39     void SetTopology(OpenSubdiv::Far::TopologyLevel const &level);
40 
GetEdgesDisplay()41     bool GetEdgesDisplay() const { return _displayEdges; }
SetEdgesDisplay(bool display)42     void SetEdgesDisplay(bool display) { _displayEdges = display; }
GetVerticesDisplay()43     bool GetVerticesDisplay() const { return _displayVertices; }
SetVerticesDisplay(bool display)44     void SetVerticesDisplay(bool display) { _displayVertices = display; }
45 
46 private:
47     bool createProgram();
48 
49     bool _displayEdges;
50     bool _displayVertices;
51 
52     ID3D11DeviceContext *_deviceContext;
53     ID3D11InputLayout *_inputLayout;
54     ID3D11VertexShader *_vertexShader;
55     ID3D11PixelShader *_pixelShader;
56     ID3D11RasterizerState *_rasterizerState;
57     ID3D11Buffer *_constantBuffer;
58     ID3D11ShaderResourceView *_edgeSharpnessSRV;
59     ID3D11Buffer *_edgeSharpness;
60     ID3D11Buffer *_edgeIndices;
61 
62     int _numEdges, _numPoints;
63 };
64 
65 #endif  // OPENSUBDIV_EXAMPLES_D3D11_CONTROL_MESH_DISPLAY_H
66