MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRenderLinesObject.h
Go to the documentation of this file.
1#pragma once
2#include "exports.h"
5#include "MRMesh/MRMatrix4.h"
6#include <MRMesh/MRId.h>
7#include "MRGLStaticHolder.h"
8#include "MRRenderGLHelpers.h"
9#include "MRRenderHelpers.h"
10
11namespace MR
12{
15
16class RenderLinesObject : public virtual IRenderObject
17{
18public:
21
22 virtual bool render( const ModelRenderParams& params ) override;
23 virtual void renderPicker( const ModelBaseRenderParams& params, unsigned geomId ) override;
24 virtual size_t heapBytes() const override;
25 virtual size_t glBytes() const override;
26 virtual void forceBindAll() override;
27
28private:
29 const ObjectLinesHolder* objLines_ = nullptr;
30 int lineIndicesSize_{ 0 };
31
32 typedef unsigned int GLuint;
33
34 GLuint linesArrayObjId_{ 0 };
35 GLuint linesPickerArrayObjId_{ 0 };
36
37 GlTexture2 positionsTex_;
38 GlTexture2 accumScreenLengthTex_;
39 GlTexture2 vertColorsTex_;
40 GlTexture2 lineColorsTex_;
41
42 void render_( const ModelRenderParams& params, bool points, RenderModelPassMask desiredPass );
43 void renderPicker_( const ModelBaseRenderParams& params, unsigned geomId, bool points );
44
45 void bindPositions_( GLuint shaderId );
46 void calcAndBindLength_( const ModelRenderParams& params, GLuint shaderId );
47
48 void bindLines_( GLStaticHolder::ShaderType shaderType );
49 void bindLinesPicker_( GLStaticHolder::ShaderType shaderType );
50
52 void initBuffers_();
53
55 void freeBuffers_();
56
57 void update_();
58
60 Matrix4f prevProj_;
61 Matrix4f prevView_;
62 Matrix4f prevModel_;
63 Vector4i prevViewport_;
64 bool needAccumLengthDirtyUpdate_( const ModelRenderParams& params );
65 void resetAccumLengthDirty_( const ModelRenderParams& params );
66
67 bool needUpdateScreenLengths_{ true };
69 uint32_t dirty_;
70};
71
73MRVIEWER_API const Vector2f& GetAvailableLineWidthRange();
74
75}
Definition MRIRenderObject.h:134
Definition MRObjectLinesHolder.h:30
Definition MRRenderLinesObject.h:17
Visual Object.
Definition MRVisualObject.h:116
ShaderType
Definition MRGLStaticHolder.h:19
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
virtual size_t glBytes() const override
returns the amount of memory this object allocated in OpenGL
RenderLinesObject(const VisualObject &visObj)
RenderModelPassMask
Various passes of the 3D rendering.
Definition MRRenderModelParameters.h:40
virtual bool render(const ModelRenderParams &params) override
Returns true if something was rendered, or false if nothing to render.
virtual void forceBindAll() override
binds all data for this render object, not to bind ever again (until object becomes dirty)
MRVIEWER_API const Vector2f & GetAvailableLineWidthRange()
Returns the range of line widths that are allowed by current renderer.
virtual void renderPicker(const ModelBaseRenderParams &params, unsigned geomId) override
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRIRenderObject.h:46
Mesh rendering parameters for primary rendering (as opposed to the picker).
Definition MRIRenderObject.h:54