GteVertexBuffer.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.1 (2016/11/28)
7 
8 #pragma once
9 
10 #include <Graphics/GteBuffer.h>
12 
13 namespace gte
14 {
15 
16 class StructuredBuffer;
17 
19 {
20 public:
21  // This constructor is for standard usage where the vertex buffer is
22  // used by the rasterizer to provide vertices to the vertex shader.
23  VertexBuffer(VertexFormat const& vformat, unsigned int numVertices,
24  bool createStorage = true);
25 
26  // This constructor is used for vertex-id-based drawing where the vertices
27  // are read from a structured buffer resource in the vertex shader. The
28  // input 'sbuffer' must be nonnull and its number of vertices is copied
29  // to 'this' number of vertices.
30  VertexBuffer(VertexFormat const& vformat,
31  std::shared_ptr<StructuredBuffer> const& sbuffer);
32 
33  // This constructor is used for vertex-id-based drawing that does not
34  // require vertices; for example, the shader itself can generate the
35  // positions from the identifiers.
36  VertexBuffer(unsigned int numVertices);
37 
38  // Member access. The function StandardUsage() returns 'true' when the
39  // first constructor is used or 'false' when the second constructor is
40  // used.
41  inline VertexFormat const& GetFormat() const;
42  inline std::shared_ptr<StructuredBuffer> const& GetSBuffer() const;
43  inline bool StandardUsage() const;
44 
45  // Get pointers to attribute data if it exists for the specified semantic
46  // and unit. Also, you request that the attribute be one of a list of
47  // required types (OR-ed bit flags). If you do not care about the type,
48  // pass DF_UNKNOWN for the required input. If the request fails, a null
49  // pointer is returned.
50  char* GetChannel(VASemantic semantic, unsigned int unit,
51  std::set<DFType> const& requiredTypes);
52 
53 protected:
55 
56  // Valid when the second constructor is used.
57  std::shared_ptr<StructuredBuffer> mSBuffer;
58 };
59 
60 
62 {
63  return mVFormat;
64 }
65 
66 inline bool VertexBuffer::StandardUsage() const
67 {
68  return mVFormat.GetNumAttributes() != 0 && mSBuffer == nullptr;
69 }
70 
71 inline std::shared_ptr<StructuredBuffer> const& VertexBuffer::GetSBuffer() const
72 {
73  return mSBuffer;
74 }
75 
76 }
std::shared_ptr< StructuredBuffer > mSBuffer
bool StandardUsage() const
VertexFormat const & GetFormat() const
std::shared_ptr< StructuredBuffer > const & GetSBuffer() const
VertexFormat mVFormat
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:02