-
Notifications
You must be signed in to change notification settings - Fork 3
/
myFboRenderer.cpp
55 lines (46 loc) · 1.53 KB
/
myFboRenderer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "myFboRenderer.h"
#include <QOpenGLFramebufferObject>
#include <iostream>
#include <FboOffscreenWindow.h>
myFboRenderer::myFboRenderer(FboOffscreenWindow *offscreenWindow)
: m_fboOffscreenWindow(offscreenWindow), m_fbo(0)
{
m_fboOffscreenWindow->Register(NULL);
m_fboOffscreenWindow->QtParentRenderer = this;
#ifdef __APPLE__
m_interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
#endif
#ifdef __linux__
m_interactor = vtkSmartPointer<quick::Vtk::GenericInteractor>::New();
#endif
#ifdef _MSC_VER
m_interactor = vtkSmartPointer<quick::Vtk::Win32Interactor>::New();
#endif
m_interactorStyle = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
m_interactor->SetRenderWindow(offscreenWindow);
m_interactor->Initialize();
m_interactor->SetInteractorStyle(m_interactorStyle);
}
myFboRenderer::~myFboRenderer()
{
m_fboOffscreenWindow->QtParentRenderer = 0;
m_fboOffscreenWindow->Delete();
}
void myFboRenderer::render()
{
m_interactor->Disable();
m_fboOffscreenWindow->PushState();
m_fboOffscreenWindow->OpenGLInitState();
m_fboOffscreenWindow->InternalRender();
m_fboOffscreenWindow->PopState();
m_interactor->Enable();
}
QOpenGLFramebufferObject *myFboRenderer::createFramebufferObject(const QSize &size)
{
std::cout<<__FUNCTION__<<std::endl;
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(4);
m_fbo = new QOpenGLFramebufferObject(size, format);
return m_fbo;
}