Free Electron
DrawI.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __draw_DrawI_h__
8 #define __draw_DrawI_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Generalized drawing of points, lines, text, and basic triangles
17 
18  @ingroup draw
19 *//***************************************************************************/
20 class FE_DL_EXPORT DrawI:
21  virtual public Component,
22  public CastableAs<DrawI>
23 {
24  public:
25  /// @brief Format of vertices for tri-stripping
26  enum StripMode
27  {
28  e_discrete,
29  e_strip,
30  e_fan,
31  e_triple
32  };
33  enum MatrixMode
34  {
35  e_modelview,
36  e_projection,
37  e_texture,
38  e_color
39  };
40 
41  /// @brief Set rendering mode
42 virtual void setDrawMode(sp<DrawMode> mode) =0;
43 
44  /// @brief Get rendering mode
45 virtual sp<DrawMode> drawMode(void) const =0;
46 
47  /// @brief Push rendering mode onto stack
48 virtual void pushDrawMode(sp<DrawMode> mode) =0;
49 
50  /// @brief Pop rendering mode from stack
51 virtual sp<DrawMode> popDrawMode(void) =0;
52 
53  /// @brief Push transform matrices
54 virtual void pushMatrixState(void) =0;
55 
56  /// @brief Pop transform matrices
57 virtual void popMatrixState(void) =0;
58 
59  /// @brief push a new 4x4 matrix on a particular stack
60 virtual void pushMatrix(MatrixMode a_mode,Real a_values[16]) =0;
61  /// @brief pop the top 4x4 matrix from a particular stack
62 virtual void popMatrix(MatrixMode a_mode) =0;
63 
64  /// @brief currently, sets vertex array to zero in OpenGL
65 virtual void unbindVertexArray(void) =0;
66 
67  /// @brief set additive lightening
68 virtual void setBrightness(Real a_brightness) =0;
69  /// @brief get lightening
70 virtual Real brightness(void) =0;
71 
72  /// @brief set multiplicitive light scaling
73 virtual void setContrast(Real a_contrast) =0;
74  /// @brief get light scaling
75 virtual Real contrast(void) =0;
76 
77  /** @brief Returns TRUE is display is local and
78  rendered directly */
79 virtual BWORD isDirect(void) const =0;
80 
81  /** @brief Set next DrawI in a chain
82 
83  If this DrawI is designed to pass drawing commands
84  to another DrawI, such as for conversion or caching,
85  this commands specifies that next component.
86 
87  Any implementation may ignore this request. */
88 virtual void setDrawChain(sp<DrawI> a_spDrawI) =0;
89 virtual sp<DrawI> drawChain(void) =0;
90 
91  /** @brief Impose a spatial translation
92 
93  If supported, this adjusts the output in an
94  implementation-specific manner.
95 
96  Any implementation may ignore this request
97  or just use part of the transform,
98  such as translation only. */
99 virtual void setTransform(const SpatialTransform& a_rTransform) =0;
100 
101  /** @brief Called once after each frame
102 
103  This shifts data access to freeze the current input
104  buffer and prepare a new empty input buffer.
105 
106  The resulting output buffer is sent on to the
107  next DrawI interface. */
108 virtual void flush(void) =0;
109 
110  /** @brief Pass on current input data as is
111 
112  This sends the current input to the
113  next DrawI interface without shifting buffers.
114  The same input can still be written to afterwards. */
115 virtual void flushLive(void) =0;
116 
117  /// @brief Reset the current input queue
118 virtual void clearInput(void) =0;
119 
120  /// @brief Returns TRUE if the current input queue is empty
121 virtual BWORD empty(void) const =0;
122 
123  /// @brief Set current view
124 virtual void setView(sp<ViewI> spViewI) =0;
125 
126  /// @brief Get current view
127 virtual sp<ViewI> view(void) const =0;
128 
129  /// @brief Get current font
130 virtual sp<FontI> font(void) =0;
131 
132  /** @brief Select the GL-specific index/handle
133 
134  An index of 0 indicates no font. */
135 //~virtual void setFontBase(U32 index) =0;
136 //~virtual I32 fontHeight(I32* pAscent,I32* pDescent) =0;
137 //~virtual I32 pixelWidth(String string) =0;
138 
139  /// @brief upscaling preference, such as for high DPI
140 virtual Real multiplication(void) =0;
141 
142  /** @brief Draw points vertex[vertices].
143 
144  The array @em vertex is assumed to contain @em vertices
145  elements.
146  If @em multicolor, points are independently colored
147  with color[vertices], else only color[0] is used.
148  If @em color is NULL, no colors are specified,
149  so the current color state is left in effect. */
150 virtual void drawPoints(const SpatialVector *vertex,
151  const SpatialVector *normal,U32 vertices,
152  BWORD multicolor,const Color *color) =0;
153 virtual void drawPoints(const SpatialVector *vertex,
154  const SpatialVector *normal,U32 vertices,
155  BWORD multicolor,const Color *color,
156  sp<DrawBufferI> spDrawBuffer) =0;
157 
158  /** @brief Draw lines
159 
160  Uses vertices and colors as explained in drawPoints.
161 
162  If @em strip is DrawI::e_strip,
163  vertices are contiguous with vertices-1 segments,
164  else vertices are independent pairs
165  with vertices/2 segments. */
166 virtual void drawLines(const SpatialVector *vertex,
167  const SpatialVector *normal,U32 vertices,
168  StripMode strip,BWORD multicolor,
169  const Color *color) =0;
170 virtual void drawLines(const SpatialVector *vertex,
171  const SpatialVector *normal,U32 vertices,
172  StripMode strip,
173  BWORD multicolor,const Color *color,
174  BWORD multiradius,const Real *radius,
175  const Vector3i *element,U32 elementCount,
176  sp<DrawBufferI> spDrawBuffer) =0;
177 
178  /** @brief Draw one curve
179 
180  Uses vertices and colors as explained in drawPoints.
181 
182  This is similar to drawLines in strip mode and
183  with a radius property. */
184 virtual void drawCurve(const SpatialVector *vertex,
185  const SpatialVector *normal,
186  const Real *radius,U32 vertices,
187  BWORD multicolor,const Color *color) =0;
188 
189  /** @brief Draw triangles
190 
191  Uses vertices and colors as explained in drawPoints.
192 
193  Normals are treated the same as vertices.
194  If @em strip is DrawI::e_strip,
195  vertices are tri-striped with
196  vertices-2 triangles, else vertices are independent
197  triplets with vertices/3 triangles. */
198 virtual void drawTriangles(const SpatialVector *vertex,
199  const SpatialVector *normal,
200  const Vector2 *texture,U32 vertices,
201  StripMode strip,BWORD multicolor,
202  const Color* color) =0;
203 virtual void drawTriangles(const SpatialVector *vertex,
204  const SpatialVector *normal,
205  const Vector2 *texture,U32 vertices,
206  StripMode strip,BWORD multicolor,
207  const Color* color,
208  const Array<I32>* vertexMap,
209  const Array<I32>* hullPointMap,
210  const Array<Vector4i>* hullFacePoint,
211  sp<DrawBufferI> spDrawBuffer) =0;
212 
213  /** @brief Draw rectangles
214 
215  Uses vertices and colors as explained in drawPoints.
216 
217  Rectangles are never stripped. */
218 virtual void drawRectangles(const SpatialVector *vertex,U32 vertices,
219  BWORD multicolor,const Color *color) =0;
220 
221  /** @brief Draw DrawableI
222 
223  If color is NULL, the surface is expected to use its
224  own color data. */
225 virtual void draw(cp<DrawableI> cpDrawableI,const Color* color) =0;
226 virtual void draw(cp<DrawableI> cpDrawableI,const Color* color,
227  sp<DrawBufferI> spDrawBuffer) =0;
228 
229 virtual void drawTransformed(const SpatialTransform& transform,
230  cp<DrawableI> cpDrawableI,const Color* color) =0;
231 virtual void drawTransformed(const SpatialTransform& transform,
232  cp<DrawableI> cpDrawableI,const Color* color,
233  sp<DrawBufferI> spDrawBuffer) =0;
234 
235  /// @brief Draw 2D box
236 virtual void drawBox(const Box2& box,const Color& color) =0;
237 
238  /// @brief Draw 2D box with pixel adjustments
239 virtual void drawBox(const Box2i& box,const Color& color) =0;
240 
241  /// @brief Draw 3D box
242 virtual void drawBox(const Box3& box,const Color& color) =0;
243 
244  /** @brief Draw screen-aligned single color text
245 
246  Text is drawn at the given location, transformed and
247  projected by the current state of the underlying
248  graphics system. */
249 virtual void drawAlignedText(const SpatialVector& location,
250  const String text,const Color& color) =0;
251 
252 virtual void drawCircle(const SpatialTransform& transform,
253  const SpatialVector *scale,
254  const Color& color) =0;
255 
256 virtual void drawSphere(const SpatialTransform& transform,
257  const SpatialVector *scale,
258  const Color& color) =0;
259 
260  /** @brief Draw a transformed cylinder or cone
261 
262  The baseScale is a additional scale at the base of the
263  cylinder. For a cone, specify a baseScale of 0. */
264 virtual void drawCylinder(const SpatialTransform& transform,
265  const SpatialVector *scale,Real baseScale,
266  const Color& color,U32 slices) =0;
267 
268 virtual void drawCylinder(const SpatialVector& location1,
269  const SpatialVector& location2,
270  Real radius1,Real radius2,
271  const Color& color,U32 slices) =0;
272 
273 virtual void drawCylinders(const SpatialTransform* transform,
274  const SpatialVector* scale,const Real *baseScale,
275  const U32* slices,U32 cylinders,
276  BWORD multicolor,const Color* color) =0;
277 
278 virtual void drawTransformedCylinders(
279  const SpatialTransform& pretransform,
280  const SpatialTransform* transform,
281  const SpatialVector* scale,const Real *baseScale,
282  const U32* slices,U32 cylinders,
283  BWORD multicolor,const Color* color) =0;
284 
285 virtual void drawArc(const SpatialTransform& transform,
286  const SpatialVector *scale,
287  Real startangle,Real endangle,
288  const Color& color) =0;
289 
290 virtual void drawTransformedPoints(
291  const SpatialTransform& transform,
292  const SpatialVector *scale,
293  const SpatialVector *vertex,
294  const SpatialVector *normal,U32 vertices,
295  BWORD multicolor,const Color *color) =0;
296 virtual void drawTransformedPoints(
297  const SpatialTransform& transform,
298  const SpatialVector *scale,
299  const SpatialVector *vertex,
300  const SpatialVector *normal,U32 vertices,
301  BWORD multicolor,const Color *color,
302  sp<DrawBufferI> spDrawBuffer) =0;
303 
304 virtual void drawTransformedLines(
305  const SpatialTransform& transform,
306  const SpatialVector *scale,
307  const SpatialVector *vertex,
308  const SpatialVector *normal,
309  U32 vertices,StripMode strip,BWORD multicolor,
310  const Color *color) =0;
311 virtual void drawTransformedLines(
312  const SpatialTransform& transform,
313  const SpatialVector *scale,
314  const SpatialVector *vertex,
315  const SpatialVector *normal,
316  U32 vertices,StripMode strip,
317  BWORD multicolor,const Color *color,
318  BWORD multiradius,const Real *radius,
319  const Vector3i *element,U32 elementCount,
320  sp<DrawBufferI> spDrawBuffer) =0;
321 
322 virtual void drawTransformedCurve(
323  const SpatialTransform& transform,
324  const SpatialVector *scale,
325  const SpatialVector *vertex,
326  const SpatialVector *normal,
327  const Real *radius,
328  U32 vertices,BWORD multicolor,
329  const Color *color) =0;
330 
331 virtual void drawTransformedTriangles(
332  const SpatialTransform& transform,
333  const SpatialVector *scale,
334  const SpatialVector *vertex,
335  const SpatialVector *normal,
336  const Vector2 *texture,U32 vertices,
337  StripMode strip,BWORD multicolor,
338  const Color *color) =0;
339 virtual void drawTransformedTriangles(
340  const SpatialTransform& transform,
341  const SpatialVector *scale,
342  const SpatialVector *vertex,
343  const SpatialVector *normal,
344  const Vector2 *texture,U32 vertices,
345  StripMode strip,BWORD multicolor,
346  const Color* color,
347  const Array<I32>* vertexMap,
348  const Array<I32>* hullPointMap,
349  const Array<Vector4i>* hullFacePoint,
350  sp<DrawBufferI> spDrawBuffer) =0;
351 
352 virtual void drawTransformedBox(
353  const SpatialTransform& transform,
354  const Box3& box,
355  const Color& color) =0;
356 
357 virtual void drawTransformedBoxes(
358  const SpatialTransform* transform,
359  const SpatialVector* scale,
360  U32 boxes,
361  BWORD multicolor,
362  const Color* color) =0;
363 
364 virtual void drawAxes(Real scale) =0;
365 virtual void drawTransformedAxes(const SpatialTransform& transform,
366  Real scale) =0;
367 
368 virtual void drawMarker(Real radius,const Color& color) =0;
369 virtual void drawTransformedMarker(const SpatialTransform& transform,
370  Real radius,const Color& color) =0;
371 
372 virtual void drawRaster(sp<ImageI> spImageI,
373  const SpatialVector& location) =0;
374 
375 virtual sp<DrawBufferI> createBuffer(void) =0;
376 };
377 
378 } /* namespace ext */
379 } /* namespace fe */
380 
381 #endif /* __draw_DrawI_h__ */
Generalized drawing of points, lines, text, and basic triangles.
Definition: DrawI.h:20
kernel
Definition: namespace.dox:3
StripMode
Format of vertices for tri-stripping.
Definition: DrawI.h:26
Special vector for color (RGBA)
Definition: Color.h:21
N-dimensional axis-aligned bounding-box.
Definition: Box.h:18
Automatically reference-counted string container.
Definition: String.h:128
Base for all interfacable components.
Definition: Component.h:20
Copy-On-Write shared pointer.
Definition: Protectable.h:93
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192