Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GeometryGL.hh
1 #ifndef __GeometryGL_hh__
2 #define __GeometryGL_hh__
3 
4 // ----------------------------------------------------------
5 // @author Jan Woetzel (c) 09/2003
6 // all rights reserved
7 
8 #include <bias_config.h>
9 
10 #ifndef BIAS_HAVE_OPENGL
11 # error Please recompile BIAS with USE_OPENGL to use this lib.
12 #endif // BIAS_HAVE_OPENGL
13 
14 
15 // STD
16 #include <vector>
17 #include <iostream>
18 
19 #include <Base/Math/Vector3.hh>
20 #include <Geometry/PMatrix.hh>
21 
22 #include <Gui/ImgObjGL.hh>
23 #include <Gui/RenderModeGL.hh>
24 
25 #ifdef BIAS_HAVE_FONTGL
26 # include <Utils/DrawTextGL.hh>
27 #endif // BIAS_HAVE_FONTGL
28 
29 
30 #ifndef VISIBLEALPHA
31 # define VISIBLEALPHA 0.0
32 #endif
33 
34 // used by OpenGLInfo:
35 #define MAX_GL_DISPLIST_ID 1000
36 #define MAX_GL_TEXOBJ_ID 1000
37 
38 namespace BIAS {
39 
40  // corners:
47  };
48 
49 
50  // jw ---------------------------------------------------------
51  /** @brief Reusable Geometry an drawing functions for OpenGL
52  @author Jan Woetzel */
53  class BIASGui_EXPORT GeometryGL {
54  public:
55  /// destructor
56  virtual ~GeometryGL();
57 
58  /// ctor
59  GeometryGL();
60 
61  /// utility functions
62 
63  /// deps to glut:
64  //static void DisplayTeapotLit(const float & size=0.5f, const bool & solid=true);
65  //static void DisplaySceneExampleLit(const bool & UseResetView=false);
66 
67  static void DisplayClear(const GLbitfield & mask=CLEAR_DEFAULT_MASK );
68 
69  static void DisplayRenderMode(const BIAS::RenderModeGL & m);
70 
71  /** draw a coord cross as three lines in r,g,b
72  @param withAxes Label true to draw x/y/Z text as axes label JW */
73  static void DisplayCoordCross(const float & size=1.0f,
74  const float & linewidth=1.0f );
75 
76 #ifdef BIAS_HAVE_FONTGL
77  /** draw only the axes labels for a coord cross as text in r,g,b JW */
78  static void DisplayCoordCrossAxesLabel(const float & size,
79  const BIAS::DrawTextGL & font,
80  const std::string & LabelX=std::string("x"),
81  const std::string & LabelY=std::string("y"),
82  const std::string & LabelZ=std::string("z") );
83 
84  /** draw coord cross with labels in r,g,b JW */
85  static void DisplayCoordCross(const float & size,
86  const float & linewidth,
87  const BIAS::DrawTextGL & font,
88  const std::string & LabelX=std::string("x"),
89  const std::string & LabelY=std::string("y"),
90  const std::string & LabelZ=std::string("z") );
91 
92 #endif
93 
94  static void DisplayCameraInternalParams(
95  const int & x0,
96  const int & y0,
97  const unsigned int & width,
98  const unsigned int & height,
99  const float & fovY,
100  const float & zNear,
101  const float & zFar );
102 
103  static void DisplayCameraExternalParams(BIAS::PMatrix & P);
104 
105  static void DisplayCameraExternalParams(const BIAS::Vector3<double> & C,
106  const BIAS::Vector3<double> & up,
107  const BIAS::Vector3<double> & a);
108 
109  /// print all GL state informatino to os including displaylist, texobj and matric info
110  static void GetInfoGL(std::ostream & os);
111  /// print individual information to os
112  static void GetInfoGLenvironment(std::ostream & os);
113  static void GetInfoGLTexID(const GLint id, int & foundTextures, std::ostream & os, const bool & noOutputIfInvalid=true);
114  static void GetInfoGLTexObjects(std::ostream & os);
115  static void GetInfoGLDisplayLists(std::ostream & os);
116  static void GetInfoGLmatrices(std::ostream & os);
117  static void GetInfoGLWriteMasks(std::ostream & os);
118 
119  /// return a name for an OpenGL flags nr.
120  static std::string GetName(const GLint flag,
121  const bool withNumericDisplay=true,
122  const bool numerixHexFormat=true);
123 
124  static BIAS::Vector3<double> GetImgCorner3d(BIAS::PMatrix & P
125  ,const unsigned int & width
126  ,const unsigned int & height
127  ,const unsigned int & corner
128  ,const double & scale );
129 
130  static BIAS::Vector2<double> GetImgCorner2d( const unsigned int & w
131  ,const unsigned int & h
132  ,const unsigned int & corner
133  ,const int texMode
134  ,const bool flipY );
135 
136  static void DisplayP(BIAS::PMatrix & P
137  ,const unsigned int & w
138  ,const unsigned int & h
139  ,const double & scale
140  ,const float & linewidth=1.0f );
141 
142  /// time dependant scene for samples
143  static void DisplaySimpleAnimation(const double & time);
144 
145  // time independant scene for samples
146  static void DisplaySceneExampleSimple();
147 
148  /// draws a pkane with attched texture coordinates
149  static void DisplayImgPlaneTextured(BIAS::PMatrix & P
150  ,const unsigned int & w
151  ,const unsigned int & h
152  ,const int & texID
153  ,const int & texTarget
154  ,const double & scale
155  ,const bool & flipY
156  ,const BIAS::Vector4<float> & vertexColor=BIAS::Vector4<float>(1.0,0.0,1.0, 0.0)
157  );
158 
159  /** compose an OpenGL 4x4 (projective) texture matrix
160  @param useRECTcoord true to use RECT 0..npixels
161  instead of 0..1 normalized pw2 texture coordinate JW */
163  CreateTextureMatrix(BIAS::PMatrix & P
164  ,const unsigned int w
165  ,const unsigned int h
166  ,const bool & useRECTcoord=false );
167 
168  static void DisplayQuadTexCoord2D(const BIAS::ImgObjGL & texobj,
169  const bool & additionalFlipY );
170 
171  static void DisplayQuadTexCoord2DFull(const BIAS::ImgObjGL & texobj,
172  const bool & additionalFlipY);
173 
174  /// creates a sample scene as one dispaly list returned in dplistID once
175  /// the arg is kept as it is if initialization was done before.
176  static void CreateSampleDisplayListScene(int & dplistID);
177 
178  // displays a simple displa ylist scene with animation
179  static void DisplayCallsSampleDisplayListScene(const double & curTime);
180 
181  /// fill
182  static void FillCubemap(BIAS::ImgObjGL & im, const bool & mipmapColorChange=false);
183 
184  };
185 } // namespace BIAS
186 #endif
CornerIndices
Definition: GeometryGL.hh:41
data holder describing OpenGL texture objects in addition to its unique texID.
Definition: ImgObjGL.hh:34
GLRenderMode describes mode for rendering.
Definition: RenderModeGL.hh:45
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
Reusable Geometry an drawing functions for OpenGL.
Definition: GeometryGL.hh:53
Draw text to OpenGL as 2D bitmap font.
Definition: DrawTextGL.hh:71