SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLDrawBits.h
Go to the documentation of this file.
1 /**
2  * \file sl/SLDrawBits.h
3  * \date July 2014
4  * \authors Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLDRAWBITS_H
11 #define SLDRAWBITS_H
12 
13 #include <SL.h>
14 
15 //-----------------------------------------------------------------------------
16 /*!
17 Drawing Bits control some visual states of the scene and are applied per scene
18 view or per single node object. Not all are used from the beginning
19 */
20 #define SL_DB_HIDDEN 1 //!< Flags an object as hidden
21 #define SL_DB_NOTSELECTABLE 2 //!< Flags an object as selected
22 #define SL_DB_MESHWIRED 4 //!< Draw polygons as wired mesh
23 #define SL_DB_NORMALS 8 //!< Draw the vertex normals
24 #define SL_DB_BBOX 16 //!< Draw the bounding boxes of a node
25 #define SL_DB_AXIS 32 //!< Draw the coordinate axis of a node
26 #define SL_DB_VOXELS 64 //!< Draw the voxels of the uniform grid
27 #define SL_DB_SKELETON 128 //!< Draw the skeletons joints
28 #define SL_DB_CULLOFF 256 //!< Turn off face culling
29 #define SL_DB_OVERDRAW 512 //!< Draw node over all other nodes
30 #define SL_DB_WITHEDGES 1024 //!< Draw faces with hard edges
31 #define SL_DB_ONLYEDGES 2048 //!< Draw only hard edges
32 #define SL_DB_BRECT 4096 //!< Draw the bounding rectangle of a node
33 #define SL_DB_GPU_SKINNING 8192 //!< Perform skinning on the GPU
34 
35 //-----------------------------------------------------------------------------
36 //! Drawing states stored in the bits of an unsigned int
37 /*! The drawing bits can be applied to the entire scene, a group or a mesh. The
38 default value is 0 signifying the default state. See the defines above for the
39 different drawing bit flags.
40 */
42 {
43 public:
44  SLDrawBits() { _bits = 0; }
45  ~SLDrawBits() { ; }
46 
47  //! Turns all bits off
48  void allOff() { _bits = 0; }
49 
50  //! Turns the specified bit on
51  void on(SLuint bit) { SL_SETBIT(_bits, bit); }
52 
53  //! Turns the specified bit off
54  void off(SLuint bit) { SL_DELBIT(_bits, bit); }
55 
56  //! Sets the specified bit to the passed state
57  void set(SLuint bit, SLbool state)
58  {
59  if (state)
60  SL_SETBIT(_bits, bit);
61  else
62  SL_DELBIT(_bits, bit);
63  }
64 
65  //! Toggles the specified bit
66  void toggle(SLuint bit) { SL_TOGBIT(_bits, bit); }
67 
68  //! Returns the specified bit
69  SLbool get(SLuint bit) { return (_bits & bit) ? true : false; }
70 
71  //! Returns the all bits
72  SLuint bits() { return _bits; }
73 
74  //! Set all bits
75  void bits(SLuint b) { _bits = b; }
76 
77 private:
78  SLuint _bits; //!< Drawing flags as a unsigned 32-bit register
79 };
80 //-----------------------------------------------------------------------------
81 #endif
#define SL_TOGBIT(VAR, VAL)
Definition: SL.h:226
#define SL_SETBIT(VAR, VAL)
Definition: SL.h:224
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
#define SL_DELBIT(VAR, VAL)
Definition: SL.h:225
Drawing states stored in the bits of an unsigned int.
Definition: SLDrawBits.h:42
void off(SLuint bit)
Turns the specified bit off.
Definition: SLDrawBits.h:54
SLbool get(SLuint bit)
Returns the specified bit.
Definition: SLDrawBits.h:69
void set(SLuint bit, SLbool state)
Sets the specified bit to the passed state.
Definition: SLDrawBits.h:57
SLuint _bits
Drawing flags as a unsigned 32-bit register.
Definition: SLDrawBits.h:78
void toggle(SLuint bit)
Toggles the specified bit.
Definition: SLDrawBits.h:66
void allOff()
Turns all bits off.
Definition: SLDrawBits.h:48
void bits(SLuint b)
Set all bits.
Definition: SLDrawBits.h:75
SLuint bits()
Returns the all bits.
Definition: SLDrawBits.h:72
void on(SLuint bit)
Turns the specified bit on.
Definition: SLDrawBits.h:51