MeshLib Documentation
Loading...
Searching...
No Matches
MRRenderMeshObject.h
Go to the documentation of this file.
1#pragma once
2#include "exports.h"
5#include "MRMesh/MRBuffer.h"
6#include "MRRenderGLHelpers.h"
7#include "MRRenderHelpers.h"
8
9namespace MR
10{
11class MRVIEWER_CLASS RenderMeshObject : public virtual IRenderObject
12{
13public:
14 MRVIEWER_API RenderMeshObject( const VisualObject& visObj );
15 MRVIEWER_API virtual ~RenderMeshObject();
16
17 MRVIEWER_API virtual bool render( const ModelRenderParams& params ) override;
18 MRVIEWER_API virtual void renderPicker( const ModelBaseRenderParams& params, unsigned geomId ) override;
19 MRVIEWER_API virtual size_t heapBytes() const override;
20 MRVIEWER_API virtual size_t glBytes() const override;
21 MRVIEWER_API virtual void forceBindAll() override;
22protected:
24
25 int vertPosSize_{ 0 };
26 int vertNormalsSize_{ 0 };
27 int vertColorsSize_{ 0 };
28 int vertUVSize_{ 0 };
29 int faceIndicesSize_{ 0 };
30 int edgeSize_{ 0 };
31 int selEdgeSize_{ 0 };
32 int bordersSize_{ 0 };
33 int pointSize_{ 0 };
34 int pointValidSize_{ 0 };
38
48
49 typedef unsigned int GLuint;
50
51 GLuint edgesArrayObjId_{ 0 };
52 GLuint borderArrayObjId_{ 0 };
54
55 GLuint selectedEdgesArrayObjId_{ 0 };
57
58 GLuint meshArrayObjId_{ 0 };
59 GLuint meshPickerArrayObjId_{ 0 };
60
65
67
72
74
80
81 int maxTexSize_{ 0 };
82
83 GLuint pointsArrayObjId_{ 0 };
85 bool dirtyPointPos_ = false;
86
87 MRVIEWER_API virtual void renderEdges_( const ModelRenderParams& parameters, bool alphaSort, GLuint vao, const Color& color, uint32_t dirtyFlag );
88
89 MRVIEWER_API virtual void renderMeshEdges_( const ModelRenderParams& parameters, bool alphaSort );
90 MRVIEWER_API virtual void renderMeshVerts_( const ModelRenderParams& parameters, bool alphaSort );
91
92 MRVIEWER_API virtual void bindMesh_( bool alphaSort );
93
94 MRVIEWER_API virtual void bindMeshPicker_();
95
96 MRVIEWER_API virtual void bindEdges_();
97 MRVIEWER_API virtual void bindBorders_();
98 MRVIEWER_API virtual void bindSelectedEdges_();
99 MRVIEWER_API virtual void bindEmptyTextures_( GLuint shaderId );
100 MRVIEWER_API virtual void bindPoints_( bool alphaSort );
101
102 MRVIEWER_API virtual void drawMesh_( bool solid, ViewportId viewportId, bool picker = false ) const;
103
104 // Create a new set of OpenGL buffer objects
105 MRVIEWER_API virtual void initBuffers_();
106
107 // Release the OpenGL buffer objects
108 MRVIEWER_API virtual void freeBuffers_();
109
110 MRVIEWER_API virtual void update_( ViewportMask mask );
111
112 // Marks dirty buffers that need to be uploaded to OpenGL
113 uint32_t dirty_{ 0 };
114 // ...
115 bool dirtyEdges_{ false };
116
117#ifdef __EMSCRIPTEN__
118 bool cornerMode = true;
119#else
120 bool cornerMode = false;
121#endif
122};
123
124}
Definition MRRenderGLHelpers.h:16
Definition MRRenderGLHelpers.h:88
Definition MRRenderGLHelpers.h:65
Definition MRIRenderObject.h:134
Definition MRObjectMeshHolder.h:30
Definition MRRenderHelpers.h:16
Definition MRRenderMeshObject.h:12
virtual MRVIEWER_API void forceBindAll() override
binds all data for this render object, not to bind ever again (until object becomes dirty)
virtual MRVIEWER_API void bindPoints_(bool alphaSort)
GlBuffer facesIndicesBuffer_
Definition MRRenderMeshObject.h:66
GlBuffer vertUVBuffer_
Definition MRRenderMeshObject.h:62
MRVIEWER_API RenderBufferRef< Vector3f > loadVertPosBuffer_()
MRVIEWER_API RenderBufferRef< UVCoord > loadVertUVBuffer_()
MRVIEWER_API RenderBufferRef< Vector4f > loadFaceNormalsTextureBuffer_()
GlTexture2 selEdgesTexture_
Definition MRRenderMeshObject.h:76
MRVIEWER_API RenderBufferRef< uint8_t > loadTexturePerFaceTextureBuffer_()
GlTexture2 emptyVertsColorTexture_
Definition MRRenderMeshObject.h:78
virtual MRVIEWER_API void bindSelectedEdges_()
MRVIEWER_API RenderBufferRef< Vector3i > loadFaceIndicesBuffer_()
virtual MRVIEWER_API void initBuffers_()
MRVIEWER_API RenderBufferRef< Vector3f > loadVertNormalsBuffer_()
unsigned int GLuint
Definition MRRenderMeshObject.h:49
MRVIEWER_API RenderMeshObject(const VisualObject &visObj)
GlTexture2 emptyLinesColorTexture_
Definition MRRenderMeshObject.h:79
MRVIEWER_API RenderBufferRef< VertId > loadPointValidIndicesBuffer_()
virtual MRVIEWER_API void bindMeshPicker_()
virtual MRVIEWER_API void renderPicker(const ModelBaseRenderParams &params, unsigned geomId) override
const ObjectMeshHolder * objMesh_
Definition MRRenderMeshObject.h:23
virtual MRVIEWER_API ~RenderMeshObject()
virtual MRVIEWER_API void bindEmptyTextures_(GLuint shaderId)
GlBuffer borderBuffer_
Definition MRRenderMeshObject.h:53
virtual MRVIEWER_API void freeBuffers_()
virtual MRVIEWER_API void bindMesh_(bool alphaSort)
virtual MRVIEWER_API size_t glBytes() const override
returns the amount of memory this object allocated in OpenGL
GlTexture2 facesNormalsTex_
Definition MRRenderMeshObject.h:70
GlTexture2 faceSelectionTex_
Definition MRRenderMeshObject.h:68
Vector2i texturePerFaceSize_
Definition MRRenderMeshObject.h:37
GlBuffer vertNormalsBuffer_
Definition MRRenderMeshObject.h:63
virtual MRVIEWER_API void drawMesh_(bool solid, ViewportId viewportId, bool picker=false) const
GlBuffer selectedEdgesBuffer_
Definition MRRenderMeshObject.h:56
MRVIEWER_API RenderBufferRef< Color > loadVertColorsBuffer_()
GlBuffer vertColorsBuffer_
Definition MRRenderMeshObject.h:64
GlTexture2 texturePerFace_
Definition MRRenderMeshObject.h:71
GlTexture2DArray textureArray_
Definition MRRenderMeshObject.h:73
virtual MRVIEWER_API size_t heapBytes() const override
returns the amount of memory this object occupies on heap
MRVIEWER_API RenderBufferRef< unsigned > loadFaceSelectionTextureBuffer_()
GlBuffer vertPosBuffer_
Definition MRRenderMeshObject.h:61
virtual MRVIEWER_API void renderMeshEdges_(const ModelRenderParams &parameters, bool alphaSort)
GlBuffer pointValidBuffer_
Definition MRRenderMeshObject.h:84
virtual MRVIEWER_API void update_(ViewportMask mask)
virtual MRVIEWER_API void bindBorders_()
GlTexture2 borderTexture_
Definition MRRenderMeshObject.h:77
virtual MRVIEWER_API void bindEdges_()
virtual MRVIEWER_API void renderEdges_(const ModelRenderParams &parameters, bool alphaSort, GLuint vao, const Color &color, uint32_t dirtyFlag)
GlTexture2 edgesTexture_
Definition MRRenderMeshObject.h:75
virtual MRVIEWER_API void renderMeshVerts_(const ModelRenderParams &parameters, bool alphaSort)
Vector2i faceSelectionTextureSize_
Definition MRRenderMeshObject.h:35
Vector2i faceNormalsTextureSize_
Definition MRRenderMeshObject.h:36
virtual MRVIEWER_API bool render(const ModelRenderParams &params) override
GlTexture2 faceColorsTex_
Definition MRRenderMeshObject.h:69
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
Visual Object.
Definition MRVisualObject.h:131
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:9
Definition MRIRenderObject.h:43
Mesh rendering parameters for primary rendering (as opposed to the picker).
Definition MRIRenderObject.h:51