| 145 | } |
| 146 | |
| 147 | GEObject* GraphicsEngine::Bind(std::shared_ptr<GraphicsObject> const& object) |
| 148 | { |
| 149 | LogAssert(object != nullptr, "Attempt to bind a null object."); |
| 150 | |
| 151 | mGOMapMutex.lock(); |
| 152 | GraphicsObject const* gtObject = object.get(); |
| 153 | GEObject* geObjectPtr = nullptr; |
| 154 | auto iter = mGOMap.find(gtObject); |
| 155 | if (iter == mGOMap.end()) |
| 156 | { |
| 157 | // The 'create' function is not null with the current engine design. |
| 158 | // If the assertion is triggered, someone changed the hierarchy of |
| 159 | // GraphicsObjectType but did not change msCreateFunctions[] to match. |
| 160 | CreateGEObject create = mCreateGEObject[object->GetType()]; |
| 161 | if (create) |
| 162 | { |
| 163 | auto geObject = create(mGEObjectCreator, gtObject); |
| 164 | LogAssert(geObject != nullptr, "Unexpected condition."); |
| 165 | |
| 166 | iter = mGOMap.insert(std::make_pair(gtObject, geObject)).first; |
| 167 | #if defined(GTE_GRAPHICS_USE_NAMED_OBJECTS) |
| 168 | geObject->SetName(object->GetName()); |
| 169 | #endif |
| 170 | geObjectPtr = iter->second.get(); |
| 171 | } |
| 172 | // else: No logger message is generated here because GL4 does not have |
| 173 | // shader creation functions. |
| 174 | } |
| 175 | else |
| 176 | { |
| 177 | geObjectPtr = iter->second.get(); |
| 178 | } |
| 179 | mGOMapMutex.unlock(); |
| 180 | return geObjectPtr; |
| 181 | } |
| 182 | |
| 183 | GEDrawTarget* GraphicsEngine::Bind(std::shared_ptr<DrawTarget> const& target) |
| 184 | { |
nothing calls this directly
no test coverage detected