GteGL4InputLayoutManager.cpp
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.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
9 #include <LowLevel/GteLogger.h>
11 using namespace gte;
12 
14 {
15  if (mMap.HasElements())
16  {
17  LogWarning("Input layout map is not empty on destruction.");
18  UnbindAll();
19  }
20 }
21 
23 {
24 }
25 
27  GLuint vbufferHandle, VertexBuffer const* vbuffer)
28 {
29  std::shared_ptr<GL4InputLayout> layout;
30  if (programHandle)
31  {
32  if (vbuffer)
33  {
34  if (!mMap.Get(std::make_pair(vbuffer, programHandle), layout))
35  {
36  layout = std::make_shared<GL4InputLayout>(programHandle, vbufferHandle, vbuffer);
37  mMap.Insert(std::make_pair(vbuffer, programHandle), layout);
38  }
39  }
40  // else: A null vertex buffer is passed when an effect wants to
41  // bypass the input assembler.
42  }
43  else
44  {
45  LogError("Program must exist.");
46  }
47  return layout.get();
48 }
49 
51 {
52  if (vbuffer)
53  {
54  std::vector<VBPPair> matches;
55  mMap.GatherMatch(vbuffer, matches);
56  for (auto match : matches)
57  {
58  std::shared_ptr<GL4InputLayout> layout;
59  mMap.Remove(match, layout);
60  }
61  return true;
62  }
63  else
64  {
65  LogError("Vertex buffer must be nonnull.");
66  return false;
67  }
68 }
69 
71 {
72  return true;
73 }
74 
76 {
77  mMap.RemoveAll();
78 }
79 
81 {
82  return mMap.HasElements();
83 }
84 
86 {
87 }
88 
90 {
91 }
92 
94  VertexBuffer const* vbuffer, std::vector<VBPPair>& matches)
95 {
96  mMutex.lock();
97  {
98  for (auto vbp : mMap)
99  {
100  if (vbuffer == vbp.first.first)
101  {
102  matches.push_back(vbp.first);
103  }
104  }
105  }
106  mMutex.unlock();
107 }
virtual bool Unbind(VertexBuffer const *vbuffer) override
void Insert(Key key, Value value)
unsigned int GLuint
Definition: glcorearb.h:89
bool Get(Key key, Value &value) const
bool Remove(Key key, Value &value)
#define LogError(message)
Definition: GteLogger.h:92
#define LogWarning(message)
Definition: GteLogger.h:95
GL4InputLayout * Bind(GLuint programHandle, GLuint vbufferHandle, VertexBuffer const *vbuffer)
virtual bool HasElements() const override
void GatherMatch(VertexBuffer const *vbuffer, std::vector< VBPPair > &matches)
bool HasElements() const


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