Blender  V3.3
StrokeRenderer.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <algorithm>
11 #include <map>
12 #include <string.h>
13 #include <utility>
14 #include <vector>
15 
16 #include "Stroke.h"
17 #include "StrokeRep.h"
18 
19 #include "../system/FreestyleConfig.h"
20 
21 #ifdef WITH_CXX_GUARDEDALLOC
22 # include "MEM_guardedalloc.h"
23 #endif
24 
25 namespace Freestyle {
26 
27 /**********************************/
28 /* */
29 /* */
30 /* TextureManager */
31 /* */
32 /* */
33 /**********************************/
34 
37  public:
39  virtual ~TextureManager();
40 
42  {
43  return _pInstance;
44  }
45 
46  void load();
47  unsigned getBrushTextureIndex(string name, Stroke::MediumType iType = Stroke::OPAQUE_MEDIUM);
48 
49  inline bool hasLoaded() const
50  {
51  return _hasLoadedTextures;
52  }
53 
54  inline unsigned int getDefaultTextureId() const
55  {
56  return _defaultTextureId;
57  }
58 
59  struct Options {
60  static void setPatternsPath(const string &path);
61  static string getPatternsPath();
62 
63  static void setBrushesPath(const string &path);
64  static string getBrushesPath();
65  };
66 
67  protected:
68  virtual void loadStandardBrushes() = 0;
69  virtual unsigned loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM) = 0;
70 
71  typedef std::pair<string, Stroke::MediumType> BrushTexture;
72  struct cmpBrushTexture {
73  bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const
74  {
75  int r = strcmp(bt1.first.c_str(), bt2.first.c_str());
76  if (r != 0) {
77  return (r < 0);
78  }
79  else {
80  return (bt1.second < bt2.second);
81  }
82  }
83  };
84  typedef std::map<BrushTexture, unsigned, cmpBrushTexture> brushesMap;
85 
89  static string _patterns_path;
90  static string _brushes_path;
91  unsigned int _defaultTextureId;
92 
93 #ifdef WITH_CXX_GUARDEDALLOC
94  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:TextureManager")
95 #endif
96 };
97 
98 /**********************************/
99 /* */
100 /* */
101 /* StrokeRenderer */
102 /* */
103 /* */
104 /**********************************/
105 
109  public:
110  virtual ~StrokeRenderer();
111 
113  virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const = 0;
114  virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const = 0;
115 
116  // initializes the texture manager
117  // lazy, checks if it has already been done
118  static bool loadTextures();
119 
120  // static unsigned int getTextureIndex(unsigned int index);
122 
123 #ifdef WITH_CXX_GUARDEDALLOC
124  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRenderer")
125 #endif
126 };
127 
128 } /* namespace Freestyle */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
Read Guarded memory(de)allocation.
Class to define the representation of a stroke (for display purpose)
Classes to define a stroke.
static TextureManager * _textureManager
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const =0
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const =0
static string _patterns_path
unsigned int _defaultTextureId
std::map< BrushTexture, unsigned, cmpBrushTexture > brushesMap
static TextureManager * getInstance()
virtual unsigned loadBrush(string fileName, Stroke::MediumType=Stroke::OPAQUE_MEDIUM)=0
unsigned int getDefaultTextureId() const
virtual void loadStandardBrushes()=0
static TextureManager * _pInstance
std::pair< string, Stroke::MediumType > BrushTexture
unsigned getBrushTextureIndex(string name, Stroke::MediumType iType=Stroke::OPAQUE_MEDIUM)
inherits from class Rep
Definition: AppCanvas.cpp:18
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)
bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const