32 #ifndef VectorGraphics_INCLUDE_ONCE 33 #define VectorGraphics_INCLUDE_ONCE 116 ImageState(
const Image* img, ETextureMode mode): mImage(img), mTextureMode(mode) {}
118 bool operator<(
const ImageState& other)
const 120 if (mImage != other.mImage)
121 return mImage < other.mImage;
123 if (mTextureMode != other.mTextureMode)
124 return mTextureMode < other.mTextureMode;
130 ETextureMode mTextureMode;
144 mPointSmoothing=
true;
145 mLineSmoothing =
true;
146 mPolygonSmoothing =
false;
148 mLineStipple = 0xFFFF;
149 memset(mPolyStipple, 0xFF, 32*32/8);
160 mAlphaFuncRefValue = 0.0f;
166 mColorMask =
ivec4(1,1,1,1);
168 mStencilMask = 0xFFFFFFFF;
169 mStencilTestEnabled =
false;
174 mStencil_RefValue = 0;
175 mStencil_FunctionMask = ~(
unsigned int)0;
181 ETextureMode mTextureMode;
184 bool mPointSmoothing;
186 bool mPolygonSmoothing;
187 unsigned short mLineStipple;
188 unsigned char mPolyStipple[32*32/8];
195 float mAlphaFuncRefValue;
201 bool mStencilTestEnabled;
202 unsigned int mStencilMask;
207 int mStencil_RefValue;
208 unsigned int mStencil_FunctionMask;
210 bool operator<(
const State& other)
const 213 if (mColor.
r() != other.mColor.r())
214 return mColor.
r() < other.mColor.r();
216 if (mColor.
g() != other.mColor.g())
217 return mColor.
g() < other.mColor.g();
219 if (mColor.
b() != other.mColor.b())
220 return mColor.
b() < other.mColor.b();
222 if (mColor.
a() != other.mColor.a())
223 return mColor.
a() < other.mColor.a();
225 if(mPointSize != other.mPointSize)
226 return mPointSize < other.mPointSize;
228 if(mImage != other.mImage)
229 return mImage < other.mImage;
231 if (mTextureMode != other.mTextureMode)
232 return mTextureMode < other.mTextureMode;
234 if (mPolygonSmoothing != other.mPolygonSmoothing)
235 return mPolygonSmoothing < other.mPolygonSmoothing;
237 if (mPointSmoothing!= other.mPointSmoothing)
238 return mPointSmoothing < other.mPointSmoothing;
240 if (mLineSmoothing!= other.mLineSmoothing)
241 return mLineSmoothing < other.mLineSmoothing;
243 if (mLineWidth != other.mLineWidth)
244 return mLineWidth < other.mLineWidth;
246 if (mLineStipple != other.mLineStipple)
247 return mLineStipple < other.mLineStipple;
249 if (mLogicOp != other.mLogicOp)
250 return mLogicOp < other.mLogicOp;
252 if ( memcmp(mPolyStipple, other.mPolyStipple, 32*32/8) != 0 )
253 return memcmp(mPolyStipple, other.mPolyStipple, 32*32/8) < 0;
255 if ( mBlendEquationRGB != other.mBlendEquationRGB)
256 return mBlendEquationRGB < other.mBlendEquationRGB;
258 if ( mBlendEquationAlpha != other.mBlendEquationAlpha)
259 return mBlendEquationAlpha < other.mBlendEquationAlpha;
261 if ( mBlendFactorSrcRGB != other.mBlendFactorSrcRGB)
262 return mBlendFactorSrcRGB < other.mBlendFactorSrcRGB;
264 if ( mBlendFactorDstRGB != other.mBlendFactorDstRGB)
265 return mBlendFactorDstRGB < other.mBlendFactorDstRGB;
267 if ( mBlendFactorSrcAlpha != other.mBlendFactorSrcAlpha)
268 return mBlendFactorSrcAlpha < other.mBlendFactorSrcAlpha;
270 if ( mBlendFactorDstAlpha != other.mBlendFactorDstAlpha)
271 return mBlendFactorDstAlpha < other.mBlendFactorDstAlpha;
273 if ( mAlphaFuncRefValue != other.mAlphaFuncRefValue)
274 return mAlphaFuncRefValue < other.mAlphaFuncRefValue;
276 if ( mAlphaFunc != other.mAlphaFunc)
277 return mAlphaFunc < other.mAlphaFunc;
279 if ( mFont != other.mFont)
280 return mFont < other.mFont;
285 if ( mColorMask.
r() != other.mColorMask.r())
286 return mColorMask.
r() < other.mColorMask.r();
288 if ( mColorMask.
g() != other.mColorMask.g())
289 return mColorMask.
g() < other.mColorMask.g();
291 if ( mColorMask.
b() != other.mColorMask.b())
292 return mColorMask.
b() < other.mColorMask.b();
294 if ( mColorMask.
a() != other.mColorMask.a())
295 return mColorMask.
a() < other.mColorMask.a();
297 if ( mStencilMask != other.mStencilMask)
298 return mStencilMask < other.mStencilMask;
300 if ( mStencilTestEnabled != other.mStencilTestEnabled)
301 return mStencilTestEnabled < other.mStencilTestEnabled;
303 if ( mStencil_SFail != other.mStencil_SFail )
304 return mStencil_SFail < other.mStencil_SFail;
306 if ( mStencil_DpFail != other.mStencil_DpFail )
307 return mStencil_DpFail < other.mStencil_DpFail;
309 if ( mStencil_DpPass != other.mStencil_DpPass )
310 return mStencil_DpPass < other.mStencil_DpPass;
312 if ( mStencil_Function != other.mStencil_Function )
313 return mStencil_Function < other.mStencil_Function;
315 if ( mStencil_RefValue != other.mStencil_RefValue )
316 return mStencil_RefValue < other.mStencil_RefValue;
318 if ( mStencil_FunctionMask != other.mStencil_FunctionMask )
319 return mStencil_FunctionMask < other.mStencil_FunctionMask;
336 Actor* drawLine(
double x1,
double y1,
double x2,
double y2);
339 Actor* drawLines(
const std::vector<dvec2>& ln);
342 Actor* drawLineStrip(
const std::vector<dvec2>& ln);
345 Actor* drawLineLoop(
const std::vector<dvec2>& ln);
348 Actor* fillPolygon(
const std::vector<dvec2>& poly);
351 Actor* fillTriangles(
const std::vector<dvec2>& triangles);
354 Actor* fillTriangleFan(
const std::vector<dvec2>& fan);
357 Actor* fillTriangleStrip(
const std::vector<dvec2>& strip);
360 Actor* fillQuads(
const std::vector<dvec2>& quads);
363 Actor* fillQuadStrip(
const std::vector<dvec2>& quad_strip);
366 Actor* drawPoint(
double x,
double y);
369 Actor* drawPoints(
const std::vector<dvec2>& pt);
372 Actor* drawEllipse(
double origx,
double origy,
double xaxis,
double yaxis,
int segments = 64);
375 Actor* fillEllipse(
double origx,
double origy,
double xaxis,
double yaxis,
int segments = 64);
378 Actor* drawQuad(
double left,
double bottom,
double right,
double top);
381 Actor* fillQuad(
double left,
double bottom,
double right,
double top);
389 void continueDrawing();
393 void endDrawing(
bool release_cache=
true);
459 void setLineStipple(ELineStipple stipple) ;
465 unsigned short lineStipple()
const {
return mState.mLineStipple; }
468 void setPolygonStipple(EPolygonStipple stipple);
471 void setPolygonStipple(
unsigned char* stipple) { memcpy(mState.mPolyStipple, stipple, 32*32/8); }
483 void getAlphaFunc(
EFunction& func,
float& ref_value)
const { ref_value=mState.mAlphaFuncRefValue; func=mState.mAlphaFunc; }
498 void setColorMask(
bool r,
bool g,
bool b,
bool a) { mState.mColorMask =
ivec4(r?1:0,g?1:0,b?1:0,a?1:0); }
525 void setStencilFunc(
EFunction func,
int refval,
unsigned int mask);
528 void getStencilFunc(
EFunction& func,
int& refval,
unsigned int& mask);
540 const Font*
font()
const {
return mState.mFont.get(); }
548 mScissor = resolveScissor(x,y,width,height);
564 Actor* clearColor(
const fvec4& color,
int x=0,
int y=0,
int w=-1,
int h=-1);
570 Actor* clearStencil(
int clear_val,
int x=0,
int y=0,
int w=-1,
int h=-1);
601 void rotate(
double deg);
604 void translate(
double x,
double y,
double z=0.0);
607 void scale(
double x,
double y,
double z=1.0);
616 const std::vector<dmat4>&
matrixStack()
const {
return mMatrixStack; }
629 void pushScissor(
int x,
int y,
int w,
int h);
635 const std::vector< ref<Scissor> >&
scissorStack()
const {
return mScissorStack; }
638 void setTransform(
Transform* transform) {
for(
int i=0; i<actors()->size(); ++i) actors()->at(i)->setTransform(transform); }
644 void generateQuadsTexCoords(
Geometry* geom,
const std::vector<dvec2>& points);
646 void generatePlanarTexCoords(
Geometry* geom,
const std::vector<dvec2>& points);
648 void generateLinearTexCoords(
Geometry* geom);
652 ref<Geometry> prepareGeometryPolyToTriangles(
const std::vector<dvec2>& ln);
654 Scissor* resolveScissor(
int x,
int y,
int width,
int height);
658 Effect* currentEffect(
const State& vgs);
667 std::vector<State> mStateStack;
668 std::vector<dmat4> mMatrixStack;
669 std::vector< ref<Scissor> > mScissorStack;
671 std::map<State, ref<Effect> > mVGToEffectMap;
672 std::map<ImageState, ref<Texture> > mImageToTextureMap;
673 std::map<RectI, ref<Scissor> > mRectToScissorMap;
void setLineSmoothing(bool smooth)
The current line smoothing mode.
Associates a Renderable object to an Effect and Transform.
int pointSize() const
The current point size.
unsigned short lineStipple() const
The current line stipple.
const fvec4 & color() const
The current color. Note that the current color also modulates the currently active image...
bool pointSmoothing() const
The current point smoothing mode.
bool lineSmoothing() const
The current line smoothing mode.
The texture is repeated over the primitive.
ActorCollection * actors()
Returns the list of Actor[s] generated by a VectorGraphics object.
void pushMatrix()
Pushes the current matrix in the matrix stack in order to restore it later with popMatrix().
void setColor(const fvec4 &color)
The current color. Note that the current color also modulates the currently active image...
A Renderable that renders text with a given Font.
void setLineWidth(float width)
The current line width, see also http://www.opengl.org/sdk/docs/man/xhtml/glLineWidth.xml for more information.
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
void startDrawing()
Starts the drawing process.
A font to be used with a Text renderable.
void setPointSmoothing(bool smooth)
The current point smoothing mode.
const T_Scalar & r() const
void setFont(const Font *font)
Sets the current Font.
Font * acquireFont(const String &font, int size, bool smooth=false)
Creates or returns an already created Font.
bool polygonSmoothing() const
The current polygon smoothing mode.
void setPolygonStipple(unsigned char *stipple)
The current polygon stipple.
The poligon is completely filled (default)
const unsigned char * polygonStipple() const
The current polygon stipple.
void removeScissor()
Disables the Scissor test and clipping.
Wraps an OpenGL texture object representing and managing all the supported texture types...
void setStencilMask(unsigned int mask)
Current stencil mask, see also http://www.opengl.org/sdk/docs/man/xhtml/glStencilMask.xml for more information.
void resetMatrix()
Resets the current transform matrix.
ETextureMode textureMode() const
The current texture mode.
ELineStipple
Line stipple patterns.
void setPointSize(int size)
The current point size.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
The texture is stretched over the primitive.
unsigned int stencilMask() const
Current stencil mask.
void setPolygonSmoothing(bool smooth)
The current polygon smoothing mode.
const Font * font() const
Returns the current Font.
void setPoint(Image *image)
Utility function equivalent to 'setImage(image); setPointSize(image->width());'.
Effect * currentEffect()
Returns the Effect representing the current VectorGraphic's state.
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
void setScissor(int x, int y, int width, int height)
Defines the scissor box and enables the scissor test.
void getAlphaFunc(EFunction &func, float &ref_value) const
The current alpha function.
Visualization Library main namespace.
int size() const
The size of the font.
float lineWidth() const
The current line width.
void setImage(Image *image)
The current image used to texture the rendered objects. Note that the current color also modulates th...
const T_Scalar & g() const
Vector4< int > ivec4
A 4 components vector with int precision.
The line is completely filled (default)
const std::vector< ref< Scissor > > & scissorStack() const
Returns the scissor stack.
The base class for all the reference counted objects.
void setStencilTestEnabled(bool enabled)
If set to 'true' the stencil test and operations will be enabled.
const std::vector< dmat4 > & matrixStack() const
Returns the matrix stack.
void setLineStipple(unsigned short stipple)
The current line stipple.
const String & filePath() const
The font's file path.
void setMatrix(const dmat4 &matrix)
Sets the current transform matrix.
const ivec4 & colorMask() const
The current color mask.
void setAlphaFunc(EFunction func, float ref_value)
The current alpha function, see also http://www.opengl.org/sdk/docs/man/xhtml/glAlphaFunc.xml for more information.
const T_Scalar & b() const
void setTransform(Transform *transform)
Binds the given Transform to all the Actor[s] that have been generated so far.
const ActorCollection * actors() const
Returns the list of Actor[s] generated by a VectorGraphics object.
unsigned char * polygonStipple()
The current polygon stipple.
Defines the sequence of Shader objects used to render an Actor.
void setColorMask(bool r, bool g, bool b, bool a)
The current color mask, see also http://www.opengl.org/sdk/docs/man/xhtml/glColorMask.xml for more information.
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
const dmat4 & matrix() const
Returns the current transform matrix.
bool smooth() const
Whether the font rendering should use linear filtering or not.
EPolygonStipple
Poligon stipple patterns.
void setLogicOp(ELogicOp op)
The current logic operation, see also http://www.opengl.org/sdk/docs/man/xhtml/glLogicOp.xml for more information.
void setDefaultFont()
Sets the default Font.
ELogicOp logicOp() const
The current logic operation.
const Scissor * scissor() const
Returns the currently active Scissor.
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
The ref<> class is used to reference-count an Object.
The VectorGraphics class is used in conjuction with SceneManagerVectorGraphics to generate and render...
The Scissor class wraps the OpenGL function glScissor(), see http://www.opengl.org/sdk/docs/man/xhtml...
void setFont(const String &name, int size, bool smooth=false)
Sets the current Font.
void setTextureMode(ETextureMode mode)
The current texture mode.
bool stencilTestEnabled() const
If set to 'true' the stencil test and operations will be enabled.
const Image * image() const
The current image used to texture the rendered objects. Note that the current color also modulates th...
Image * image()
The current image used to texture the rendered objects. Note that the current color also modulates th...
ETextureMode
Defines how the texture is applied to the rendering primitive.
VLGRAPHICS_EXPORT FontManager * defFontManager()
Returns the default FontManager used by Visualization Library.
const T_Scalar & a() const