Blender  V2.93
StrokeRenderer.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
24 #include <algorithm>
25 #include <map>
26 #include <string.h>
27 #include <utility>
28 #include <vector>
29 
30 #include "Stroke.h"
31 #include "StrokeRep.h"
32 
33 #include "../system/FreestyleConfig.h"
34 
35 #ifdef WITH_CXX_GUARDEDALLOC
36 # include "MEM_guardedalloc.h"
37 #endif
38 
39 namespace Freestyle {
40 
41 /**********************************/
42 /* */
43 /* */
44 /* TextureManager */
45 /* */
46 /* */
47 /**********************************/
48 
51  public:
53  virtual ~TextureManager();
54 
56  {
57  return _pInstance;
58  }
59 
60  void load();
61  unsigned getBrushTextureIndex(string name, Stroke::MediumType iType = Stroke::OPAQUE_MEDIUM);
62 
63  inline bool hasLoaded() const
64  {
65  return _hasLoadedTextures;
66  }
67 
68  inline unsigned int getDefaultTextureId() const
69  {
70  return _defaultTextureId;
71  }
72 
73  struct Options {
74  static void setPatternsPath(const string &path);
75  static string getPatternsPath();
76 
77  static void setBrushesPath(const string &path);
78  static string getBrushesPath();
79  };
80 
81  protected:
82  virtual void loadStandardBrushes() = 0;
83  virtual unsigned loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM) = 0;
84 
85  typedef std::pair<string, Stroke::MediumType> BrushTexture;
86  struct cmpBrushTexture {
87  bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const
88  {
89  int r = strcmp(bt1.first.c_str(), bt2.first.c_str());
90  if (r != 0) {
91  return (r < 0);
92  }
93  else {
94  return (bt1.second < bt2.second);
95  }
96  }
97  };
98  typedef std::map<BrushTexture, unsigned, cmpBrushTexture> brushesMap;
99 
103  static string _patterns_path;
104  static string _brushes_path;
105  unsigned int _defaultTextureId;
106 
107 #ifdef WITH_CXX_GUARDEDALLOC
108  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:TextureManager")
109 #endif
110 };
111 
112 /**********************************/
113 /* */
114 /* */
115 /* StrokeRenderer */
116 /* */
117 /* */
118 /**********************************/
119 
123  public:
124  virtual ~StrokeRenderer();
125 
127  virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const = 0;
128  virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const = 0;
129 
130  // initializes the texture manager
131  // lazy, checks if it has already been done
132  static bool loadTextures();
133 
134  // static unsigned int getTextureIndex(unsigned int index);
136 
137 #ifdef WITH_CXX_GUARDEDALLOC
138  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRenderer")
139 #endif
140 };
141 
142 } /* 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
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:32
static void setPatternsPath(const string &path)
static void setBrushesPath(const string &path)
bool operator()(const BrushTexture &bt1, const BrushTexture &bt2) const