Blender  V3.3
StrokeRenderer.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include "StrokeRenderer.h"
9 
10 #include "../geometry/GeomUtils.h"
11 
12 using namespace std;
13 
14 namespace Freestyle {
15 
16 /**********************************/
17 /* */
18 /* */
19 /* StrokeRenderer */
20 /* */
21 /* */
22 /**********************************/
23 
24 TextureManager *StrokeRenderer::_textureManager = nullptr;
25 
26 StrokeRenderer::~StrokeRenderer() = default;
27 
28 bool StrokeRenderer::loadTextures()
29 {
30  _textureManager->load();
31  return true;
32 }
33 
34 /**********************************/
35 /* */
36 /* */
37 /* TextureManager */
38 /* */
39 /* */
40 /**********************************/
41 
42 TextureManager *TextureManager::_pInstance = nullptr;
43 
44 string TextureManager::_patterns_path;
45 
46 string TextureManager::_brushes_path;
47 
48 TextureManager::TextureManager()
49 {
50  _hasLoadedTextures = false;
51  _pInstance = this;
52  _defaultTextureId = 0;
53 }
54 
55 TextureManager::~TextureManager()
56 {
57  if (!_brushesMap.empty()) {
58  _brushesMap.clear();
59  }
60  _pInstance = nullptr;
61 }
62 
63 void TextureManager::load()
64 {
65  if (_hasLoadedTextures) {
66  return;
67  }
68  loadStandardBrushes();
69  _hasLoadedTextures = true;
70 }
71 
72 unsigned TextureManager::getBrushTextureIndex(string name, Stroke::MediumType iType)
73 {
74  BrushTexture bt(name, iType);
75  brushesMap::iterator b = _brushesMap.find(bt);
76  if (b == _brushesMap.end()) {
77  unsigned texId = loadBrush(name, iType);
78  _brushesMap[bt] = texId;
79  return texId;
80  // XXX!
81  cerr << "brush file " << name << " not found" << endl;
82  return 0;
83  }
84 
85  return _brushesMap[bt];
86 }
87 
88 void TextureManager::Options::setPatternsPath(const string &path)
89 {
90  _patterns_path = path;
91 }
92 
93 string TextureManager::Options::getPatternsPath()
94 {
95  return _patterns_path;
96 }
97 
98 void TextureManager::Options::setBrushesPath(const string &path)
99 {
100  _brushes_path = path;
101 }
102 
103 string TextureManager::Options::getBrushesPath()
104 {
105  return _brushes_path;
106 }
107 
108 } /* namespace Freestyle */
Classes to render a stroke with OpenGL.
std::pair< string, Stroke::MediumType > BrushTexture
inherits from class Rep
Definition: AppCanvas.cpp:18
static const pxr::TfToken b("b", pxr::TfToken::Immortal)