1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0026711: Visualization, TKOpenGl - support creation of multisampling off-screen FBOs

OpenGl_Texture::Init2DMultisample() - new method to initialize multisampled texture.
Graphic3d_RenderingParams::NbMsaaSamples - add option defining MSAA samples number.

RayTracing will keep using FBO without MSAA, however it is possible to combine
MSAA for rasterization and FSAA for RayTracing.

OpenGl_FrameBuffer constructor has been changed to do not take arguments.
OpenGl_FrameBuffer::Init() method has been extended with mandatory parameters
defining Color and Depth attachment formats
and optional parameter defining number of MSAA parameters.

Draw Harness, add option -msaa to vrenderparams.
This commit is contained in:
kgv
2015-10-21 19:06:02 +03:00
committed by bugmaster
parent 9535c4be46
commit 3c4b62a436
17 changed files with 508 additions and 168 deletions

View File

@@ -16,7 +16,7 @@
#include <OpenGl_ArbFBO.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_GlCore15.hxx>
#include <OpenGl_GlCore32.hxx>
#include <Graphic3d_TextureParams.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Standard_Assert.hxx>
@@ -660,6 +660,58 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
theType, &theImage);
}
// =======================================================================
// function : Init2DMultisample
// purpose :
// =======================================================================
bool OpenGl_Texture::Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
const GLsizei theNbSamples,
const GLint theTextFormat,
const GLsizei theSizeX,
const GLsizei theSizeY)
{
if (!Create (theCtx)
|| theNbSamples > theCtx->MaxMsaaSamples()
|| theNbSamples < 1)
{
return false;
}
const GLsizei aNbSamples = OpenGl_Context::GetPowerOfTwo (theNbSamples, theCtx->MaxMsaaSamples());
myTarget = GL_TEXTURE_2D_MULTISAMPLE;
if(theSizeX > theCtx->MaxTextureSize()
|| theSizeY > theCtx->MaxTextureSize())
{
return false;
}
Bind (theCtx);
//myTextFormat = theTextFormat;
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->Functions()->glTexStorage2DMultisample != NULL)
{
theCtx->Functions()->glTexStorage2DMultisample (myTarget, aNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE);
}
else
{
theCtx->Functions()->glTexImage2DMultisample (myTarget, aNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE);
}
#else
theCtx->Functions() ->glTexStorage2DMultisample (myTarget, aNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE);
#endif
if (theCtx->core11fwd->glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
return false;
}
mySizeX = theSizeX;
mySizeY = theSizeY;
Unbind (theCtx);
return true;
}
// =======================================================================
// function : InitRectangle
// purpose :