BALL 1.5.0
Loading...
Searching...
No Matches
glRenderer.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_VIEW_RENDERING_RENDERERS_GLRENDERER_H
6#define BALL_VIEW_RENDERING_RENDERERS_GLRENDERER_H
7
8#ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
10#endif
11
12#ifndef BALL_MATHS_QUATERNION_H
14#endif
15
16#ifndef BALL_VIEW_DATATYPE_COLORRGBA_H
18#endif
19
20#ifndef BALL_VIEW_KERNEL_GEOMETRICOBJECT_H
22#endif
23
24#ifndef BALL_VIEW_KERNEL_STAGE_H
26#endif
27
28#ifdef BALL_HAS_GLEW
29# include <GL/glew.h>
30#elif defined(BALL_OS_DARWIN)
31# include <OpenGL/gl.h>
32# include <OpenGL/glu.h>
33#else
34# include <GL/gl.h>
35# include <GL/glu.h>
36#endif
37
38#ifndef BALL_VIEW_RENDERING_GLDISPLAYLIST_H
40#endif
41
42#ifndef BALL_DATATYPE_REGULARDATA3D_H
44#endif
45
46#ifndef APIENTRY
47#define APIENTRY
48#endif
49
50class QFont;
51
52namespace BALL
53{
54// defines the maximal number of GL-objects, which can be selected in picking mode
55// a number as big as 100.000 is needed for large molecules, just to be sure we use a million
56#define BALL_GLRENDERER_PICKING_NUMBER_OF_MAX_OBJECTS 1000000
57 namespace VIEW
58 {
59 class Scene;
60 class GLDisplayList;
61 class MeshBuffer;
62 class ColorMap;
63 class RenderTarget;
64
70 : public Renderer
71 {
72 friend class Scene;
73 public:
74
77 {
79 RENDER_MODE_UNDEFINED = 0,
80
83
86
88 RENDER_MODE_ALWAYS_FRONT
89 };
90
91
94 {
96 DIRECT_RENDERING = 0,
97
100
102 REBUILD_DISPLAY_LISTS
103 };
104
105
112 {
113 public:
114
115 WrongModes(const char* file, int line, int mode, int precision);
116 };
117
119 typedef unsigned int Name;
120
123
125 virtual ~GLRenderer();
126
128 virtual void clear();
129
131 void dump(std::ostream& s, Size depth) const;
132
134 inline Name getName(const GeometricObject& object);
135
138
139 using Renderer::init;
140
142 virtual bool init(const Stage& stage, float width, float height);
143
145 virtual void setLights(bool reset_all = false);
146
149 virtual void setSmoothLines(bool smooth_lines);
150 virtual bool getSmoothLines();
151
154 virtual void pickObjects(Position x1, Position y1, Position x2, Position y2,
155 std::list<GeometricObject*>& objects);
156
161
166 void pickObjects2(std::list<GeometricObject*>& objects);
167
170 void setFogIntensity(float intensity);
171
174
177
179 void setSize(float width, float height);
180
182 float getXScale() const;
183
185 float getYScale() const;
186
188 virtual void updateBackgroundColor();
189
190 // Initialise transparent rendering
192
193 // Initialise solid rendering
194 void initSolid();
195
196 // Initialise always front rendering
198
200 void setAntialiasing(bool state);
201
204
207
209 void drawBuffered(const Representation& rep);
210
212 bool hasDisplayListFor(const Representation& rep) const;
213
216
218 void setRenderMode(RenderMode mode) { render_mode_ = mode;}
219
224 virtual void renderToBuffer(RenderTarget* renderTarget, BufferMode);
225
227 virtual bool render(const Representation& representation, bool for_display_list = false);
228
229 virtual void bufferingDependentRender_(const Representation& repr, BufferMode mode);
230
234 bool isExtensionSupported(const String& extension) const;
235
238
241
244
247
250
252 vector<String> getExtensions();
253
256
258 bool enableVertexBuffers(bool state);
259
262
265
268
271
272 //_
273 void setColorRGBA_(const ColorRGBA& color);
274
275 //_
276 void vertexVector3_(const Vector3& v);
277
278 //
279 void updateCamera(const Camera* camera = 0);
280
281 //
282 void setupStereo(float eye_separation, float focal_length);
283
286
287 virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f, float& top_f, float& bottom_f);
288
289 void updateMaterialForRepresentation(Representation const* rep) { bufferRepresentation(*rep); }
290
291 protected:
292
297
298 void renderRepresentation_(const Representation& representation, bool for_display_list);
299
302
304 virtual void renderLabel_(const Label& /*label*/);
305
307 virtual void renderLine_(const Line& /*line*/);
308
310 virtual void renderMultiLine_(const MultiLine& line);
311
313 virtual void renderMesh_(const Mesh& /*mesh*/);
314
316 virtual void renderQuadMesh_(const QuadMesh& /*mesh*/);
317
320
323
331 virtual void renderRuler();
332
334 virtual void renderPoint_(const Point& /*point*/);
335
337 virtual void renderSimpleBox_(const SimpleBox& /*box*/);
338
340 virtual void renderBox_(const Box& /*box*/);
341
343 virtual void renderSphere_(const Sphere& /*sphere*/);
344
346 virtual void renderDisc_(const Disc& /*disc*/);
347
349 virtual void renderTube_(const Tube& /*tube*/);
350
352 virtual void renderTwoColoredLine_(const TwoColoredLine& /*two_colored_line*/);
353
355 virtual void renderTwoColoredTube_(const TwoColoredTube& /*two_colored_tube*/);
356
358 virtual void renderClippingPlane_(const ClippingPlane& plane);
359
362
363 //_
364 void setColor4ub_(const GeometricObject& object);
365
366 //_
368
369 //_
371
372 //_
374
375 //_
376 void createDottedSphere_(int precision);
377
378 //_
379 void subdivideTriangle_(Vector3& v1, Vector3& v2, Vector3& v3, int precision);
380
381 //_
383
384 //_
386
387 //_
389
390 //_
392
393 //_
394 void normalVector3_(const Vector3& v);
395
396
397 //_
399
400 //_
402 { glTexCoord3f(v.x, v.y, v.z); }
403
404 //_
405 void scaleVector3_(const Vector3& v);
406
407 //_
408 void rotateVector3Angle_(const Vector3& v, Real angle);
409
410 //_
411 void scale_(float f);
412
413
415
416 //_
417 void setOrthographicZoom(float orthographic_zoom);
418
419 //_
421
422 //_
423 void generateIlluminationTexture_(float ka, float kd, float kr, float shininess);
424
427
428 // Sets the current OpenGL material
432
435
436 //_
437 float near_;
438 //_
439 float far_;
440 //_
441 float left_;
442 //_
443 float right_;
444 //_
445 float top_;
446 //_
447 float bottom_;
448
449 //_
450 float x_scale_;
451
452 //_
453 float y_scale_;
454
461 GLubyte line_tex_[128][128][4];
462
463 // naming of geometric objects
468
476
478
487 GLUquadricObj* GLU_quadric_obj_;
490
492 };
493
494# ifndef BALL_NO_INLINE_FUNCTIONS
495# include <BALL/VIEW/RENDERING/RENDERERS/glRenderer.iC>
496# endif
497
498 } // namespace VIEW
499} // namespace BALL
500
501#endif // BALL_VIEW_RENDERING_GLRENDERER_H
#define BALL_GLRENDERER_PICKING_NUMBER_OF_MAX_OBJECTS
Definition glRenderer.h:56
DrawingMode
Enumeration for Drawing Modes.
HashMap class based on the STL map (containing serveral convenience functions)
bool enableVertexBuffers(bool state)
float getYScale() const
Position display_lists_index_
Definition glRenderer.h:483
GeometricObjectHashMap name_to_object_
Definition glRenderer.h:469
virtual void renderSimpleBox_(const SimpleBox &)
Render a simple box (parallel to the axes)
void setAntialiasing(bool state)
Enable or disable antialiasing.
void subdivideTriangle_(Vector3 &v1, Vector3 &v2, Vector3 &v3, int precision)
virtual void renderTube_(const Tube &)
Render a tube.
HashMap< Name, const GeometricObject * > GeometricObjectHashMap
Definition glRenderer.h:465
RenderMode getRenderMode() const
virtual void renderQuadMesh_(const QuadMesh &)
Render a quad mesh.
virtual void renderToBuffer(RenderTarget *renderTarget, BufferMode)
void updateMaterialForRepresentation(Representation const *rep)
Definition glRenderer.h:289
virtual void setLights(bool reset_all=false)
Set the light sources according to the stage.
virtual void renderBox_(const Box &)
Render a box.
GLDisplayList * GL_tubes_list_
Definition glRenderer.h:456
virtual void renderLine_(const Line &)
Render a line.
void generateIlluminationTexture_(float ka, float kd, float kr, float shininess)
GLDisplayList * sphere_list_
Definition glRenderer.h:458
void scale_(float f)
virtual void renderTwoColoredTube_(const TwoColoredTube &)
Render a tube with two colors.
void clearVertexBuffersFor(Representation &rep)
void setMaterial_(const Stage::Material &mat)
void setColor4ub_(const GeometricObject &object)
void translateVector3_(const Vector3 &v)
virtual void bufferingDependentRender_(const Representation &repr, BufferMode mode)
void renderRepresentation_(const Representation &representation, bool for_display_list)
void setColorRGBA_(const ColorRGBA &color)
virtual void clear()
Explicit default initialization.
GLRenderer()
Default Constructor.
void setupGridClipPlanes_(const GridVisualisation &slice)
virtual void renderTwoColoredLine_(const TwoColoredLine &)
Render a line with two colors.
Position getTextureIndex_(Position x, Position y, Position z, Size width, Size height)
GLDisplayList * GL_boxes_list_
Definition glRenderer.h:457
GLUquadricObj * GLU_quadric_obj_
Definition glRenderer.h:487
Name getName(const GeometricObject &object)
DrawingMode getDrawingMode() const
DrawingMode drawing_mode_
Definition glRenderer.h:431
void renderRepresentations_(BufferMode mode)
void texCoordVector3_(const Vector3 &v)
Definition glRenderer.h:401
virtual bool getSmoothLines()
virtual void renderRuler()
Position createTextureFromGrid(const RegularData3D &grid, const ColorMap &map)
void scaleVector3_(const Vector3 &v)
virtual void renderDisc_(const Disc &)
Render a disc.
virtual void renderPoint_(const Point &)
Render a single point.
unsigned int Name
Typedef for OPENGL names.
Definition glRenderer.h:119
virtual bool render(const Representation &representation, bool for_display_list=false)
HashMap< const Representation *, GLDisplayList * > DisplayListHashMap
Definition glRenderer.h:466
virtual void renderGridVisualisation_(const GridVisualisation &vol)
Render a grid slice.
void bufferRepresentation(const Representation &rep)
Buffer the visualisation for the given Representation into OpenGL VertexBuffer Objects and DisplayLis...
HashMap< const GeometricObject *, Name > NameHashMap
Definition glRenderer.h:464
void updateCamera(const Camera *camera=0)
vector< String > getExtensions()
void dump(std::ostream &s, Size depth) const
virtual void renderSphere_(const Sphere &)
Render a sphere.
void setFogIntensity(float intensity)
MeshBufferHashMap rep_to_buffers_
Definition glRenderer.h:472
void setSize(float width, float height)
Set the size of the display.
HashMap< const RegularData3D *, Position > grid_to_texture_
Definition glRenderer.h:488
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2, std::list< GeometricObject * > &objects)
bool isExtensionSupported(const String &extension) const
virtual ~GLRenderer()
Destructor.
void removeRepresentation(const Representation &rep)
Remove all VertexBuffer and DisplayLists for the given Representation.
DisplayListHashMap display_lists_
Definition glRenderer.h:471
void drawBuffered(const Representation &rep)
Draw the visualisation of the given Representation from the VertexBuffers and a DisplayList.
void removeTextureFor_(const RegularData3D &grid)
void setRenderMode(RenderMode mode)
Definition glRenderer.h:218
void pickObjects1(Position x1, Position y1, Position x2, Position y2)
float getXScale() const
GLDisplayList * GL_spheres_list_
Definition glRenderer.h:455
bool hasDisplayListFor(const Representation &rep) const
Test if a Representation has a DisplayList.
void initGLU_(DrawingMode mode)
virtual void renderLabel_(const Label &)
bool vertexBuffersSupported() const
void createDottedSphere_(int precision)
virtual void updateBackgroundColor()
Update the background color from the stage.
NameHashMap object_to_name_
Definition glRenderer.h:470
@ DISPLAY_LISTS_RENDERING
Render the contents of the display lists.
Definition glRenderer.h:99
virtual void renderMultiLine_(const MultiLine &line)
Render an illuminated line.
bool vertexBuffersEnabled() const
virtual void renderClippingPlane_(const ClippingPlane &plane)
virtual void getFrustum(float &near_f, float &far_f, float &left_f, float &right_f, float &top_f, float &bottom_f)
void rotateVector3Angle_(const Vector3 &v, Real angle)
virtual void setSmoothLines(bool smooth_lines)
GeometricObject * getObject(GLRenderer::Name name) const
void vertexVector3_(const Vector3 &v)
void setOrthographicZoom(float orthographic_zoom)
HashMap< const Representation *, vector< MeshBuffer * > > MeshBufferHashMap
Definition glRenderer.h:467
void pickObjects2(std::list< GeometricObject * > &objects)
GLDisplayList line_list_
Definition glRenderer.h:459
virtual bool init(const Stage &stage, float width, float height)
Initialise the renderer, e.g. the display lists.
void setupStereo(float eye_separation, float focal_length)
float getOrthographicZoom(void)
virtual void renderMesh_(const Mesh &)
Render a surface mesh.
void normalVector3_(const Vector3 &v)
WrongModes(const char *file, int line, int mode, int precision)
#define BALL_VIEW_EXPORT