get image function
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
GLWidget::GLWidget(QWidget *parent) : QWidget(parent) {
|
GLWidget::GLWidget(QWidget *parent) : QWidget(parent) {
|
||||||
view_ = new QGLView();
|
view_ = new QGLView();
|
||||||
view_->setFlags(windowFlags() | Qt::FramelessWindowHint);
|
//view_->setFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||||
container = QWidget::createWindowContainer(view_, this);
|
container = QWidget::createWindowContainer(view_, this);
|
||||||
lay = new QVBoxLayout(this);
|
lay = new QVBoxLayout(this);
|
||||||
lay->addWidget(container);
|
lay->addWidget(container);
|
||||||
|
|||||||
@@ -173,6 +173,9 @@ public:
|
|||||||
void setCurrentAction(RendererService::HandleAction ha) {renderer_.rend_service.setCurrentAction(ha);}
|
void setCurrentAction(RendererService::HandleAction ha) {renderer_.rend_service.setCurrentAction(ha);}
|
||||||
void setContextActions(QList<QAction*> al) {context_menu.clear(); context_menu.addActions(al);}
|
void setContextActions(QList<QAction*> al) {context_menu.clear(); context_menu.addActions(al);}
|
||||||
void popupMenu(const QPoint &pos, QAction *at = nullptr) {context_menu.popup(pos, at);}
|
void popupMenu(const QPoint &pos, QAction *at = nullptr) {context_menu.popup(pos, at);}
|
||||||
|
void setGrabImage(bool on) {renderer_.setGrabImage(on);}
|
||||||
|
bool isGrabImage() const {return renderer_.isGrabImage();}
|
||||||
|
QImage getImage() const {return renderer_.getImage();}
|
||||||
|
|
||||||
GLfloat aspect, iaspect;
|
GLfloat aspect, iaspect;
|
||||||
Renderer renderer_;
|
Renderer renderer_;
|
||||||
|
|||||||
17
renderer.cpp
17
renderer.cpp
@@ -85,6 +85,7 @@ void Renderer::init(int width, int height) {
|
|||||||
initCoeffTextures();
|
initCoeffTextures();
|
||||||
markReloadTextures();
|
markReloadTextures();
|
||||||
tex_env.init();
|
tex_env.init();
|
||||||
|
if (is_grabbing) fbo_out.enablePixelBuffer();
|
||||||
need_init_shaders = true;
|
need_init_shaders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,18 +348,18 @@ void Renderer::renderScene() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// tonemapping
|
/// tonemapping
|
||||||
if (tone_proc.process()) fbo_out.bind();
|
tone_proc.process();
|
||||||
if (bindShader(srTonemapPass, &prog)) {
|
if (bindShader(srTonemapPass, &prog)) {
|
||||||
|
fbo_out.bind();
|
||||||
prog->setUniformValue("gamma", gamma_);
|
prog->setUniformValue("gamma", gamma_);
|
||||||
prog->setUniformValue("frame_max", tone_proc.frameMax());
|
prog->setUniformValue("frame_max", tone_proc.frameMax());
|
||||||
fbo_out.bindColorTexture(obrSum, 0);
|
fbo_out.bindColorTexture(obrSum, 0);
|
||||||
fbo_out.setWriteBuffer(obrTonemap);
|
fbo_out.setWriteBuffer(obrTonemap);
|
||||||
renderQuad(prog, quad);
|
renderQuad(prog, quad);
|
||||||
|
fbo_out.release();
|
||||||
} else {
|
} else {
|
||||||
fbo_out.blit(obrSum, fbo_out.id(), obrTonemap, fbo_out.rect(), fbo_out.rect());
|
fbo_out.blit(obrSum, fbo_out.id(), obrTonemap, fbo_out.rect(), fbo_out.rect());
|
||||||
}
|
}
|
||||||
//glClearFramebuffer(Qt::red, false);
|
|
||||||
fbo_out.release();
|
|
||||||
|
|
||||||
/// apply hovers and selection frame
|
/// apply hovers and selection frame
|
||||||
if (edit_mode) {
|
if (edit_mode) {
|
||||||
@@ -367,6 +368,11 @@ void Renderer::renderScene() {
|
|||||||
} else {
|
} else {
|
||||||
fbo_out.blit(obrTonemap, 0, 0, fbo_out.rect(), QRect(QPoint(), view->size()));
|
fbo_out.blit(obrTonemap, 0, 0, fbo_out.rect(), QRect(QPoint(), view->size()));
|
||||||
}
|
}
|
||||||
|
if (is_grabbing) {
|
||||||
|
fbo_out.queryImage(0);
|
||||||
|
last_img = fbo_out.getImage().mirrored();
|
||||||
|
//qDebug() << last_img.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -374,3 +380,8 @@ void Renderer::setCameraLightMode(int m) {
|
|||||||
camera_light_mode = m;
|
camera_light_mode = m;
|
||||||
view->scene()->setLightsChanged();
|
view->scene()->setLightsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::setGrabImage(bool on) {
|
||||||
|
is_grabbing = on;
|
||||||
|
//fbo_out.enablePixelBuffer();
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ public:
|
|||||||
void renderScene();
|
void renderScene();
|
||||||
void setCameraLightMode(int m);
|
void setCameraLightMode(int m);
|
||||||
int cameraLightMode() const {return camera_light_mode;}
|
int cameraLightMode() const {return camera_light_mode;}
|
||||||
|
void setGrabImage(bool on);
|
||||||
|
bool isGrabImage() const {return is_grabbing;}
|
||||||
|
QImage getImage() const {return last_img;}
|
||||||
|
|
||||||
QImage materialThumbnail(Material * m) {return rend_mat.materialThumbnail(m);}
|
QImage materialThumbnail(Material * m) {return rend_mat.materialThumbnail(m);}
|
||||||
void recreateMaterialThumbnails(bool force_all = false) {rend_mat.recreateMaterialThumbnails(force_all);}
|
void recreateMaterialThumbnails(bool force_all = false) {rend_mat.recreateMaterialThumbnails(force_all);}
|
||||||
@@ -125,6 +128,8 @@ private:
|
|||||||
QVector4D corner_dirs[4];
|
QVector4D corner_dirs[4];
|
||||||
QVector<QVector3D> hcontent;
|
QVector<QVector3D> hcontent;
|
||||||
QMap<int, QList<Light*>> cur_lights;
|
QMap<int, QList<Light*>> cur_lights;
|
||||||
|
QImage last_img;
|
||||||
|
bool is_grabbing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RENDERER_H
|
#endif // RENDERER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user