fixes #0004103: Black screen when using rubberband selection

This commit is contained in:
wmayer
2019-09-17 15:55:05 +02:00
parent f76e74d2c1
commit f4bc889b4d
4 changed files with 76 additions and 20 deletions

View File

@@ -416,6 +416,13 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr,
#endif
this->framebuffer = NULL;
this->numSamples = -1;
#if defined(HAVE_QT5_OPENGL)
//this->texFormat = GL_RGBA32F_ARB;
this->texFormat = GL_RGB32F_ARB;
#else
//this->texFormat = GL_RGBA;
this->texFormat = GL_RGB;
#endif
this->cache_context = 0;
this->pbuffer = false;
}
@@ -532,6 +539,18 @@ SoQtOffscreenRenderer::getNumPasses(void) const
return PRIVATE(this)->numSamples;
}
void
SoQtOffscreenRenderer::setInternalTextureFormat(GLenum internalTextureFormat)
{
PRIVATE(this)->texFormat = internalTextureFormat;
}
GLenum
SoQtOffscreenRenderer::internalTextureFormat() const
{
return PRIVATE(this)->texFormat;
}
void
SoQtOffscreenRenderer::setPbufferEnable(SbBool enable)
{
@@ -603,13 +622,7 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples)
// is to use a certain background color using GL_RGB as texture
// format and in the output image search for the above color and
// replaces it with the color requested by the user.
#if defined(HAVE_QT5_OPENGL)
//fmt.setInternalTextureFormat(GL_RGBA32F_ARB);
fmt.setInternalTextureFormat(GL_RGB32F_ARB);
#else
//fmt.setInternalTextureFormat(GL_RGBA);
fmt.setInternalTextureFormat(GL_RGB);
#endif
fmt.setInternalTextureFormat(this->texFormat);
#else
QtGLFramebufferObject::Attachment fmt;
fmt = QtGLFramebufferObject::Depth;

View File

@@ -117,6 +117,9 @@ public:
void setNumPasses(const int num);
int getNumPasses(void) const;
void setInternalTextureFormat(GLenum internalTextureFormat);
GLenum internalTextureFormat() const;
void setPbufferEnable(SbBool enable);
SbBool getPbufferEnable(void) const;
@@ -148,6 +151,7 @@ private:
SbBool didallocation;
SbBool pbuffer;
int numSamples;
GLenum texFormat;
#if defined(HAVE_QT5_OPENGL)
QImage glImage;
#endif

View File

@@ -1557,6 +1557,7 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI
if (!useCoinOffscreenRenderer) {
SoQtOffscreenRenderer renderer(vp);
renderer.setNumPasses(s);
renderer.setInternalTextureFormat(getInternalTextureFormat());
renderer.setPbufferEnable(usePixelBuffer);
if (bgColor.isValid())
renderer.setBackgroundColor(SbColor4f(bgColor.redF(), bgColor.greenF(), bgColor.blueF(), bgColor.alphaF()));
@@ -1859,6 +1860,53 @@ int View3DInventorViewer::getNumSamples()
}
}
GLenum View3DInventorViewer::getInternalTextureFormat() const
{
#if defined(HAVE_QT5_OPENGL)
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View");
std::string format = hGrp->GetASCII("InternalTextureFormat", "Default");
if (format == "GL_RGB") {
return GL_RGB;
}
else if (format == "GL_RGBA") {
return GL_RGBA;
}
else if (format == "GL_RGB8") {
return GL_RGB8;
}
else if (format == "GL_RGBA8") {
return GL_RGBA8;
}
else if (format == "GL_RGB10") {
return GL_RGB10;
}
else if (format == "GL_RGB10_A2") {
return GL_RGB10_A2;
}
else if (format == "GL_RGB16") {
return GL_RGB16;
}
else if (format == "GL_RGBA16") {
return GL_RGBA16;
}
else if (format == "GL_RGB32F") {
return GL_RGB32F_ARB;
}
else if (format == "GL_RGBA32F") {
return GL_RGBA32F_ARB;
}
else {
QOpenGLFramebufferObjectFormat fboFormat;
return fboFormat.internalTextureFormat();
}
#else
//return GL_RGBA;
return GL_RGB;
#endif
}
void View3DInventorViewer::setRenderType(const RenderType type)
{
renderType = type;
@@ -1946,7 +1994,7 @@ QImage View3DInventorViewer::grabFramebuffer()
fboFormat.setSamples(getNumSamples());
fboFormat.setAttachment(QOpenGLFramebufferObject::Depth);
fboFormat.setTextureTarget(GL_TEXTURE_2D);
fboFormat.setInternalTextureFormat(GL_RGB32F_ARB);
fboFormat.setInternalTextureFormat(getInternalTextureFormat());
QOpenGLFramebufferObject fbo(width, height, fboFormat);
renderToFramebuffer(&fbo);
@@ -1978,18 +2026,8 @@ void View3DInventorViewer::imageFromFramebuffer(int width, int height, int sampl
// is to use a certain background color using GL_RGB as texture
// format and in the output image search for the above color and
// replaces it with the color requested by the user.
#if defined(HAVE_QT5_OPENGL)
if (App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetBool("SaveThumbnailFix",false)) {
fboFormat.setInternalTextureFormat(GL_RGBA32F_ARB);
}
else {
fboFormat.setInternalTextureFormat(GL_RGB32F_ARB);
}
#else
//fboFormat.setInternalTextureFormat(GL_RGBA);
fboFormat.setInternalTextureFormat(GL_RGB);
#endif
fboFormat.setInternalTextureFormat(getInternalTextureFormat());
QtGLFramebufferObject fbo(width, height, fboFormat);
const QColor col = backgroundColor();

View File

@@ -377,6 +377,7 @@ public:
virtual PyObject *getPyObject(void);
protected:
GLenum getInternalTextureFormat() const;
void renderScene();
void renderFramebuffer();
void renderGLImage();