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{
13class RenderLinesObject : public virtual IRenderObject
14{
15public:
18
19 virtual bool render( const ModelRenderParams& params ) override;
20 virtual void renderPicker( const ModelBaseRenderParams& params, unsigned geomId ) override;
21 virtual size_t heapBytes() const override;
22 virtual size_t glBytes() const override;
23 virtual void forceBindAll() override;
24
25private:
26 const ObjectLinesHolder* objLines_ = nullptr;
27 int lineIndicesSize_{ 0 };
28
29 typedef unsigned int GLuint;
30
31 GLuint linesArrayObjId_{ 0 };
32 GLuint linesPickerArrayObjId_{ 0 };
33
34 GlTexture2 positionsTex_;
35 GlTexture2 accumScreenLengthTex_;
36 GlTexture2 vertColorsTex_;
37 GlTexture2 lineColorsTex_;
38
39 void render_( const ModelRenderParams& params, bool points );
40 void renderPicker_( const ModelBaseRenderParams& params, unsigned geomId, bool points );
41
42 void bindPositions_( GLuint shaderId );
43 void calcAndBindLength_( const ModelRenderParams& params, GLuint shaderId );
44
45 void bindLines_( GLStaticHolder::ShaderType shaderType );
46 void bindLinesPicker_( GLStaticHolder::ShaderType shaderType );
47
48 // Create a new set of OpenGL buffer objects
49 void initBuffers_();
50
51 // Release the OpenGL buffer objects
52 void freeBuffers_();
53
54 void update_();
55
56 // these are to be checked as dirty flag for calculating screen length on CPU
57 Matrix4f prevProj_;
58 Matrix4f prevView_;
59 Matrix4f prevModel_;
60 Vector4i prevViewport_;
61 bool needAccumLengthDirtyUpdate_( const ModelRenderParams& params );
62 void resetAccumLengthDirty_( const ModelRenderParams& params );
63
64 bool needUpdateScreenLengths_{ true };
65 // Marks dirty buffers that need to be uploaded to OpenGL
66 uint32_t dirty_;
67};
68
69// Returns the range of line widths that are allowed by current renderer
70MRVIEWER_API const Vector2f& GetAvailableLineWidthRange();
71
72}
ShaderType
Definition MRGLStaticHolder.h:16
Definition MRIRenderObject.h:131
Definition MRObjectLinesHolder.h:27
Definition MRRenderLinesObject.h:14
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)
virtual bool render(const ModelRenderParams &params) override
virtual void forceBindAll() override
binds all data for this render object, not to bind ever again (until object becomes dirty)
virtual void renderPicker(const ModelBaseRenderParams &params, unsigned geomId) override
Visual Object.
Definition MRVisualObject.h:119
Definition MRCameraOrientationPlugin.h:8
MRVIEWER_API const Vector2f & GetAvailableLineWidthRange()
Definition MRIRenderObject.h:43
Mesh rendering parameters for primary rendering (as opposed to the picker).
Definition MRIRenderObject.h:51