DrawModes.hh 23.2 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
Jan Möbius's avatar
Jan Möbius committed
4
 *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
Jan Möbius's avatar
Jan Möbius committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
Jan Möbius's avatar
Jan Möbius committed
37
 *   $Revision$                                                       *
Jan Möbius's avatar
Jan Möbius committed
38 39 40 41
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72




//=============================================================================
//
//  CLASS DrawModes
//
//=============================================================================

#ifndef ACG_DRAWMODES_HH
#define ACG_DRAWMODES_HH


//== FORWARD DECLARATIONS =====================================================


namespace ACG 
{
  namespace SceneGraph 
  {
    class BaseNode;
  }
}


//== INCLUDES =================================================================

#include <string>
#include <vector>
#include "../Config/ACGDefines.hh"
Jan Möbius's avatar
Jan Möbius committed
73
#include <bitset>
Jan Möbius's avatar
 
Jan Möbius committed
74

75 76 77 78 79
// Avoid compiler warning in MSC
#if defined (_MSC_VER)
#   pragma warning (disable:4251)
#endif

Jan Möbius's avatar
 
Jan Möbius committed
80 81 82 83 84 85 86 87 88 89 90
//== NAMESPACES ===============================================================


namespace ACG {
namespace SceneGraph {

/** This namespace consists of the definition of all available draw modes,  
    function to get their name (description()) and to include them in a
    QPopupMenu.
*/

91

Jan Möbius's avatar
 
Jan Möbius committed
92 93
namespace DrawModes {

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

  /** \brief Lighting stage of a mesh: unlit, smooth, phong
   *
   *   Don't confuse this with the interpolation mode of vertex attributes.
   *   This only says where to apply lighting, and nothing else.
   *
   *   Instead the interpolation mode is customizable for each attribute,
   *   making DrawModeProperties more flexible.
   *
   *   flat shading can be achieved by using LIGHTSTAGE_SMOOTH
   *   and setting the normal source to NORMAL_PER_FACE
   */
  enum DrawModeLightStage
  {
    LIGHTSTAGE_UNLIT,  /**< No lighting,  normals may be used by user defined shaders */
    LIGHTSTAGE_SMOOTH, /**< Perform lighting in vertex shader   */
    LIGHTSTAGE_PHONG   /**< Perform lighting in fragment shader */
  };

  /** \brief Primitive mode of a mesh.
   *
   *  Example: PRIMITIVE_EDGE on a polygon mesh renders only edges of the mesh.
   */
  enum DrawModePrimitive
  {
    PRIMITIVE_POINT,
    PRIMITIVE_EDGE,
    PRIMITIVE_HALFEDGE,
    PRIMITIVE_WIREFRAME,
    PRIMITIVE_HIDDENLINE,
    PRIMITIVE_POLYGON,
    PRIMITIVE_CELL
  };

  /** \brief Source of Primitive Colors.
   *
   *   This is interpreted as a per vertex diffuse and ambient color and multiplied with
   *   the material diffuse/ambient colors.
   */
  enum DrawModeColorSource
  {
    COLOR_NONE,         /**< Use material colors only */
    COLOR_PER_VERTEX,   /**< Load per vertex colors and modulate with material color */
    COLOR_PER_HALFEDGE, /**< Load per halfedge colors and modulate with material color */
    COLOR_PER_FACE      /**< Load per face colors and modulate with material color */
  };

  /** \brief Source of Texture Coordinates.
   *
   *   This must be specified for a textured draw.
   */
  enum DrawModeTexCoordSource
  {
    TEXCOORD_NONE,         /**< Disable texture mapping */
    TEXCOORD_PER_VERTEX,   /**< Use per vertex texcoords for texture mapping */
    TEXCOORD_PER_HALFEDGE, /**< Use per halfedge texcoords for texture mapping */
    //  TEXCOORD_PER_FACE // TODO: discuss texcoords per face? is it useful?
  };

  /** \brief Source of Normals.
   *
   *   This must be specified if lighting is enabled.
   */
  enum DrawModeNormalSource
  {
    NORMAL_NONE,          /**< Disable lighting */
    NORMAL_PER_VERTEX,    /**< Use per vertex normals */
    NORMAL_PER_HALFEDGE,  /**< Use per halfedge normals */
    NORMAL_PER_FACE       /**< Use per face normals \note per face is implicitly used in SHADE_FLAT mode  */
  };

165
  typedef std::bitset<128> ModeFlagSet;
Jan Möbius's avatar
Jan Möbius committed
166

167
  /** \brief DrawModeProperties stores a set of properties that defines, how to render an object.
168
   *
169 170 171 172 173
   * A property may be the primitive type, normal source, color source ...
   * Each property is atomic, i.e. it can not be combined with other properties of the same type.
   *  Example:  primitive may be PRIMITIVE_POLYGON or PRIMITIVE_POINTS, but not both at the same time.
   *  This restriction makes a property set well defined; it is always a valid set of properties.
   *  To have combined DrawModes i.e. flat + wireframe you have to use the layer approach of DrawMode.
174 175
   */
  class ACGDLLEXPORT DrawModeProperties {
176

177
  public:
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
    DrawModeProperties(
      DrawModePrimitive _primitive = PRIMITIVE_POLYGON,
      DrawModeLightStage _lightStage = LIGHTSTAGE_UNLIT,
      DrawModeNormalSource _normalSource = NORMAL_NONE,
      DrawModeColorSource _colorSource = COLOR_NONE,
      DrawModeTexCoordSource _texcoordSource = TEXCOORD_NONE,
      bool _envMapping = false);

    //===========================================================================
      /** @name Getter/Setter of all properties
      * @{ */
    //===========================================================================

    DrawModePrimitive primitive() const { return primitive_; }
    void primitive(DrawModePrimitive _val) { primitive_ = _val; }

    DrawModeLightStage lightStage() const { return lightStage_; }
    void lightStage(DrawModeLightStage _val) { lightStage_ = _val; }

    DrawModeColorSource colorSource() const { return colorSource_; }
    void colorSource(DrawModeColorSource _val) { colorSource_ = _val; }

    DrawModeNormalSource normalSource() const { return normalSource_; }
    void normalSource(DrawModeNormalSource _val) { normalSource_ = _val; }

    DrawModeTexCoordSource texcoordSource() const { return texcoordSource_; }
    void texcoordSource(DrawModeTexCoordSource _val) { texcoordSource_ = _val; }

    /** @} */

    //===========================================================================
      /** @name Helper functions for more convenient use in renderer
      * @{ */
    //===========================================================================

    /// Is lighting enabled?
    bool lighting() const { return lightStage_ != LIGHTSTAGE_UNLIT && normalSource_ != NORMAL_NONE; }

    /// Is texturing enabled?
    bool textured() const { return texcoordSource_ != TEXCOORD_NONE; }

    /// Are colors used?
    bool colored() const { return colorSource_ != COLOR_NONE; }

    /// Is flat shading used (Normals per face)?
    bool flatShaded() const { return normalSource_ == NORMAL_PER_FACE; }
224 225 226 227 228 229 230 231 232 233 234
    /** @} */

    //===========================================================================
      /** @name Comparison functions
      * @{ */
    //===========================================================================

    /** \brief compare two properties
     *
     * @param _other Right hand side
     */
Jan Möbius's avatar
Jan Möbius committed
235
    bool operator!=( const DrawModeProperties& _other ) const {
236 237 238 239 240 241 242 243
      return ( (envMapped_      != _other.envMapped_)      ||
               (primitive_      != _other.primitive_)      ||
               (lightStage_     != _other.lightStage_)     ||
               (colorSource_    != _other.colorSource_)    ||
               (texcoordSource_ != _other.texcoordSource_) ||
               (normalSource_   != _other.normalSource_)
              );
    }
244 245 246 247 248 249 250 251 252 253 254 255 256 257
    
    /** \brief compare two properties
     *
     * @param _other Right hand side
     */
    bool operator==( const DrawModeProperties& _other ) const {
      return ( (envMapped_      == _other.envMapped_)      &&
               (primitive_      == _other.primitive_)      &&
               (lightStage_     == _other.lightStage_)     &&
               (colorSource_    == _other.colorSource_)    &&
               (texcoordSource_ == _other.texcoordSource_) &&
               (normalSource_   == _other.normalSource_)
              );
    }
258 259

    /** @} */
260 261 262

  private:

263 264 265 266
    bool envMapped_;

    /// Specify which type of primitives will get uploaded to the graphics card
    DrawModePrimitive primitive_;
267

268 269 270 271 272 273 274
    DrawModeLightStage lightStage_;

    DrawModeColorSource colorSource_;

    DrawModeTexCoordSource texcoordSource_;

    DrawModeNormalSource normalSource_;
275 276 277 278 279

    // TODO: Shaders

  };

280 281 282 283 284 285
  /** \brief Specifies a DrawMode
   *
   * This class specifies a DrawMode. It can contain several properties and layers
   * that define, how objects will be rendered.
   *
   */
Mike Kremer's avatar
Mike Kremer committed
286
  class ACGDLLEXPORT DrawMode {
Jan Möbius's avatar
Jan Möbius committed
287 288 289 290 291 292 293
    public:
      
      DrawMode(); 
      
      /** \brief constructor for unsigned int. 
      *
      * This constructor creates a DrawMode with the given drawMode index.
294
      * Be CareFull! this constructor can only be used to construct atomic draw modes!
Jan Möbius's avatar
Jan Möbius committed
295
      * The int will not be handled like an bitset but really as an index.
Jan Möbius's avatar
Jan Möbius committed
296 297 298
      * See the list of draw modes below to check for the right numbers.
      * You should use the predefined drawModes or create new ones using the other functions
      * and ignore this constructor!
299 300
      *
      * @param _index Index of the new DrawMode
Jan Möbius's avatar
Jan Möbius committed
301
      */
302
      DrawMode(unsigned int _index);
Jan Möbius's avatar
Jan Möbius committed
303 304 305 306 307
      
      /** \brief constructor for ModeFlags. 
      *
      * This constructor creates a DrawMode from a bitset.
      * This makes it easier to predefine draw modes using a bitset.
308 309
      *
      * @param _flags Flags for the new drawmode defined by a bitset
Jan Möbius's avatar
Jan Möbius committed
310 311
      */      
      DrawMode( ModeFlagSet _flags );
312

313 314 315 316 317

      //===========================================================================
      /** @name Operators
       * @{ */
      //===========================================================================
Jan Möbius's avatar
Jan Möbius committed
318
      DrawMode & operator = (const DrawMode& _mode );
319

Jan Möbius's avatar
Jan Möbius committed
320
      bool operator==(const DrawMode& _mode) const;
321

322
      DrawMode operator&(const DrawMode& _mode) const;
Jan Möbius's avatar
Jan Möbius committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
      
      DrawMode& operator++();
      
      DrawMode& operator|=( const DrawMode& _mode2  );
      
      DrawMode& operator&=( const DrawMode& _mode2  );
      
      bool operator!=( const DrawMode& _mode2  ) const;
      
      DrawMode operator|( const DrawMode& _mode2  ) const;
      
      DrawMode operator^( const DrawMode& _mode2  ) const;
      
      DrawMode operator~( ) const;
      
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
      operator bool() const;

      /** @} */

      //===========================================================================
      /** @name Layer Management
       * @{ */
      //===========================================================================

      /** \brief add another layer on top of this drawmode
       *
       * This allows for combinations of DrawModes.
       * The renderer will iterator over all layers of the drawmode
       *  and issue a new draw call for each layer.
       * Example:
       *  layer 0 : flat shading properties
       *  layer 1 : edge drawing properties
       *
       * The result will be a flat shaded object with it's wireframe on top of it.
       * Does duplicate check, in case the property set is already in the layer list.
       *
       * addLayer is also called in bitwise | operator for backwards compatibility with bitset DrawModes
       *
       * @param _props Property that should be added
       */
      void addLayer(const DrawModeProperties* _props); // same as bitwise or operator

      /** \brief returns the layer count
       */
      unsigned int getNumLayers() const;

      /** \brief returns the property set at layer i
       *
       * @param _i Layer that is requested
       */
      const DrawModeProperties* getLayer(unsigned int _i) const;

      /** \brief remove layer at index i
       *
       * @param _i Layer that is requested
       */
      bool removeLayer(unsigned int _i);

      /** \brief remove layer if it is in list
       *
       * @param _prop Property that should be removed if it's available
       */
      bool removeLayer(const DrawModeProperties* _prop);

387 388 389 390 391 392 393

      /** \brief returns layer index of a property, -1 if not in list
       *
       * @param _prop Property to be searched for
       */
      int getLayerIndex(const DrawModeProperties* _prop) const;

394 395 396
      /** @} */


Jan Möbius's avatar
Jan Möbius committed
397 398 399 400 401
      /** \brief get an index of the current drawMode
      *
      * If this drawMode is a combination of different drawModes, the returned value will be 0.
      * Otherwise the internal flag index will be returned
      */
402
      unsigned int getIndex() const;
403 404 405 406 407 408 409 410 411 412 413

      /** \brief filter out one drawmode
      *
      * This removes one or more drawmodes if this drawode is not atomic.
      */
      void filter( DrawMode _filter );


      /** \brief combine with another drawmode
      */
      void combine( DrawMode _mode );
Jan Möbius's avatar
Jan Möbius committed
414 415 416 417 418
      
      /** Get a description string for this DrawMode
      * An empty string is returned if this is not a valid draw mode.
      * this list has the format DrawModeName+DrawMOdeName+...
      */
419
      std::string description() const;
Jan Möbius's avatar
Jan Möbius committed
420 421 422
      
      /** \brief Check if this is an atomic draw Mode
      *
423
      * This function checks, if this is a atomic draw mode ( no combination of multiple draw modes )
Jan Möbius's avatar
Jan Möbius committed
424
      */
Jan Möbius's avatar
Jan Möbius committed
425
      bool isAtomic() const;
Jan Möbius's avatar
Jan Möbius committed
426 427 428
      
      /** \brief Check whether an Atomic DrawMode is active in this draw Mode
      */ 
429
      bool containsAtomicDrawMode( DrawMode _atomicDrawMode ) const;
Jan Möbius's avatar
Jan Möbius committed
430
      
431
      /** \brief Separates this drawMode into a list of all separate atomic draw modes
Jan Möbius's avatar
Jan Möbius committed
432
      *
433 434
      * A drawMode can consist of several atomic draw modes. This function returns a list of the separated
      * atomic draw modes.
Jan Möbius's avatar
Jan Möbius committed
435
      */
436
      std::vector< DrawMode > getAtomicDrawModes() const;
Jan Möbius's avatar
Jan Möbius committed
437 438 439
      
      /** \brief Get the number of maximum Modes which could be handled by the current implementation
      */
440
      unsigned int maxModes() const;
Jan Möbius's avatar
Jan Möbius committed
441
      
442

443 444 445 446 447 448 449 450 451 452 453 454 455 456
      /** \brief returns the base properties of this draw mode
       *
       * Base properties are the original properties that defined the DrawMode before any merge operation.
       * They are located at layer 0, so actually this function has the same effect as getLayer(0).
       * 
       * Every DrawMode is property based with only two exceptions:
       *  - NONE
       *  - DEFAULT
       *
       * getDrawModeProperties returns 0 for these.
       */
      const DrawModeProperties* getDrawModeProperties() const;

      /** \brief set the base properties of this draw mode
457
       *
458
       * @param _props Properties to be set
459
       */
460
      void setDrawModeProperties(const DrawModeProperties* _props);
461

462
      /** \brief set the base properties of this draw mode
463
       *
464
       * @param _props Properties to be set
465
       */
466 467 468
      void setDrawModeProperties(const DrawModeProperties& _props);


469 470 471 472 473 474
      /** \brief checks consistency of property layers
       *
       * There should only be at most one layer for each primitive type for example
       */
      bool checkConsistency() const;

Jan Möbius's avatar
Jan Möbius committed
475 476
    private:
      ModeFlagSet modeFlags_;
477 478 479 480 481 482

      /** vector for combined DrawModes
      * -> holds DrawModeProperties for each layer
      * -> original layer at index 0
      */
      std::vector<DrawModeProperties> layers_;
Jan Möbius's avatar
 
Jan Möbius committed
483
  };
Jan Möbius's avatar
Jan Möbius committed
484
  
485
    
Jan Möbius's avatar
Jan Möbius committed
486
  /// not a valid draw mode
Jan Möbius's avatar
Jan Möbius committed
487
  extern ACGDLLEXPORT DrawMode NONE;
Jan Möbius's avatar
Jan Möbius committed
488
  /// use the default (global) draw mode and not the node's own.
Jan Möbius's avatar
Jan Möbius committed
489
  extern ACGDLLEXPORT DrawMode DEFAULT;
Jan Möbius's avatar
Jan Möbius committed
490 491 492 493 494
  
  //======================================================================
  //  Point Based Rendering Modes
  //======================================================================
  /// draw unlighted points using the default base color
Jan Möbius's avatar
Jan Möbius committed
495
  extern ACGDLLEXPORT DrawMode POINTS;
496

Jan Möbius's avatar
Jan Möbius committed
497
  /// draw colored, but not lighted points (requires point colors)
Jan Möbius's avatar
Jan Möbius committed
498
  extern ACGDLLEXPORT DrawMode POINTS_COLORED;
Jan Möbius's avatar
Jan Möbius committed
499
  /// draw shaded points (requires point normals)
Jan Möbius's avatar
Jan Möbius committed
500
  extern ACGDLLEXPORT DrawMode POINTS_SHADED;
Jan Möbius's avatar
Jan Möbius committed
501 502 503 504
  
  //======================================================================
  //  Edge Based Rendering Modes
  //======================================================================
505
  /// draw edges
Jan Möbius's avatar
Jan Möbius committed
506
  extern ACGDLLEXPORT DrawMode EDGES;
507 508

  /// draw edges with colors (without shading)
Jan Möbius's avatar
Jan Möbius committed
509
  extern ACGDLLEXPORT DrawMode EDGES_COLORED;
Jan Möbius's avatar
Jan Möbius committed
510
  /// draw wireframe
Jan Möbius's avatar
Jan Möbius committed
511
  extern ACGDLLEXPORT DrawMode WIREFRAME;
Jan Möbius's avatar
Jan Möbius committed
512 513 514 515
  
  //======================================================================
  //  Face Based Rendering Modes
  //======================================================================  
516
  // draw faces
Jan Möbius's avatar
Jan Möbius committed
517
  extern ACGDLLEXPORT DrawMode FACES;
Jan Möbius's avatar
Jan Möbius committed
518 519

  /// draw hidden line (2 rendering passes needed)
Jan Möbius's avatar
Jan Möbius committed
520
  extern ACGDLLEXPORT DrawMode HIDDENLINE;
Jan Möbius's avatar
Jan Möbius committed
521
  /// draw flat shaded faces (requires face normals)
Jan Möbius's avatar
Jan Möbius committed
522
  extern ACGDLLEXPORT DrawMode SOLID_FLAT_SHADED;
Jan Möbius's avatar
Jan Möbius committed
523
  /// draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)  
Jan Möbius's avatar
Jan Möbius committed
524
  extern ACGDLLEXPORT DrawMode SOLID_SMOOTH_SHADED;
Jan Möbius's avatar
Jan Möbius committed
525
  /// draw phong shaded faces
Jan Möbius's avatar
Jan Möbius committed
526
  extern ACGDLLEXPORT DrawMode SOLID_PHONG_SHADED;
Jan Möbius's avatar
Jan Möbius committed
527
  /// draw colored, but not lighted faces using face colors
Jan Möbius's avatar
Jan Möbius committed
528
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED;
529
  /// draw colored, but not lighted faces using interpolated vertex colors
Jan Möbius's avatar
Jan Möbius committed
530
  extern ACGDLLEXPORT DrawMode SOLID_POINTS_COLORED;
531 532
  /// draw faces, but use Gouraud shading to interpolate vertex colors
  extern ACGDLLEXPORT DrawMode SOLID_POINTS_COLORED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
533
  /// draw environment mapped  
Jan Möbius's avatar
Jan Möbius committed
534
  extern ACGDLLEXPORT DrawMode SOLID_ENV_MAPPED;
Jan Möbius's avatar
Jan Möbius committed
535
  /// draw textured faces
Jan Möbius's avatar
Jan Möbius committed
536
  extern ACGDLLEXPORT DrawMode SOLID_TEXTURED;
Jan Möbius's avatar
Jan Möbius committed
537
  /// draw smooth shaded textured faces
Jan Möbius's avatar
Jan Möbius committed
538
  extern ACGDLLEXPORT DrawMode SOLID_TEXTURED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
539
  /// draw textured faces
Jan Möbius's avatar
Jan Möbius committed
540
  extern ACGDLLEXPORT DrawMode SOLID_1DTEXTURED;
Jan Möbius's avatar
Jan Möbius committed
541
  /// draw smooth shaded textured faces
Jan Möbius's avatar
Jan Möbius committed
542
  extern ACGDLLEXPORT DrawMode SOLID_1DTEXTURED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
543
  /// draw textured faces
Jan Möbius's avatar
Jan Möbius committed
544
  extern ACGDLLEXPORT DrawMode SOLID_3DTEXTURED;
Jan Möbius's avatar
Jan Möbius committed
545
  /// draw smooth shaded textured faces
Jan Möbius's avatar
Jan Möbius committed
546
  extern ACGDLLEXPORT DrawMode SOLID_3DTEXTURED_SHADED;
Jan Möbius's avatar
Jan Möbius committed
547
  /// draw flat shaded and colored faces (requires face normals and colors)
Jan Möbius's avatar
Jan Möbius committed
548
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_FLAT_SHADED;
549 550
  /// draw smooth shaded and colored faces (requires vertex normals and face colors)
  extern ACGDLLEXPORT DrawMode SOLID_FACES_COLORED_SMOOTH_SHADED;
Jan Möbius's avatar
Jan Möbius committed
551
  /// draw per halfedge textured faces
Jan Möbius's avatar
Jan Möbius committed
552
  extern ACGDLLEXPORT DrawMode SOLID_2DTEXTURED_FACE;
Jan Möbius's avatar
Jan Möbius committed
553
  /// draw per halfedge textured faces
Jan Möbius's avatar
Jan Möbius committed
554
  extern ACGDLLEXPORT DrawMode SOLID_2DTEXTURED_FACE_SHADED;
Jan Möbius's avatar
Jan Möbius committed
555 556
  /// drawing is controlled by shaders
  /// ( Use shadernodes to set them before the actual object to render)
Jan Möbius's avatar
Jan Möbius committed
557
  extern ACGDLLEXPORT DrawMode SOLID_SHADER;
558 559
  /// draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
  extern ACGDLLEXPORT DrawMode SOLID_SMOOTH_SHADED_FEATURES;
560 561 562 563 564

  //======================================================================
  //  Face Based Rendering Modes
  //======================================================================  
  // draw cells
Jan Möbius's avatar
Jan Möbius committed
565
  extern ACGDLLEXPORT DrawMode CELLS;
566 567

  /// draw cells with colors (without shading)
Jan Möbius's avatar
Jan Möbius committed
568
  extern ACGDLLEXPORT DrawMode CELLS_COLORED;
569 570


571 572 573 574
  //======================================================================
  //  Halfedge Based Rendering Modes
  //======================================================================
  /// draw halfedges
Jan Möbius's avatar
Jan Möbius committed
575
  extern ACGDLLEXPORT DrawMode HALFEDGES;
576 577

  /// draw halfedges with colors (without shading)
Jan Möbius's avatar
Jan Möbius committed
578
  extern ACGDLLEXPORT DrawMode HALFEDGES_COLORED;
579

580

Jan Möbius's avatar
Jan Möbius committed
581
  /// marks the last used ID
Jan Möbius's avatar
Jan Möbius committed
582
  extern ACGDLLEXPORT DrawMode UNUSED;
Jan Möbius's avatar
Jan Möbius committed
583
  
Jan Möbius's avatar
 
Jan Möbius committed
584

Jan Möbius's avatar
Jan Möbius committed
585 586 587
  //=======================================================================
  // Non Member Functions
  //=======================================================================
Jan Möbius's avatar
 
Jan Möbius committed
588 589 590 591 592 593 594
  
  /** Initialize the default modes.
      This function has to be called at least once at application startup.
  */
  ACGDLLEXPORT 
  void initializeDefaultDrawModes( void );

595 596 597 598 599
  /** \brief Add a custom DrawMode.
   *
      The id of the new draw mode is returned. If it already exists, the id of the existing one
      is returned.

Jan Möbius's avatar
Jan Möbius committed
600 601 602 603 604
      Property based draw modes consist of various flags, which define which primitives and
      additional information are send to the gpu.

      @param _name Name of the draw mode to add
      @param _propertyBased If set to true a property based draw mode is created.
605
      @return Id of the new draw mode
Jan Möbius's avatar
 
Jan Möbius committed
606
  */
607 608
  ACGDLLEXPORT
  const DrawMode& addDrawMode( const std::string & _name, bool _propertyBased = false);
609

Jan Möbius's avatar
 
Jan Möbius committed
610

611 612 613 614 615 616
  /** \brief Get a custom DrawMode.
   *
      The id of the draw mode is returned or if it does not exist, DrawMode::NONE is returned.

      @param _name Name of the drawmode
      @return Id of the draw mode or DrawModes::NONE
617 618
  */
  ACGDLLEXPORT 
619 620
  const DrawMode& getDrawMode( const std::string & _name);

Jan Möbius's avatar
Jan Möbius committed
621 622 623
  
  /** \brief Check if the given draw mode exists
  *
Jan Möbius's avatar
 
Jan Möbius committed
624
  */
Jan Möbius's avatar
Jan Möbius committed
625 626 627 628
  ACGDLLEXPORT   
  bool drawModeExists(const std::string & _name);
  
  /** \brief given an index of an atomic draw mode, return the drawmode
Jan Möbius's avatar
 
Jan Möbius committed
629 630
  */
  ACGDLLEXPORT 
Jan Möbius's avatar
Jan Möbius committed
631
  DrawMode getDrawModeFromIndex( unsigned int _index );
Jan Möbius's avatar
 
Jan Möbius committed
632 633 634 635 636 637 638 639 640

//=============================================================================
} // namespace DrawModes
} // namespace SceneGraph
} // namespace ACG
//=============================================================================
#endif // ACG_DRAWMODES_HH defined
//=============================================================================