MeshLib C++ Docs
Loading...
Searching...
No Matches
MRViewportGL.h
Go to the documentation of this file.
1#pragma once
2#include "MRViewerFwd.h"
3#include "MRMesh/MRVector4.h"
4#include "MRMesh/MRVector2.h"
5#include "MRMesh/MRBox.h"
6#include "MRMesh/MRPlane3.h"
7#include "MRMesh/MRColor.h"
10
11#include <span>
12
13namespace MR
14{
17
20{
21 Vector4f a, b;
22};
23
24inline bool operator==( const SegmEndColors& a, const SegmEndColors& b )
25{
26 return a.a == b.a && a.b == b.b;
27}
28
31{
32 std::vector<Vector3f> points;
33 std::vector<Vector4f> colors;
34};
35
37{
38 return a.points == b.points && a.colors == b.colors;
39}
40
43{
44public:
45 typedef unsigned int GLuint;
46 typedef float GLfloat;
47
48 ViewportGL() = default;
51 ViewportGL& operator = ( const ViewportGL& ) { return *this; }
52
53 MRVIEWER_API ViewportGL( ViewportGL&& other ) noexcept;
56
58 void init();
60 void free();
61
63 void drawBorder( const Box2f& rect, const Color& color ) const;
64
66 void fillViewport( const Box2f& rect, const Color& color ) const;
67
69 bool checkInit() const;
70
73 {
74 std::span<VisualObject* const> renderVector;
76 Plane3f clippingPlane;
77 };
79 {
80 unsigned geomId{ unsigned( -1 ) };
81 unsigned primId{ unsigned( -1 ) };
83 };
86 {
87 float zBuffer{1.0f};
88 };
89 using PickResults = std::vector<PickResult>;
91 PickResults pickObjects( const PickParameters& params, const std::vector<Vector2i>& picks ) const;
94 std::vector<unsigned> findUniqueObjectsInRect( const PickParameters& params, const Box2i& rect,
95 int maxRenderResolutionSide ) const;
96
97 using BasePickResults = std::vector<BasePickResult>;
105 ScaledPickRes pickObjectsInRect( const PickParameters& params, const Box2i& rect,
106 int maxRenderResolutionSide ) const;
107
108private:
109 struct PickColor
110 {
111 unsigned color[4];
112 };
113
114 struct PickTextureFrameBuffer
115 {
116 void resize( const Vector2i& size );
117 void del();
118 void bind( bool read );
119 private:
120 unsigned int framebuffer_{ 0 };
121 unsigned int colorTexture_{ 0 };
122 unsigned int renderbuffer_{ 0 };
123 Vector2i size_;
124 };
125 mutable PickTextureFrameBuffer pickFBO_;
126
127 std::vector<PickColor> pickObjectsInRect_( const PickParameters& params, const Box2i& rect ) const;
128
129 bool inited_ = false;
130
131 GLuint add_line_colors_vbo = 0;
132 GLuint add_line_vbo = 0;
133 GLuint add_line_vao = 0;
134
135 GLuint add_point_colors_vbo = 0;
136 GLuint add_point_vbo = 0;
137 GLuint add_point_vao = 0;
138
139 GLuint border_line_vbo = 0;
140 GLuint border_line_vao = 0;
141};
142
143}
This class holds data needed to render viewport primitives and accumulative picker via OpenGL.
Definition MRViewportGL.h:43
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
Vector4f a
Definition MRViewportGL.h:21
BasePickResults pickRes
Definition MRViewportGL.h:100
unsigned primId
id of picked object in PickParameters::renderVector (-1 means invalid)
Definition MRViewportGL.h:81
MRVIEWER_API ViewportGL(ViewportGL &&other) noexcept
Box2i updatedBox
Definition MRViewportGL.h:101
std::vector< BasePickResult > BasePickResults
Definition MRViewportGL.h:97
unsigned int GLuint
Definition MRViewportGL.h:45
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
Vector4f b
Definition MRViewportGL.h:21
void fillViewport(const Box2f &rect, const Color &color) const
Fills viewport with given color (clear frame buffer)
ViewportGL(const ViewportGL &)
Copy operators do nothing, not to share GL data.
Definition MRViewportGL.h:50
float GLfloat
Definition MRViewportGL.h:46
bool checkInit() const
Check that members have been initialized.
BaseRenderParams baseRenderParams
objects to pick
Definition MRViewportGL.h:75
float zBuffer
Definition MRViewportGL.h:87
std::vector< PickResult > PickResults
Definition MRViewportGL.h:89
ViewportGL()=default
unsigned color[4]
Definition MRViewportGL.h:111
void resize(const Vector2i &size)
unsigned geomId
Definition MRViewportGL.h:80
PickResults pickObjects(const PickParameters &params, const std::vector< Vector2i > &picks) const
Find picked object, face id and z coordinate, of objects given in parameters (works for vector of pic...
void init()
Initialize all GL buffers and arrays.
std::vector< Vector3f > points
Definition MRViewportGL.h:32
void free()
Free all GL data.
std::vector< Vector4f > colors
Definition MRViewportGL.h:33
ViewportGL & operator=(const ViewportGL &)
Definition MRViewportGL.h:51
std::span< VisualObject *const > renderVector
Definition MRViewportGL.h:74
void drawBorder(const Box2f &rect, const Color &color) const
Binds and draws viewport border.
std::vector< unsigned > findUniqueObjectsInRect(const PickParameters &params, const Box2i &rect, int maxRenderResolutionSide) const
ScaledPickRes pickObjectsInRect(const PickParameters &params, const Box2i &rect, int maxRenderResolutionSide) const
Plane3f clippingPlane
parameters for rendering pick object
Definition MRViewportGL.h:76
@ other
Angle, normally float. Measure in radians.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Common rendering parameters for meshes and UI.
Definition MRIRenderObject.h:36
Definition MRColor.h:12
colors of segment ends
Definition MRViewportGL.h:20
Definition MRViewportGL.h:79
Parameters of objects picking.
Definition MRViewportGL.h:73
Result of object picking.
Definition MRViewportGL.h:86
Definition MRViewportGL.h:99
stores points and corresponding colors (sizes of vectors should be the same)
Definition MRViewportGL.h:31