mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0029528: Visualization, TKOpenGl - allow defining sRGB textures
OpenGL rendering is now done into sRGB framebuffer. OpenGl_ShaderManager::prepareStdProgramFboBlit() has been extended by programs resolving MSAA texture and applying gamma correction as fallbacks. Quantity_Color definition has been modified to store RGB components in linear color space within Quantity_TOC_RGB type. Standard colors defined by Quantity_NameOfColor enumeration has been updated accordingly. New Quantity_TOC_sRGB type has been introduced to handle RGB components in non-linear sRGB color space. OpenGl_TextureFormat class definition has been moved to dedicated files. New method OpenGl_TextureFormat::FindFormat() replaces OpenGl_Texture::GetDataFormat(). New method OpenGl_TextureFormat::FindSizedFormat() replaces OpenGl_FrameBuffer::getColorDataFormat() and OpenGl_FrameBuffer::getDepthDataFormat(). Graphic3d_TextureRoot::IsColorMap() - introduced new property defining if RGB(A)8 image formats should be loaded as sRGB(A) textures or as data RGB(A) textures. OpenGl_Texture initialization methods have been extended with new theIsColorMap argument. vreadpixel - added argument -sRGB printing color in sRGB color space. Test cases have been updated to new sRGB rendered results.
This commit is contained in:
parent
aaf8d6a98d
commit
ba00aab7a0
@ -1860,6 +1860,27 @@ The application code relying on this matter should be updated to either specify
|
||||
|
||||
@section upgrade_occt750 Upgrade to OCCT 7.5.0
|
||||
|
||||
@subsection upgrade_750_srgb_color RGB color definition
|
||||
|
||||
OCCT 3D Viewer has been improved to properly perform lighting using in linear RGB color space and then convert result into non-linear gamma-shifted sRGB color space before displaying on display.
|
||||
This change affects texture mapping, material definition and color definition.
|
||||
|
||||
Previously *Quantity_Color* definition was provided with unspecified RGB color space.
|
||||
In practice, mixed color spaces have been actually used, with non-linear sRGB prevailing in general.
|
||||
Since OCCT 7.5.0, *Quantity_Color* now specifies that components are defined in linear RGB color space.
|
||||
|
||||
This change affects following parts:
|
||||
* Standard colors defined by *Quantity_NameOfColor* enumeration have been converted into linear RGB values within Quantity_Color construction.
|
||||
* Application may use new enumeration value *Quantity_TOC_sRGB* for passing/fetching colors in sRGB color space,
|
||||
which can be useful for interoperation with color picking widgets (returning 8-bit integer values within [0..255] range)
|
||||
or for porting colors constants within old application code without manual conversion.
|
||||
* *Graphic3d_MaterialAspect* color components are now expected in linear RGB color space,
|
||||
and standard OCCT materials within *Graphic3d_NameOfMaterial* enumeration have been updated accordingly.
|
||||
* Texture mapping now handles new *Graphic3d_TextureRoot::IsColorMap()* for interpreting content in linear RGB or sRGB color space.
|
||||
It is responsibility of user specifying this flag correctly. The flag value is TRUE by default.
|
||||
* Method *Image_PixMap::PixelColor()* has been extended with a new Boolean flag for performing linearization of non-linear sRGB.
|
||||
This flag is FALSE by default; application should consider passing TRUE instead for further handling *Quantity_Color* properly as linear RGB values.
|
||||
|
||||
@subsection upgrade_750_rename Renaming of types
|
||||
|
||||
Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity.
|
||||
|
@ -138,6 +138,8 @@ Cocoa_Window::Cocoa_Window (const Standard_CString theTitle,
|
||||
{
|
||||
throw Aspect_WindowDefinitionError("Unable to create window");
|
||||
}
|
||||
// for the moment, OpenGL renderer is expected to output sRGB colorspace
|
||||
[myHWindow setColorSpace: [NSColorSpace sRGBColorSpace]];
|
||||
myHView = [[myHWindow contentView] retain];
|
||||
|
||||
NSString* aTitleNs = [[NSString alloc] initWithUTF8String: theTitle];
|
||||
|
@ -193,14 +193,11 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
|
||||
myIsOwnDepth = true;
|
||||
theCtx->arbFBO->glGenFramebuffers (1, &myGlFBufferId);
|
||||
|
||||
GLenum aPixelFormat = 0, aDataType = 0;
|
||||
if (myDepthFormat != 0
|
||||
&& getDepthDataFormat (myDepthFormat, aPixelFormat, aDataType)
|
||||
&& !myDepthStencilTexture->Init (theCtx, myDepthFormat,
|
||||
aPixelFormat, aDataType,
|
||||
aSizeX, aSizeY, Graphic3d_TOT_2D))
|
||||
const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
|
||||
if (aDepthFormat.IsValid()
|
||||
&& !myDepthStencilTexture->Init (theCtx, aDepthFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString("D3DHost_FrameBuffer, could not initialize GL_DEPTH24_STENCIL8 texture ") + aSizeX + "x" + aSizeY);
|
||||
return Standard_False;
|
||||
@ -288,17 +285,16 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
myColorTextures (0)->GetTarget(), myColorTextures (0)->TextureId(), 0);
|
||||
|
||||
GLenum aDepthPixelFormat = 0, aDepthDataType = 0;
|
||||
getDepthDataFormat (myDepthFormat, aDepthPixelFormat, aDepthDataType);
|
||||
const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
|
||||
if (myDepthStencilTexture->IsValid())
|
||||
{
|
||||
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthPixelFormat == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
#else
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
if (aDepthPixelFormat == GL_DEPTH_STENCIL)
|
||||
if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
|
||||
{
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
@ -310,12 +306,12 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
|
||||
if (myDepthStencilTexture->IsValid())
|
||||
{
|
||||
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthPixelFormat == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), 0, 0);
|
||||
#else
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), 0, 0);
|
||||
if (aDepthPixelFormat == GL_DEPTH_STENCIL)
|
||||
if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
|
||||
{
|
||||
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), 0, 0);
|
||||
|
@ -91,9 +91,9 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_ASPECT;
|
||||
|
||||
Shininess = 0.0078125f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.50f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.25f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.24f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.06f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.004896f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
BSDF.Kd = Graphic3d_Vec3 (0.2f);
|
||||
@ -104,7 +104,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_ASPECT;
|
||||
|
||||
Shininess = 1.00f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.44f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.22f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.50f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.0f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
@ -117,9 +117,9 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_ASPECT;
|
||||
|
||||
Shininess = 0.09375f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.33f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.165f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.40f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.44f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.162647f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
BSDF.Kd = Graphic3d_Vec3 (0.2f);
|
||||
@ -131,7 +131,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Shininess = 0.05f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (1.0f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.62f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.342392f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (1.0f));
|
||||
|
||||
BSDF.Kd = Graphic3d_Vec3 (0.0f);
|
||||
@ -145,7 +145,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Shininess = 0.13f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.47f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.45f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.170645f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
BSDF = Graphic3d_BSDF::CreateMetallic (Graphic3d_Vec3 (0.985f, 0.985f, 0.985f),
|
||||
@ -158,8 +158,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.58f, 0.42f, 0.20f)), 0.045f);
|
||||
|
||||
Shininess = 0.65f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.329f, 0.224f, 0.027f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.780f, 0.569f, 0.114f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.088428f, 0.041081f, 0.002090f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.570482f, 0.283555f, 0.012335f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.992f, 0.941f, 0.808f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -170,8 +170,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.65f, 0.35f, 0.15f)), 0.045f);
|
||||
|
||||
Shininess = 0.65f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.213f, 0.128f, 0.054f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.714f, 0.428f, 0.181f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.037301f, 0.014931f, 0.004305f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.468185f, 0.153344f, 0.027491f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.590f, 0.408f, 0.250f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -182,8 +182,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.955008f, 0.637427f, 0.538163f)), 0.045f);
|
||||
|
||||
Shininess = 0.65f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.191f, 0.074f, 0.023f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.604f, 0.270f, 0.083f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.030370f, 0.006451f, 0.001780f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.323236f, 0.059254f, 0.007584f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.950f, 0.640f, 0.540f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -194,8 +194,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (1.000000f, 0.765557f, 0.336057f)), 0.045f);
|
||||
|
||||
Shininess = 0.80f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.300f, 0.230f, 0.095f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.752f, 0.580f, 0.100f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.073239f, 0.043234f, 0.009264f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.525643f, 0.295700f, 0.010023f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (1.000f, 0.710f, 0.290f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -206,8 +206,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateConductor (1.8800f, 3.4900f), 0.045f);
|
||||
|
||||
Shininess = 0.50f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.106f, 0.059f, 0.114f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.427f, 0.471f, 0.541f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.010979f, 0.004795f, 0.012335f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.152583f, 0.188174f, 0.253972f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.333f, 0.333f, 0.522f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -215,9 +215,9 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_ASPECT;
|
||||
|
||||
Shininess = 0.01f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.26f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.13f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.75f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.05f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.003936f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
BSDF.Kd = Graphic3d_Vec3 (0.482353f, 0.482353f, 0.482353f);
|
||||
@ -229,8 +229,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.971519f, 0.959915f, 0.915324f)), 0.045f);
|
||||
|
||||
Shininess = 0.75f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.275f, 0.275f, 0.250f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.630f, 0.630f, 0.630f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.061465f, 0.061465f, 0.050876f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.354692f, 0.354692f, 0.354692f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.950f, 0.930f, 0.880f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -241,8 +241,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateConductor (Graphic3d_Vec3 (2.90f, 2.80f, 2.53f), Graphic3d_Vec3 (3.08f, 2.90f, 2.74f)), 0.045f);
|
||||
|
||||
Shininess = 0.90f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.150f, 0.150f, 0.180f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.500f, 0.510f, 0.520f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.019607f, 0.019607f, 0.027212f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.214041f, 0.223414f, 0.233022f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.560f, 0.570f, 0.580f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -254,8 +254,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
DiffuseCoef = 0.75f;
|
||||
|
||||
Shininess = 0.17f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (1.00f, 0.8f, 0.62f) * 0.19f);
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (1.00f, 0.8f, 0.62f) * 0.75f);
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.030074f, 0.020069f, 0.013011f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.522522f, 0.318547f, 0.183064f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.98f, 1.0f, 0.60f) * 0.08f);
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
@ -269,8 +269,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.549585f, 0.556114f, 0.554256f)), 0.045f);
|
||||
|
||||
Shininess = 0.90f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.200f, 0.200f, 0.225f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.550f, 0.550f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.033105f, 0.033105f, 0.041436f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.263273f, 0.263273f, 0.263273f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.975f, 0.975f, 0.975f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -281,8 +281,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Graphic3d_Fresnel::CreateSchlick (Graphic3d_Vec3 (0.913183f, 0.921494f, 0.924524f)), 0.045f);
|
||||
|
||||
Shininess = 0.75f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.300f, 0.300f, 0.300f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.600f, 0.600f, 0.600f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.073239f, 0.073239f, 0.073239f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.318547f, 0.318547f, 0.318547f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.910f, 0.920f, 0.920f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -293,7 +293,7 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.62f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 0.90f, 0.414f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f, 0.787412f, 0.142892f));
|
||||
|
||||
BSDF.Kd = Graphic3d_Vec3 (0.0f);
|
||||
BSDF.Ks = Graphic3d_Vec4 (0.5f, 0.5f, 0.5f, 0.f);
|
||||
@ -304,8 +304,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_PHYSIC;
|
||||
|
||||
Shininess = 0.3f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.054f, 0.050f, 0.066f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.183f, 0.170f, 0.225f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.004305f, 0.003936f, 0.005532f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.028053f, 0.024515f, 0.041436f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.333f, 0.329f, 0.346f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
@ -316,8 +316,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_PHYSIC;
|
||||
|
||||
Shininess = 0.10f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.135f, 0.223f, 0.158f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.540f, 0.890f, 0.630f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.016338f, 0.040729f, 0.021493f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.252950f, 0.767769f, 0.354692f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.316f, 0.316f, 0.316f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
@ -329,8 +329,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
MaterialType = Graphic3d_MATERIAL_PHYSIC;
|
||||
|
||||
Shininess = 0.01f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.050f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.150f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.003936f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.019607f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
||||
@ -348,8 +348,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
TransparencyCoef = 0.80f;
|
||||
|
||||
Shininess = 0.90f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.450f, 0.450f, 0.475f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.050f, 0.075f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.170645f, 0.170645f, 0.191627f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.003936f, 0.003936f, 0.006571f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.380f, 0.380f, 0.380f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -364,8 +364,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
TransparencyCoef = 0.80f;
|
||||
|
||||
Shininess = 0.50f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.550f, 0.575f, 0.575f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.050f, 0.075f, 0.075f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.263273f, 0.290143f, 0.290143f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.003936f, 0.006571f, 0.006571f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.920f, 0.920f, 0.920f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -380,8 +380,8 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
TransparencyCoef = 0.80f;
|
||||
|
||||
Shininess = 0.90f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.550f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.100f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.263273f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.010023f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
@ -397,22 +397,22 @@ RawMaterial::RawMaterial (Graphic3d_NameOfMaterial theName, const char* theStrin
|
||||
TransparencyCoef = 0.80f;
|
||||
|
||||
Shininess = 0.90f;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.550f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.100f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.263273f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.010023f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.970f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
case Graphic3d_NOM_UserDefined:
|
||||
MaterialType = Graphic3d_MATERIAL_PHYSIC;
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.1f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.8f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.6f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.2f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
break;
|
||||
case Graphic3d_NOM_DEFAULT:
|
||||
MaterialType = Graphic3d_MATERIAL_ASPECT;
|
||||
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.30f));
|
||||
Colors[Graphic3d_TOR_AMBIENT] = Quantity_Color (Graphic3d_Vec3 (0.15f));
|
||||
Colors[Graphic3d_TOR_DIFFUSE] = Quantity_Color (Graphic3d_Vec3 (0.65f));
|
||||
Colors[Graphic3d_TOR_SPECULAR] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
Colors[Graphic3d_TOR_EMISSION] = Quantity_Color (Graphic3d_Vec3 (0.0f));
|
||||
|
@ -17,98 +17,63 @@
|
||||
#ifndef _Graphic3d_TextureMap_HeaderFile
|
||||
#define _Graphic3d_TextureMap_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <Graphic3d_TextureRoot.hxx>
|
||||
#include <Graphic3d_TypeOfTexture.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Graphic3d_LevelOfTextureAnisotropy.hxx>
|
||||
class TCollection_AsciiString;
|
||||
|
||||
|
||||
class Graphic3d_TextureMap;
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_TextureMap, Graphic3d_TextureRoot)
|
||||
|
||||
//! This is an abstract class for managing texture applyable on polygons.
|
||||
class Graphic3d_TextureMap : public Graphic3d_TextureRoot
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureMap, Graphic3d_TextureRoot)
|
||||
public:
|
||||
|
||||
|
||||
|
||||
//! enable texture smoothing
|
||||
Standard_EXPORT void EnableSmooth();
|
||||
|
||||
|
||||
//! Returns TRUE if the texture is smoothed.
|
||||
Standard_EXPORT Standard_Boolean IsSmoothed() const;
|
||||
|
||||
|
||||
//! disable texture smoothing
|
||||
Standard_EXPORT void DisableSmooth();
|
||||
|
||||
|
||||
//! enable texture modulate mode.
|
||||
//! enable texture modulate mode.
|
||||
//! the image is modulate with the shading of the surface.
|
||||
Standard_EXPORT void EnableModulate();
|
||||
|
||||
|
||||
//! disable texture modulate mode.
|
||||
//! the image is directly decal on the surface.
|
||||
Standard_EXPORT void DisableModulate();
|
||||
|
||||
|
||||
//! Returns TRUE if the texture is modulate.
|
||||
Standard_EXPORT Standard_Boolean IsModulate() const;
|
||||
|
||||
|
||||
//! use this methods if you want to enable
|
||||
//! texture repetition on your objects.
|
||||
Standard_EXPORT void EnableRepeat();
|
||||
|
||||
|
||||
//! use this methods if you want to disable
|
||||
//! texture repetition on your objects.
|
||||
Standard_EXPORT void DisableRepeat();
|
||||
|
||||
|
||||
//! Returns TRUE if the texture repeat is enable.
|
||||
Standard_EXPORT Standard_Boolean IsRepeat() const;
|
||||
|
||||
//! @return level of anisontropy texture filter.
|
||||
|
||||
//! @return level of anisotropy texture filter.
|
||||
//! Default value is Graphic3d_LOTA_OFF.
|
||||
Standard_EXPORT Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const;
|
||||
|
||||
//! @param theLevel level of anisontropy texture filter.
|
||||
|
||||
//! @param theLevel level of anisotropy texture filter.
|
||||
Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureMap,Graphic3d_TextureRoot)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Standard_EXPORT Graphic3d_TextureMap(const TCollection_AsciiString& theFileName, const Graphic3d_TypeOfTexture theType);
|
||||
|
||||
Standard_EXPORT Graphic3d_TextureMap(const Handle(Image_PixMap)& thePixMap, const Graphic3d_TypeOfTexture theType);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_TextureMap, Graphic3d_TextureRoot)
|
||||
|
||||
#endif // _Graphic3d_TextureMap_HeaderFile
|
||||
|
@ -89,7 +89,8 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const TCollection_AsciiString& the
|
||||
: myParams (new Graphic3d_TextureParams()),
|
||||
myPath (theFileName),
|
||||
myRevision (0),
|
||||
myType (theType)
|
||||
myType (theType),
|
||||
myIsColorMap (true)
|
||||
{
|
||||
generateId();
|
||||
}
|
||||
@ -103,7 +104,8 @@ Graphic3d_TextureRoot::Graphic3d_TextureRoot (const Handle(Image_PixMap)& theP
|
||||
: myParams (new Graphic3d_TextureParams()),
|
||||
myPixMap (thePixMap),
|
||||
myRevision (0),
|
||||
myType (theType)
|
||||
myType (theType),
|
||||
myIsColorMap (true)
|
||||
{
|
||||
generateId();
|
||||
}
|
||||
|
@ -91,6 +91,19 @@ public:
|
||||
//! @return low-level texture parameters
|
||||
const Handle(Graphic3d_TextureParams)& GetParams() const { return myParams; }
|
||||
|
||||
//! Return flag indicating color nature of values within the texture; TRUE by default.
|
||||
//!
|
||||
//! This flag will be used to interpret 8-bit per channel RGB(A) images as sRGB(A) textures
|
||||
//! with implicit linearizion of color components.
|
||||
//! Has no effect on images with floating point values (always considered linearized).
|
||||
//!
|
||||
//! When set to FALSE, such images will be interpreted as textures will be linear component values,
|
||||
//! which is useful for RGB(A) textures defining non-color properties (like Normalmap/Metalness/Roughness).
|
||||
Standard_Boolean IsColorMap() const { return myIsColorMap; }
|
||||
|
||||
//! Set flag indicating color nature of values within the texture.
|
||||
void SetColorMap (Standard_Boolean theIsColor) { myIsColorMap = theIsColor; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a texture from a file
|
||||
@ -108,12 +121,13 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Graphic3d_TextureParams) myParams; //!< associated texture parameters
|
||||
TCollection_AsciiString myTexId; //!< unique identifier of this resource (for sharing graphic resource); should never be modified outside constructor
|
||||
Handle(Image_PixMap) myPixMap; //!< image pixmap - as one of the ways for defining the texture source
|
||||
OSD_Path myPath; //!< image file path - as one of the ways for defining the texture source
|
||||
Standard_Size myRevision; //!< image revision - for signaling changes in the texture source (e.g. file update, pixmap update)
|
||||
Graphic3d_TypeOfTexture myType; //!< texture type
|
||||
Handle(Graphic3d_TextureParams) myParams; //!< associated texture parameters
|
||||
TCollection_AsciiString myTexId; //!< unique identifier of this resource (for sharing graphic resource); should never be modified outside constructor
|
||||
Handle(Image_PixMap) myPixMap; //!< image pixmap - as one of the ways for defining the texture source
|
||||
OSD_Path myPath; //!< image file path - as one of the ways for defining the texture source
|
||||
Standard_Size myRevision; //!< image revision - for signaling changes in the texture source (e.g. file update, pixmap update)
|
||||
Graphic3d_TypeOfTexture myType; //!< texture type
|
||||
Standard_Boolean myIsColorMap; //!< flag indicating color nature of values within the texture
|
||||
|
||||
};
|
||||
|
||||
|
@ -29,6 +29,7 @@ enum Graphic3d_TypeOfLimit
|
||||
Graphic3d_TypeOfLimit_HasRayTracingTextures, //!< indicates whether ray tracing textures are supported
|
||||
Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling, //!< indicates whether adaptive screen sampling is supported
|
||||
Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic,//!< indicates whether optimized adaptive screen sampling is supported (hardware supports atomic float operations)
|
||||
Graphic3d_TypeOfLimit_HasSRGB, //!< indicates whether sRGB rendering is supported
|
||||
Graphic3d_TypeOfLimit_HasBlendedOit, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (without MSAA).
|
||||
Graphic3d_TypeOfLimit_HasBlendedOitMsaa, //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (with MSAA).
|
||||
Graphic3d_TypeOfLimit_HasFlatShading, //!< indicates whether Flat shading (Graphic3d_TOSM_FACET) is supported
|
||||
|
@ -218,7 +218,7 @@ Standard_Boolean IGESCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc)
|
||||
checkColorRange ( r );
|
||||
checkColorRange ( g );
|
||||
checkColorRange ( b );
|
||||
col.SetValues ( 0.01*r, 0.01*g, 0.01*b, Quantity_TOC_RGB );
|
||||
col.SetValues ( 0.01*r, 0.01*g, 0.01*b, Quantity_TOC_sRGB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +308,9 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
|
||||
Handle(TCollection_HAsciiString) str =
|
||||
new TCollection_HAsciiString ( col.StringName ( col.Name() ) );
|
||||
colent = new IGESGraph_Color;
|
||||
colent->Init ( col.Red() * 100., col.Green() * 100., col.Blue() * 100., str );
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
col.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
colent->Init ( aColor_sRGB.r() * 100., aColor_sRGB.g() * 100., aColor_sRGB.b() * 100., str );
|
||||
AddEntity ( colent );
|
||||
colors.Bind ( c, colent );
|
||||
}
|
||||
|
@ -71,13 +71,15 @@ Standard_Boolean operator== ( const MeshVS_TwoColors& K1,
|
||||
MeshVS_TwoColors BindTwoColors ( const Quantity_Color& theCol1, const Quantity_Color& theCol2 )
|
||||
{
|
||||
MeshVS_TwoColors aRes;
|
||||
|
||||
aRes.r1 = unsigned ( theCol1.Red() * 255.0 );
|
||||
aRes.g1 = unsigned ( theCol1.Green() * 255.0 );
|
||||
aRes.b1 = unsigned ( theCol1.Blue() * 255.0 );
|
||||
aRes.r2 = unsigned ( theCol2.Red() * 255.0 );
|
||||
aRes.g2 = unsigned ( theCol2.Green() * 255.0 );
|
||||
aRes.b2 = unsigned ( theCol2.Blue() * 255.0 );
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
theCol1.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
aRes.r1 = unsigned ( aColor_sRGB.r() * 255.0 );
|
||||
aRes.g1 = unsigned ( aColor_sRGB.g() * 255.0 );
|
||||
aRes.b1 = unsigned ( aColor_sRGB.b() * 255.0 );
|
||||
theCol2.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
aRes.r2 = unsigned ( aColor_sRGB.r() * 255.0 );
|
||||
aRes.g2 = unsigned ( aColor_sRGB.g() * 255.0 );
|
||||
aRes.b2 = unsigned ( aColor_sRGB.b() * 255.0 );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
@ -94,11 +96,11 @@ Quantity_Color ExtractColor ( MeshVS_TwoColors& theTwoColors, const Standard_Int
|
||||
if ( Index == 1 )
|
||||
aRes.SetValues ( Standard_Real (theTwoColors.r1) / max,
|
||||
Standard_Real (theTwoColors.g1) / max,
|
||||
Standard_Real (theTwoColors.b1) / max, Quantity_TOC_RGB );
|
||||
Standard_Real (theTwoColors.b1) / max, Quantity_TOC_sRGB );
|
||||
else if (Index == 2)
|
||||
aRes.SetValues ( Standard_Real (theTwoColors.r2) / max,
|
||||
Standard_Real (theTwoColors.g2) / max,
|
||||
Standard_Real (theTwoColors.b2) / max, Quantity_TOC_RGB );
|
||||
Standard_Real (theTwoColors.b2) / max, Quantity_TOC_sRGB );
|
||||
|
||||
return aRes;
|
||||
}
|
||||
@ -112,8 +114,8 @@ void ExtractColors ( MeshVS_TwoColors& theTwoColors, Quantity_Color& theCol1, Qu
|
||||
Standard_Real max = 255.0;
|
||||
theCol1.SetValues ( Standard_Real (theTwoColors.r1) / max,
|
||||
Standard_Real (theTwoColors.g1) / max,
|
||||
Standard_Real (theTwoColors.b1) / max, Quantity_TOC_RGB );
|
||||
Standard_Real (theTwoColors.b1) / max, Quantity_TOC_sRGB );
|
||||
theCol2.SetValues ( Standard_Real (theTwoColors.r2) / max,
|
||||
Standard_Real (theTwoColors.g2) / max,
|
||||
Standard_Real (theTwoColors.b2) / max, Quantity_TOC_RGB );
|
||||
Standard_Real (theTwoColors.b2) / max, Quantity_TOC_sRGB );
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ OpenGl_FrameBuffer.hxx
|
||||
OpenGl_FrameBuffer.cxx
|
||||
OpenGl_Texture.cxx
|
||||
OpenGl_Texture.hxx
|
||||
OpenGl_TextureFormat.cxx
|
||||
OpenGl_TextureFormat.hxx
|
||||
OpenGl_TextureSet.cxx
|
||||
OpenGl_TextureSet.hxx
|
||||
OpenGl_Resource.hxx
|
||||
|
@ -1767,7 +1767,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
|
||||
|
||||
aSprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
|
||||
aSprite->Init (theCtx, *anImage, Graphic3d_TOT_2D, true);
|
||||
if (!hadAlreadyAlpha)
|
||||
{
|
||||
if (anImageA.IsNull()
|
||||
@ -1778,7 +1778,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
if (!anImageA.IsNull())
|
||||
{
|
||||
aSpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
|
||||
aSpriteA->Init (theCtx, *anImageA, Graphic3d_TOT_2D, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,6 @@ OpenGl_BackgroundArray::OpenGl_BackgroundArray (const Graphic3d_TypeOfBackground
|
||||
myViewHeight (0),
|
||||
myToUpdate (Standard_False)
|
||||
{
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
|
||||
myDrawMode = GL_TRIANGLE_STRIP;
|
||||
myIsFillType = true;
|
||||
|
||||
@ -140,11 +137,12 @@ void OpenGl_BackgroundArray::invalidateData()
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
{
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
switch (myType)
|
||||
{
|
||||
case Graphic3d_TOB_GRADIENT:
|
||||
{
|
||||
if (!createGradientArray())
|
||||
if (!createGradientArray (aCtx))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
@ -174,7 +172,6 @@ Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& t
|
||||
}
|
||||
|
||||
// Init VBO
|
||||
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||
if (myIsVboInit)
|
||||
{
|
||||
clearMemoryGL (aCtx);
|
||||
@ -191,7 +188,7 @@ Standard_Boolean OpenGl_BackgroundArray::init (const Handle(OpenGl_Workspace)& t
|
||||
// method : createGradientArray
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_BackgroundArray::createGradientArray() const
|
||||
Standard_Boolean OpenGl_BackgroundArray::createGradientArray (const Handle(OpenGl_Context)& theCtx) const
|
||||
{
|
||||
// Initialize data for primitive array
|
||||
Graphic3d_Attribute aGragientAttribInfo[] =
|
||||
@ -200,6 +197,11 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray() const
|
||||
{ Graphic3d_TOA_COLOR, Graphic3d_TOD_VEC3 }
|
||||
};
|
||||
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
}
|
||||
if (!myAttribs->Init (4, aGragientAttribInfo, 2))
|
||||
{
|
||||
return Standard_False;
|
||||
@ -311,7 +313,7 @@ Standard_Boolean OpenGl_BackgroundArray::createGradientArray() const
|
||||
*aVertData = aVertices[anIt];
|
||||
|
||||
OpenGl_Vec3* aColorData = reinterpret_cast<OpenGl_Vec3* >(myAttribs->changeValue (anIt) + myAttribs->AttributeOffset (1));
|
||||
*aColorData = OpenGl_Vec3(aCorners[anIt][0], aCorners[anIt][1], aCorners[anIt][2]);
|
||||
*aColorData = theCtx->Vec4FromQuantityColor (OpenGl_Vec4(aCorners[anIt][0], aCorners[anIt][1], aCorners[anIt][2], 1.0f)).rgb();
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
@ -329,6 +331,11 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
|
||||
{ Graphic3d_TOA_UV, Graphic3d_TOD_VEC2 }
|
||||
};
|
||||
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
}
|
||||
if (!myAttribs->Init (4, aTextureAttribInfo, 2))
|
||||
{
|
||||
return Standard_False;
|
||||
@ -397,6 +404,11 @@ Standard_Boolean OpenGl_BackgroundArray::createCubeMapArray() const
|
||||
{ Graphic3d_TOA_POS, Graphic3d_TOD_VEC2}
|
||||
};
|
||||
|
||||
if (myAttribs.IsNull())
|
||||
{
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
myAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
}
|
||||
if (!myAttribs->Init(4, aCubeMapAttribInfo, 1))
|
||||
{
|
||||
return Standard_False;
|
||||
@ -428,7 +440,9 @@ void OpenGl_BackgroundArray::Render (const Handle(OpenGl_Workspace)& theWorkspac
|
||||
}
|
||||
if (myToUpdate
|
||||
|| myViewWidth != aViewSizeX
|
||||
|| myViewHeight != aViewSizeY)
|
||||
|| myViewHeight != aViewSizeY
|
||||
|| myAttribs.IsNull()
|
||||
|| myVboAttribs.IsNull())
|
||||
{
|
||||
myViewWidth = aViewSizeX;
|
||||
myViewHeight = aViewSizeY;
|
||||
|
@ -79,7 +79,7 @@ protected:
|
||||
Standard_EXPORT Standard_Boolean init (const Handle(OpenGl_Workspace)& theWorkspace) const;
|
||||
|
||||
//! Initializes gradient arrays.
|
||||
Standard_EXPORT Standard_Boolean createGradientArray() const;
|
||||
Standard_EXPORT Standard_Boolean createGradientArray (const Handle(OpenGl_Context)& theCtx) const;
|
||||
|
||||
//! Initializes texture arrays.
|
||||
//! @param theWorkspace OpenGl workspace that stores texture in the current enabled face aspect.
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include <OpenGl_GlCore20.hxx>
|
||||
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
@ -25,7 +24,8 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_Caps::OpenGl_Caps()
|
||||
: vboDisable (Standard_False),
|
||||
: sRGBDisable (Standard_False),
|
||||
vboDisable (Standard_False),
|
||||
pntSpritesDisable (Standard_False),
|
||||
keepArrayData (Standard_False),
|
||||
ffpEnable (Standard_False),
|
||||
@ -67,6 +67,7 @@ OpenGl_Caps::OpenGl_Caps()
|
||||
// =======================================================================
|
||||
OpenGl_Caps& OpenGl_Caps::operator= (const OpenGl_Caps& theCopy)
|
||||
{
|
||||
sRGBDisable = theCopy.sRGBDisable;
|
||||
vboDisable = theCopy.vboDisable;
|
||||
pntSpritesDisable = theCopy.pntSpritesDisable;
|
||||
keepArrayData = theCopy.keepArrayData;
|
||||
|
@ -27,7 +27,8 @@ class OpenGl_Caps : public Standard_Transient
|
||||
|
||||
public: //! @name flags to disable particular functionality, should be used only for testing purposes!
|
||||
|
||||
Standard_Boolean vboDisable; //!< flag permits VBO usage, will significantly affect performance (OFF by default)
|
||||
Standard_Boolean sRGBDisable; //!< Disables sRGB rendering (OFF by default)
|
||||
Standard_Boolean vboDisable; //!< disallow VBO usage for debugging purposes (OFF by default)
|
||||
Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
|
||||
Standard_Boolean keepArrayData; //!< Disables freeing CPU memory after building VBOs (OFF by default)
|
||||
Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (OFF by default)
|
||||
|
@ -116,11 +116,17 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
hasHighp (Standard_False),
|
||||
hasUintIndex(Standard_False),
|
||||
hasTexRGBA8(Standard_False),
|
||||
hasFlatShading (OpenGl_FeatureNotAvailable),
|
||||
#else
|
||||
hasHighp (Standard_True),
|
||||
hasUintIndex(Standard_True),
|
||||
hasTexRGBA8(Standard_True),
|
||||
#endif
|
||||
hasTexSRGB (Standard_False),
|
||||
hasFboSRGB (Standard_False),
|
||||
hasSRGBControl (Standard_False),
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
hasFlatShading (OpenGl_FeatureNotAvailable),
|
||||
#else
|
||||
hasFlatShading (OpenGl_FeatureInCore),
|
||||
#endif
|
||||
hasGlslBitwiseOps (OpenGl_FeatureNotAvailable),
|
||||
@ -195,7 +201,8 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
|
||||
myDefaultVao (0),
|
||||
myColorMask (true),
|
||||
myAlphaToCoverage (false),
|
||||
myIsGlDebugCtx (Standard_False),
|
||||
myIsGlDebugCtx (false),
|
||||
myIsSRgbWindow (false),
|
||||
myResolution (Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION),
|
||||
myResolutionRatio (1.0f),
|
||||
myLineWidthScale (1.0f),
|
||||
@ -464,6 +471,34 @@ void OpenGl_Context::SetDrawBuffers (const Standard_Integer theNb, const Standar
|
||||
myFuncs->glDrawBuffers (theNb, (const GLenum*)theDrawBuffers);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFrameBufferSRGB
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Context::SetFrameBufferSRGB (bool theIsFbo)
|
||||
{
|
||||
if (!hasFboSRGB)
|
||||
{
|
||||
myIsSRgbActive = false;
|
||||
return;
|
||||
}
|
||||
myIsSRgbActive = ToRenderSRGB()
|
||||
&& (theIsFbo || myIsSRgbWindow);
|
||||
if (!hasSRGBControl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (myIsSRgbActive)
|
||||
{
|
||||
core11fwd->glEnable (GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
else
|
||||
{
|
||||
core11fwd->glDisable (GL_FRAMEBUFFER_SRGB);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCullBackFaces
|
||||
// purpose :
|
||||
@ -1349,6 +1384,9 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
|
||||
hasTexRGBA8 = IsGlGreaterEqual (3, 0)
|
||||
|| CheckExtension ("GL_OES_rgb8_rgba8");
|
||||
hasTexSRGB = IsGlGreaterEqual (3, 0);
|
||||
hasFboSRGB = IsGlGreaterEqual (3, 0);
|
||||
hasSRGBControl = CheckExtension ("GL_EXT_sRGB_write_control");
|
||||
// NPOT textures has limited support within OpenGL ES 2.0
|
||||
// which are relaxed by OpenGL ES 3.0 or some extensions
|
||||
//arbNPTW = IsGlGreaterEqual (3, 0)
|
||||
@ -1506,6 +1544,9 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
|
||||
|
||||
hasTexRGBA8 = Standard_True;
|
||||
hasTexSRGB = IsGlGreaterEqual (2, 0);
|
||||
hasFboSRGB = IsGlGreaterEqual (2, 1);
|
||||
hasSRGBControl = hasFboSRGB;
|
||||
arbDrawBuffers = CheckExtension ("GL_ARB_draw_buffers");
|
||||
arbNPTW = CheckExtension ("GL_ARB_texture_non_power_of_two");
|
||||
arbTexFloat = IsGlGreaterEqual (3, 0)
|
||||
@ -2821,6 +2862,47 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
myHasRayTracingAdaptiveSamplingAtomic = myHasRayTracingAdaptiveSampling
|
||||
&& CheckExtension ("GL_NV_shader_atomic_float");
|
||||
#endif
|
||||
|
||||
if (arbFBO != NULL
|
||||
&& hasFboSRGB)
|
||||
{
|
||||
// Detect if window buffer is considered by OpenGL as sRGB-ready
|
||||
// (linear RGB color written by shader is automatically converted into sRGB)
|
||||
// or not (offscreen FBO should be blit into window buffer with gamma correction).
|
||||
const GLenum aDefWinBuffer =
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
GL_BACK_LEFT;
|
||||
#else
|
||||
GL_BACK;
|
||||
#endif
|
||||
GLint aWinColorEncoding = 0; // GL_LINEAR
|
||||
arbFBO->glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER, aDefWinBuffer, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &aWinColorEncoding);
|
||||
ResetErrors (true);
|
||||
myIsSRgbWindow = aWinColorEncoding == GL_SRGB;
|
||||
|
||||
// On desktop OpenGL, pixel formats are almost always sRGB-ready, even when not requested;
|
||||
// it is safe behavior on desktop where GL_FRAMEBUFFER_SRGB is disabled by default
|
||||
// (contrary to OpenGL ES, where it is enabled by default).
|
||||
// NVIDIA drivers, however, always return GL_LINEAR even for sRGB-ready pixel formats on Windows platform,
|
||||
// while AMD and Intel report GL_SRGB as expected.
|
||||
// macOS drivers seems to be also report GL_LINEAR even for [NSColorSpace sRGBColorSpace].
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
#ifdef __APPLE__
|
||||
myIsSRgbWindow = true;
|
||||
#else
|
||||
if (!myIsSRgbWindow
|
||||
&& myVendor.Search ("nvidia") != -1)
|
||||
{
|
||||
myIsSRgbWindow = true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (!myIsSRgbWindow)
|
||||
{
|
||||
Message::DefaultMessenger()->Send ("OpenGl_Context, warning: window buffer is not sRGB-ready.\n"
|
||||
"Check OpenGL window creation parameters for optimal performance.", Message_Trace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -3400,10 +3482,10 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_Aspects* theAspect,
|
||||
? anAspect->BackInteriorColor()
|
||||
: aFrontIntColor;
|
||||
|
||||
myMatFront.Init (aMatFrontSrc, aFrontIntColor);
|
||||
myMatFront.Init (*this, aMatFrontSrc, aFrontIntColor);
|
||||
if (toDistinguish)
|
||||
{
|
||||
myMatBack.Init (aMatBackSrc, aBackIntColor);
|
||||
myMatBack.Init (*this, aMatBackSrc, aBackIntColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3507,7 +3589,10 @@ void OpenGl_Context::SetColor4fv (const OpenGl_Vec4& theColor)
|
||||
{
|
||||
if (!myActiveProgram.IsNull())
|
||||
{
|
||||
myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_COLOR), theColor);
|
||||
if (const OpenGl_ShaderUniformLocation& aLoc = myActiveProgram->GetStateLocation (OpenGl_OCCT_COLOR))
|
||||
{
|
||||
myActiveProgram->SetUniform (this, aLoc, Vec4FromQuantityColor (theColor));
|
||||
}
|
||||
}
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
else if (core11 != NULL)
|
||||
|
@ -538,6 +538,55 @@ public:
|
||||
//! @return TRUE if atomic adaptive screen sampling in ray tracing mode is supported
|
||||
Standard_Boolean HasRayTracingAdaptiveSamplingAtomic() const { return myHasRayTracingAdaptiveSamplingAtomic; }
|
||||
|
||||
//! Returns TRUE if sRGB rendering is supported.
|
||||
bool HasSRGB() const
|
||||
{
|
||||
return hasTexSRGB
|
||||
&& hasFboSRGB;
|
||||
}
|
||||
|
||||
//! Returns TRUE if sRGB rendering is supported and permitted.
|
||||
bool ToRenderSRGB() const
|
||||
{
|
||||
return HasSRGB()
|
||||
&& !caps->sRGBDisable
|
||||
&& !caps->ffpEnable;
|
||||
}
|
||||
|
||||
//! Returns TRUE if window/surface buffer is sRGB-ready.
|
||||
//!
|
||||
//! When offscreen FBOs are created in sRGB, but window is not sRGB-ready,
|
||||
//! blitting into window should be done with manual gamma correction.
|
||||
//!
|
||||
//! In desktop OpenGL, window buffer can be considered as sRGB-ready by default,
|
||||
//! even when application has NOT requested sRGB-ready pixel format,
|
||||
//! and rendering is managed via GL_FRAMEBUFFER_SRGB state.
|
||||
//!
|
||||
//! In OpenGL ES, sRGB-ready window surface should be explicitly requested on construction,
|
||||
//! and cannot be disabled/enabled without GL_EXT_sRGB_write_control extension afterwards
|
||||
//! (GL_FRAMEBUFFER_SRGB can be considered as always tuned ON).
|
||||
bool IsWindowSRGB() const { return myIsSRgbWindow; }
|
||||
|
||||
//! Convert Quantity_ColorRGBA into vec4
|
||||
//! with conversion or no conversion into non-linear sRGB
|
||||
//! basing on ToRenderSRGB() flag.
|
||||
OpenGl_Vec4 Vec4FromQuantityColor (const OpenGl_Vec4& theColor) const
|
||||
{
|
||||
return ToRenderSRGB()
|
||||
? Vec4LinearFromQuantityColor(theColor)
|
||||
: Vec4sRGBFromQuantityColor (theColor);
|
||||
}
|
||||
|
||||
//! Convert Quantity_ColorRGBA into vec4.
|
||||
//! Quantity_Color is expected to be linear RGB, hence conversion is NOT required
|
||||
const OpenGl_Vec4& Vec4LinearFromQuantityColor (const OpenGl_Vec4& theColor) const { return theColor; }
|
||||
|
||||
//! Convert Quantity_ColorRGBA (linear RGB) into non-linear sRGB vec4.
|
||||
OpenGl_Vec4 Vec4sRGBFromQuantityColor (const OpenGl_Vec4& theColor) const
|
||||
{
|
||||
return Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB (theColor);
|
||||
}
|
||||
|
||||
//! Returns true if VBO is supported and permitted.
|
||||
inline bool ToUseVbo() const
|
||||
{
|
||||
@ -688,6 +737,20 @@ public: //! @name methods to alter or retrieve current state
|
||||
SetDrawBuffer (theBuffer);
|
||||
}
|
||||
|
||||
//! Returns cached GL_FRAMEBUFFER_SRGB state.
|
||||
//! If TRUE, GLSL program is expected to write linear RGB color.
|
||||
//! Otherwise, GLSL program might need manually converting result color into sRGB color space.
|
||||
bool IsFrameBufferSRGB() const { return myIsSRgbActive; }
|
||||
|
||||
//! Enables/disables GL_FRAMEBUFFER_SRGB flag.
|
||||
//! This flag can be set to:
|
||||
//! - TRUE when writing into offscreen FBO (always expected to be in sRGB or RGBF formats).
|
||||
//! - TRUE when writing into sRGB-ready window buffer (might require choosing proper pixel format on window creation).
|
||||
//! - FALSE if sRGB rendering is not supported or sRGB-not-ready window buffer is used for drawing.
|
||||
//! @param theIsFbo [in] flag indicating writing into offscreen FBO (always expected sRGB-ready when sRGB FBO is supported)
|
||||
//! or into window buffer (FALSE, sRGB-readiness might vary).
|
||||
Standard_EXPORT void SetFrameBufferSRGB (bool theIsFbo);
|
||||
|
||||
//! Return cached flag indicating writing into color buffer is enabled or disabled (glColorMask).
|
||||
bool ColorMask() const { return myColorMask; }
|
||||
|
||||
@ -893,6 +956,9 @@ public: //! @name extensions
|
||||
Standard_Boolean hasHighp; //!< highp in GLSL ES fragment shader is supported
|
||||
Standard_Boolean hasUintIndex; //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint)
|
||||
Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
|
||||
Standard_Boolean hasTexSRGB; //!< sRGB texture formats (desktop OpenGL 2.0, OpenGL ES 3.0 or GL_EXT_texture_sRGB)
|
||||
Standard_Boolean hasFboSRGB; //!< sRGB FBO render targets (desktop OpenGL 2.1, OpenGL ES 3.0)
|
||||
Standard_Boolean hasSRGBControl; //!< sRGB write control (any desktop OpenGL, OpenGL ES + GL_EXT_sRGB_write_control extension)
|
||||
OpenGl_FeatureFlag hasFlatShading; //!< Complex flag indicating support of Flat shading (Graphic3d_TOSM_FACET) (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)
|
||||
OpenGl_FeatureFlag hasGlslBitwiseOps; //!< GLSL supports bitwise operations; OpenGL 3.0 / OpenGL ES 3.0 (GLSL 130 / GLSL ES 300) or OpenGL 2.1 + GL_EXT_gpu_shader4
|
||||
OpenGl_FeatureFlag hasDrawBuffers; //!< Complex flag indicating support of multiple draw buffers (desktop OpenGL 2.0, OpenGL ES 3.0, GL_ARB_draw_buffers, GL_EXT_draw_buffers)
|
||||
@ -1015,6 +1081,8 @@ private: //! @name fields tracking current state
|
||||
Standard_Boolean myAllowAlphaToCov; //!< flag allowing GL_SAMPLE_ALPHA_TO_COVERAGE usage
|
||||
Standard_Boolean myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state
|
||||
Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
|
||||
Standard_Boolean myIsSRgbWindow; //!< indicates that window buffer is sRGB-ready
|
||||
Standard_Boolean myIsSRgbActive; //!< flag indicating GL_FRAMEBUFFER_SRGB state
|
||||
TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
|
||||
TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
|
||||
unsigned int myResolution; //!< Pixels density (PPI), defines scaling factor for parameters like text size
|
||||
|
@ -147,15 +147,11 @@ bool OpenGl_Font::createTexture (const Handle(OpenGl_Context)& theCtx)
|
||||
|
||||
Image_PixMap aBlackImg;
|
||||
if (!aBlackImg.InitZero (Image_Format_Alpha, Standard_Size(aTextureSizeX), Standard_Size(aTextureSizeY))
|
||||
|| !aTexture->Init (theCtx, aBlackImg, Graphic3d_TOT_2D)) // myTextureFormat
|
||||
|| !aTexture->Init (theCtx, aBlackImg, Graphic3d_TOT_2D, true)) // myTextureFormat
|
||||
{
|
||||
TCollection_ExtendedString aMsg;
|
||||
aMsg += "New texture initialization of size ";
|
||||
aMsg += aTextureSizeX;
|
||||
aMsg += "x";
|
||||
aMsg += aTextureSizeY;
|
||||
aMsg += " for textured font has failed.";
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("New texture initialization of size ")
|
||||
+ aTextureSizeX + "x" + aTextureSizeY + " for textured font has failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -40,119 +40,6 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : getDepthDataFormat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_FrameBuffer::getDepthDataFormat (GLint theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
switch (theTextFormat)
|
||||
{
|
||||
case GL_DEPTH24_STENCIL8:
|
||||
{
|
||||
thePixelFormat = GL_DEPTH_STENCIL;
|
||||
theDataType = GL_UNSIGNED_INT_24_8;
|
||||
return true;
|
||||
}
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
{
|
||||
thePixelFormat = GL_DEPTH_STENCIL;
|
||||
theDataType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||
return true;
|
||||
}
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
{
|
||||
thePixelFormat = GL_DEPTH_COMPONENT;
|
||||
theDataType = GL_UNSIGNED_SHORT;
|
||||
return true;
|
||||
}
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
{
|
||||
thePixelFormat = GL_DEPTH_COMPONENT;
|
||||
theDataType = GL_UNSIGNED_INT;
|
||||
return true;
|
||||
}
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
{
|
||||
thePixelFormat = GL_DEPTH_COMPONENT;
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : getColorDataFormat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_FrameBuffer::getColorDataFormat (const Handle(OpenGl_Context)& theGlContext,
|
||||
GLint theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
switch (theTextFormat)
|
||||
{
|
||||
case GL_RGBA32F:
|
||||
{
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case GL_R32F:
|
||||
{
|
||||
thePixelFormat = GL_RED;
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case GL_RGBA16F:
|
||||
{
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_HALF_FLOAT;
|
||||
if (theGlContext->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
theDataType = GL_HALF_FLOAT_OES;
|
||||
#else
|
||||
theDataType = GL_FLOAT;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case GL_R16F:
|
||||
{
|
||||
thePixelFormat = GL_RED;
|
||||
theDataType = GL_HALF_FLOAT;
|
||||
if (theGlContext->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
theDataType = GL_HALF_FLOAT_OES;
|
||||
#else
|
||||
theDataType = GL_FLOAT;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case GL_RGBA8:
|
||||
case GL_RGBA:
|
||||
{
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case GL_RGB8:
|
||||
case GL_RGB:
|
||||
{
|
||||
thePixelFormat = GL_RGB;
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_FrameBuffer
|
||||
// purpose :
|
||||
@ -265,7 +152,7 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
|
||||
&& !aColorTexture->Init2DMultisample (theGlContext, theNbSamples,
|
||||
aColorFormat, aSizeX, aSizeY))
|
||||
{
|
||||
Release (theGlContext.operator->());
|
||||
Release (theGlContext.get());
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
@ -274,17 +161,13 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
|
||||
{
|
||||
for (Standard_Integer aColorBufferIdx = 0; aColorBufferIdx < myColorTextures.Length(); ++aColorBufferIdx)
|
||||
{
|
||||
GLenum aPixelFormat = 0;
|
||||
GLenum aDataType = 0;
|
||||
const Handle(OpenGl_Texture)& aColorTexture = myColorTextures (aColorBufferIdx);
|
||||
const GLint aColorFormat = myColorFormats (aColorBufferIdx);
|
||||
if (aColorFormat != 0
|
||||
&& getColorDataFormat (theGlContext, aColorFormat, aPixelFormat, aDataType)
|
||||
&& !aColorTexture->Init (theGlContext, aColorFormat,
|
||||
aPixelFormat, aDataType,
|
||||
aSizeX, aSizeY, Graphic3d_TOT_2D))
|
||||
const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theGlContext, aColorFormat);
|
||||
if (aFormat.IsValid()
|
||||
&& !aColorTexture->Init (theGlContext, aFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
|
||||
{
|
||||
Release (theGlContext.operator->());
|
||||
Release (theGlContext.get());
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
@ -402,18 +285,13 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
|
||||
}
|
||||
else
|
||||
{
|
||||
GLenum aPixelFormat = 0;
|
||||
GLenum aDataType = 0;
|
||||
|
||||
for (Standard_Integer aColorBufferIdx = 0; aColorBufferIdx < myColorTextures.Length(); ++aColorBufferIdx)
|
||||
{
|
||||
const Handle(OpenGl_Texture)& aColorTexture = myColorTextures (aColorBufferIdx);
|
||||
const GLint aColorFormat = myColorFormats (aColorBufferIdx);
|
||||
if (aColorFormat != 0
|
||||
&& getColorDataFormat (theGlContext, aColorFormat, aPixelFormat, aDataType)
|
||||
&& !aColorTexture->Init (theGlContext, aColorFormat,
|
||||
aPixelFormat, aDataType,
|
||||
aSizeX, aSizeY, Graphic3d_TOT_2D))
|
||||
const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theGlContext, aColorFormat);
|
||||
if (aFormat.IsValid()
|
||||
&& !aColorTexture->Init (theGlContext, aFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
|
||||
{
|
||||
Release (theGlContext.operator->());
|
||||
return Standard_False;
|
||||
@ -422,21 +300,14 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
|
||||
|
||||
// extensions (GL_OES_packed_depth_stencil, GL_OES_depth_texture) + GL version might be used to determine supported formats
|
||||
// instead of just trying to create such texture
|
||||
if (myDepthFormat != 0
|
||||
&& getDepthDataFormat (myDepthFormat, aPixelFormat, aDataType)
|
||||
&& !myDepthStencilTexture->Init (theGlContext, myDepthFormat,
|
||||
aPixelFormat, aDataType,
|
||||
aSizeX, aSizeY, Graphic3d_TOT_2D))
|
||||
const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theGlContext, myDepthFormat);
|
||||
if (aDepthFormat.IsValid()
|
||||
&& !myDepthStencilTexture->Init (theGlContext, aDepthFormat, Graphic3d_Vec2i (aSizeX, aSizeY), Graphic3d_TOT_2D))
|
||||
{
|
||||
TCollection_ExtendedString aMsg = TCollection_ExtendedString()
|
||||
+ "Warning! Depth textures are not supported by hardware!";
|
||||
theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
|
||||
GL_DEBUG_TYPE_PORTABILITY,
|
||||
0,
|
||||
GL_DEBUG_SEVERITY_HIGH,
|
||||
aMsg);
|
||||
theGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Warning! Depth textures are not supported by hardware!");
|
||||
|
||||
hasStencilRB = aPixelFormat == GL_DEPTH_STENCIL
|
||||
hasStencilRB = aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL
|
||||
&& theGlContext->extPDS;
|
||||
GLint aDepthStencilFormat = hasStencilRB
|
||||
? GL_DEPTH24_STENCIL8
|
||||
@ -599,10 +470,8 @@ Standard_Boolean OpenGl_FrameBuffer::InitWithRB (const Handle(OpenGl_Context)& t
|
||||
bool hasStencilRB = false;
|
||||
if (myDepthFormat != 0)
|
||||
{
|
||||
GLenum aPixelFormat = 0;
|
||||
GLenum aDataType = 0;
|
||||
getDepthDataFormat (myDepthFormat, aPixelFormat, aDataType);
|
||||
hasStencilRB = aPixelFormat == GL_DEPTH_STENCIL;
|
||||
const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theGlCtx, myDepthFormat);
|
||||
hasStencilRB = aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL;
|
||||
|
||||
theGlCtx->arbFBO->glGenRenderbuffers (1, &myGlDepthRBufferId);
|
||||
theGlCtx->arbFBO->glBindRenderbuffer (GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
@ -789,6 +658,7 @@ void OpenGl_FrameBuffer::ChangeViewport (const GLsizei theVPSizeX,
|
||||
void OpenGl_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theGlCtx)
|
||||
{
|
||||
theGlCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, myGlFBufferId);
|
||||
theGlCtx->SetFrameBufferSRGB (true);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -798,6 +668,7 @@ void OpenGl_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theGlCtx)
|
||||
void OpenGl_FrameBuffer::BindDrawBuffer (const Handle(OpenGl_Context)& theGlCtx)
|
||||
{
|
||||
theGlCtx->arbFBO->glBindFramebuffer (GL_DRAW_FRAMEBUFFER, myGlFBufferId);
|
||||
theGlCtx->SetFrameBufferSRGB (true);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -823,6 +694,7 @@ void OpenGl_FrameBuffer::UnbindBuffer (const Handle(OpenGl_Context)& theGlCtx)
|
||||
else
|
||||
{
|
||||
theGlCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, NO_FRAMEBUFFER);
|
||||
theGlCtx->SetFrameBufferSRGB (false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,19 +269,6 @@ protected:
|
||||
return myGlFBufferId != NO_FRAMEBUFFER;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Determine data type from texture sized format.
|
||||
Standard_EXPORT static bool getDepthDataFormat (GLint theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType);
|
||||
|
||||
//! Determine data type from texture sized format.
|
||||
Standard_EXPORT static bool getColorDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType);
|
||||
|
||||
protected:
|
||||
|
||||
typedef NCollection_Vector<Handle(OpenGl_Texture)> OpenGl_TextureArray;
|
||||
|
@ -76,6 +76,10 @@
|
||||
// OpenGL ES 3.0+ or GL_OES_element_index_uint extension
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
|
||||
// GL_EXT_sRGB_write_control extension for OpenGL ES
|
||||
// adds GL_FRAMEBUFFER_SRGB_EXT flag as on desktop OpenGL
|
||||
#define GL_FRAMEBUFFER_SRGB 0x8DB9
|
||||
|
||||
// OpenGL ES 3.1+
|
||||
#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
|
||||
#define GL_MAX_SAMPLES 0x8D57
|
||||
@ -93,6 +97,10 @@
|
||||
// GL_EXT_texture_format_BGRA8888
|
||||
#define GL_BGRA_EXT 0x80E1 // same as GL_BGRA on desktop
|
||||
|
||||
#define GL_SRGB 0x8C40
|
||||
#define GL_SRGB8 0x8C41
|
||||
#define GL_SRGB8_ALPHA8 0x8C43
|
||||
|
||||
#define GL_R16 0x822A
|
||||
#define GL_R16F 0x822D
|
||||
#define GL_R32F 0x822E
|
||||
@ -161,6 +169,7 @@
|
||||
|
||||
#define GL_READ_FRAMEBUFFER 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER 0x8CA9
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
|
||||
|
||||
#define GL_TEXTURE_3D 0x806F
|
||||
#define GL_TEXTURE_WRAP_R 0x8072
|
||||
|
@ -408,6 +408,8 @@ Standard_Integer OpenGl_GraphicDriver::InquireLimit (const Graphic3d_TypeOfLimit
|
||||
return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSampling()) ? 1 : 0;
|
||||
case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic:
|
||||
return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSamplingAtomic()) ? 1 : 0;
|
||||
case Graphic3d_TypeOfLimit_HasSRGB:
|
||||
return (!aCtx.IsNull() && aCtx->HasSRGB()) ? 1 : 0;
|
||||
case Graphic3d_TypeOfLimit_HasBlendedOit:
|
||||
return (!aCtx.IsNull()
|
||||
&& aCtx->hasDrawBuffers != OpenGl_FeatureNotAvailable
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <OpenGl_Vec.hxx>
|
||||
|
||||
class OpenGl_Context;
|
||||
|
||||
//! OpenGL material definition
|
||||
struct OpenGl_Material
|
||||
{
|
||||
@ -52,8 +54,9 @@ struct OpenGl_Material
|
||||
Params (1.0f, 0.0f, 0.0f, 0.0f) {}
|
||||
|
||||
//! Initialize material
|
||||
void Init (const Graphic3d_MaterialAspect& theProp,
|
||||
const Quantity_Color& theInteriorColor);
|
||||
void Init (const OpenGl_Context& theCtx,
|
||||
const Graphic3d_MaterialAspect& theProp,
|
||||
const Quantity_Color& theInteriorColor);
|
||||
|
||||
//! Returns packed (serialized) representation of material properties
|
||||
const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
|
||||
|
@ -408,6 +408,7 @@ OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
|
||||
myShadingModel (Graphic3d_TOSM_VERTEX),
|
||||
myUnlitPrograms (new OpenGl_SetOfPrograms()),
|
||||
myContext (theContext),
|
||||
mySRgbState (theContext->ToRenderSRGB()),
|
||||
myHasLocalOrigin (Standard_False),
|
||||
myLastView (NULL)
|
||||
{
|
||||
@ -435,7 +436,8 @@ void OpenGl_ShaderManager::clear()
|
||||
myOutlinePrograms.Nullify();
|
||||
myMapOfLightPrograms.Clear();
|
||||
myFontProgram.Nullify();
|
||||
myBlitProgram.Nullify();
|
||||
myBlitPrograms[0].Init (Handle(OpenGl_ShaderProgram)());
|
||||
myBlitPrograms[1].Init (Handle(OpenGl_ShaderProgram)());
|
||||
myBoundBoxProgram.Nullify();
|
||||
myBoundBoxVertBuffer.Nullify();
|
||||
for (Standard_Integer aModeIter = 0; aModeIter < Graphic3d_StereoMode_NB; ++aModeIter)
|
||||
@ -562,6 +564,23 @@ void OpenGl_ShaderManager::switchLightPrograms()
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UpdateSRgbState
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_ShaderManager::UpdateSRgbState()
|
||||
{
|
||||
if (mySRgbState == myContext->ToRenderSRGB())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mySRgbState = myContext->ToRenderSRGB();
|
||||
|
||||
// special cases - GLSL programs dealing with sRGB/linearRGB internally
|
||||
myStereoPrograms[Graphic3d_StereoMode_Anaglyph].Nullify();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UpdateLightSourceStateTo
|
||||
// purpose : Updates state of OCCT light sources
|
||||
@ -744,6 +763,8 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignoring OpenGl_Context::ToRenderSRGB() for light colors,
|
||||
// as non-absolute colors for lights are rare and require tuning anyway
|
||||
aLightType.Type = aLight.Type();
|
||||
aLightType.IsHeadlight = aLight.IsHeadlight();
|
||||
aLightParams.Color = aLight.PackedColor();
|
||||
@ -1227,7 +1248,7 @@ void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)
|
||||
}
|
||||
else
|
||||
{
|
||||
theProgram->SetUniform (myContext, aLocWireframeColor, theAspect->EdgeColorRGBA());
|
||||
theProgram->SetUniform (myContext, aLocWireframeColor, myContext->Vec4FromQuantityColor (theAspect->EdgeColorRGBA()));
|
||||
}
|
||||
}
|
||||
if (const OpenGl_ShaderUniformLocation aLocQuadModeState = theProgram->GetStateLocation (OpenGl_OCCT_QUAD_MODE_STATE))
|
||||
@ -1313,11 +1334,36 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BindFboBlitProgram
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderManager::BindFboBlitProgram (Standard_Integer theNbSamples,
|
||||
Standard_Boolean theIsFallback_sRGB)
|
||||
{
|
||||
NCollection_Array1<Handle(OpenGl_ShaderProgram)>& aList = myBlitPrograms[theIsFallback_sRGB ? 1 : 0];
|
||||
Standard_Integer aNbSamples = Max (theNbSamples, 1);
|
||||
if (aNbSamples > aList.Upper())
|
||||
{
|
||||
aList.Resize (1, aNbSamples, true);
|
||||
}
|
||||
|
||||
Handle(OpenGl_ShaderProgram)& aProg = aList[aNbSamples];
|
||||
if (aProg.IsNull())
|
||||
{
|
||||
prepareStdProgramFboBlit (aProg, aNbSamples, theIsFallback_sRGB);
|
||||
}
|
||||
return !aProg.IsNull()
|
||||
&& myContext->BindProgram (aProg);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : prepareStdProgramFboBlit
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit()
|
||||
Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
Standard_Integer theNbSamples,
|
||||
Standard_Boolean theIsFallback_sRGB)
|
||||
{
|
||||
OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
|
||||
aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec2 TexCoord", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
|
||||
@ -1329,18 +1375,63 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit()
|
||||
EOL" gl_Position = vec4(occVertex.x, occVertex.y, 0.0, 1.0);"
|
||||
EOL"}";
|
||||
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D uColorSampler", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D uDepthSampler", Graphic3d_TOS_FRAGMENT));
|
||||
TCollection_AsciiString aSrcFrag =
|
||||
EOL"void main()"
|
||||
TCollection_AsciiString aSrcFrag;
|
||||
if (theNbSamples > 1)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("highp sampler2DMS uColorSampler", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("highp sampler2DMS uDepthSampler", Graphic3d_TOS_FRAGMENT));
|
||||
#else
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2DMS uColorSampler", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2DMS uDepthSampler", Graphic3d_TOS_FRAGMENT));
|
||||
#endif
|
||||
aSrcFrag = TCollection_AsciiString()
|
||||
+ EOL"#define THE_NUM_SAMPLES " + theNbSamples
|
||||
+ (theIsFallback_sRGB ? EOL"#define THE_SHIFT_sRGB" : "")
|
||||
+ EOL"void main()"
|
||||
EOL"{"
|
||||
EOL" ivec2 aSize = textureSize (uColorSampler);"
|
||||
EOL" ivec2 anUV = ivec2 (vec2 (aSize) * TexCoord);"
|
||||
EOL" gl_FragDepth = texelFetch (uDepthSampler, anUV, THE_NUM_SAMPLES / 2 - 1).r;"
|
||||
EOL
|
||||
EOL" vec4 aColor = vec4 (0.0);"
|
||||
EOL" for (int aSample = 0; aSample < THE_NUM_SAMPLES; ++aSample)"
|
||||
EOL" {"
|
||||
EOL" vec4 aVal = texelFetch (uColorSampler, anUV, aSample);"
|
||||
EOL" aColor += aVal;"
|
||||
EOL" }"
|
||||
EOL" aColor /= float(THE_NUM_SAMPLES);"
|
||||
EOL"#ifdef THE_SHIFT_sRGB"
|
||||
EOL" aColor.rgb = pow (aColor.rgb, vec3 (1.0 / 2.2));"
|
||||
EOL"#endif"
|
||||
EOL" occSetFragColor (aColor);"
|
||||
EOL"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D uColorSampler", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("sampler2D uDepthSampler", Graphic3d_TOS_FRAGMENT));
|
||||
aSrcFrag = TCollection_AsciiString()
|
||||
+ (theIsFallback_sRGB ? EOL"#define THE_SHIFT_sRGB" : "")
|
||||
+ EOL"void main()"
|
||||
EOL"{"
|
||||
EOL" gl_FragDepth = occTexture2D (uDepthSampler, TexCoord).r;"
|
||||
EOL" occSetFragColor (occTexture2D (uColorSampler, TexCoord));"
|
||||
EOL" vec4 aColor = occTexture2D (uColorSampler, TexCoord);"
|
||||
EOL"#ifdef THE_SHIFT_sRGB"
|
||||
EOL" aColor.rgb = pow (aColor.rgb, vec3 (1.0 / 2.2));"
|
||||
EOL"#endif"
|
||||
EOL" occSetFragColor (aColor);"
|
||||
EOL"}";
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
{
|
||||
// required for MSAA sampler
|
||||
aProgramSrc->SetHeader ("#version 310 es");
|
||||
}
|
||||
else if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
aProgramSrc->SetHeader ("#version 300 es");
|
||||
}
|
||||
@ -1364,22 +1455,31 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFboBlit()
|
||||
aProgramSrc->SetHeader ("#version 150");
|
||||
}
|
||||
#endif
|
||||
aProgramSrc->SetId ("occt_blit");
|
||||
TCollection_AsciiString anId = "occt_blit";
|
||||
if (theNbSamples > 1)
|
||||
{
|
||||
anId += TCollection_AsciiString ("_msaa") + theNbSamples;
|
||||
}
|
||||
if (theIsFallback_sRGB)
|
||||
{
|
||||
anId += "_gamma";
|
||||
}
|
||||
aProgramSrc->SetId (anId);
|
||||
aProgramSrc->SetDefaultSampler (false);
|
||||
aProgramSrc->SetNbLightsMax (0);
|
||||
aProgramSrc->SetNbClipPlanesMax (0);
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX, aUniforms, aStageInOuts));
|
||||
aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
|
||||
TCollection_AsciiString aKey;
|
||||
if (!Create (aProgramSrc, aKey, myBlitProgram))
|
||||
if (!Create (aProgramSrc, aKey, theProgram))
|
||||
{
|
||||
myBlitProgram = new OpenGl_ShaderProgram(); // just mark as invalid
|
||||
theProgram = new OpenGl_ShaderProgram(); // just mark as invalid
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
myContext->BindProgram (myBlitProgram);
|
||||
myBlitProgram->SetSampler (myContext, "uColorSampler", Graphic3d_TextureUnit_0);
|
||||
myBlitProgram->SetSampler (myContext, "uDepthSampler", Graphic3d_TextureUnit_1);
|
||||
myContext->BindProgram (theProgram);
|
||||
theProgram->SetSampler (myContext, "uColorSampler", Graphic3d_TextureUnit_0);
|
||||
theProgram->SetSampler (myContext, "uDepthSampler", Graphic3d_TextureUnit_1);
|
||||
myContext->BindProgram (NULL);
|
||||
return Standard_True;
|
||||
}
|
||||
@ -2432,19 +2532,21 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
|
||||
aName = "anaglyph";
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("mat4 uMultL", Graphic3d_TOS_FRAGMENT));
|
||||
aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("mat4 uMultR", Graphic3d_TOS_FRAGMENT));
|
||||
aSrcFrag =
|
||||
EOL"const vec4 THE_POW_UP = vec4 (2.2, 2.2, 2.2, 1.0);"
|
||||
EOL"const vec4 THE_POW_DOWN = 1.0 / vec4 (2.2, 2.2, 2.2, 1.0);"
|
||||
EOL
|
||||
EOL"void main()"
|
||||
EOL"{"
|
||||
EOL" vec4 aColorL = occTexture2D (uLeftSampler, TexCoord);"
|
||||
EOL" vec4 aColorR = occTexture2D (uRightSampler, TexCoord);"
|
||||
EOL" aColorL = pow (aColorL, THE_POW_UP);" // normalize
|
||||
EOL" aColorR = pow (aColorR, THE_POW_UP);"
|
||||
EOL" vec4 aColor = uMultR * aColorR + uMultL * aColorL;"
|
||||
EOL" occSetFragColor (pow (aColor, THE_POW_DOWN));"
|
||||
EOL"}";
|
||||
const TCollection_AsciiString aNormalize = mySRgbState
|
||||
? EOL"#define sRgb2linear(theColor) theColor"
|
||||
EOL"#define linear2sRgb(theColor) theColor"
|
||||
: EOL"#define sRgb2linear(theColor) pow(theColor, vec4(2.2, 2.2, 2.2, 1.0))"
|
||||
EOL"#define linear2sRgb(theColor) pow(theColor, 1.0 / vec4(2.2, 2.2, 2.2, 1.0))";
|
||||
aSrcFrag = aNormalize
|
||||
+ EOL"void main()"
|
||||
EOL"{"
|
||||
EOL" vec4 aColorL = occTexture2D (uLeftSampler, TexCoord);"
|
||||
EOL" vec4 aColorR = occTexture2D (uRightSampler, TexCoord);"
|
||||
EOL" aColorL = sRgb2linear (aColorL);"
|
||||
EOL" aColorR = sRgb2linear (aColorR);"
|
||||
EOL" vec4 aColor = uMultR * aColorR + uMultL * aColorL;"
|
||||
EOL" occSetFragColor (linear2sRgb (aColor));"
|
||||
EOL"}";
|
||||
break;
|
||||
}
|
||||
case Graphic3d_StereoMode_RowInterlaced:
|
||||
|
@ -50,6 +50,9 @@ public:
|
||||
//! Release all resources.
|
||||
Standard_EXPORT void clear();
|
||||
|
||||
//! Fetch sRGB state from caps and invalidates programs, if necessary.
|
||||
Standard_EXPORT void UpdateSRgbState();
|
||||
|
||||
//! Return local camera transformation.
|
||||
const gp_XYZ& LocalOrigin() const { return myLocalOrigin; }
|
||||
|
||||
@ -198,15 +201,10 @@ public:
|
||||
}
|
||||
|
||||
//! Bind program for FBO blit operation.
|
||||
Standard_Boolean BindFboBlitProgram()
|
||||
{
|
||||
if (myBlitProgram.IsNull())
|
||||
{
|
||||
prepareStdProgramFboBlit();
|
||||
}
|
||||
return !myBlitProgram.IsNull()
|
||||
&& myContext->BindProgram (myBlitProgram);
|
||||
}
|
||||
//! @param theNbSamples [in] number of samples within source MSAA texture
|
||||
//! @param theIsFallback_sRGB [in] flag indicating that destination buffer is not sRGB-ready
|
||||
Standard_EXPORT Standard_Boolean BindFboBlitProgram (Standard_Integer theNbSamples,
|
||||
Standard_Boolean theIsFallback_sRGB);
|
||||
|
||||
//! Bind program for blended order-independent transparency buffers compositing.
|
||||
Standard_Boolean BindOitCompositingProgram (const Standard_Boolean theIsMSAAEnabled)
|
||||
@ -631,7 +629,9 @@ protected:
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramFont();
|
||||
|
||||
//! Prepare standard GLSL program for FBO blit operation.
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramFboBlit();
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramFboBlit (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
Standard_Integer theNbSamples,
|
||||
Standard_Boolean theIsFallback_sRGB);
|
||||
|
||||
//! Prepare standard GLSL programs for OIT compositing operation.
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramOitCompositing (const Standard_Boolean theMsaa);
|
||||
@ -763,7 +763,8 @@ protected:
|
||||
Handle(OpenGl_SetOfPrograms) myUnlitPrograms; //!< programs matrix without lighting
|
||||
Handle(OpenGl_SetOfPrograms) myOutlinePrograms; //!< programs matrix without lighting for outline presentation
|
||||
Handle(OpenGl_ShaderProgram) myFontProgram; //!< standard program for textured text
|
||||
Handle(OpenGl_ShaderProgram) myBlitProgram; //!< standard program for FBO blit emulation
|
||||
NCollection_Array1<Handle(OpenGl_ShaderProgram)>
|
||||
myBlitPrograms[2]; //!< standard program for FBO blit emulation
|
||||
Handle(OpenGl_ShaderProgram) myBoundBoxProgram; //!< standard program for bounding box
|
||||
Handle(OpenGl_ShaderProgram) myOitCompositingProgram[2]; //!< standard program for OIT compositing (default and MSAA).
|
||||
OpenGl_MapOfShaderPrograms myMapOfLightPrograms; //!< map of lighting programs depending on lights configuration
|
||||
@ -775,6 +776,7 @@ protected:
|
||||
Handle(OpenGl_VertexBuffer) myBoundBoxVertBuffer; //!< bounding box vertex buffer
|
||||
|
||||
OpenGl_Context* myContext; //!< OpenGL context
|
||||
Standard_Boolean mySRgbState; //!< track sRGB state
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -177,240 +177,22 @@ bool OpenGl_Texture::InitSamplerObject (const Handle(OpenGl_Context)& theCtx)
|
||||
&& mySampler->Init (theCtx, *this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDataFormat
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_Format theFormat,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
theTextFormat = GL_RGBA8;
|
||||
thePixelFormat = 0;
|
||||
theDataType = 0;
|
||||
switch (theFormat)
|
||||
{
|
||||
case Image_Format_GrayF:
|
||||
{
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
theTextFormat = GL_R8; // GL_R32F
|
||||
thePixelFormat = GL_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theTextFormat = GL_LUMINANCE8;
|
||||
#else
|
||||
theTextFormat = GL_LUMINANCE;
|
||||
#endif
|
||||
thePixelFormat = GL_LUMINANCE;
|
||||
}
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_AlphaF:
|
||||
{
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
theTextFormat = GL_R8; // GL_R32F
|
||||
thePixelFormat = GL_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theTextFormat = GL_ALPHA8;
|
||||
#else
|
||||
theTextFormat = GL_ALPHA;
|
||||
#endif
|
||||
thePixelFormat = GL_ALPHA;
|
||||
}
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_RGBAF:
|
||||
{
|
||||
theTextFormat = GL_RGBA8; // GL_RGBA32F
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_BGRAF:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_RGBA8; // GL_RGBA32F
|
||||
thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_RGBF:
|
||||
{
|
||||
theTextFormat = GL_RGB8; // GL_RGB32F
|
||||
thePixelFormat = GL_RGB;
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_BGRF:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theTextFormat = GL_RGB8; // GL_RGB32F
|
||||
thePixelFormat = GL_BGR; // equals to GL_BGR_EXT
|
||||
theDataType = GL_FLOAT;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
case Image_Format_RGBA:
|
||||
{
|
||||
theTextFormat = GL_RGBA8;
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_BGRA:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_RGBA8;
|
||||
#else
|
||||
if (!theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_BGRA_EXT;
|
||||
#endif
|
||||
thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_RGB32:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// ask driver to convert data to RGB8 to save memory
|
||||
theTextFormat = GL_RGB8;
|
||||
#else
|
||||
// conversion is not supported
|
||||
theTextFormat = GL_RGBA8;
|
||||
#endif
|
||||
thePixelFormat = GL_RGBA;
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_BGR32:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_RGB8;
|
||||
#else
|
||||
if (!theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_BGRA_EXT;
|
||||
#endif
|
||||
thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_RGB:
|
||||
{
|
||||
theTextFormat = GL_RGB8;
|
||||
thePixelFormat = GL_RGB;
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_BGR:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
theTextFormat = GL_RGB8;
|
||||
thePixelFormat = GL_BGR; // equals to GL_BGR_EXT
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
case Image_Format_Gray:
|
||||
{
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
theTextFormat = GL_R8;
|
||||
thePixelFormat = GL_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theTextFormat = GL_LUMINANCE8;
|
||||
#else
|
||||
theTextFormat = GL_LUMINANCE;
|
||||
#endif
|
||||
thePixelFormat = GL_LUMINANCE;
|
||||
}
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_Alpha:
|
||||
{
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
theTextFormat = GL_R8;
|
||||
thePixelFormat = GL_RED;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
theTextFormat = GL_ALPHA8;
|
||||
#else
|
||||
theTextFormat = GL_ALPHA;
|
||||
#endif
|
||||
thePixelFormat = GL_ALPHA;
|
||||
}
|
||||
theDataType = GL_UNSIGNED_BYTE;
|
||||
return true;
|
||||
}
|
||||
case Image_Format_UNKNOWN:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Standard_Integer theTextFormat,
|
||||
const GLenum thePixelFormat,
|
||||
const GLenum theDataType,
|
||||
const Standard_Integer theSizeX,
|
||||
const Standard_Integer theSizeY,
|
||||
const OpenGl_TextureFormat& theFormat,
|
||||
const Graphic3d_Vec2i& theSizeXY,
|
||||
const Graphic3d_TypeOfTexture theType,
|
||||
const Image_PixMap* theImage)
|
||||
{
|
||||
if (theSizeX < 1
|
||||
|| theSizeY < 1)
|
||||
if (theSizeXY.x() < 1
|
||||
|| theSizeXY.y() < 1)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error: texture of 0 size cannot be created.");
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -423,14 +205,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
#endif
|
||||
const Standard_Boolean toCreateMipMaps = (theType == Graphic3d_TOT_2D_MIPMAP);
|
||||
const bool toPatchExisting = IsValid()
|
||||
&& myTextFormat == thePixelFormat
|
||||
&& myTextFormat == theFormat.PixelFormat()
|
||||
&& myTarget == aTarget
|
||||
&& myHasMipmaps == toCreateMipMaps
|
||||
&& mySizeX == theSizeX
|
||||
&& (mySizeY == theSizeY || theType == Graphic3d_TOT_1D);
|
||||
&& mySizeX == theSizeXY.x()
|
||||
&& (mySizeY == theSizeXY.y() || theType == Graphic3d_TOT_1D);
|
||||
if (!Create (theCtx))
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -441,37 +223,37 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
else
|
||||
{
|
||||
myIsAlpha = thePixelFormat == GL_ALPHA;
|
||||
myIsAlpha = theFormat.PixelFormat() == GL_ALPHA;
|
||||
}
|
||||
|
||||
myHasMipmaps = toCreateMipMaps;
|
||||
myTextFormat = thePixelFormat;
|
||||
mySizedFormat = theTextFormat;
|
||||
myTextFormat = theFormat.PixelFormat();
|
||||
mySizedFormat = theFormat.InternalFormat();
|
||||
myNbSamples = 1;
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
const GLint anIntFormat = theTextFormat;
|
||||
const GLint anIntFormat = theFormat.InternalFormat();
|
||||
#else
|
||||
// ES 2.0 does not support sized formats and format conversions - them detected from data type
|
||||
const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? theTextFormat : thePixelFormat;
|
||||
const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? theFormat.InternalFormat() : theFormat.PixelFormat();
|
||||
#endif
|
||||
|
||||
if (theDataType == GL_FLOAT && !theCtx->arbTexFloat)
|
||||
if (theFormat.DataType() == GL_FLOAT
|
||||
&& !theCtx->arbTexFloat)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error: floating-point textures are not supported by hardware.");
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
const GLsizei aMaxSize = theCtx->MaxTextureSize();
|
||||
if (theSizeX > aMaxSize
|
||||
|| theSizeY > aMaxSize)
|
||||
if (theSizeXY.x() > aMaxSize
|
||||
|| theSizeXY.y() > aMaxSize)
|
||||
{
|
||||
TCollection_ExtendedString aWarnMessage = TCollection_ExtendedString ("Error: Texture dimension - ")
|
||||
+ theSizeX + "x" + theSizeY + " exceeds hardware limits (" + aMaxSize + "x" + aMaxSize + ")";
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
|
||||
Release (theCtx.operator->());
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: Texture dimension - ") + theSizeXY.x() + "x" + theSizeXY.y()
|
||||
+ " exceeds hardware limits (" + aMaxSize + "x" + aMaxSize + ")");
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
@ -481,18 +263,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
// however some hardware (NV30 - GeForce FX, RadeOn 9xxx and Xxxx) supports GLSL but not NPOT!
|
||||
// Trying to create NPOT textures on such hardware will not fail
|
||||
// but driver will fall back into software rendering,
|
||||
const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeX, aMaxSize);
|
||||
const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeY, aMaxSize);
|
||||
|
||||
if (theSizeX != aWidthP2
|
||||
|| (theType != Graphic3d_TOT_1D && theSizeY != aHeightP2))
|
||||
const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize);
|
||||
const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.y(), aMaxSize);
|
||||
if (theSizeXY.x() != aWidthP2
|
||||
|| (theType != Graphic3d_TOT_1D && theSizeXY.y() != aHeightP2))
|
||||
{
|
||||
TCollection_ExtendedString aWarnMessage =
|
||||
TCollection_ExtendedString ("Error: NPOT Textures (") + theSizeX + "x" + theSizeY + ") are not supported by hardware.";
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
|
||||
|
||||
Release (theCtx.operator->());
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: NPOT Textures (") + theSizeXY.x() + "x" + theSizeXY.y() + ")"
|
||||
" are not supported by hardware.");
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -500,18 +279,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
else if (!theCtx->IsGlGreaterEqual (3, 0) && theType == Graphic3d_TOT_2D_MIPMAP)
|
||||
{
|
||||
// Mipmap NPOT textures are not supported by OpenGL ES 2.0.
|
||||
const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeX, aMaxSize);
|
||||
const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeY, aMaxSize);
|
||||
|
||||
if (theSizeX != aWidthP2
|
||||
|| theSizeY != aHeightP2)
|
||||
const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize);
|
||||
const GLsizei aHeightP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.y(), aMaxSize);
|
||||
if (theSizeXY.x() != aWidthP2
|
||||
|| theSizeXY.y() != aHeightP2)
|
||||
{
|
||||
TCollection_ExtendedString aWarnMessage =
|
||||
TCollection_ExtendedString ("Error: Mipmap NPOT Textures (") + theSizeX + "x" + theSizeY + ") are not supported by OpenGL ES 2.0";
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
|
||||
|
||||
Release (theCtx.operator->());
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: Mipmap NPOT Textures (") + theSizeXY.x() + "x" + theSizeXY.y() + ")"
|
||||
" are not supported by OpenGL ES 2.0");
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -551,15 +327,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
if (toPatchExisting)
|
||||
{
|
||||
glTexSubImage1D (GL_TEXTURE_1D, 0, 0,
|
||||
theSizeX, thePixelFormat, theDataType, aDataPtr);
|
||||
theSizeXY.x(), theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
}
|
||||
|
||||
// use proxy to check texture could be created or not
|
||||
glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat,
|
||||
theSizeX, 0,
|
||||
thePixelFormat, theDataType, NULL);
|
||||
theSizeXY.x(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), NULL);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
|
||||
if (aTestWidth == 0)
|
||||
@ -571,16 +347,16 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
|
||||
glTexImage1D (GL_TEXTURE_1D, 0, anIntFormat,
|
||||
theSizeX, 0,
|
||||
thePixelFormat, theDataType, aDataPtr);
|
||||
theSizeXY.x(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
mySizeX = theSizeX;
|
||||
mySizeX = theSizeXY.x();
|
||||
mySizeY = 1;
|
||||
|
||||
Unbind (theCtx);
|
||||
@ -588,7 +364,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
#else
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error: 1D textures are not supported by hardware.");
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@ -600,8 +376,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
0, 0,
|
||||
theSizeX, theSizeY,
|
||||
thePixelFormat, theDataType, aDataPtr);
|
||||
theSizeXY.x(), theSizeXY.y(),
|
||||
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
}
|
||||
@ -609,8 +385,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// use proxy to check texture could be created or not
|
||||
glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
|
||||
theSizeX, theSizeY, 0,
|
||||
thePixelFormat, theDataType, NULL);
|
||||
theSizeXY.x(), theSizeXY.y(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), NULL);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
|
||||
@ -618,28 +394,29 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
// no memory or broken input parameters
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
|
||||
theSizeX, theSizeY, 0,
|
||||
thePixelFormat, theDataType, aDataPtr);
|
||||
theSizeXY.x(), theSizeXY.y(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
|
||||
const GLenum anErr = glGetError();
|
||||
if (anErr != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: 2D texture ") + theSizeX + "x" + theSizeY
|
||||
+ " IF: " + int(anIntFormat) + " PF: " + int(thePixelFormat) + " DT: " + int(theDataType)
|
||||
TCollection_AsciiString ("Error: 2D texture ") + theSizeXY.x() + "x" + theSizeXY.y()
|
||||
+ " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
|
||||
+ " DT: " + int(theFormat.DataType())
|
||||
+ " can not be created with error " + int(anErr) + ".");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
mySizeX = theSizeX;
|
||||
mySizeY = theSizeY;
|
||||
mySizeX = theSizeXY.x();
|
||||
mySizeY = theSizeXY.y();
|
||||
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
@ -652,8 +429,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0,
|
||||
0, 0,
|
||||
theSizeX, theSizeY,
|
||||
thePixelFormat, theDataType, aDataPtr);
|
||||
theSizeXY.x(), theSizeXY.y(),
|
||||
theFormat.PixelFormat(), theFormat.DataType(), aDataPtr);
|
||||
if (theCtx->arbFBO != NULL)
|
||||
{
|
||||
// generate mipmaps
|
||||
@ -661,7 +438,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -673,8 +450,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// use proxy to check texture could be created or not
|
||||
glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
|
||||
theSizeX, theSizeY, 0,
|
||||
thePixelFormat, theDataType, NULL);
|
||||
theSizeXY.x(), theSizeXY.y(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), NULL);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
|
||||
@ -682,29 +459,30 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
// no memory or broken input parameters
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// upload main picture
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
|
||||
theSizeX, theSizeY, 0,
|
||||
thePixelFormat, theDataType, theImage->Data());
|
||||
theSizeXY.x(), theSizeXY.y(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), theImage->Data());
|
||||
const GLenum aTexImgErr = glGetError();
|
||||
if (aTexImgErr != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Error: 2D texture ") + theSizeX + "x" + theSizeY
|
||||
+ " IF: " + int(anIntFormat) + " PF: " + int(thePixelFormat) + " DT: " + int(theDataType)
|
||||
TCollection_AsciiString ("Error: 2D texture ") + theSizeXY.x() + "x" + theSizeXY.y()
|
||||
+ " IF: " + int(anIntFormat) + " PF: " + int(theFormat.PixelFormat())
|
||||
+ " DT: " + int(theFormat.DataType())
|
||||
+ " can not be created with error " + int(aTexImgErr) + ".");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
mySizeX = theSizeX;
|
||||
mySizeY = theSizeY;
|
||||
mySizeX = theSizeXY.x();
|
||||
mySizeY = theSizeXY.y();
|
||||
|
||||
if (theCtx->arbFBO != NULL)
|
||||
{
|
||||
@ -715,18 +493,16 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const TCollection_ExtendedString aWarnMessage ("Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -741,7 +517,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
}
|
||||
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -751,27 +527,23 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theImage,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
const Graphic3d_TypeOfTexture theType,
|
||||
const Standard_Boolean theIsColorMap)
|
||||
{
|
||||
if (theImage.IsEmpty())
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
GLenum aPixelFormat;
|
||||
GLenum aDataType;
|
||||
GLint aTextFormat;
|
||||
if (!GetDataFormat (theCtx, theImage, aTextFormat, aPixelFormat, aDataType))
|
||||
const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theImage.Format(), theIsColorMap);
|
||||
if (!aFormat.IsValid())
|
||||
{
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
return Init (theCtx,
|
||||
aTextFormat, aPixelFormat, aDataType,
|
||||
(Standard_Integer)theImage.SizeX(),
|
||||
(Standard_Integer)theImage.SizeY(),
|
||||
return Init (theCtx, aFormat, Graphic3d_Vec2i ((Standard_Integer)theImage.SizeX(), (Standard_Integer)theImage.SizeY()),
|
||||
theType, &theImage);
|
||||
}
|
||||
|
||||
@ -791,7 +563,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
case Graphic3d_TOT_CUBEMAP:
|
||||
{
|
||||
return InitCubeMap (theCtx, Handle(Graphic3d_CubeMap)::DownCast(theTextureMap));
|
||||
return initCubeMap (theCtx, Handle(Graphic3d_CubeMap)::DownCast(theTextureMap),
|
||||
0, Image_Format_RGB, false, theTextureMap->IsColorMap());
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -800,7 +573,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Init (theCtx, *anImage, theTextureMap->Type());
|
||||
return Init (theCtx, *anImage, theTextureMap->Type(), theTextureMap->IsColorMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -935,24 +708,14 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLint theTextFormat,
|
||||
const GLenum thePixelFormat,
|
||||
const GLenum theDataType,
|
||||
const Standard_Integer theSizeX,
|
||||
const Standard_Integer theSizeY,
|
||||
const Standard_Integer theSizeZ,
|
||||
const OpenGl_TextureFormat& theFormat,
|
||||
const Graphic3d_Vec3i& theSizeXYZ,
|
||||
const void* thePixels)
|
||||
{
|
||||
if (theCtx->Functions()->glTexImage3D == NULL)
|
||||
{
|
||||
TCollection_ExtendedString aMsg ("Error: three-dimensional textures are not supported by hardware.");
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
|
||||
GL_DEBUG_TYPE_ERROR,
|
||||
0,
|
||||
GL_DEBUG_SEVERITY_HIGH,
|
||||
aMsg);
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error: three-dimensional textures are not supported by hardware.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -965,83 +728,80 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
|
||||
myNbSamples = 1;
|
||||
myHasMipmaps = false;
|
||||
|
||||
const GLsizei aSizeX = Min (theCtx->MaxTextureSize(), theSizeX);
|
||||
const GLsizei aSizeY = Min (theCtx->MaxTextureSize(), theSizeY);
|
||||
const GLsizei aSizeZ = Min (theCtx->MaxTextureSize(), theSizeZ);
|
||||
|
||||
const Graphic3d_Vec3i aSizeXYZ = theSizeXYZ.cwiseMin (Graphic3d_Vec3i (theCtx->MaxTextureSize()));
|
||||
if (aSizeXYZ != theSizeXYZ)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error: 3D texture dimensions exceed hardware limits.");
|
||||
Release (theCtx.get());
|
||||
Unbind (theCtx);
|
||||
return false;
|
||||
}
|
||||
Bind (theCtx);
|
||||
|
||||
if (theDataType == GL_FLOAT && !theCtx->arbTexFloat)
|
||||
if (theFormat.DataType() == GL_FLOAT
|
||||
&& !theCtx->arbTexFloat)
|
||||
{
|
||||
TCollection_ExtendedString aMsg ("Error: floating-point textures are not supported by hardware.");
|
||||
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
|
||||
GL_DEBUG_TYPE_ERROR,
|
||||
0,
|
||||
GL_DEBUG_SEVERITY_HIGH,
|
||||
aMsg);
|
||||
|
||||
Release (theCtx.operator->());
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Error: floating-point textures are not supported by hardware.");
|
||||
Release (theCtx.get());
|
||||
Unbind (theCtx);
|
||||
return false;
|
||||
}
|
||||
|
||||
mySizedFormat = theTextFormat;
|
||||
mySizedFormat = theFormat.InternalFormat();
|
||||
|
||||
// setup the alignment
|
||||
OpenGl_UnpackAlignmentSentry::Reset();
|
||||
|
||||
#if !defined (GL_ES_VERSION_2_0)
|
||||
theCtx->core15fwd->glTexImage3D (GL_PROXY_TEXTURE_3D, 0, mySizedFormat,
|
||||
aSizeX, aSizeY, aSizeZ, 0,
|
||||
thePixelFormat, theDataType, NULL);
|
||||
aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), NULL);
|
||||
|
||||
GLint aTestSizeX = 0;
|
||||
GLint aTestSizeY = 0;
|
||||
GLint aTestSizeZ = 0;
|
||||
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeX);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeY);
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeZ);
|
||||
NCollection_Vec3<GLint> aTestSizeXYZ;
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeXYZ.x());
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeXYZ.y());
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeXYZ.z());
|
||||
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
|
||||
|
||||
if (aTestSizeX == 0 || aTestSizeY == 0 || aTestSizeZ == 0)
|
||||
if (aTestSizeXYZ.x() == 0 || aTestSizeXYZ.y() == 0 || aTestSizeXYZ.z() == 0)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
applyDefaultSamplerParams (theCtx);
|
||||
theCtx->Functions()->glTexImage3D (myTarget, 0, mySizedFormat,
|
||||
aSizeX, aSizeY, aSizeZ, 0,
|
||||
thePixelFormat, theDataType, thePixels);
|
||||
aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0,
|
||||
theFormat.PixelFormat(), theFormat.DataType(), thePixels);
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.operator->());
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
mySizeX = aSizeX;
|
||||
mySizeY = aSizeY;
|
||||
mySizeZ = aSizeZ;
|
||||
mySizeX = aSizeXYZ.x();
|
||||
mySizeY = aSizeXYZ.y();
|
||||
mySizeZ = aSizeXYZ.z();
|
||||
|
||||
Unbind (theCtx);
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitCubeMap
|
||||
// function : initCubeMap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
bool OpenGl_Texture::initCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Size theSize,
|
||||
Image_Format theFormat,
|
||||
Standard_Boolean theToGenMipmap)
|
||||
Standard_Size theSize,
|
||||
Image_Format theFormat,
|
||||
Standard_Boolean theToGenMipmap,
|
||||
Standard_Boolean theIsColorMap)
|
||||
{
|
||||
if (!Create (theCtx))
|
||||
{
|
||||
@ -1051,8 +811,7 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
if (!theCubeMap.IsNull())
|
||||
{
|
||||
Handle(Image_PixMap) anImage = theCubeMap->Reset().Value();
|
||||
if (!anImage.IsNull())
|
||||
if (Handle(Image_PixMap) anImage = theCubeMap->Reset().Value())
|
||||
{
|
||||
theSize = anImage->SizeX();
|
||||
theFormat = anImage->Format();
|
||||
@ -1060,17 +819,14 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
else
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Unable to get the first side of cubemap");
|
||||
"Unable to get the first side of cubemap");
|
||||
Release(theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum aPixelFormat = GL_RGB;
|
||||
GLenum aDataType = 0;
|
||||
GLint aTextFormat = 0;
|
||||
|
||||
if (!GetDataFormat (theCtx, theFormat, aTextFormat, aPixelFormat, aDataType))
|
||||
OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, theIsColorMap);
|
||||
if (!aFormat.IsValid())
|
||||
{
|
||||
Unbind(theCtx);
|
||||
Release(theCtx.get());
|
||||
@ -1123,8 +879,8 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
else
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, TCollection_AsciiString() +
|
||||
"Unable to get [" + i + "] side of cubemap");
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString() + "Unable to get [" + i + "] side of cubemap");
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
@ -1133,17 +889,18 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
|
||||
glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
|
||||
aTextFormat,
|
||||
aFormat.InternalFormat(),
|
||||
GLsizei(theSize), GLsizei(theSize),
|
||||
0, aPixelFormat, aDataType,
|
||||
0, aFormat.PixelFormat(), aFormat.DataType(),
|
||||
aData);
|
||||
|
||||
OpenGl_UnpackAlignmentSentry::Reset();
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
const GLenum anErr = glGetError();
|
||||
if (anErr != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Unable to initialize side of cubemap");
|
||||
TCollection_AsciiString ("Unable to initialize side of cubemap. Error #") + int(anErr));
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
@ -1152,16 +909,16 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
if (theToGenMipmap && theCtx->arbFBO != NULL)
|
||||
{
|
||||
theCtx->arbFBO->glGenerateMipmap (myTarget);
|
||||
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
"Unable to generate mipmap of cubemap");
|
||||
Unbind(theCtx);
|
||||
Release(theCtx.get());
|
||||
return false;
|
||||
}
|
||||
theCtx->arbFBO->glGenerateMipmap (myTarget);
|
||||
const GLenum anErr = glGetError();
|
||||
if (anErr != GL_NO_ERROR)
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString ("Unable to generate mipmap of cubemap. Error #") + int(anErr));
|
||||
Unbind (theCtx);
|
||||
Release (theCtx.get());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Unbind (theCtx.get());
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define _OpenGl_Texture_H__
|
||||
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <OpenGl_GlCore13.hxx>
|
||||
#include <OpenGl_TextureFormat.hxx>
|
||||
#include <OpenGl_NamedResource.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <Graphic3d_TextureUnit.hxx>
|
||||
@ -25,262 +25,6 @@
|
||||
class Graphic3d_TextureParams;
|
||||
class Image_PixMap;
|
||||
|
||||
//! Selects preferable texture format for specified parameters.
|
||||
template<class T>
|
||||
struct OpenGl_TextureFormatSelector
|
||||
{
|
||||
// Not implemented
|
||||
};
|
||||
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLubyte>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_R8;
|
||||
case 2:
|
||||
return GL_RG8;
|
||||
case 3:
|
||||
return GL_RGB8;
|
||||
case 4:
|
||||
return GL_RGBA8;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_UNSIGNED_BYTE;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLushort>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_R16;
|
||||
case 2:
|
||||
return GL_RG16;
|
||||
case 3:
|
||||
return GL_RGB16;
|
||||
case 4:
|
||||
return GL_RGBA16;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_UNSIGNED_SHORT;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLfloat>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_R32F;
|
||||
case 2:
|
||||
return GL_RG32F;
|
||||
case 3:
|
||||
return GL_RGB32F;
|
||||
case 4:
|
||||
return GL_RGBA32F;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_FLOAT;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLuint>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_RED;
|
||||
case 2:
|
||||
return GL_RG;
|
||||
case 3:
|
||||
return GL_RGB;
|
||||
case 4:
|
||||
return GL_RGBA;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_UNSIGNED_INT;
|
||||
}
|
||||
};
|
||||
|
||||
//! Only unsigned formats are available in OpenGL ES 2.0
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLbyte>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_R8_SNORM;
|
||||
case 2:
|
||||
return GL_RG8_SNORM;
|
||||
case 3:
|
||||
return GL_RGB8_SNORM;
|
||||
case 4:
|
||||
return GL_RGBA8_SNORM;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_BYTE;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLshort>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_R16_SNORM;
|
||||
case 2:
|
||||
return GL_RG16_SNORM;
|
||||
case 3:
|
||||
return GL_RGB16_SNORM;
|
||||
case 4:
|
||||
return GL_RGBA16_SNORM;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_SHORT;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct OpenGl_TextureFormatSelector<GLint>
|
||||
{
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_RED_SNORM;
|
||||
case 2:
|
||||
return GL_RG_SNORM;
|
||||
case 3:
|
||||
return GL_RGB_SNORM;
|
||||
case 4:
|
||||
return GL_RGBA_SNORM;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static GLint DataType()
|
||||
{
|
||||
return GL_INT;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//! Stores parameters of OpenGL texture format.
|
||||
class OpenGl_TextureFormat
|
||||
{
|
||||
friend class OpenGl_Texture;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns OpenGL format of the pixel data.
|
||||
inline GLenum Format() const
|
||||
{
|
||||
switch (myChannels)
|
||||
{
|
||||
case 1:
|
||||
return GL_RED;
|
||||
case 2:
|
||||
return GL_RG;
|
||||
case 3:
|
||||
return GL_RGB;
|
||||
case 4:
|
||||
return GL_RGBA;
|
||||
default:
|
||||
return GL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns OpenGL internal format of the pixel data.
|
||||
inline GLint Internal() const
|
||||
{
|
||||
return myInternal;
|
||||
}
|
||||
|
||||
//! Returns OpenGL data type of the pixel data.
|
||||
inline GLint DataType() const
|
||||
{
|
||||
return myDataType;
|
||||
}
|
||||
|
||||
//! Returns texture format for specified type and number of channels.
|
||||
template<class T, int N>
|
||||
static OpenGl_TextureFormat Create()
|
||||
{
|
||||
return OpenGl_TextureFormat (N,
|
||||
OpenGl_TextureFormatSelector<T>::Internal(N),
|
||||
OpenGl_TextureFormatSelector<T>::DataType());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Creates new texture format.
|
||||
OpenGl_TextureFormat (const GLint theChannels,
|
||||
const GLint theInternal,
|
||||
const GLint theDataType)
|
||||
: myInternal (theInternal),
|
||||
myChannels (theChannels),
|
||||
myDataType (theDataType) {}
|
||||
|
||||
private:
|
||||
|
||||
GLint myInternal; //!< OpenGL internal format of the pixel data
|
||||
GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
|
||||
GLint myDataType; //!< OpenGL data type of input pixel data
|
||||
|
||||
};
|
||||
|
||||
//! Texture resource.
|
||||
class OpenGl_Texture : public OpenGl_NamedResource
|
||||
{
|
||||
@ -305,59 +49,32 @@ public:
|
||||
Standard_EXPORT virtual ~OpenGl_Texture();
|
||||
|
||||
//! @return true if current object was initialized
|
||||
inline bool IsValid() const
|
||||
{
|
||||
return myTextureId != NO_TEXTURE;
|
||||
}
|
||||
bool IsValid() const { return myTextureId != NO_TEXTURE; }
|
||||
|
||||
//! @return target to which the texture is bound (GL_TEXTURE_1D, GL_TEXTURE_2D)
|
||||
inline GLenum GetTarget() const
|
||||
{
|
||||
return myTarget;
|
||||
}
|
||||
GLenum GetTarget() const { return myTarget; }
|
||||
|
||||
//! @return texture width (0 LOD)
|
||||
inline GLsizei SizeX() const
|
||||
{
|
||||
return mySizeX;
|
||||
}
|
||||
GLsizei SizeX() const { return mySizeX; }
|
||||
|
||||
//! @return texture height (0 LOD)
|
||||
inline GLsizei SizeY() const
|
||||
{
|
||||
return mySizeY;
|
||||
}
|
||||
GLsizei SizeY() const { return mySizeY; }
|
||||
|
||||
//! @return texture ID
|
||||
inline GLuint TextureId() const
|
||||
{
|
||||
return myTextureId;
|
||||
}
|
||||
GLuint TextureId() const { return myTextureId; }
|
||||
|
||||
//! @return texture format (not sized)
|
||||
inline GLenum GetFormat() const
|
||||
{
|
||||
return myTextFormat;
|
||||
}
|
||||
GLenum GetFormat() const { return myTextFormat; }
|
||||
|
||||
//! @return texture format (sized)
|
||||
GLint SizedFormat() const
|
||||
{
|
||||
return mySizedFormat;
|
||||
}
|
||||
GLint SizedFormat() const { return mySizedFormat; }
|
||||
|
||||
//! Return true for GL_RED and GL_ALPHA formats.
|
||||
bool IsAlpha() const
|
||||
{
|
||||
return myIsAlpha;
|
||||
}
|
||||
bool IsAlpha() const { return myIsAlpha; }
|
||||
|
||||
//! Setup to interprete the format as Alpha by Shader Manager
|
||||
//! (should be GL_ALPHA within compatible context or GL_RED otherwise).
|
||||
void SetAlpha (const bool theValue)
|
||||
{
|
||||
myIsAlpha = theValue;
|
||||
}
|
||||
void SetAlpha (const bool theValue) { myIsAlpha = theValue; }
|
||||
|
||||
//! Creates Texture id if not yet generated.
|
||||
//! Data should be initialized by another method.
|
||||
@ -409,17 +126,15 @@ public:
|
||||
//! Notice that texture will be unbound after this call.
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theImage,
|
||||
const Graphic3d_TypeOfTexture theType);
|
||||
const Graphic3d_TypeOfTexture theType,
|
||||
const Standard_Boolean theIsColorMap);
|
||||
|
||||
//! Initialize the texture with specified format, size and texture type.
|
||||
//! If theImage is empty the texture data will contain trash.
|
||||
//! Notice that texture will be unbound after this call.
|
||||
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLint theTextFormat,
|
||||
const GLenum thePixelFormat,
|
||||
const GLenum theDataType,
|
||||
const GLsizei theSizeX,
|
||||
const GLsizei theSizeY,
|
||||
const OpenGl_TextureFormat& theFormat,
|
||||
const Graphic3d_Vec2i& theSizeXY,
|
||||
const Graphic3d_TypeOfTexture theType,
|
||||
const Image_PixMap* theImage = NULL);
|
||||
|
||||
@ -445,66 +160,112 @@ public:
|
||||
|
||||
//! Initializes 3D texture rectangle with specified format and size.
|
||||
Standard_EXPORT bool Init3D (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLint theTextFormat,
|
||||
const GLenum thePixelFormat,
|
||||
const GLenum theDataType,
|
||||
const Standard_Integer theSizeX,
|
||||
const Standard_Integer theSizeY,
|
||||
const Standard_Integer theSizeZ,
|
||||
const OpenGl_TextureFormat& theFormat,
|
||||
const Graphic3d_Vec3i& theSizeXYZ,
|
||||
const void* thePixels);
|
||||
|
||||
//! Initializes 6 sides of cubemap.
|
||||
//! If theCubeMap is not NULL then size and format will be taken from it
|
||||
//! and corresponding arguments will be ignored.
|
||||
//! Otherwise this parametres will be taken from arguments.
|
||||
//! theToGenMipmap allows to generate mipmaped cubemap.
|
||||
Standard_EXPORT bool InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Size theSize = 0,
|
||||
Image_Format theFormat = Image_Format_RGB,
|
||||
Standard_Boolean theToGenMipmap = Standard_False);
|
||||
|
||||
//! The same InitCubeMap but there is another order of arguments.
|
||||
bool InitCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Boolean theToGenMipmap,
|
||||
Standard_Size theSize = 0,
|
||||
Image_Format theFormat = Image_Format_RGB)
|
||||
{
|
||||
return InitCubeMap (theCtx, theCubeMap, theSize, theFormat, theToGenMipmap);
|
||||
}
|
||||
|
||||
//! @return true if texture was generated within mipmaps
|
||||
Standard_Boolean HasMipmaps() const { return myHasMipmaps; }
|
||||
|
||||
//! Return texture type and format by Image_Format.
|
||||
Standard_EXPORT static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_Format theFromat,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType);
|
||||
|
||||
//! Return texture type and format by Image_PixMap data format.
|
||||
static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theData,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
return GetDataFormat (theCtx, theData.Format(), theTextFormat, thePixelFormat, theDataType);
|
||||
}
|
||||
|
||||
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
|
||||
Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns TRUE for point sprite texture.
|
||||
virtual bool IsPointSprite() const { return false; }
|
||||
|
||||
public:
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat::FindFormat() should be used instead")
|
||||
static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_Format theFormat,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, false);
|
||||
theTextFormat = aFormat.InternalFormat();
|
||||
thePixelFormat = aFormat.PixelFormat();
|
||||
theDataType = aFormat.DataType();
|
||||
return aFormat.IsValid();
|
||||
}
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat::FindFormat() should be used instead")
|
||||
static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theData,
|
||||
GLint& theTextFormat,
|
||||
GLenum& thePixelFormat,
|
||||
GLenum& theDataType)
|
||||
{
|
||||
OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theData.Format(), false);
|
||||
theTextFormat = aFormat.InternalFormat();
|
||||
thePixelFormat = aFormat.PixelFormat();
|
||||
theDataType = aFormat.DataType();
|
||||
return aFormat.IsValid();
|
||||
}
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat should be passed instead of separate parameters")
|
||||
bool Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLint theTextFormat,
|
||||
const GLenum thePixelFormat,
|
||||
const GLenum theDataType,
|
||||
const GLsizei theSizeX,
|
||||
const GLsizei theSizeY,
|
||||
const Graphic3d_TypeOfTexture theType,
|
||||
const Image_PixMap* theImage = NULL)
|
||||
{
|
||||
OpenGl_TextureFormat aFormat;
|
||||
aFormat.SetInternalFormat (theTextFormat);
|
||||
aFormat.SetPixelFormat (thePixelFormat);
|
||||
aFormat.SetDataType (theDataType);
|
||||
return Init (theCtx, aFormat, Graphic3d_Vec2i (theSizeX, theSizeY), theType, theImage);
|
||||
}
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, theIsColorMap parameter should be explicitly specified")
|
||||
bool Init (const Handle(OpenGl_Context)& theCtx,
|
||||
const Image_PixMap& theImage,
|
||||
const Graphic3d_TypeOfTexture theType)
|
||||
{
|
||||
return Init (theCtx, theImage, theType, true);
|
||||
}
|
||||
|
||||
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat should be passed instead of separate parameters")
|
||||
bool Init3D (const Handle(OpenGl_Context)& theCtx,
|
||||
const GLint theTextFormat,
|
||||
const GLenum thePixelFormat,
|
||||
const GLenum theDataType,
|
||||
const Standard_Integer theSizeX,
|
||||
const Standard_Integer theSizeY,
|
||||
const Standard_Integer theSizeZ,
|
||||
const void* thePixels)
|
||||
{
|
||||
OpenGl_TextureFormat aFormat;
|
||||
aFormat.SetInternalFormat (theTextFormat);
|
||||
aFormat.SetPixelFormat (thePixelFormat);
|
||||
aFormat.SetDataType (theDataType);
|
||||
return Init3D (theCtx, aFormat, Graphic3d_Vec3i (theSizeX, theSizeY, theSizeZ), thePixels);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Apply default sampler parameters after texture creation.
|
||||
Standard_EXPORT void applyDefaultSamplerParams (const Handle(OpenGl_Context)& theCtx);
|
||||
|
||||
//! Initializes 6 sides of cubemap.
|
||||
//! If theCubeMap is not NULL then size and format will be taken from it and corresponding arguments will be ignored.
|
||||
//! Otherwise this parametres will be taken from arguments.
|
||||
//! @param theCtx [in] active OpenGL context
|
||||
//! @param theCubeMap [in] cubemap definition, can be NULL
|
||||
//! @param theSize [in] cubemap dimensions
|
||||
//! @param theFormat [in] image format
|
||||
//! @param theToGenMipmap [in] flag to generate mipmaped cubemap
|
||||
//! @param theIsColorMap [in] flag indicating cubemap storing color values
|
||||
Standard_EXPORT bool initCubeMap (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_CubeMap)& theCubeMap,
|
||||
Standard_Size theSize,
|
||||
Image_Format theFormat,
|
||||
Standard_Boolean theToGenMipmap,
|
||||
Standard_Boolean theIsColorMap);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(OpenGl_Sampler) mySampler; //!< texture sampler
|
||||
|
439
src/OpenGl/OpenGl_TextureFormat.cxx
Normal file
439
src/OpenGl/OpenGl_TextureFormat.cxx
Normal file
@ -0,0 +1,439 @@
|
||||
// Copyright (c) 2017-2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <OpenGl_TextureFormat.hxx>
|
||||
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : FindFormat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
Image_Format theFormat,
|
||||
bool theIsColorMap)
|
||||
{
|
||||
OpenGl_TextureFormat aFormat;
|
||||
switch (theFormat)
|
||||
{
|
||||
case Image_Format_GrayF:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_R8); // GL_R32F
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetInternalFormat (GL_LUMINANCE8);
|
||||
#else
|
||||
aFormat.SetInternalFormat (GL_LUMINANCE);
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_LUMINANCE);
|
||||
}
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_AlphaF:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_R8); // GL_R32F
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetInternalFormat (GL_ALPHA8);
|
||||
#else
|
||||
aFormat.SetInternalFormat (GL_ALPHA);
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_ALPHA);
|
||||
}
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_RGBAF:
|
||||
{
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_RGBA8); // GL_RGBA32F
|
||||
aFormat.SetPixelFormat (GL_RGBA);
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_BGRAF:
|
||||
{
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_RGBA8); // GL_RGBA32F
|
||||
aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_RGBF:
|
||||
{
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (GL_RGB8); // GL_RGB32F
|
||||
aFormat.SetPixelFormat (GL_RGB);
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_BGRF:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (GL_RGB8); // GL_RGB32F
|
||||
aFormat.SetPixelFormat (GL_BGR); // equals to GL_BGR_EXT
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
#else
|
||||
return OpenGl_TextureFormat();
|
||||
#endif
|
||||
}
|
||||
case Image_Format_RGBA:
|
||||
{
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_RGBA8);
|
||||
aFormat.SetPixelFormat (GL_RGBA);
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_BGRA:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2)
|
||||
&& !theCtx->extBgra)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_RGBA8);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
|
||||
}
|
||||
#else
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
// GL_SRGB8_ALPHA8 with texture swizzling would be better
|
||||
}
|
||||
if (!theCtx->extBgra)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_BGRA_EXT);
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_RGB32:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
// ask driver to convert data to RGB8 to save memory
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (GL_RGB8);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8);
|
||||
}
|
||||
#else
|
||||
// conversion is not supported
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_RGBA8);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
|
||||
}
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_RGBA);
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_BGR32:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (GL_RGB8);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8);
|
||||
}
|
||||
#else
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
// GL_SRGB8_ALPHA8 with texture swizzling would be better
|
||||
}
|
||||
if (!theCtx->extBgra)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (GL_BGRA_EXT);
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_RGB:
|
||||
{
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (GL_RGB8);
|
||||
aFormat.SetPixelFormat (GL_RGB);
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8);
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_BGR:
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (!theCtx->IsGlGreaterEqual (1, 2)
|
||||
&& !theCtx->extBgra)
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (GL_RGB8);
|
||||
if (theIsColorMap
|
||||
&& theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_SRGB8);
|
||||
}
|
||||
aFormat.SetPixelFormat (GL_BGR); // equals to GL_BGR_EXT
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
#endif
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_Gray:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_R8);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetInternalFormat (GL_LUMINANCE8);
|
||||
#else
|
||||
aFormat.SetInternalFormat (GL_LUMINANCE);
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_LUMINANCE);
|
||||
}
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_Alpha:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
if (theCtx->core11 == NULL)
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_R8);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetInternalFormat (GL_ALPHA8);
|
||||
#else
|
||||
aFormat.SetInternalFormat (GL_ALPHA);
|
||||
#endif
|
||||
aFormat.SetPixelFormat (GL_ALPHA);
|
||||
}
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
return aFormat;
|
||||
}
|
||||
case Image_Format_UNKNOWN:
|
||||
{
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
}
|
||||
return OpenGl_TextureFormat();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FindSizedFormat
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theSizedFormat)
|
||||
{
|
||||
OpenGl_TextureFormat aFormat;
|
||||
switch (theSizedFormat)
|
||||
{
|
||||
case GL_RGBA32F:
|
||||
{
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RGBA);
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_R32F:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_RGBA16F:
|
||||
{
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RGBA);
|
||||
aFormat.SetDataType (GL_HALF_FLOAT);
|
||||
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetDataType (GL_HALF_FLOAT_OES);
|
||||
#else
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
#endif
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
case GL_R16F:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RED);
|
||||
aFormat.SetDataType (GL_HALF_FLOAT);
|
||||
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
aFormat.SetDataType (GL_HALF_FLOAT_OES);
|
||||
#else
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
#endif
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
case GL_SRGB8_ALPHA8:
|
||||
case GL_RGBA8:
|
||||
case GL_RGBA:
|
||||
{
|
||||
aFormat.SetNbComponents (4);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RGBA);
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
if (theSizedFormat == GL_SRGB8_ALPHA8
|
||||
&& !theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_RGBA8); // fallback format
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
case GL_SRGB8:
|
||||
case GL_RGB8:
|
||||
case GL_RGB:
|
||||
{
|
||||
aFormat.SetNbComponents (3);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RGB);
|
||||
aFormat.SetDataType (GL_UNSIGNED_BYTE);
|
||||
if (theSizedFormat == GL_SRGB8
|
||||
&& !theCtx->ToRenderSRGB())
|
||||
{
|
||||
aFormat.SetInternalFormat (GL_RGB8); // fallback format
|
||||
}
|
||||
return aFormat;
|
||||
}
|
||||
// integer types
|
||||
case GL_R32I:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RED_INTEGER);
|
||||
aFormat.SetDataType (GL_INT);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_RG32I:
|
||||
{
|
||||
aFormat.SetNbComponents (2);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_RG_INTEGER);
|
||||
aFormat.SetDataType (GL_INT);
|
||||
return aFormat;
|
||||
}
|
||||
// depth formats
|
||||
case GL_DEPTH24_STENCIL8:
|
||||
{
|
||||
aFormat.SetNbComponents (2);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_DEPTH_STENCIL);
|
||||
aFormat.SetDataType (GL_UNSIGNED_INT_24_8);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
{
|
||||
aFormat.SetNbComponents (2);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_DEPTH_STENCIL);
|
||||
aFormat.SetDataType (GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_DEPTH_COMPONENT);
|
||||
aFormat.SetDataType (GL_UNSIGNED_SHORT);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_DEPTH_COMPONENT);
|
||||
aFormat.SetDataType (GL_UNSIGNED_INT);
|
||||
return aFormat;
|
||||
}
|
||||
case GL_DEPTH_COMPONENT32F:
|
||||
{
|
||||
aFormat.SetNbComponents (1);
|
||||
aFormat.SetInternalFormat (theSizedFormat);
|
||||
aFormat.SetPixelFormat (GL_DEPTH_COMPONENT);
|
||||
aFormat.SetDataType (GL_FLOAT);
|
||||
return aFormat;
|
||||
}
|
||||
}
|
||||
return aFormat;
|
||||
}
|
262
src/OpenGl/OpenGl_TextureFormat.hxx
Normal file
262
src/OpenGl/OpenGl_TextureFormat.hxx
Normal file
@ -0,0 +1,262 @@
|
||||
// Copyright (c) 2017-2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OpenGl_TextureFormat_HeaderFile
|
||||
#define _OpenGl_TextureFormat_HeaderFile
|
||||
|
||||
#include <Image_Format.hxx>
|
||||
#include <OpenGl_GlCore13.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
class OpenGl_Context;
|
||||
|
||||
//! Stores parameters of OpenGL texture format.
|
||||
class OpenGl_TextureFormat
|
||||
{
|
||||
public:
|
||||
|
||||
//! Returns texture format for specified type and number of channels.
|
||||
//! @tparam theCompType component type
|
||||
//! @tparam theNbComps number of components
|
||||
template<class theCompType, int theNbComps>
|
||||
static OpenGl_TextureFormat Create();
|
||||
|
||||
//! Find texture format suitable to specified image format.
|
||||
//! @param theCtx [in] OpenGL context defining supported texture formats
|
||||
//! @param theFormat [in] image format
|
||||
//! @param theIsColorMap [in] flag indicating color nature of image (to select sRGB texture)
|
||||
//! @return found format or invalid format
|
||||
Standard_EXPORT static OpenGl_TextureFormat FindFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
Image_Format theFormat,
|
||||
bool theIsColorMap);
|
||||
|
||||
//! Find texture format suitable to specified internal (sized) texture format.
|
||||
//! @param theCtx [in] OpenGL context defining supported texture formats
|
||||
//! @param theSizedFormat [in] sized (internal) texture format (example: GL_RGBA8)
|
||||
//! @return found format or invalid format
|
||||
Standard_EXPORT static OpenGl_TextureFormat FindSizedFormat (const Handle(OpenGl_Context)& theCtx,
|
||||
GLint theSizedFormat);
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor (invalid texture format).
|
||||
OpenGl_TextureFormat() : myInternalFormat (0), myPixelFormat (0), myDataType (0), myNbComponents (0) {}
|
||||
|
||||
//! Return TRUE if format is defined.
|
||||
bool IsValid() const
|
||||
{
|
||||
return myInternalFormat != 0
|
||||
&& myPixelFormat != 0
|
||||
&& myDataType != 0;
|
||||
}
|
||||
|
||||
//! Returns OpenGL internal format of the pixel data (example: GL_R32F).
|
||||
GLint InternalFormat() const { return myInternalFormat; }
|
||||
|
||||
//! Sets texture internal format.
|
||||
void SetInternalFormat (GLint theInternal) { myInternalFormat = theInternal; }
|
||||
|
||||
//! Returns OpenGL format of the pixel data (example: GL_RED).
|
||||
GLenum PixelFormat() const { return myPixelFormat; }
|
||||
|
||||
//! Sets OpenGL format of the pixel data.
|
||||
void SetPixelFormat (GLenum theFormat) { myPixelFormat = theFormat; }
|
||||
|
||||
//! Returns OpenGL data type of the pixel data (example: GL_FLOAT).
|
||||
GLint DataType() const { return myDataType; }
|
||||
|
||||
//! Sets OpenGL data type of the pixel data.
|
||||
void SetDataType (GLint theType) { myDataType = theType; }
|
||||
|
||||
//! Returns number of components (channels). Here for debugging purposes.
|
||||
GLint NbComponents() const { return myNbComponents; }
|
||||
|
||||
//! Sets number of components (channels).
|
||||
void SetNbComponents (GLint theNbComponents) { myNbComponents = theNbComponents; }
|
||||
|
||||
//! Return TRUE if internal texture format is sRGB(A).
|
||||
bool IsSRGB() const
|
||||
{
|
||||
return myInternalFormat == GL_SRGB8
|
||||
|| myInternalFormat == GL_SRGB8_ALPHA8;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Returns OpenGL internal format of the pixel data (example: GL_R32F).
|
||||
GLint Internal() const { return myInternalFormat; }
|
||||
|
||||
//! Returns OpenGL format of the pixel data (example: GL_RED).
|
||||
GLenum Format() const { return myPixelFormat; }
|
||||
|
||||
private:
|
||||
|
||||
GLint myInternalFormat; //!< OpenGL internal format of the pixel data
|
||||
GLenum myPixelFormat; //!< OpenGL pixel format
|
||||
GLint myDataType; //!< OpenGL data type of input pixel data
|
||||
GLint myNbComponents; //!< number of channels for each pixel (from 1 to 4)
|
||||
|
||||
};
|
||||
|
||||
//! Selects preferable texture format for specified parameters.
|
||||
template<class T> struct OpenGl_TextureFormatSelector
|
||||
{
|
||||
// Not implemented
|
||||
};
|
||||
|
||||
//! Specialization for unsigned byte.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLubyte>
|
||||
{
|
||||
static GLint DataType() { return GL_UNSIGNED_BYTE; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_R8;
|
||||
case 2: return GL_RG8;
|
||||
case 3: return GL_RGB8;
|
||||
case 4: return GL_RGBA8;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Specialization for unsigned short.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLushort>
|
||||
{
|
||||
static GLint DataType() { return GL_UNSIGNED_SHORT; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_R16;
|
||||
case 2: return GL_RG16;
|
||||
case 3: return GL_RGB16;
|
||||
case 4: return GL_RGBA16;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Specialization for float.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLfloat>
|
||||
{
|
||||
static GLint DataType() { return GL_FLOAT; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_R32F;
|
||||
case 2: return GL_RG32F;
|
||||
case 3: return GL_RGB32F;
|
||||
case 4: return GL_RGBA32F;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Specialization for unsigned int.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLuint>
|
||||
{
|
||||
static GLint DataType() { return GL_UNSIGNED_INT; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_RED;
|
||||
case 2: return GL_RG;
|
||||
case 3: return GL_RGB;
|
||||
case 4: return GL_RGBA;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Only unsigned formats are available in OpenGL ES 2.0
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
//! Specialization for signed byte.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLbyte>
|
||||
{
|
||||
static GLint DataType() { return GL_BYTE; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_R8_SNORM;
|
||||
case 2: return GL_RG8_SNORM;
|
||||
case 3: return GL_RGB8_SNORM;
|
||||
case 4: return GL_RGBA8_SNORM;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Specialization for signed short.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLshort>
|
||||
{
|
||||
static GLint DataType() { return GL_SHORT; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_R16_SNORM;
|
||||
case 2: return GL_RG16_SNORM;
|
||||
case 3: return GL_RGB16_SNORM;
|
||||
case 4: return GL_RGBA16_SNORM;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Specialization for signed int.
|
||||
template<> struct OpenGl_TextureFormatSelector<GLint>
|
||||
{
|
||||
static GLint DataType() { return GL_INT; }
|
||||
static GLint Internal (GLuint theChannels)
|
||||
{
|
||||
switch (theChannels)
|
||||
{
|
||||
case 1: return GL_RED_SNORM;
|
||||
case 2: return GL_RG_SNORM;
|
||||
case 3: return GL_RGB_SNORM;
|
||||
case 4: return GL_RGBA_SNORM;
|
||||
default: return GL_NONE;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// =======================================================================
|
||||
// function : Create
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
template<class theCompType, int theNbComps>
|
||||
inline OpenGl_TextureFormat OpenGl_TextureFormat::Create()
|
||||
{
|
||||
OpenGl_TextureFormat aFormat;
|
||||
aFormat.SetNbComponents (theNbComps);
|
||||
aFormat.SetInternalFormat (OpenGl_TextureFormatSelector<theCompType>::Internal (theNbComps));
|
||||
aFormat.SetDataType (OpenGl_TextureFormatSelector<theCompType>::DataType());
|
||||
GLenum aPixelFormat = GL_NONE;
|
||||
switch (theNbComps)
|
||||
{
|
||||
case 1: aPixelFormat = GL_RED; break;
|
||||
case 2: aPixelFormat = GL_RG; break;
|
||||
case 3: aPixelFormat = GL_RGB; break;
|
||||
case 4: aPixelFormat = GL_RGBA; break;
|
||||
}
|
||||
aFormat.SetPixelFormat (aPixelFormat);
|
||||
return aFormat;
|
||||
}
|
||||
|
||||
#endif // _OpenGl_TextureFormat_HeaderFile
|
@ -301,9 +301,11 @@ bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext,
|
||||
|| theOffsetsTexture->SizeY() != (int )anOffsets.SizeY
|
||||
|| !theOffsetsTexture->IsValid())
|
||||
{
|
||||
theOffsetsTexture->Release (theContext.operator->());
|
||||
if (!theOffsetsTexture->Init (theContext, GL_RG32I, GL_RG_INTEGER, GL_INT,
|
||||
(int )anOffsets.SizeX, (int )anOffsets.SizeY, Graphic3d_TOT_2D))
|
||||
theOffsetsTexture->Release (theContext.get());
|
||||
if (!theOffsetsTexture->Init (theContext,
|
||||
OpenGl_TextureFormat::FindSizedFormat (theContext, GL_RG32I),
|
||||
Graphic3d_Vec2i ((int )anOffsets.SizeX, (int )anOffsets.SizeY),
|
||||
Graphic3d_TOT_2D))
|
||||
{
|
||||
hasErrors = true;
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myCurrLightSourceState (theCounter->Increment()),
|
||||
myLightsRevision (0),
|
||||
myLastLightSourceState (0, 0),
|
||||
myFboColorFormat (GL_RGBA8),
|
||||
mySRgbState (-1),
|
||||
myFboColorFormat (GL_SRGB8_ALPHA8), // note that GL_SRGB8 is not required to be renderable, unlike GL_RGB8, GL_RGBA8, GL_SRGB8_ALPHA8
|
||||
myFboDepthFormat (GL_DEPTH24_STENCIL8),
|
||||
myToFlipOutput (Standard_False),
|
||||
myFrameCounter (0),
|
||||
@ -132,13 +133,12 @@ OpenGl_View::~OpenGl_View()
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ReleaseGlResources
|
||||
// function : releaseSrgbResources
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
void OpenGl_View::releaseSrgbResources (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
myGraduatedTrihedron.Release (theCtx.get());
|
||||
myFrameStatsPrs.Release (theCtx.get());
|
||||
myRenderParams.RebuildRayTracingShaders = true;
|
||||
|
||||
if (!myTextureEnv.IsNull())
|
||||
{
|
||||
@ -184,6 +184,22 @@ void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
myFullScreenQuad .Release (theCtx.get());
|
||||
myFullScreenQuadFlip .Release (theCtx.get());
|
||||
|
||||
// Technically we should also re-initialize all sRGB/RGB8 color textures.
|
||||
// But for now consider this sRGB disabling/enabling to be done at application start-up
|
||||
// and re-create dynamically only frame buffers.
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ReleaseGlResources
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
myGraduatedTrihedron.Release (theCtx.get());
|
||||
myFrameStatsPrs.Release (theCtx.get());
|
||||
|
||||
releaseSrgbResources (theCtx);
|
||||
|
||||
releaseRaytraceResources (theCtx);
|
||||
}
|
||||
|
||||
@ -259,7 +275,7 @@ void OpenGl_View::initTextureEnv (const Handle(OpenGl_Context)& theContext)
|
||||
Handle(Image_PixMap) anImage = myTextureEnvData->GetImage();
|
||||
if (!anImage.IsNull())
|
||||
{
|
||||
aTextureEnv->Init (theContext, *anImage.operator->(), myTextureEnvData->Type());
|
||||
aTextureEnv->Init (theContext, *anImage, myTextureEnvData->Type(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
//! Default destructor.
|
||||
Standard_EXPORT virtual ~OpenGl_View();
|
||||
|
||||
//! Release OpenGL resources.
|
||||
Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
|
||||
|
||||
//! Deletes and erases the view.
|
||||
@ -424,6 +425,9 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
//! Release sRGB resources (frame-buffers, textures, etc.).
|
||||
void releaseSrgbResources (const Handle(OpenGl_Context)& theCtx);
|
||||
|
||||
//! Copy content of Back buffer to the Front buffer.
|
||||
bool copyBackToFront();
|
||||
|
||||
@ -490,6 +494,7 @@ protected: //! @name Rendering properties
|
||||
|
||||
//! Two framebuffers (left and right views) store cached main presentation
|
||||
//! of the view (without presentation of immediate layers).
|
||||
Standard_Integer mySRgbState; //!< track sRGB state
|
||||
GLint myFboColorFormat; //!< sized format for color attachments
|
||||
GLint myFboDepthFormat; //!< sized format for depth-stencil attachments
|
||||
OpenGl_ColorFormats myFboOitColorConfig; //!< selected color format configuration for OIT color attachments
|
||||
|
@ -393,6 +393,11 @@ OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_Aspects* theA
|
||||
anIndex == 0 ? 1.0f : anIndex,
|
||||
anIndex == 0 ? 1.0f : 1.0f / anIndex);
|
||||
|
||||
aResMat.Ambient = theGlContext->Vec4FromQuantityColor (aResMat.Ambient);
|
||||
aResMat.Diffuse = theGlContext->Vec4FromQuantityColor (aResMat.Diffuse);
|
||||
aResMat.Specular = theGlContext->Vec4FromQuantityColor (aResMat.Specular);
|
||||
aResMat.Emission = theGlContext->Vec4FromQuantityColor (aResMat.Emission);
|
||||
|
||||
// Serialize physically-based material properties
|
||||
const Graphic3d_BSDF& aBSDF = aSrcMat.BSDF();
|
||||
|
||||
@ -1095,6 +1100,10 @@ TCollection_AsciiString OpenGl_View::generateShaderPrefix (const Handle(OpenGl_C
|
||||
{
|
||||
aPrefixString += TCollection_AsciiString ("\n#define TRANSPARENT_SHADOWS");
|
||||
}
|
||||
if (!theGlContext->ToRenderSRGB())
|
||||
{
|
||||
aPrefixString += TCollection_AsciiString ("\n#define THE_SHIFT_sRGB");
|
||||
}
|
||||
|
||||
// If OpenGL driver supports bindless textures and texturing
|
||||
// is actually used, activate texturing in ray-tracing mode
|
||||
@ -1866,12 +1875,16 @@ Standard_Boolean OpenGl_View::updateRaytraceBuffers (const Standard_Integer
|
||||
// workaround for some NVIDIA drivers
|
||||
myRaytraceVisualErrorTexture[aViewIter]->Release (theGlContext.operator->());
|
||||
myRaytraceTileSamplesTexture[aViewIter]->Release (theGlContext.operator->());
|
||||
myRaytraceVisualErrorTexture[aViewIter]->Init (theGlContext, GL_R32I, GL_RED_INTEGER, GL_INT,
|
||||
myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
||||
myRaytraceVisualErrorTexture[aViewIter]->Init (theGlContext,
|
||||
OpenGl_TextureFormat::FindSizedFormat (theGlContext, GL_R32I),
|
||||
Graphic3d_Vec2i (myTileSampler.NbTilesX(), myTileSampler.NbTilesY()),
|
||||
Graphic3d_TOT_2D);
|
||||
if (!myRaytraceParameters.AdaptiveScreenSamplingAtomic)
|
||||
{
|
||||
myRaytraceTileSamplesTexture[aViewIter]->Init (theGlContext, GL_R32I, GL_RED_INTEGER, GL_INT,
|
||||
myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);
|
||||
myRaytraceTileSamplesTexture[aViewIter]->Init (theGlContext,
|
||||
OpenGl_TextureFormat::FindSizedFormat (theGlContext, GL_R32I),
|
||||
Graphic3d_Vec2i (myTileSampler.NbTilesX(), myTileSampler.NbTilesY()),
|
||||
Graphic3d_TOT_2D);
|
||||
}
|
||||
}
|
||||
else // non-adaptive mode
|
||||
@ -2564,24 +2577,18 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer the
|
||||
static_cast<GLsizei> (aTextures.size()), reinterpret_cast<const OpenGl_Vec2u*> (&aTextures.front()));
|
||||
}
|
||||
|
||||
// Set background colors (only gradient background supported)
|
||||
// Set background colors (only vertical gradient background supported)
|
||||
OpenGl_Vec4 aBackColorTop = myBgColor, aBackColorBot = myBgColor;
|
||||
if (myBackgrounds[Graphic3d_TOB_GRADIENT] != NULL
|
||||
&& myBackgrounds[Graphic3d_TOB_GRADIENT]->IsDefined())
|
||||
{
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0));
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1));
|
||||
}
|
||||
else
|
||||
{
|
||||
const OpenGl_Vec4& aBackColor = myBgColor;
|
||||
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], aBackColor);
|
||||
theProgram->SetUniform (theGlContext,
|
||||
myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], aBackColor);
|
||||
aBackColorTop = myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (0);
|
||||
aBackColorBot = myBackgrounds[Graphic3d_TOB_GRADIENT]->GradientColor (1);
|
||||
}
|
||||
aBackColorTop = theGlContext->Vec4FromQuantityColor (aBackColorTop);
|
||||
aBackColorBot = theGlContext->Vec4FromQuantityColor (aBackColorBot);
|
||||
theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorTop], aBackColorTop);
|
||||
theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], aBackColorBot);
|
||||
|
||||
// Set environment map parameters
|
||||
const Standard_Boolean toDisableEnvironmentMap = myTextureEnv.IsNull()
|
||||
|
@ -180,10 +180,20 @@ void OpenGl_View::Redraw()
|
||||
++myFrameCounter;
|
||||
const Graphic3d_StereoMode aStereoMode = myRenderParams.StereoMode;
|
||||
Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
|
||||
Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext();
|
||||
const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext();
|
||||
aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
|
||||
aCtx->SetLineFeather (myRenderParams.LineFeather);
|
||||
|
||||
const Standard_Integer anSRgbState = aCtx->ToRenderSRGB() ? 1 : 0;
|
||||
if (mySRgbState != -1
|
||||
&& mySRgbState != anSRgbState)
|
||||
{
|
||||
releaseSrgbResources (aCtx);
|
||||
initTextureEnv (aCtx);
|
||||
}
|
||||
mySRgbState = anSRgbState;
|
||||
aCtx->ShaderManager()->UpdateSRgbState();
|
||||
|
||||
// release pending GL resources
|
||||
aCtx->ReleaseDelayed();
|
||||
|
||||
@ -799,7 +809,7 @@ void OpenGl_View::redraw (const Graphic3d_Camera::Projection theProjection,
|
||||
glClearDepthf (1.0f);
|
||||
#endif
|
||||
|
||||
const OpenGl_Vec4& aBgColor = myBgColor;
|
||||
const OpenGl_Vec4 aBgColor = aCtx->Vec4FromQuantityColor (myBgColor);
|
||||
glClearColor (aBgColor.r(), aBgColor.g(), aBgColor.b(), 0.0f);
|
||||
|
||||
glClear (toClear);
|
||||
@ -1143,6 +1153,7 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
|
||||
else
|
||||
{
|
||||
aCtx->arbFBO->glBindFramebuffer (GL_DRAW_FRAMEBUFFER, 0);
|
||||
aCtx->SetFrameBufferSRGB (false);
|
||||
}
|
||||
|
||||
// Render non-polygonal elements in default layer
|
||||
@ -1158,6 +1169,7 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
|
||||
else
|
||||
{
|
||||
aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, 0);
|
||||
aCtx->SetFrameBufferSRGB (false);
|
||||
}
|
||||
|
||||
// Reset OpenGl aspects state to default to avoid enabling of
|
||||
@ -1355,6 +1367,7 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
|
||||
else
|
||||
{
|
||||
aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER);
|
||||
aCtx->SetFrameBufferSRGB (false);
|
||||
}
|
||||
const Standard_Integer aViewport[4] = { 0, 0, aDrawSizeX, aDrawSizeY };
|
||||
aCtx->ResizeViewport (aViewport);
|
||||
@ -1366,8 +1379,10 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
|
||||
#endif
|
||||
aCtx->core20fwd->glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
const bool toApplyGamma = aCtx->ToRenderSRGB() != aCtx->IsFrameBufferSRGB();
|
||||
if (aCtx->arbFBOBlit != NULL
|
||||
&& theReadFbo->NbSamples() != 0)
|
||||
&& !toApplyGamma
|
||||
&& theReadFbo->NbSamples() != 0)
|
||||
{
|
||||
GLbitfield aCopyMask = 0;
|
||||
theReadFbo->BindReadBuffer (aCtx);
|
||||
@ -1397,6 +1412,7 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
|
||||
aCopyMask |= GL_DEPTH_BUFFER_BIT;
|
||||
}
|
||||
aCtx->arbFBO->glBindFramebuffer (GL_DRAW_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER);
|
||||
aCtx->SetFrameBufferSRGB (false);
|
||||
}
|
||||
|
||||
// we don't copy stencil buffer here... does it matter for performance?
|
||||
@ -1437,6 +1453,7 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
|
||||
else
|
||||
{
|
||||
aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER);
|
||||
aCtx->SetFrameBufferSRGB (false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1460,7 +1477,7 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
|
||||
OpenGl_VertexBuffer* aVerts = initBlitQuad (theToFlip);
|
||||
const Handle(OpenGl_ShaderManager)& aManager = aCtx->ShaderManager();
|
||||
if (aVerts->IsValid()
|
||||
&& aManager->BindFboBlitProgram())
|
||||
&& aManager->BindFboBlitProgram (theReadFbo != NULL ? theReadFbo->NbSamples() : 0, toApplyGamma))
|
||||
{
|
||||
aCtx->SetSampleAlphaToCoverage (false);
|
||||
theReadFbo->ColorTexture()->Bind (aCtx, Graphic3d_TextureUnit_0);
|
||||
|
@ -192,6 +192,13 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
EGLSurface anEglSurf = EGL_NO_SURFACE;
|
||||
if ((EGLContext )theGContext == EGL_NO_CONTEXT)
|
||||
{
|
||||
// EGL_KHR_gl_colorspace extension specifies if OpenGL should write into window buffer as into sRGB or RGB framebuffer
|
||||
//const int aSurfAttribs[] =
|
||||
//{
|
||||
// EGL_GL_COLORSPACE_KHR, !theCaps->sRGBDisable ? EGL_GL_COLORSPACE_SRGB_KHR : EGL_GL_COLORSPACE_LINEAR_KHR,
|
||||
// EGL_NONE,
|
||||
//};
|
||||
|
||||
// create new surface
|
||||
anEglSurf = eglCreateWindowSurface (anEglDisplay,
|
||||
anEglConfig,
|
||||
@ -221,6 +228,8 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
{
|
||||
EGL_WIDTH, myWidth,
|
||||
EGL_HEIGHT, myHeight,
|
||||
// EGL_KHR_gl_colorspace extension specifies if OpenGL should write into window buffer as into sRGB or RGB framebuffer
|
||||
//EGL_GL_COLORSPACE_KHR, !theCaps->sRGBDisable ? EGL_GL_COLORSPACE_SRGB_KHR : EGL_GL_COLORSPACE_LINEAR_KHR,
|
||||
EGL_NONE
|
||||
};
|
||||
anEglSurf = eglCreatePbufferSurface (anEglDisplay, anEglConfig, aSurfAttribs);
|
||||
@ -365,6 +374,10 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
WGL_COLOR_BITS_ARB, 24,
|
||||
WGL_DEPTH_BITS_ARB, 24,
|
||||
WGL_STENCIL_BITS_ARB, 8,
|
||||
// WGL_EXT_colorspace extension specifies if OpenGL should write into window buffer as into sRGB or RGB framebuffer
|
||||
//WGL_COLORSPACE_EXT, !theCaps->sRGBDisable ? WGL_COLORSPACE_SRGB_EXT : WGL_COLORSPACE_LINEAR_EXT,
|
||||
// requires WGL_ARB_framebuffer_sRGB or WGL_EXT_framebuffer_sRGB extensions
|
||||
//WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, !theCaps->sRGBDisable ? GL_TRUE : GL_FALSE,
|
||||
WGL_ACCELERATION_ARB, theCaps->contextNoAccel ? WGL_NO_ACCELERATION_ARB : WGL_FULL_ACCELERATION_ARB,
|
||||
0, 0,
|
||||
};
|
||||
|
@ -54,8 +54,9 @@ namespace
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat,
|
||||
const Quantity_Color& theInteriorColor)
|
||||
void OpenGl_Material::Init (const OpenGl_Context& theCtx,
|
||||
const Graphic3d_MaterialAspect& theMat,
|
||||
const Quantity_Color& theInteriorColor)
|
||||
{
|
||||
ChangeShine() = 128.0f * theMat.Shininess();
|
||||
ChangeTransparency() = theMat.Alpha();
|
||||
@ -82,6 +83,11 @@ void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Ambient = theCtx.Vec4FromQuantityColor (Ambient);
|
||||
Diffuse = theCtx.Vec4FromQuantityColor (Diffuse);
|
||||
Specular = theCtx.Vec4FromQuantityColor (Specular);
|
||||
Emission = theCtx.Vec4FromQuantityColor (Emission);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@ -341,7 +347,7 @@ Handle(OpenGl_FrameBuffer) OpenGl_Workspace::FBOCreate (const Standard_Integer t
|
||||
const Handle(OpenGl_Context)& aCtx = GetGlContext();
|
||||
aCtx->BindTextures (Handle(OpenGl_TextureSet)());
|
||||
Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer();
|
||||
if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_RGBA8, GL_DEPTH24_STENCIL8, 0))
|
||||
if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_SRGB8_ALPHA8, GL_DEPTH24_STENCIL8, 0))
|
||||
{
|
||||
aFrameBuffer->Release (aCtx.operator->());
|
||||
return Handle(OpenGl_FrameBuffer)();
|
||||
|
@ -1103,8 +1103,8 @@ static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc,
|
||||
|
||||
Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape);
|
||||
|
||||
Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB);
|
||||
Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB);
|
||||
Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_sRGB);
|
||||
Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_sRGB);
|
||||
|
||||
Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes();
|
||||
Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
|
||||
@ -1130,9 +1130,9 @@ static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc,
|
||||
anAISContext->Display (anAisIO, 1, 0, Standard_True);
|
||||
|
||||
Standard_Real r, g, b;
|
||||
aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
|
||||
aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_sRGB);
|
||||
di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
|
||||
aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
|
||||
aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_sRGB);
|
||||
di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
|
||||
|
||||
return 0;
|
||||
@ -1163,8 +1163,8 @@ static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc,
|
||||
AISContext->Display (ais, 1, 0, Standard_False);
|
||||
AISContext->SetMaterial (ais, Graphic3d_NOM_SHINY_PLASTIC, Standard_False);
|
||||
|
||||
Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
|
||||
Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
|
||||
Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_sRGB);
|
||||
Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_sRGB);
|
||||
Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
|
||||
|
||||
Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
|
||||
|
@ -1688,7 +1688,7 @@ static Standard_Integer OCC23951 (Draw_Interpretor& di, Standard_Integer argc, c
|
||||
XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->SetShape(lab1, s1);
|
||||
TDataStd_Name::Set(lab1, "Box1");
|
||||
|
||||
Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
|
||||
Quantity_Color yellow(Quantity_NOC_YELLOW);
|
||||
XCAFDoc_DocumentTool::ColorTool (aDoc->Main())->SetColor(lab1, yellow, XCAFDoc_ColorGen);
|
||||
XCAFDoc_DocumentTool::ColorTool(aDoc->Main())->SetVisibility(lab1, 0);
|
||||
|
||||
@ -1731,7 +1731,7 @@ static Standard_Integer OCC23950 (Draw_Interpretor& di, Standard_Integer argc, c
|
||||
TDF_Label component01 = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->AddComponent (labelA0, lab1, location0);
|
||||
XCAFDoc_DocumentTool::ShapeTool (aDoc->Main ())->UpdateAssemblies();
|
||||
|
||||
Quantity_Color yellow(1,1,0, Quantity_TOC_RGB);
|
||||
Quantity_Color yellow(Quantity_NOC_YELLOW);
|
||||
XCAFDoc_DocumentTool::ColorTool (labelA0)->SetColor (component01, yellow, XCAFDoc_ColorGen);
|
||||
XCAFDoc_DocumentTool::ColorTool (labelA0)->SetVisibility (component01, 0);
|
||||
|
||||
|
@ -46,16 +46,24 @@ namespace
|
||||
struct Quantity_StandardColor
|
||||
{
|
||||
const char* StringName;
|
||||
NCollection_Vec3<float> sRgbValues;
|
||||
NCollection_Vec3<float> RgbValues;
|
||||
Quantity_NameOfColor EnumName;
|
||||
|
||||
Quantity_StandardColor (Quantity_NameOfColor theName, const char* theStringName, const NCollection_Vec3<float>& theVec3)
|
||||
: StringName (theStringName), RgbValues (theVec3), EnumName (theName) {}
|
||||
Quantity_StandardColor (Quantity_NameOfColor theName,
|
||||
const char* theStringName,
|
||||
const NCollection_Vec3<float>& thesRGB,
|
||||
const NCollection_Vec3<float>& theRGB)
|
||||
: StringName (theStringName),
|
||||
sRgbValues (thesRGB),
|
||||
RgbValues (theRGB),
|
||||
EnumName (theName) {}
|
||||
};
|
||||
}
|
||||
|
||||
// Note that HTML/hex sRGB representation is ignored
|
||||
#define RawColor(theName, theHex, theR, theG, theB) Quantity_StandardColor(Quantity_NOC_##theName, #theName, NCollection_Vec3<float>(theR##f, theG##f, theB##f))
|
||||
#define RawColor(theName, theHex, SRGB, sR, sG, sB, RGB, theR, theG, theB) \
|
||||
Quantity_StandardColor(Quantity_NOC_##theName, #theName, NCollection_Vec3<float>(sR##f, sG##f, sB##f), NCollection_Vec3<float>(theR##f, theG##f, theB##f))
|
||||
|
||||
//! Name list of standard materials (defined within enumeration).
|
||||
static const Quantity_StandardColor THE_COLORS[] =
|
||||
@ -96,8 +104,9 @@ NCollection_Vec3<float> Quantity_Color::valuesOf (const Quantity_NameOfColor the
|
||||
const NCollection_Vec3<float>& anRgb = THE_COLORS[theName].RgbValues;
|
||||
switch (theType)
|
||||
{
|
||||
case Quantity_TOC_RGB: return anRgb;
|
||||
case Quantity_TOC_HLS: return Convert_sRGB_To_HLS (anRgb);
|
||||
case Quantity_TOC_RGB: return anRgb;
|
||||
case Quantity_TOC_sRGB: return Convert_LinearRGB_To_sRGB (anRgb);
|
||||
case Quantity_TOC_HLS: return Convert_LinearRGB_To_HLS (anRgb);
|
||||
}
|
||||
throw Standard_ProgramError("Internal error");
|
||||
}
|
||||
@ -191,10 +200,18 @@ Quantity_Color::Quantity_Color (const Standard_Real theR1, const Standard_Real t
|
||||
myRgb.SetValues (float(theR1), float(theR2), float(theR3));
|
||||
break;
|
||||
}
|
||||
case Quantity_TOC_sRGB:
|
||||
{
|
||||
Quantity_ColorValidateRgbRange(theR1, theR2, theR3);
|
||||
myRgb.SetValues ((float )Convert_sRGB_To_LinearRGB (theR1),
|
||||
(float )Convert_sRGB_To_LinearRGB (theR2),
|
||||
(float )Convert_sRGB_To_LinearRGB (theR3));
|
||||
break;
|
||||
}
|
||||
case Quantity_TOC_HLS:
|
||||
{
|
||||
Quantity_ColorValidateHlsRange(theR1, theR2, theR3);
|
||||
myRgb = Convert_HLS_To_sRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
|
||||
myRgb = Convert_HLS_To_LinearRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -216,11 +233,11 @@ Quantity_Color::Quantity_Color (const NCollection_Vec3<float>& theRgb)
|
||||
// =======================================================================
|
||||
void Quantity_Color::ChangeContrast (const Standard_Real theDelta)
|
||||
{
|
||||
NCollection_Vec3<float> aHls = Convert_sRGB_To_HLS (myRgb);
|
||||
NCollection_Vec3<float> aHls = Convert_LinearRGB_To_HLS (myRgb);
|
||||
aHls[2] += aHls[2] * Standard_ShortReal (theDelta) / 100.0f; // saturation
|
||||
if (!((aHls[2] > 1.0f) || (aHls[2] < 0.0f)))
|
||||
{
|
||||
myRgb = Convert_HLS_To_sRGB (aHls);
|
||||
myRgb = Convert_HLS_To_LinearRGB (aHls);
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,11 +247,11 @@ void Quantity_Color::ChangeContrast (const Standard_Real theDelta)
|
||||
// =======================================================================
|
||||
void Quantity_Color::ChangeIntensity (const Standard_Real theDelta)
|
||||
{
|
||||
NCollection_Vec3<float> aHls = Convert_sRGB_To_HLS (myRgb);
|
||||
NCollection_Vec3<float> aHls = Convert_LinearRGB_To_HLS (myRgb);
|
||||
aHls[1] += aHls[1] * Standard_ShortReal (theDelta) / 100.0f; // light
|
||||
if (!((aHls[1] > 1.0f) || (aHls[1] < 0.0f)))
|
||||
{
|
||||
myRgb = Convert_HLS_To_sRGB (aHls);
|
||||
myRgb = Convert_HLS_To_LinearRGB (aHls);
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,10 +270,18 @@ void Quantity_Color::SetValues (const Standard_Real theR1, const Standard_Real t
|
||||
myRgb.SetValues (float(theR1), float(theR2), float(theR3));
|
||||
break;
|
||||
}
|
||||
case Quantity_TOC_sRGB:
|
||||
{
|
||||
Quantity_ColorValidateRgbRange(theR1, theR2, theR3);
|
||||
myRgb.SetValues ((float )Convert_sRGB_To_LinearRGB (theR1),
|
||||
(float )Convert_sRGB_To_LinearRGB (theR2),
|
||||
(float )Convert_sRGB_To_LinearRGB (theR3));
|
||||
break;
|
||||
}
|
||||
case Quantity_TOC_HLS:
|
||||
{
|
||||
Quantity_ColorValidateHlsRange(theR1, theR2, theR3);
|
||||
myRgb = Convert_HLS_To_sRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
|
||||
myRgb = Convert_HLS_To_LinearRGB (NCollection_Vec3<float> (float(theR1), float(theR2), float(theR3)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -270,8 +295,8 @@ void Quantity_Color::Delta (const Quantity_Color& theColor,
|
||||
Standard_Real& theDC,
|
||||
Standard_Real& theDI) const
|
||||
{
|
||||
const NCollection_Vec3<float> aHls1 = Convert_sRGB_To_HLS (myRgb);
|
||||
const NCollection_Vec3<float> aHls2 = Convert_sRGB_To_HLS (theColor.myRgb);
|
||||
const NCollection_Vec3<float> aHls1 = Convert_LinearRGB_To_HLS (myRgb);
|
||||
const NCollection_Vec3<float> aHls2 = Convert_LinearRGB_To_HLS (theColor.myRgb);
|
||||
theDC = Standard_Real (aHls1[2] - aHls2[2]); // saturation
|
||||
theDI = Standard_Real (aHls1[1] - aHls2[1]); // light
|
||||
}
|
||||
@ -282,11 +307,14 @@ void Quantity_Color::Delta (const Quantity_Color& theColor,
|
||||
// =======================================================================
|
||||
Quantity_NameOfColor Quantity_Color::Name() const
|
||||
{
|
||||
Standard_ShortReal aDist2 = 4.0f;
|
||||
// it is better finding closest sRGB color (closest to human eye) instead of linear RGB color,
|
||||
// as enumeration defines color names for human
|
||||
const NCollection_Vec3<float> ansRgbVec (Convert_LinearRGB_To_sRGB (NCollection_Vec3<Standard_Real> (myRgb)));
|
||||
Standard_ShortReal aDist2 = ShortRealLast();
|
||||
Quantity_NameOfColor aResName = Quantity_NOC_BLACK;
|
||||
for (Standard_Integer aColIter = Quantity_NOC_BLACK; aColIter <= Quantity_NOC_WHITE; ++aColIter)
|
||||
{
|
||||
const Standard_ShortReal aNewDist2 = (myRgb - THE_COLORS[aColIter].RgbValues).SquareModulus();
|
||||
const Standard_ShortReal aNewDist2 = (ansRgbVec - THE_COLORS[aColIter].sRgbValues).SquareModulus();
|
||||
if (aNewDist2 < aDist2)
|
||||
{
|
||||
aResName = Quantity_NameOfColor (aColIter);
|
||||
@ -316,9 +344,16 @@ void Quantity_Color::Values (Standard_Real& theR1, Standard_Real& theR2, Standar
|
||||
theR3 = myRgb.b();
|
||||
break;
|
||||
}
|
||||
case Quantity_TOC_sRGB:
|
||||
{
|
||||
theR1 = Convert_LinearRGB_To_sRGB ((Standard_Real )myRgb.r());
|
||||
theR2 = Convert_LinearRGB_To_sRGB ((Standard_Real )myRgb.g());
|
||||
theR3 = Convert_LinearRGB_To_sRGB ((Standard_Real )myRgb.b());
|
||||
break;
|
||||
}
|
||||
case Quantity_TOC_HLS:
|
||||
{
|
||||
const NCollection_Vec3<float> aHls = Convert_sRGB_To_HLS (myRgb);
|
||||
const NCollection_Vec3<float> aHls = Convert_LinearRGB_To_HLS (myRgb);
|
||||
theR1 = aHls[0];
|
||||
theR2 = aHls[1];
|
||||
theR3 = aHls[2];
|
||||
|
@ -27,6 +27,11 @@
|
||||
#include <NCollection_Vec4.hxx>
|
||||
|
||||
//! This class allows the definition of an RGB color as triplet of 3 normalized floating point values (red, green, blue).
|
||||
//!
|
||||
//! Although Quantity_Color can be technically used for pass-through storage of RGB triplet in any color space,
|
||||
//! other OCCT interfaces taking/returning Quantity_Color would expect them in linear space.
|
||||
//! Therefore, take a look into methods converting to and from non-linear sRGB color space, if needed;
|
||||
//! for instance, application usually providing color picking within 0..255 range in sRGB color space.
|
||||
class Quantity_Color
|
||||
{
|
||||
public:
|
||||
@ -83,10 +88,10 @@ public:
|
||||
//! Returns the Hue component (hue angle) of the color
|
||||
//! in degrees within range [0.0; 360.0], 0.0 being Red.
|
||||
//! -1.0 is a special value reserved for grayscale color (S should be 0.0)
|
||||
Standard_Real Hue() const { return Convert_sRGB_To_HLS (myRgb)[0]; }
|
||||
Standard_Real Hue() const { return Convert_LinearRGB_To_HLS (myRgb)[0]; }
|
||||
|
||||
//! Returns the Light component (value of the lightness) of the color within range [0.0; 1.0].
|
||||
Standard_Real Light() const { return Convert_sRGB_To_HLS (myRgb)[1]; }
|
||||
Standard_Real Light() const { return Convert_LinearRGB_To_HLS (myRgb)[1]; }
|
||||
|
||||
//! Increases or decreases the intensity (variation of the lightness).
|
||||
//! The delta is a percentage. Any value greater than zero will increase the intensity.
|
||||
@ -94,7 +99,7 @@ public:
|
||||
Standard_EXPORT void ChangeIntensity (const Standard_Real theDelta);
|
||||
|
||||
//! Returns the Saturation component (value of the saturation) of the color within range [0.0; 1.0].
|
||||
Standard_Real Saturation() const { return Convert_sRGB_To_HLS (myRgb)[2]; }
|
||||
Standard_Real Saturation() const { return Convert_LinearRGB_To_HLS (myRgb)[2]; }
|
||||
|
||||
//! Increases or decreases the contrast (variation of the saturation).
|
||||
//! The delta is a percentage. Any value greater than zero will increase the contrast.
|
||||
@ -102,13 +107,13 @@ public:
|
||||
Standard_EXPORT void ChangeContrast (const Standard_Real theDelta);
|
||||
|
||||
//! Returns TRUE if the distance between two colors is greater than Epsilon().
|
||||
Standard_Boolean IsDifferent (const Quantity_Color& theOther) const { return (Distance (theOther) > Epsilon()); }
|
||||
Standard_Boolean IsDifferent (const Quantity_Color& theOther) const { return (SquareDistance (theOther) > Epsilon() * Epsilon()); }
|
||||
|
||||
//! Alias to IsDifferent().
|
||||
Standard_Boolean operator!= (const Quantity_Color& theOther) const { return IsDifferent (theOther); }
|
||||
|
||||
//! Returns TRUE if the distance between two colors is no greater than Epsilon().
|
||||
Standard_Boolean IsEqual (const Quantity_Color& theOther) const { return (Distance (theOther) <= Epsilon()); }
|
||||
Standard_Boolean IsEqual (const Quantity_Color& theOther) const { return (SquareDistance (theOther) <= Epsilon() * Epsilon()); }
|
||||
|
||||
//! Alias to IsEqual().
|
||||
Standard_Boolean operator== (const Quantity_Color& theOther) const { return IsEqual (theOther); }
|
||||
@ -175,7 +180,7 @@ public:
|
||||
static TCollection_AsciiString ColorToHex (const Quantity_Color& theColor,
|
||||
const bool theToPrefixHash = true)
|
||||
{
|
||||
NCollection_Vec3<Standard_ShortReal> anSRgb = (NCollection_Vec3<Standard_ShortReal> )theColor;
|
||||
NCollection_Vec3<Standard_ShortReal> anSRgb = Convert_LinearRGB_To_sRGB ((NCollection_Vec3<Standard_ShortReal> )theColor);
|
||||
NCollection_Vec3<Standard_Integer> anSRgbInt (anSRgb * 255.0f + NCollection_Vec3<Standard_ShortReal> (0.5f));
|
||||
char aBuff[10];
|
||||
Sprintf (aBuff, theToPrefixHash ? "#%02X%02X%02X" : "%02X%02X%02X",
|
||||
@ -203,6 +208,8 @@ public:
|
||||
|
||||
//! Convert the color value to ARGB integer value, with alpha equals to 0.
|
||||
//! So the output is formatted as 0x00RRGGBB.
|
||||
//! Note that this unpacking does NOT involve non-linear sRGB -> linear RGB conversion,
|
||||
//! as would be usually expected for RGB color packed into 4 bytes.
|
||||
//! @param theColor [in] color to convert
|
||||
//! @param theARGB [out] result color encoded as integer
|
||||
static void Color2argb (const Quantity_Color& theColor,
|
||||
@ -216,14 +223,16 @@ public:
|
||||
| (aColor.b() & 0xff));
|
||||
}
|
||||
|
||||
//! Convert integer ARGB value to Color. Alpha bits are ignored
|
||||
//! Convert integer ARGB value to Color. Alpha bits are ignored.
|
||||
//! Note that this packing does NOT involve linear -> non-linear sRGB conversion,
|
||||
//! as would be usually expected to preserve higher (for human eye) color precision in 4 bytes.
|
||||
static void Argb2color (const Standard_Integer theARGB,
|
||||
Quantity_Color& theColor)
|
||||
{
|
||||
const NCollection_Vec3<Standard_Real> aColor (static_cast <Standard_Real> ((theARGB & 0xff0000) >> 16),
|
||||
static_cast <Standard_Real> ((theARGB & 0x00ff00) >> 8),
|
||||
static_cast <Standard_Real> ((theARGB & 0x0000ff)));
|
||||
theColor.SetValues (aColor.r() / 255.0, aColor.g() / 255.0, aColor.b() / 255.0, Quantity_TOC_RGB);
|
||||
theColor.SetValues (aColor.r() / 255.0, aColor.g() / 255.0, aColor.b() / 255.0, Quantity_TOC_sRGB);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -310,7 +319,7 @@ public:
|
||||
//! Set the value used to compare two colors for equality.
|
||||
Standard_EXPORT static void SetEpsilon (const Standard_Real theEpsilon);
|
||||
|
||||
//! Converts HLS components into RGB ones.
|
||||
//! Converts HLS components into sRGB ones.
|
||||
static void HlsRgb (const Standard_Real theH, const Standard_Real theL, const Standard_Real theS,
|
||||
Standard_Real& theR, Standard_Real& theG, Standard_Real& theB)
|
||||
{
|
||||
@ -320,7 +329,7 @@ public:
|
||||
theB = anRgb[2];
|
||||
}
|
||||
|
||||
//! Converts RGB components into HLS ones.
|
||||
//! Converts sRGB components into HLS ones.
|
||||
static void RgbHls (const Standard_Real theR, const Standard_Real theG, const Standard_Real theB,
|
||||
Standard_Real& theH, Standard_Real& theL, Standard_Real& theS)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ namespace
|
||||
for (Standard_Integer aColorComponentIndex = 2; aColorComponentIndex >= 0; --aColorComponentIndex)
|
||||
{
|
||||
const Standard_ShortReal aColorComponent = takeColorComponentFromInteger (theColorInteger, theColorComponentBase);
|
||||
aColor[aColorComponentIndex] = aColorComponent;
|
||||
aColor[aColorComponentIndex] = Quantity_Color::Convert_sRGB_To_LinearRGB (aColorComponent);
|
||||
}
|
||||
if (theColorInteger != 0)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
static TCollection_AsciiString ColorToHex (const Quantity_ColorRGBA& theColor,
|
||||
const bool theToPrefixHash = true)
|
||||
{
|
||||
NCollection_Vec4<Standard_ShortReal> anSRgb = (NCollection_Vec4<Standard_ShortReal> )theColor;
|
||||
NCollection_Vec4<Standard_ShortReal> anSRgb = Convert_LinearRGB_To_sRGB ((NCollection_Vec4<Standard_ShortReal> )theColor);
|
||||
NCollection_Vec4<Standard_Integer> anSRgbInt (anSRgb * 255.0f + NCollection_Vec4<Standard_ShortReal> (0.5f));
|
||||
char aBuff[12];
|
||||
Sprintf (aBuff, theToPrefixHash ? "#%02X%02X%02X%02X" : "%02X%02X%02X%02X",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@
|
||||
enum Quantity_TypeOfColor
|
||||
{
|
||||
Quantity_TOC_RGB, //!< normalized linear RGB (red, green, blue) values within range [0..1] for each component
|
||||
Quantity_TOC_sRGB, //!< normalized non-linear gamma-shifted RGB (red, green, blue) values within range [0..1] for each component
|
||||
Quantity_TOC_HLS, //!< hue + light + saturation components, where:
|
||||
//! - First component is the Hue (H) angle in degrees within range [0.0; 360.0], 0.0 being Red;
|
||||
//! value -1.0 is a special value reserved for grayscale color (S should be 0.0).
|
||||
|
@ -385,7 +385,7 @@ bool RWGltf_GltfJsonParser::gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)&
|
||||
else if (gltfReadVec4 (anAmb, anAmbVal)
|
||||
&& validateColor4 (anAmb))
|
||||
{
|
||||
theMat->AmbientColor = Quantity_Color (anAmb.r(), anAmb.g(), anAmb.b(), Quantity_TOC_RGB);
|
||||
theMat->AmbientColor = Quantity_Color (anAmb.r(), anAmb.g(), anAmb.b(), Quantity_TOC_sRGB);
|
||||
}
|
||||
|
||||
if (aDiffVal != NULL
|
||||
@ -396,14 +396,14 @@ bool RWGltf_GltfJsonParser::gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)&
|
||||
else if (gltfReadVec4 (aDiff, aDiffVal)
|
||||
&& validateColor4 (aDiff))
|
||||
{
|
||||
theMat->DiffuseColor = Quantity_Color (aDiff.r(), aDiff.g(), aDiff.b(), Quantity_TOC_RGB);
|
||||
theMat->DiffuseColor = Quantity_Color (aDiff.r(), aDiff.g(), aDiff.b(), Quantity_TOC_sRGB);
|
||||
theMat->Transparency = float(1.0 - aDiff.a());
|
||||
}
|
||||
|
||||
if (gltfReadVec4 (anEmi, anEmiVal)
|
||||
&& validateColor4 (anEmi))
|
||||
{
|
||||
theMat->EmissiveColor = Quantity_Color (anEmi.r(), anEmi.g(), anEmi.b(), Quantity_TOC_RGB);
|
||||
theMat->EmissiveColor = Quantity_Color (anEmi.r(), anEmi.g(), anEmi.b(), Quantity_TOC_sRGB);
|
||||
}
|
||||
|
||||
if (aSpecVal != NULL
|
||||
@ -414,7 +414,7 @@ bool RWGltf_GltfJsonParser::gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)&
|
||||
if (gltfReadVec4 (aSpec, aSpecVal)
|
||||
&& validateColor4 (aSpec))
|
||||
{
|
||||
theMat->SpecularColor = Quantity_Color (aSpec.r(), aSpec.g(), aSpec.b(), Quantity_TOC_RGB);
|
||||
theMat->SpecularColor = Quantity_Color (aSpec.r(), aSpec.g(), aSpec.b(), Quantity_TOC_sRGB);
|
||||
}
|
||||
|
||||
if (aShinVal != NULL
|
||||
|
@ -36,10 +36,10 @@ public:
|
||||
Standard_ShortReal Transparency;
|
||||
|
||||
RWGltf_MaterialCommon()
|
||||
: AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
|
||||
DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
|
||||
SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
|
||||
EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
|
||||
: AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_sRGB),
|
||||
DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_sRGB),
|
||||
EmissiveColor(Quantity_NOC_BLACK),
|
||||
Shininess (1.0f),
|
||||
Transparency (0.0f) {}
|
||||
|
||||
|
@ -32,9 +32,9 @@ struct RWObj_Material
|
||||
Standard_ShortReal Transparency;
|
||||
|
||||
RWObj_Material()
|
||||
: AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
|
||||
DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
|
||||
SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
|
||||
: AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_sRGB),
|
||||
DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_sRGB),
|
||||
Shininess (1.0f),
|
||||
Transparency (0.0f) {}
|
||||
|
||||
|
@ -177,7 +177,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
|
||||
aPos = aNext;
|
||||
if (validateColor (aColor))
|
||||
{
|
||||
aMat.AmbientColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
|
||||
aMat.AmbientColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_sRGB);
|
||||
hasAspect = true;
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
|
||||
aPos = aNext;
|
||||
if (validateColor (aColor))
|
||||
{
|
||||
aMat.DiffuseColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
|
||||
aMat.DiffuseColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_sRGB);
|
||||
hasAspect = true;
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ bool RWObj_MtlReader::Read (const TCollection_AsciiString& theFolder,
|
||||
aPos = aNext;
|
||||
if (validateColor (aColor))
|
||||
{
|
||||
aMat.SpecularColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_RGB);
|
||||
aMat.SpecularColor = Quantity_Color (aColor.r(), aColor.g(), aColor.b(), Quantity_TOC_sRGB);
|
||||
hasAspect = true;
|
||||
}
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
|
||||
}
|
||||
else {
|
||||
// default white color
|
||||
surfColor = Styles.EncodeColor(Quantity_Color(1,1,1,Quantity_TOC_RGB),DPDCs,ColRGBs);
|
||||
surfColor = Styles.EncodeColor(Quantity_Color(Quantity_NOC_WHITE),DPDCs,ColRGBs);
|
||||
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
|
||||
if ( isComponent )
|
||||
setDefaultInstanceColor( override, PSA);
|
||||
@ -1857,7 +1857,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
|
||||
// set default color for invisible SHUO.
|
||||
Standard_Boolean isSetDefaultColor = Standard_False;
|
||||
if (surfColor.IsNull() && curvColor.IsNull() && !style.IsVisible() ) {
|
||||
surfColor = Styles.EncodeColor ( Quantity_Color( 1, 1, 1, Quantity_TOC_RGB ) );
|
||||
surfColor = Styles.EncodeColor ( Quantity_Color(Quantity_NOC_WHITE) );
|
||||
isSetDefaultColor = Standard_True;
|
||||
}
|
||||
Handle(StepVisual_PresentationStyleAssignment) PSA =
|
||||
|
@ -632,7 +632,9 @@ Handle(StepVisual_Colour) STEPConstruct_Styles::EncodeColor(const Quantity_Color
|
||||
else {
|
||||
Handle(TCollection_HAsciiString) ColName = new TCollection_HAsciiString ( "" );
|
||||
Handle(StepVisual_ColourRgb) ColRGB = new StepVisual_ColourRgb;
|
||||
ColRGB->Init ( ColName, C.Red(), C.Green(), C.Blue() );
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
C.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
ColRGB->Init ( ColName, aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b() );
|
||||
return ColRGB;
|
||||
}
|
||||
}
|
||||
@ -675,14 +677,18 @@ Handle(StepVisual_Colour) STEPConstruct_Styles::EncodeColor
|
||||
}
|
||||
else {
|
||||
Handle(StepVisual_ColourRgb) ColRGB;
|
||||
gp_Pnt P(C.Red(),C.Green(),C.Blue());
|
||||
gp_Pnt P;
|
||||
C.Values (P.ChangeCoord().ChangeData()[0],
|
||||
P.ChangeCoord().ChangeData()[1],
|
||||
P.ChangeCoord().ChangeData()[2],
|
||||
Quantity_TOC_sRGB);
|
||||
if(ColRGBs.IsBound(P)) {
|
||||
ColRGB = Handle(StepVisual_ColourRgb)::DownCast(ColRGBs.Find(P));
|
||||
if(!ColRGB.IsNull()) return ColRGB;
|
||||
}
|
||||
Handle(TCollection_HAsciiString) ColName = new TCollection_HAsciiString ( "" );
|
||||
ColRGB = new StepVisual_ColourRgb;
|
||||
ColRGB->Init ( ColName, C.Red(), C.Green(), C.Blue() );
|
||||
ColRGB->Init ( ColName, P.Coord (1), P.Coord (2), P.Coord (3) );
|
||||
ColRGBs.Bind(P,ColRGB);
|
||||
return ColRGB;
|
||||
}
|
||||
@ -703,10 +709,10 @@ Standard_Boolean STEPConstruct_Styles::DecodeColor (const Handle(StepVisual_Colo
|
||||
if(norm<rgb->Green()) norm = rgb->Green();
|
||||
if(norm<rgb->Blue()) norm = rgb->Blue();
|
||||
Col.SetValues(rgb->Red()/norm, rgb->Green()/norm,
|
||||
rgb->Blue()/norm, Quantity_TOC_RGB);
|
||||
rgb->Blue()/norm, Quantity_TOC_sRGB);
|
||||
}
|
||||
else
|
||||
Col.SetValues(rgb->Red(), rgb->Green(), rgb->Blue(), Quantity_TOC_RGB);
|
||||
Col.SetValues(rgb->Red(), rgb->Green(), rgb->Blue(), Quantity_TOC_sRGB);
|
||||
return Standard_True;
|
||||
}
|
||||
else if ( Colour->IsKind (STANDARD_TYPE(StepVisual_PreDefinedColour)) ) {
|
||||
|
@ -144,8 +144,12 @@ void main (void)
|
||||
aColor = ToneMappingFilmic (aColor, uWhitePoint);
|
||||
#endif // TONE_MAPPING
|
||||
|
||||
#ifdef THE_SHIFT_sRGB
|
||||
// apply gamma correction (we use gamma = 2)
|
||||
OutColor = vec4 (sqrt (aColor.rgb), 0.f);
|
||||
#else
|
||||
OutColor = vec4 (aColor.rgb, 0.f);
|
||||
#endif
|
||||
|
||||
#else // not PATH_TRACING
|
||||
|
||||
|
@ -703,12 +703,15 @@ vec3 IntersectLight (in SRay theRay, in int theDepth, in float theHitDistance, o
|
||||
{
|
||||
if (theDepth + uSphereMapForBack == 0) // view ray and map is hidden
|
||||
{
|
||||
aTotalRadiance = pow (BackgroundColor().rgb, vec3 (2.f));
|
||||
aTotalRadiance = BackgroundColor().rgb;
|
||||
}
|
||||
else
|
||||
{
|
||||
aTotalRadiance = pow (FetchEnvironment (Latlong (theRay.Direct)).rgb, vec3 (2.f));
|
||||
aTotalRadiance = FetchEnvironment (Latlong (theRay.Direct)).rgb;
|
||||
}
|
||||
#ifdef THE_SHIFT_sRGB
|
||||
aTotalRadiance = pow (aTotalRadiance, vec3 (2.f));
|
||||
#endif
|
||||
}
|
||||
|
||||
return aTotalRadiance;
|
||||
|
@ -147,8 +147,12 @@ static const char Shaders_Display_fs[] =
|
||||
" aColor = ToneMappingFilmic (aColor, uWhitePoint);\n"
|
||||
"#endif // TONE_MAPPING\n"
|
||||
"\n"
|
||||
"#ifdef THE_SHIFT_sRGB\n"
|
||||
" // apply gamma correction (we use gamma = 2)\n"
|
||||
" OutColor = vec4 (sqrt (aColor.rgb), 0.f);\n"
|
||||
"#else\n"
|
||||
" OutColor = vec4 (aColor.rgb, 0.f);\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"#else // not PATH_TRACING\n"
|
||||
"\n"
|
||||
|
@ -706,12 +706,15 @@ static const char Shaders_PathtraceBase_fs[] =
|
||||
" {\n"
|
||||
" if (theDepth + uSphereMapForBack == 0) // view ray and map is hidden\n"
|
||||
" {\n"
|
||||
" aTotalRadiance = pow (BackgroundColor().rgb, vec3 (2.f));\n"
|
||||
" aTotalRadiance = BackgroundColor().rgb;\n"
|
||||
" }\n"
|
||||
" else\n"
|
||||
" {\n"
|
||||
" aTotalRadiance = pow (FetchEnvironment (Latlong (theRay.Direct)).rgb, vec3 (2.f));\n"
|
||||
" aTotalRadiance = FetchEnvironment (Latlong (theRay.Direct)).rgb;\n"
|
||||
" }\n"
|
||||
" #ifdef THE_SHIFT_sRGB\n"
|
||||
" aTotalRadiance = pow (aTotalRadiance, vec3 (2.f));\n"
|
||||
" #endif\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" return aTotalRadiance;\n"
|
||||
|
@ -695,7 +695,7 @@ namespace
|
||||
theColor = Quantity_Color (Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
|
||||
Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
|
||||
Standard_Real(myBullardGenerator.NextInt() % 256) / 255.0,
|
||||
Quantity_TOC_RGB);
|
||||
Quantity_TOC_sRGB);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -213,7 +213,7 @@ namespace
|
||||
}
|
||||
|
||||
const Graphic3d_Vec4 aRealColor = Graphic3d_Vec4 (anIntegerColor) / static_cast<Standard_ShortReal> (THE_MAX_INTEGER_COLOR_COMPONENT);
|
||||
theColor = Quantity_ColorRGBA (aRealColor);
|
||||
theColor = Quantity_ColorRGBA (Quantity_ColorRGBA::Convert_sRGB_To_LinearRGB (aRealColor));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2490,7 +2490,7 @@ static Standard_Integer VAspects (Draw_Interpretor& theDI,
|
||||
aChangeSet->FaceBoundaryColor = Quantity_Color (aNames.Value (3).IntegerValue() / 255.0,
|
||||
aNames.Value (4).IntegerValue() / 255.0,
|
||||
aNames.Value (5).IntegerValue() / 255.0,
|
||||
Quantity_TOC_RGB);
|
||||
Quantity_TOC_sRGB);
|
||||
aNames.Remove (5);
|
||||
aNames.Remove (4);
|
||||
aNames.Remove (3);
|
||||
|
@ -1090,9 +1090,9 @@ static Standard_Integer VListMaterials (Draw_Interpretor& theDI,
|
||||
if (aMatFile.is_open())
|
||||
{
|
||||
aMatFile << "newmtl " << aMatName << "\n";
|
||||
aMatFile << "Ka " << anAmbient << "\n";
|
||||
aMatFile << "Kd " << aDiffuse << "\n";
|
||||
aMatFile << "Ks " << aSpecular << "\n";
|
||||
aMatFile << "Ka " << Quantity_Color::Convert_LinearRGB_To_sRGB (anAmbient) << "\n";
|
||||
aMatFile << "Kd " << Quantity_Color::Convert_LinearRGB_To_sRGB (aDiffuse) << "\n";
|
||||
aMatFile << "Ks " << Quantity_Color::Convert_LinearRGB_To_sRGB (aSpecular) << "\n";
|
||||
aMatFile << "Ns " << aShiness << "\n";
|
||||
if (aMat.Transparency() >= 0.0001)
|
||||
{
|
||||
|
@ -5824,7 +5824,7 @@ void V3d_LineItem::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePre
|
||||
const Standard_Integer /*theMode*/)
|
||||
{
|
||||
thePresentation->Clear();
|
||||
Quantity_Color aColor (1.0, 0, 0, Quantity_TOC_RGB);
|
||||
Quantity_Color aColor (Quantity_NOC_RED);
|
||||
Standard_Integer aWidth, aHeight;
|
||||
ViewerTest::CurrentView()->Window()->Size (aWidth, aHeight);
|
||||
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
||||
@ -6759,6 +6759,7 @@ static int VCaps (Draw_Interpretor& theDI,
|
||||
|
||||
if (theArgNb < 2)
|
||||
{
|
||||
theDI << "sRGB: " << (aCaps->sRGBDisable ? "0" : "1") << "\n";
|
||||
theDI << "VBO: " << (aCaps->vboDisable ? "0" : "1") << "\n";
|
||||
theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
|
||||
theDI << "SoftMode:" << (aCaps->contextNoAccel ? "1" : "0") << "\n";
|
||||
@ -6814,6 +6815,16 @@ static int VCaps (Draw_Interpretor& theDI,
|
||||
}
|
||||
aCaps->usePolygonMode = toEnable;
|
||||
}
|
||||
else if (anArgCase == "-srgb")
|
||||
{
|
||||
Standard_Boolean toEnable = Standard_True;
|
||||
if (++anArgIter < theArgNb
|
||||
&& !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
|
||||
{
|
||||
--anArgIter;
|
||||
}
|
||||
aCaps->sRGBDisable = !toEnable;
|
||||
}
|
||||
else if (anArgCase == "-vbo")
|
||||
{
|
||||
Standard_Boolean toEnable = Standard_True;
|
||||
@ -7042,16 +7053,19 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool toShowName = false, toShowHls = false, toShowHex = false;
|
||||
bool toShowName = false, toShowHls = false, toShowHex = false, toShow_sRGB = false;
|
||||
for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
|
||||
{
|
||||
TCollection_AsciiString aParam (theArgVec[anIter]);
|
||||
aParam.LowerCase();
|
||||
if (aParam == "-rgb"
|
||||
|| aParam == "rgb")
|
||||
|| aParam == "rgb"
|
||||
|| aParam == "-srgb"
|
||||
|| aParam == "srgb")
|
||||
{
|
||||
aFormat = Image_Format_RGB;
|
||||
aBufferType = Graphic3d_BT_RGB;
|
||||
toShow_sRGB = aParam == "-srgb" || aParam == "srgb";
|
||||
}
|
||||
else if (aParam == "-hls"
|
||||
|| aParam == "hls")
|
||||
@ -7067,10 +7081,13 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
||||
aBufferType = Graphic3d_BT_RGB;
|
||||
}
|
||||
else if (aParam == "-rgba"
|
||||
|| aParam == "rgba")
|
||||
|| aParam == "rgba"
|
||||
|| aParam == "-srgba"
|
||||
|| aParam == "srgba")
|
||||
{
|
||||
aFormat = Image_Format_RGBA;
|
||||
aBufferType = Graphic3d_BT_RGBA;
|
||||
toShow_sRGB = aParam == "-srgba" || aParam == "srgba";
|
||||
}
|
||||
else if (aParam == "-rgbaf"
|
||||
|| aParam == "rgbaf")
|
||||
@ -7123,7 +7140,7 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
||||
}
|
||||
theDI.Reset();
|
||||
|
||||
Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY);
|
||||
Quantity_ColorRGBA aColor = anImage.PixelColor (anX, anY, true);
|
||||
if (toShowName)
|
||||
{
|
||||
if (aBufferType == Graphic3d_BT_RGBA)
|
||||
@ -7157,6 +7174,11 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
||||
{
|
||||
theDI << aColor.GetRGB().Hue() << " " << aColor.GetRGB().Light() << " " << aColor.GetRGB().Saturation();
|
||||
}
|
||||
else if (toShow_sRGB)
|
||||
{
|
||||
const Graphic3d_Vec4 aColor_sRGB = Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor);
|
||||
theDI << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b();
|
||||
}
|
||||
else
|
||||
{
|
||||
theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue();
|
||||
@ -7165,7 +7187,8 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
||||
}
|
||||
case Graphic3d_BT_RGBA:
|
||||
{
|
||||
theDI << aColor.GetRGB().Red() << " " << aColor.GetRGB().Green() << " " << aColor.GetRGB().Blue() << " " << aColor.Alpha();
|
||||
const Graphic3d_Vec4 aVec4 = toShow_sRGB ? Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB ((Graphic3d_Vec4 )aColor) : (Graphic3d_Vec4 )aColor;
|
||||
theDI << aVec4.r() << " " << aVec4.g() << " " << aVec4.b() << " " << aVec4.a();
|
||||
break;
|
||||
}
|
||||
case Graphic3d_BT_Depth:
|
||||
@ -13884,13 +13907,14 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: greenMagentaSimple",
|
||||
__FILE__, VStereo, group);
|
||||
theCommands.Add ("vcaps",
|
||||
"vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
|
||||
"vcaps [-sRGB {0|1}] [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
|
||||
"\n\t\t: [-compatibleProfile {0|1}]"
|
||||
"\n\t\t: [-vsync {0|1}] [-useWinBuffer {0|1}]"
|
||||
"\n\t\t: [-quadBuffer {0|1}] [-stereo {0|1}]"
|
||||
"\n\t\t: [-softMode {0|1}] [-noupdate|-update]"
|
||||
"\n\t\t: [-noExtensions {0|1}] [-maxVersion Major Minor]"
|
||||
"\n\t\t: Modify particular graphic driver options:"
|
||||
"\n\t\t: sRGB - enable/disable sRGB rendering"
|
||||
"\n\t\t: FFP - use fixed-function pipeline instead of"
|
||||
"\n\t\t: built-in GLSL programs"
|
||||
"\n\t\t: (requires compatible profile)"
|
||||
@ -13916,7 +13940,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
" with f option returns free memory in bytes",
|
||||
__FILE__, VMemGpu, group);
|
||||
theCommands.Add ("vreadpixel",
|
||||
"vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
|
||||
"vreadpixel xPixel yPixel [{rgb|rgba|sRGB|sRGBa|depth|hls|rgbf|rgbaf}=rgba] [-name|-hex]"
|
||||
" : Read pixel value for active view",
|
||||
__FILE__, VReadPixel, group);
|
||||
theCommands.Add("diffimage",
|
||||
|
@ -18,13 +18,11 @@
|
||||
|
||||
Vrml_DirectionalLight::Vrml_DirectionalLight():
|
||||
myOnOff(Standard_True),
|
||||
myIntensity(1)
|
||||
myIntensity(1),
|
||||
myColor (Quantity_NOC_WHITE),
|
||||
myDirection (0, 0, -1)
|
||||
{
|
||||
gp_Vec tmpVec(0,0,-1);
|
||||
myDirection = tmpVec;
|
||||
|
||||
Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
|
||||
myColor = tmpColor;
|
||||
//
|
||||
}
|
||||
|
||||
Vrml_DirectionalLight::Vrml_DirectionalLight(const Standard_Boolean aOnOff,
|
||||
@ -106,8 +104,10 @@ Standard_OStream& Vrml_DirectionalLight::Print(Standard_OStream& anOStream) cons
|
||||
Abs(myColor.Green() - 1) > 0.0001 ||
|
||||
Abs(myColor.Blue() - 1) > 0.0001 )
|
||||
{
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << " color\t";
|
||||
anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
|
||||
anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
|
||||
}
|
||||
|
||||
if ( Abs(myDirection.X() - 0) > 0.0001 ||
|
||||
|
@ -51,21 +51,10 @@ Vrml_Material::Vrml_Material(const Handle(Quantity_HArray1OfColor)& aAmbientColo
|
||||
|
||||
Vrml_Material::Vrml_Material()
|
||||
{
|
||||
Quantity_Color tmpcolor;
|
||||
// myAmbientColor = new Quantity_HArray1OfColor(1,1);
|
||||
tmpcolor.SetValues(0.2, 0.2, 0.2, Quantity_TOC_RGB);
|
||||
myAmbientColor = new Quantity_HArray1OfColor(1,1,tmpcolor);
|
||||
// myAmbientColor->SetValue(1, tmpcolor);
|
||||
// myDiffuseColor = new Quantity_HArray1OfColor(1,1);
|
||||
tmpcolor.SetValues(0.8, 0.8, 0.8, Quantity_TOC_RGB);
|
||||
myDiffuseColor = new Quantity_HArray1OfColor(1,1,tmpcolor);
|
||||
// myDiffuseColor->SetValue(1, tmpcolor);
|
||||
mySpecularColor = new Quantity_HArray1OfColor(1,1);
|
||||
tmpcolor.SetValues(0, 0, 0, Quantity_TOC_RGB);
|
||||
mySpecularColor->SetValue(1, tmpcolor);
|
||||
myEmissiveColor = new Quantity_HArray1OfColor(1,1);
|
||||
tmpcolor.SetValues(0, 0, 0, Quantity_TOC_RGB);
|
||||
myEmissiveColor->SetValue(1, tmpcolor);
|
||||
myAmbientColor = new Quantity_HArray1OfColor (1, 1, Quantity_Color (0.2, 0.2, 0.2, Quantity_TOC_sRGB));
|
||||
myDiffuseColor = new Quantity_HArray1OfColor (1, 1, Quantity_Color (0.8, 0.8, 0.8, Quantity_TOC_sRGB));
|
||||
mySpecularColor = new Quantity_HArray1OfColor (1, 1, Quantity_NOC_BLACK);
|
||||
myEmissiveColor = new Quantity_HArray1OfColor (1, 1, Quantity_NOC_BLACK);
|
||||
|
||||
myShininess = new TColStd_HArray1OfReal (1,1,0.2);
|
||||
myTransparency = new TColStd_HArray1OfReal (1,1,0);
|
||||
@ -149,6 +138,7 @@ Handle(TColStd_HArray1OfReal) Vrml_Material::Transparency() const
|
||||
|
||||
Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
|
||||
{
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
Standard_Integer i;
|
||||
anOStream << "Material {\n";
|
||||
|
||||
@ -160,7 +150,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
|
||||
anOStream << " ambientColor [\n\t";
|
||||
for ( i = myAmbientColor->Lower(); i <= myAmbientColor->Upper(); i++ )
|
||||
{
|
||||
anOStream << myAmbientColor->Value(i).Red() << ' ' << myAmbientColor->Value(i).Green() << ' ' << myAmbientColor->Value(i).Blue();
|
||||
myAmbientColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
|
||||
if ( i < myAmbientColor->Length() )
|
||||
anOStream << ",\n\t"; // ,,,,,,,,,,
|
||||
}
|
||||
@ -175,7 +166,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
|
||||
anOStream << " diffuseColor [\n\t";
|
||||
for ( i = myDiffuseColor->Lower(); i <= myDiffuseColor->Upper(); i++ )
|
||||
{
|
||||
anOStream << myDiffuseColor->Value(i).Red() << ' ' << myDiffuseColor->Value(i).Green() << ' ' << myDiffuseColor->Value(i).Blue();
|
||||
myDiffuseColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
|
||||
if ( i < myDiffuseColor->Length() )
|
||||
anOStream << ",\n\t";
|
||||
}
|
||||
@ -190,7 +182,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
|
||||
anOStream << " specularColor [\n\t";
|
||||
for ( i = mySpecularColor->Lower(); i <= mySpecularColor->Upper(); i++ )
|
||||
{
|
||||
anOStream << mySpecularColor->Value(i).Red() << ' ' << mySpecularColor->Value(i).Green() << ' ' << mySpecularColor->Value(i).Blue();
|
||||
mySpecularColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
|
||||
if ( i < mySpecularColor->Length() )
|
||||
anOStream << ",\n\t";
|
||||
}
|
||||
@ -205,7 +198,8 @@ Standard_OStream& Vrml_Material::Print(Standard_OStream& anOStream) const
|
||||
anOStream << " emissiveColor [\n\t";
|
||||
for ( i = myEmissiveColor->Lower(); i <= myEmissiveColor->Upper(); i++ )
|
||||
{
|
||||
anOStream << myEmissiveColor->Value(i).Red() << ' ' << myEmissiveColor->Value(i).Green() << ' ' << myEmissiveColor->Value(i).Blue();
|
||||
myEmissiveColor->Value(i).Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << aColor_sRGB.r() << ' ' << aColor_sRGB.g() << ' ' << aColor_sRGB.b();
|
||||
if ( i < myEmissiveColor->Length() )
|
||||
anOStream << ",\n\t";
|
||||
}
|
||||
|
@ -18,13 +18,11 @@
|
||||
|
||||
Vrml_PointLight::Vrml_PointLight():
|
||||
myOnOff(Standard_True),
|
||||
myIntensity(1)
|
||||
myIntensity(1),
|
||||
myColor (Quantity_NOC_WHITE),
|
||||
myLocation (0, 0, 1)
|
||||
{
|
||||
gp_Vec tmpVec(0,0,1);
|
||||
myLocation = tmpVec;
|
||||
|
||||
Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
|
||||
myColor = tmpColor;
|
||||
//
|
||||
}
|
||||
|
||||
Vrml_PointLight::Vrml_PointLight( const Standard_Boolean aOnOff,
|
||||
@ -106,8 +104,10 @@ Standard_OStream& Vrml_PointLight::Print(Standard_OStream& anOStream) const
|
||||
Abs(myColor.Green() - 1) > 0.0001 ||
|
||||
Abs(myColor.Blue() - 1) > 0.0001 )
|
||||
{
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << " color\t";
|
||||
anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
|
||||
anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
|
||||
}
|
||||
|
||||
if ( Abs(myLocation.X() - 0) > 0.0001 ||
|
||||
|
@ -19,17 +19,13 @@
|
||||
Vrml_SpotLight::Vrml_SpotLight():
|
||||
myOnOff(Standard_True),
|
||||
myIntensity(1),
|
||||
myColor (Quantity_NOC_WHITE),
|
||||
myLocation (0, 0, 1),
|
||||
myDirection (0, 0, -1),
|
||||
myDropOffRate(0),
|
||||
myCutOffAngle(0.785398)
|
||||
{
|
||||
gp_Vec tmpVec(0,0,1);
|
||||
myLocation = tmpVec;
|
||||
|
||||
tmpVec.SetCoord(0,0,-1);
|
||||
myDirection = tmpVec;
|
||||
|
||||
Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
|
||||
myColor = tmpColor;
|
||||
//
|
||||
}
|
||||
|
||||
Vrml_SpotLight::Vrml_SpotLight( const Standard_Boolean aOnOff,
|
||||
@ -147,8 +143,10 @@ Standard_OStream& Vrml_SpotLight::Print(Standard_OStream& anOStream) const
|
||||
Abs(myColor.Green() - 1) > 0.0001 ||
|
||||
Abs(myColor.Blue() - 1) > 0.0001 )
|
||||
{
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
myColor.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
anOStream << " color\t";
|
||||
anOStream << myColor.Red() << " " << myColor.Green() << " " << myColor.Blue() << "\n";
|
||||
anOStream << aColor_sRGB.r() << " " << aColor_sRGB.g() << " " << aColor_sRGB.b() << "\n";
|
||||
}
|
||||
|
||||
if ( Abs(myLocation.X() - 0) > 0.0001 ||
|
||||
|
@ -46,10 +46,7 @@ VrmlAPI_Writer::VrmlAPI_Writer()
|
||||
{
|
||||
myDrawer = new VrmlConverter_Drawer;
|
||||
myDeflection = -1;
|
||||
Quantity_Color color;
|
||||
color.SetValues(0, 0, 0, Quantity_TOC_RGB);
|
||||
Handle(Quantity_HArray1OfColor) Col1 = new Quantity_HArray1OfColor(1,1);
|
||||
Col1->SetValue(1,color);
|
||||
Handle(Quantity_HArray1OfColor) Col1 = new Quantity_HArray1OfColor (1, 1, Quantity_NOC_BLACK);
|
||||
Handle(TColStd_HArray1OfReal) kik1 = new TColStd_HArray1OfReal(1,1,0.0);
|
||||
Handle(TColStd_HArray1OfReal) kik2 = new TColStd_HArray1OfReal(1,1,0.1);
|
||||
myFrontMaterial = new Vrml_Material(Col1,Col1, Col1, Col1, kik1, kik2);
|
||||
@ -76,10 +73,7 @@ void VrmlAPI_Writer::ResetToDefaults()
|
||||
myShininess = 0.1;
|
||||
Handle(TColStd_HArray1OfReal) kik1 = new TColStd_HArray1OfReal(1,1,myTransparency);
|
||||
Handle(TColStd_HArray1OfReal) kik2 = new TColStd_HArray1OfReal(1,1,myShininess);
|
||||
Handle(Quantity_HArray1OfColor) Col = new Quantity_HArray1OfColor(1,1);
|
||||
Quantity_Color color;
|
||||
color.SetValues(0, 0, 0, Quantity_TOC_RGB);
|
||||
Col->SetValue(1,color);
|
||||
Handle(Quantity_HArray1OfColor) Col = new Quantity_HArray1OfColor(1, 1, Quantity_NOC_BLACK);
|
||||
//
|
||||
myFrontMaterial->SetAmbientColor(Col); myFrontMaterial->SetTransparency(kik1);myFrontMaterial->SetShininess(kik2);
|
||||
myPointsMaterial->SetAmbientColor(Col); myPointsMaterial->SetTransparency(kik1);myPointsMaterial->SetShininess(kik2);
|
||||
@ -91,13 +85,8 @@ void VrmlAPI_Writer::ResetToDefaults()
|
||||
myUnfreeBoundsMaterial->SetAmbientColor(Col); myUnfreeBoundsMaterial->SetTransparency(kik1);myUnfreeBoundsMaterial->SetShininess(kik2);
|
||||
//
|
||||
//
|
||||
Handle(Quantity_HArray1OfColor) Col2 = new Quantity_HArray1OfColor(1,1);
|
||||
color.SetValues(0.75, 0.75, 0.75, Quantity_TOC_RGB);
|
||||
Col2->SetValue(1,color);
|
||||
Handle(Quantity_HArray1OfColor) Col3 = new Quantity_HArray1OfColor(1,1);
|
||||
color.SetValues(0.82, 0.79, 0.42, Quantity_TOC_RGB);
|
||||
Col3->SetValue(1,color);
|
||||
|
||||
Handle(Quantity_HArray1OfColor) Col2 = new Quantity_HArray1OfColor(1, 1, Quantity_Color (0.75, 0.75, 0.75, Quantity_TOC_sRGB));
|
||||
Handle(Quantity_HArray1OfColor) Col3 = new Quantity_HArray1OfColor(1, 1, Quantity_Color (0.82, 0.79, 0.42, Quantity_TOC_sRGB));
|
||||
myUisoMaterial->SetDiffuseColor(Col2);
|
||||
myVisoMaterial->SetDiffuseColor(Col2);
|
||||
myFreeBoundsMaterial->SetDiffuseColor(Col2);
|
||||
|
@ -52,7 +52,7 @@ class VrmlData_Color : public VrmlData_ArrayVec3d
|
||||
*/
|
||||
inline const Quantity_Color Color (const Standard_Integer i) const
|
||||
{ return Quantity_Color (Value(i).X(), Value(i).Y(), Value(i).Z(),
|
||||
Quantity_TOC_RGB); }
|
||||
Quantity_TOC_sRGB); }
|
||||
|
||||
/**
|
||||
* Set the array data
|
||||
|
@ -36,9 +36,9 @@ VrmlData_Material::VrmlData_Material ()
|
||||
: myAmbientIntensity (0.2),
|
||||
myShininess (0.2),
|
||||
myTransparency (0.),
|
||||
myDiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
|
||||
myEmissiveColor (0., 0., 0., Quantity_TOC_RGB),
|
||||
mySpecularColor (0., 0., 0., Quantity_TOC_RGB)
|
||||
myDiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
myEmissiveColor (Quantity_NOC_BLACK),
|
||||
mySpecularColor (Quantity_NOC_BLACK)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
@ -55,9 +55,9 @@ VrmlData_Material::VrmlData_Material (const VrmlData_Scene& theScene,
|
||||
myAmbientIntensity (theAmbientIntens < 0. ? 0.2 : theAmbientIntens),
|
||||
myShininess (theShininess < 0. ? 0.2 : theShininess),
|
||||
myTransparency (theTransparency < 0 ? 0. : theTransparency),
|
||||
myDiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
|
||||
myEmissiveColor (0., 0., 0., Quantity_TOC_RGB),
|
||||
mySpecularColor (0., 0., 0., Quantity_TOC_RGB)
|
||||
myDiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
myEmissiveColor (Quantity_NOC_BLACK),
|
||||
mySpecularColor (Quantity_NOC_BLACK)
|
||||
{}
|
||||
|
||||
|
||||
@ -169,11 +169,11 @@ VrmlData_ErrorStatus VrmlData_Material::Read (VrmlData_InBuffer& theBuffer)
|
||||
myShininess = anIntensity[1];
|
||||
myTransparency = anIntensity[2];
|
||||
myDiffuseColor.SetValues (aColor[0].X(), aColor[0].Y(), aColor[0].Z(),
|
||||
Quantity_TOC_RGB);
|
||||
Quantity_TOC_sRGB);
|
||||
myEmissiveColor.SetValues (aColor[1].X(), aColor[1].Y(), aColor[1].Z(),
|
||||
Quantity_TOC_RGB);
|
||||
Quantity_TOC_sRGB);
|
||||
mySpecularColor.SetValues (aColor[2].X(), aColor[2].Y(), aColor[2].Z(),
|
||||
Quantity_TOC_RGB);
|
||||
Quantity_TOC_sRGB);
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
@ -193,7 +193,7 @@ VrmlData_ErrorStatus VrmlData_Material::Write (const char * thePrefix) const
|
||||
{
|
||||
char buf[128];
|
||||
Standard_Real val[3];
|
||||
Quantity_TypeOfColor bidType (Quantity_TOC_RGB);
|
||||
const Quantity_TypeOfColor bidType = Quantity_TOC_sRGB;
|
||||
const Standard_Real aConf (0.001 * Precision::Confusion());
|
||||
|
||||
if (OK(aStatus) && fabs(myAmbientIntensity - 0.2) > aConf) {
|
||||
@ -252,7 +252,7 @@ Standard_Boolean VrmlData_Material::IsDefault () const
|
||||
myTransparency < aConf)
|
||||
{
|
||||
Standard_Real val[3][3];
|
||||
Quantity_TypeOfColor bidType (Quantity_TOC_RGB);
|
||||
const Quantity_TypeOfColor bidType = Quantity_TOC_sRGB;
|
||||
myDiffuseColor.Values (val[0][0], val[0][1], val[0][2], bidType);
|
||||
myEmissiveColor.Values (val[1][0], val[1][1], val[1][2], bidType);
|
||||
mySpecularColor.Values (val[2][0], val[2][1], val[2][2], bidType);
|
||||
|
@ -546,11 +546,11 @@ Handle(VrmlData_Appearance) VrmlData_ShapeConvert::defaultMaterialFace () const
|
||||
const Handle(VrmlData_Material) aMaterial =
|
||||
new VrmlData_Material (myScene, 0L, 1.0, 0.022, 0.);
|
||||
aMaterial->SetDiffuseColor (Quantity_Color(0.780392, 0.568627, 0.113725,
|
||||
Quantity_TOC_RGB));
|
||||
Quantity_TOC_sRGB));
|
||||
aMaterial->SetEmissiveColor(Quantity_Color(0.329412, 0.223529, 0.027451,
|
||||
Quantity_TOC_RGB));
|
||||
Quantity_TOC_sRGB));
|
||||
aMaterial->SetSpecularColor(Quantity_Color(0.992157, 0.941176, 0.807843,
|
||||
Quantity_TOC_RGB));
|
||||
Quantity_TOC_sRGB));
|
||||
myScene.AddNode (aMaterial, Standard_False);
|
||||
anAppearance = new VrmlData_Appearance (myScene, aNodeName);
|
||||
anAppearance->SetMaterial (aMaterial);
|
||||
@ -903,11 +903,13 @@ Handle(VrmlData_Appearance) VrmlData_ShapeConvert::makeMaterialFromColor(
|
||||
}
|
||||
else
|
||||
{
|
||||
aNodeName.AssignCat(aColor.GetRGB().Red());
|
||||
NCollection_Vec3<Standard_Real> aColor_sRGB;
|
||||
aColor.GetRGB().Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
|
||||
aNodeName.AssignCat(aColor_sRGB.r());
|
||||
aNodeName.AssignCat("_");
|
||||
aNodeName.AssignCat(aColor.GetRGB().Green());
|
||||
aNodeName.AssignCat(aColor_sRGB.g());
|
||||
aNodeName.AssignCat("_");
|
||||
aNodeName.AssignCat(aColor.GetRGB().Blue());
|
||||
aNodeName.AssignCat(aColor_sRGB.b());
|
||||
}
|
||||
|
||||
Handle(VrmlData_Appearance) anAppearance =
|
||||
|
@ -1,25 +1,19 @@
|
||||
puts "========"
|
||||
puts "OCC26379"
|
||||
puts "0026379: Wrong result produced by the volume maker algorithm"
|
||||
puts "========"
|
||||
puts ""
|
||||
#######################################################
|
||||
# Wrong result produced by the volume maker algorithm
|
||||
#######################################################
|
||||
|
||||
restore [locate_data_file OCC26379-csf_2.brep] cf
|
||||
mkvolume result cf -ni
|
||||
|
||||
vinit
|
||||
vsetdispmode 1
|
||||
vdisplay result
|
||||
vclear
|
||||
vinit View1
|
||||
vdisplay -dispMode 1 result
|
||||
vfit
|
||||
|
||||
set bug_info [vreadpixel 350 310 name]
|
||||
if {$bug_info != "DARKGOLDENROD3 1"} {
|
||||
puts "ERROR: OCC26379 is reproduced. Volume is incorrect."
|
||||
}
|
||||
if { [vreadpixel 350 310 -rgb -name] == "BLACK" } { puts "ERROR: OCC26379 is reproduced. Volume is incorrect." }
|
||||
|
||||
checkprops result -s 6.60933e+006
|
||||
checkshape result
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -1,25 +1,19 @@
|
||||
puts "========"
|
||||
puts "OCC26379"
|
||||
puts "0026379: Wrong result produced by the volume maker algorithm"
|
||||
puts "========"
|
||||
puts ""
|
||||
#######################################################
|
||||
# Wrong result produced by the volume maker algorithm
|
||||
#######################################################
|
||||
|
||||
restore [locate_data_file OCC26379-csf_3.brep] cf
|
||||
mkvolume result cf -ni
|
||||
|
||||
vinit
|
||||
vsetdispmode 1
|
||||
vdisplay result
|
||||
vclear
|
||||
vinit View1
|
||||
vdisplay -dispMode 1 result
|
||||
vfit
|
||||
|
||||
set bug_info [vreadpixel 350 310 name]
|
||||
if {$bug_info != "DARKGOLDENROD3 1"} {
|
||||
puts "ERROR: OCC26379 is reproduced. Volume is incorrect."
|
||||
}
|
||||
if { [vreadpixel 350 310 -rgb -name] == "BLACK" } { puts "ERROR: OCC26379 is reproduced. Volume is incorrect." }
|
||||
|
||||
checkprops result -s 7.22211e+006
|
||||
checkshape result
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -37,14 +37,8 @@ if {$nb != "3"} {
|
||||
}
|
||||
|
||||
# Check colors
|
||||
set color [XGetShapeColor DD 0:1:1:3 surf]
|
||||
if {$color != "RED"} {
|
||||
puts "Error: wrong color."
|
||||
}
|
||||
set color [XGetShapeColor DD 0:1:1:4 surf]
|
||||
if {$color != "DARKORANGE1"} {
|
||||
puts "Error: wrong color."
|
||||
}
|
||||
if {[XGetShapeColor DD 0:1:1:3 surf] != "RED"} { puts "Error: wrong color." }
|
||||
if {[XGetShapeColor DD 0:1:1:4 surf] != "DARKGOLDENROD1"} { puts "Error: wrong color." }
|
||||
|
||||
Close D
|
||||
Close DD
|
||||
|
@ -13,10 +13,10 @@ vdisplay -dispMode 1 b1 b2
|
||||
vfit
|
||||
vselprops selHighlight -dispMode -1
|
||||
vselect 0 0 400 400 1
|
||||
if { [vreadpixel 50 300 rgb name] != "GRAY66" } { puts "Error: b1 should be selected."}
|
||||
if { [vreadpixel 300 200 rgb name] != "GRAY66" } { puts "Error: b2 should be selected."}
|
||||
if { [vreadpixel 50 300 rgb name] != "GRAY73" } { puts "Error: b1 should be selected."}
|
||||
if { [vreadpixel 300 200 rgb name] != "GRAY73" } { puts "Error: b2 should be selected."}
|
||||
vselect 200 200
|
||||
if { [vreadpixel 50 300 rgb name] != "DARKGOLDENROD3" } { puts "Error: b1 should not be selected."}
|
||||
if { [vreadpixel 300 200 rgb name] != "GRAY66" } { puts "Error: b2 should be selected."}
|
||||
if { [vreadpixel 50 300 rgb name] != "DARKGOLDENROD" } { puts "Error: b1 should not be selected."}
|
||||
if { [vreadpixel 300 200 rgb name] != "GRAY73" } { puts "Error: b2 should be selected."}
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -1,37 +0,0 @@
|
||||
puts "============"
|
||||
puts "OCC22879"
|
||||
puts "============"
|
||||
puts ""
|
||||
#######################################################################
|
||||
# Possible bug in Opengl_togl_begin_layer_mode.cxx
|
||||
#######################################################################
|
||||
|
||||
vfont add [locate_data_file DejaVuSans.ttf] SansFont
|
||||
|
||||
set BugNumber OCC22879
|
||||
|
||||
vinit
|
||||
|
||||
vdrawtext t1 "Text Height=14" -2d -perspos -1 1 -pos 10 -10 0 -height 14 -color WHITE -font SansFont
|
||||
vdrawtext t2 "Text Height=25" -2d -perspos -1 1 -pos 10 -40 0 -height 25 -color WHITE -font SansFont
|
||||
vdrawtext t3 "Arial" -2d -perspos -1 1 -pos 10 -60 0 -height 18 -font SansFont -color RED
|
||||
vdrawtext t4 "Times New Roman" -2d -perspos -1 1 -pos 10 -80 0 -height 18 -font SansFont -color BLUE
|
||||
vdrawtext t5 "Subtitle" -2d -perspos -1 1 -pos 10 -110 0 -height 20 -font SansFont -color GREEN -disptype subtitle -subcolor 0.3 0.3 0.3
|
||||
vdrawtext t6 "Decal" -2d -perspos -1 1 -pos 10 -140 0 -height 20 -font SansFont -color BLUE -disptype decal -subcolor 1 0 0
|
||||
vdrawtext t7 "Blend" -2d -perspos -1 1 -pos 10 -170 0 -height 20 -font SansFont -color RED -disptype blend
|
||||
box b 50 -700 450 50 50 50
|
||||
vdisplay b
|
||||
vsetdispmode 1
|
||||
vsetcolor b ANTIQUEWHITE
|
||||
|
||||
checkcolor 24 55 0.753 0.000 0.000
|
||||
checkcolor 16 76 0.000 0.000 1.000
|
||||
checkcolor 25 107 0.000 1.000 0.000
|
||||
checkcolor 34 114 0.298 0.298 0.298
|
||||
checkcolor 24 131 0.922 0.000 0.000
|
||||
checkcolor 18 139 0.145 0.000 0.855
|
||||
checkcolor 56 160 1.000 0.000 0.000
|
||||
checkcolor 30 160 0.188 0.761 0.698
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
|
@ -37,12 +37,6 @@ vdump $imagedir/${casename}.png
|
||||
set aWireColor [vreadpixel 54 150 rgb name]
|
||||
set anEdgeColor [vreadpixel 100 90 rgb name]
|
||||
set aFaceColor [vreadpixel 30 200 rgb name]
|
||||
if {"$aWireColor" != "HOTPINK"} {
|
||||
puts "Error: wrong Wire color"
|
||||
}
|
||||
if {"$anEdgeColor" != "RED"} {
|
||||
puts "Error: wrong Edge color"
|
||||
}
|
||||
if {"$aFaceColor" != "GRAY62"} {
|
||||
puts "Error: wrong Face color"
|
||||
}
|
||||
if {"$aWireColor" != "HOTPINK"} { puts "Error: wrong Wire color" }
|
||||
if {"$anEdgeColor" != "RED"} { puts "Error: wrong Edge color" }
|
||||
if {"$aFaceColor" != "GRAY69"} { puts "Error: wrong Face color" }
|
||||
|
@ -10,7 +10,7 @@ vaxo
|
||||
|
||||
# create default color scale
|
||||
vcolorscale cs1 -demo -xy 0 0
|
||||
foreach {y aColor} {20 RED 60 DARKORANGE1 100 GOLD 140 GREENYELLOW 180 CHARTREUSE2 220 GREEN 250 MEDIUMSPRINGGREEN 290 CYAN 330 DODGERBLUE1 370 BLUE} { if { [vreadpixel 15 $y rgb name] != "$aColor" } { puts "Error: wrong color at $y" } }
|
||||
foreach {y aColor} {20 RED 60 DARKORANGE1 100 GOLD 140 GREENYELLOW 220 GREEN 250 MEDIUMSPRINGGREEN 290 CYAN 330 DODGERBLUE1 370 BLUE} { if { [vreadpixel 15 $y rgb name] != "$aColor" } { puts "Error: wrong color at $y" } }
|
||||
|
||||
# reduce color scale range and number of intervals
|
||||
vcolorscale cs2 -range 0 20 5 -xy 60 0
|
||||
@ -26,5 +26,5 @@ vcolorscale cs4 -color 1 0.42 0.35 0.8
|
||||
vcolorscale cs4 -color 5 pink
|
||||
vcolorscale cs4 -label 6 "last"
|
||||
vcolorscale cs4 -title "My color scale"
|
||||
foreach {y aColor} {60 PINK 120 RED 200 GREEN 280 BLUE 350 SLATEBLUE} { if { [vreadpixel 215 $y rgb name] != "$aColor" } { puts "Error: wrong color at $y" } }
|
||||
foreach {y aColor} {60 PINK 120 RED 200 GREEN 280 BLUE 350 LIGHTSTEELBLUE3} { if { [vreadpixel 215 $y rgb name] != "$aColor" } { puts "Error: wrong color at $y" } }
|
||||
vdump ${imagedir}/${casename}.png
|
||||
|
@ -1,24 +1,21 @@
|
||||
puts "========"
|
||||
puts "OCC25340"
|
||||
puts "0025340: Visualization, AIS_InteractiveContext - properly apply selection filters at Neutral point"
|
||||
puts "========"
|
||||
puts ""
|
||||
#############################################################################################
|
||||
# Visualization, AIS_InteractiveContext - properly apply selection filters at Neutral point
|
||||
#############################################################################################
|
||||
|
||||
pload QAcommands
|
||||
|
||||
vinit
|
||||
vinit View1
|
||||
|
||||
box b 1 2 3
|
||||
vdisplay b
|
||||
vfit
|
||||
vtrihedron t
|
||||
set color_1 [vreadpixel 87 25]
|
||||
set color_1 [vreadpixel 87 25 -rgb -name]
|
||||
|
||||
OCC25340
|
||||
vselect 87 25
|
||||
set color_2 [vreadpixel 87 25]
|
||||
set color_2 [vreadpixel 87 25 -rgb -name]
|
||||
|
||||
if {$color_2 != $color_1} {
|
||||
puts "ERROR: OCC25340 is reproduced"
|
||||
@ -26,11 +23,11 @@ if {$color_2 != $color_1} {
|
||||
puts " final color of trihedron is: $color_2"
|
||||
}
|
||||
|
||||
if {$color_2 != "0.43137255311012268 0.48235294222831726 0.54509806632995605 1"} {
|
||||
if {$color_2 != "LIGHTSTEELBLUE4"} {
|
||||
puts "ERROR: OCC25340 is reproduced"
|
||||
puts " additional investigation is needed"
|
||||
puts " expected color is: 0.43137255311012268 0.48235294222831726 0.54509806632995605 1"
|
||||
puts " current color is: $_color_2"
|
||||
puts " expected color is: LIGHTSTEELBLUE4"
|
||||
puts " current color is: $color_2"
|
||||
}
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -5,12 +5,11 @@ puts "========"
|
||||
box b 0 0 0 1 2 3
|
||||
|
||||
# prepare view
|
||||
vinit View1
|
||||
vclear
|
||||
vinit View1
|
||||
vglinfo
|
||||
vsetdispmode 1
|
||||
vaxo
|
||||
vdisplay b
|
||||
vdisplay -dispMode 1 b
|
||||
vfit
|
||||
|
||||
# customize object
|
||||
@ -19,7 +18,4 @@ vaspects b -subshapes b_3 -setcolor RED
|
||||
vaspects b -setmaterial PLASTIC
|
||||
|
||||
# validate results
|
||||
set aFaceColor [vreadpixel 128 256 rgb name]
|
||||
if {"$aFaceColor" != "RED4"} {
|
||||
puts "Error: wrong Face color"
|
||||
}
|
||||
if { [vreadpixel 128 256 -rgb -name] != "RED4"} { puts "Error: wrong Face color" }
|
||||
|
@ -3,13 +3,12 @@ puts "0025544: Visualization, TKOpenGl - support grayscale textures"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
vinit View1
|
||||
vclear
|
||||
vinit View1
|
||||
|
||||
box b 1 2 3
|
||||
vaxo
|
||||
vsetdispmode 1
|
||||
vdisplay b
|
||||
vdisplay -dispMode 1 b
|
||||
vtexture b 1 -modulate on
|
||||
vfit
|
||||
|
||||
@ -20,9 +19,5 @@ vtexture b 1 -modulate off
|
||||
set aColorDec [vreadpixel 290 180 rgb name]
|
||||
vdump $imagedir/${casename}_decal.png
|
||||
|
||||
if {"$aColorMod" != "GOLDENROD4"} {
|
||||
puts "Error: wrong color with modulation ON"
|
||||
}
|
||||
if {"$aColorDec" != "GRAY80"} {
|
||||
puts "Error: wrong color with modulation OFF"
|
||||
}
|
||||
if {"$aColorMod" != "GOLDENROD4"} { puts "Error: wrong color with modulation ON" }
|
||||
if {"$aColorDec" != "GRAY91"} { puts "Error: wrong color with modulation OFF" }
|
||||
|
@ -8,8 +8,8 @@ set aSubShapeTriang $imagedir/${casename}_subshape_triangulation.png
|
||||
set aShapeTriang $imagedir/${casename}_shape_triangulation.png
|
||||
set aDiff $imagedir/${casename}_diff.png
|
||||
|
||||
vinit View1
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vsetdispmode 1
|
||||
|
||||
@ -34,35 +34,23 @@ verase -inview b1
|
||||
vmoveto 250 347
|
||||
|
||||
set aColorV2B1 [vreadpixel 50 250 rgb name]
|
||||
if { $aColorV2B1 != "BLACK" } {
|
||||
puts "Error: box b1 (red) should NOT be visible in View2!"
|
||||
}
|
||||
if { $aColorV2B1 != "BLACK" } { puts "Error: box b1 (red) should NOT be visible in View2!" }
|
||||
|
||||
set aColorV2B2 [vreadpixel 200 350 rgb name]
|
||||
if { $aColorV2B2 != "GREEN3" } {
|
||||
puts "Error: box b2 (green) should be visible in View2!"
|
||||
}
|
||||
if { $aColorV2B2 != "GREEN2" } { puts "Error: box b2 (green) should be visible in View2!" }
|
||||
|
||||
set aColorV2B3 [vreadpixel 250 200 rgb name]
|
||||
if { $aColorV2B3 != "DARKGOLDENROD3" } {
|
||||
puts "Error: box b3 (goldenrod) should be visible in View2!"
|
||||
}
|
||||
if { $aColorV2B3 != "DARKGOLDENROD" } { puts "Error: box b3 (goldenrod) should be visible in View2!" }
|
||||
vdump $imagedir/${casename}_v2.png
|
||||
|
||||
vactivate View1
|
||||
vfit
|
||||
set aColorV1B1 [vreadpixel 50 250 rgb name]
|
||||
if { $aColorV1B1 != "RED3" } {
|
||||
puts "Error: box b1 (red) should be visible in View1!"
|
||||
}
|
||||
if { $aColorV1B1 != "RED2" } { puts "Error: box b1 (red) should be visible in View1!" }
|
||||
|
||||
set aColorV1B2 [vreadpixel 200 350 rgb name]
|
||||
if { $aColorV1B2 != "BLACK" } {
|
||||
puts "Error: box b2 (green) should NOT be visible in View1!"
|
||||
}
|
||||
if { $aColorV1B2 != "BLACK" } { puts "Error: box b2 (green) should NOT be visible in View1!" }
|
||||
|
||||
set aColorV1B3 [vreadpixel 250 200 rgb name]
|
||||
if { $aColorV1B3 != "DARKGOLDENROD3" } {
|
||||
puts "Error: box b3 (goldenrod) should be visible in View1!"
|
||||
}
|
||||
if { $aColorV1B3 != "DARKGOLDENROD" } { puts "Error: box b3 (goldenrod) should be visible in View1!" }
|
||||
vdump $imagedir/${casename}_v1.png
|
||||
|
@ -17,6 +17,6 @@ vfit
|
||||
vselprops dynHighlight -dispMode -1 -transp 0.5 -material PLASTIC
|
||||
vmoveto 250 250
|
||||
|
||||
if { [vreadpixel 250 250 rgb name] != "PALEGREEN3" } { puts "Error: wrong highlighting color" }
|
||||
if { [vreadpixel 250 250 rgb name] != "GRAY58" } { puts "Error: wrong highlighting color" }
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -24,6 +24,6 @@ verase
|
||||
|
||||
# rotation
|
||||
vrotate -mouseStart 100 100 -mouseMove 300 300
|
||||
if {"[vreadpixel 220 50 rgb name]" != "GOLDENROD2"} { puts "Error: Rotation is not correct" }
|
||||
if {"[vreadpixel 220 50 rgb name]" != "GOLDENROD3"} { puts "Error: Rotation is not correct" }
|
||||
|
||||
vdump ${imagedir}/${casename}.png
|
||||
|
@ -41,8 +41,6 @@ vrotate -mouseStart ${x_mouse_start_coord} ${y_mouse_start_coord} -mouseMove ${x
|
||||
vselect 0 0
|
||||
|
||||
# check color
|
||||
if {"[vreadpixel ${x_check_coord} ${y_check_coord} rgb name]" != "GOLDENROD2"} {
|
||||
puts "Error : Rotation is not correct"
|
||||
}
|
||||
if {"[vreadpixel ${x_check_coord} ${y_check_coord} rgb name]" != "GOLDENROD3"} { puts "Error : Rotation is not correct" }
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -49,7 +49,7 @@ set aColor3 [vreadpixel 225 150 rgb name]
|
||||
set aColor4 [vreadpixel 325 200 rgb name]
|
||||
|
||||
# note that aColor2 is not expected to be capped
|
||||
if { "$aColor0" != "GRAY61" || "$aColor1" != "GRAY61" || "$aColor2" == "GRAY61" || "$aColor3" != "GRAY61" || "$aColor4" != "GRAY61" } {
|
||||
if { "$aColor0" != "GRAY72" || "$aColor1" != "GRAY72" || "$aColor2" == "GRAY72" || "$aColor3" != "GRAY72" || "$aColor4" != "GRAY72" } {
|
||||
puts "Error: capping color does not match"
|
||||
}
|
||||
|
||||
|
@ -17,17 +17,11 @@ vcircle circle radP1 radP2 radP3 1
|
||||
vfit
|
||||
|
||||
vselect 40 120 185 320
|
||||
set aColor [vreadpixel 120 200 rgb name]
|
||||
if {$aColor != "DARKGOLDENROD3"} {
|
||||
puts "ERROR: the circle is selected with no overlap mode activated"
|
||||
}
|
||||
if {[vreadpixel 120 200 rgb name] != "DARKGOLDENROD"} { puts "ERROR: the circle is selected with no overlap mode activated" }
|
||||
|
||||
vselect 0 0
|
||||
|
||||
vselect 40 120 185 320 -allowoverlap 1
|
||||
set aColor [vreadpixel 120 200 rgb name]
|
||||
if {$aColor != "GRAY66"} {
|
||||
puts "ERROR: the circle is not selected with overlap mode activated"
|
||||
}
|
||||
if {[vreadpixel 120 200 rgb name] != "GRAY73"} { puts "ERROR: the circle is not selected with overlap mode activated" }
|
||||
|
||||
vdump ${imagedir}/${casename}.png
|
||||
|
@ -24,11 +24,11 @@ vsetlocation bz2 -25 -25 -25
|
||||
|
||||
vselect 0 0
|
||||
vselect 387 77
|
||||
if { [vreadpixel 387 77 rgb name] != "GRAY66" } { puts "Error picking zoom persistence object(s)" }
|
||||
if { [vreadpixel 387 77 rgb name] != "GRAY73" } { puts "Error picking zoom persistence object(s)" }
|
||||
|
||||
vselect 0 0
|
||||
vselect 330 120 410 50
|
||||
if { [vreadpixel 387 77 rgb name] != "GRAY66" || [vreadpixel 352 96 rgb name] != "GRAY66" } { puts "Error selecting zoom persistence object(s)" }
|
||||
if { [vreadpixel 387 77 rgb name] != "GRAY73" || [vreadpixel 352 96 rgb name] != "GRAY73" } { puts "Error selecting zoom persistence object(s)" }
|
||||
|
||||
# 2) Rotate persistence
|
||||
|
||||
@ -37,11 +37,11 @@ vdisplay br -dispMode 1 -highMode 1 -trsfPers rotate -trsfPersPos -200 -200 -200
|
||||
vsetmaterial br PLASTIC
|
||||
vselect 0 0
|
||||
vselect 160 200
|
||||
if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error picking rotate persistence object" }
|
||||
if { [vreadpixel 160 180 rgb name] != "GRAY89" } { puts "Error picking rotate persistence object" }
|
||||
|
||||
vselect 0 0
|
||||
vselect 130 230 190 170
|
||||
if { [vreadpixel 160 180 rgb name] != "WHITE" } { puts "Error selecting rotate persistence object" }
|
||||
if { [vreadpixel 160 180 rgb name] != "GRAY89" } { puts "Error selecting rotate persistence object" }
|
||||
|
||||
# 3) Zoom + Rotate persistence
|
||||
|
||||
@ -51,20 +51,20 @@ vdisplay bzr -dispMode 1 -highMode 1 -trsfPers zoomRotate -trsfPersPos -200 100
|
||||
vsetmaterial bzr PLASTIC
|
||||
vselect 0 0
|
||||
vselect 250 90
|
||||
if { [vreadpixel 250 90 rgb name] != "WHITE" } { puts "Error picking zoom-rotate persistence object" }
|
||||
if { [vreadpixel 250 90 rgb name] != "GRAY89" } { puts "Error picking zoom-rotate persistence object" }
|
||||
vselect 0 0
|
||||
vselect 200 70 286 110
|
||||
if { [vreadpixel 250 90 rgb name] != "WHITE" } { puts "Error selecting zoom-rotate persistence object" }
|
||||
if { [vreadpixel 250 90 rgb name] != "GRAY89" } { puts "Error selecting zoom-rotate persistence object" }
|
||||
|
||||
# 4) Trihedron persistence
|
||||
|
||||
vdisplay bt -dispMode 1 -highMode 1 -trsfPers trihedron -trsfPersPos -1 -1 62
|
||||
vselect 0 0
|
||||
vselect 132 300
|
||||
if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error picking trihedron persistence object" }
|
||||
if { [vreadpixel 132 300 rgb name] != "GRAY73" } { puts "Error picking trihedron persistence object" }
|
||||
vselect 0 0
|
||||
vselect 50 223 235 395
|
||||
if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error selecting trihedron persistence object" }
|
||||
if { [vreadpixel 132 300 rgb name] != "GRAY73" } { puts "Error selecting trihedron persistence object" }
|
||||
|
||||
vselect 50 410 410 50
|
||||
vstate -entities
|
||||
|
@ -18,10 +18,10 @@ vaxo
|
||||
vfit
|
||||
vpan 200 0
|
||||
vmoveto 399 200
|
||||
if { [vreadpixel 399 200 rgb name] != "DARKTURQUOISE" } { puts "Error: incorrect color after forward panning in View1" }
|
||||
if { [vreadpixel 399 200 rgb name] != "CYAN2" } { puts "Error: incorrect color after forward panning in View1" }
|
||||
vpan -200 0
|
||||
vmoveto 200 200
|
||||
if { [vreadpixel 200 200 rgb name] != "DARKTURQUOISE" } { puts "Error: incorrect color after backward panning in View1" }
|
||||
if { [vreadpixel 200 200 rgb name] != "CYAN2" } { puts "Error: incorrect color after backward panning in View1" }
|
||||
vdump ${imagedir}/${casename}_1.png
|
||||
|
||||
# Test panning with aspect ratio 1:2
|
||||
@ -30,10 +30,10 @@ vaxo
|
||||
vfit
|
||||
vpan 100 0
|
||||
vmoveto 199 100
|
||||
if { [vreadpixel 199 100 rgb name] != "DARKTURQUOISE" } { puts "Error: incorrect color after forward panning in View2" }
|
||||
if { [vreadpixel 199 100 rgb name] != "CYAN2" } { puts "Error: incorrect color after forward panning in View2" }
|
||||
vpan -100 0
|
||||
vmoveto 100 100
|
||||
if { [vreadpixel 100 100 rgb name] != "DARKTURQUOISE" } { puts "Error: incorrect color after backward panning in View2" }
|
||||
if { [vreadpixel 100 100 rgb name] != "CYAN2" } { puts "Error: incorrect color after backward panning in View2" }
|
||||
vdump ${imagedir}/${casename}_2.png
|
||||
|
||||
# Test panning with aspect ratio 2:1
|
||||
@ -42,8 +42,8 @@ vaxo
|
||||
vfit
|
||||
vpan 200 0
|
||||
vmoveto 399 100
|
||||
if { [vreadpixel 399 100 rgb name] != "DARKTURQUOISE" } { puts "Error: incorrect color after forward panning in View3" }
|
||||
if { [vreadpixel 399 100 rgb name] != "CYAN2" } { puts "Error: incorrect color after forward panning in View3" }
|
||||
vpan -200 0
|
||||
vmoveto 200 100
|
||||
if { [vreadpixel 200 100 rgb name] != "DARKTURQUOISE" } { puts "Error: incorrect color after backward panning in View3" }
|
||||
if { [vreadpixel 200 100 rgb name] != "CYAN2" } { puts "Error: incorrect color after backward panning in View3" }
|
||||
vdump ${imagedir}/${casename}_3.png
|
||||
|
@ -1,36 +1,24 @@
|
||||
puts "============"
|
||||
puts "CR26680"
|
||||
puts "0026680: Visualization - Changed behavior of mesh visualization and selection in OMF sample"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
##########################################################################################
|
||||
puts "Visualization - Changed behavior of mesh visualization and selection in OMF sample"
|
||||
##########################################################################################
|
||||
|
||||
pload VISUALIZATION XDE
|
||||
|
||||
vinit
|
||||
vinit View1
|
||||
meshfromstl m [locate_data_file bug26680.stl]
|
||||
meshcolors m elem2 1
|
||||
|
||||
vselmode 0 1
|
||||
|
||||
vmoveto 200 200
|
||||
if {[vreadpixel 197 257 rgb name] != "CYAN"} {
|
||||
puts "ERROR: presentation for dynamic highlight of the object is wrong!"
|
||||
}
|
||||
if {[vreadpixel 197 257 rgb name] != "CYAN"} { puts "ERROR: presentation for dynamic highlight of the object is wrong!" }
|
||||
vmoveto 0 0
|
||||
if {[vreadpixel 197 257 rgb name] != "BLUE2"} {
|
||||
puts "ERROR: the object is not unhighlighted after dynamic highlight!"
|
||||
}
|
||||
if {[vreadpixel 197 257 rgb name] != "BLUE"} { puts "ERROR: the object is not unhighlighted after dynamic highlight!" }
|
||||
|
||||
vselect 200 200
|
||||
if {[vreadpixel 197 257 rgb name] != "GRAY93"} {
|
||||
puts "ERROR: presentation for selection highlight is wrong!"
|
||||
}
|
||||
if {[vreadpixel 197 257 rgb name] != "GRAY86"} { puts "ERROR: presentation for selection highlight is wrong!" }
|
||||
vselect 0 0
|
||||
if {[vreadpixel 197 257 rgb name] != "BLUE2"} {
|
||||
puts "ERROR: the object is not unhighlighted after selection highlight!"
|
||||
}
|
||||
if {[vreadpixel 197 257 rgb name] != "BLUE"} { puts "ERROR: the object is not unhighlighted after selection highlight!" }
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -1,15 +1,11 @@
|
||||
puts "============"
|
||||
puts "CR26719"
|
||||
puts "0026719: Visualization - cannot pick zoom persistent object"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
##########################################################################################
|
||||
puts "Visualization - cannot pick zoom persistent object"
|
||||
##########################################################################################
|
||||
|
||||
pload VISUALIZATION MODELING
|
||||
|
||||
vinit
|
||||
vinit View1
|
||||
vsetdispmode 1
|
||||
|
||||
restore [locate_data_file face1.brep] f
|
||||
@ -25,12 +21,8 @@ vviewparams -eye 0.7 -1.14 -0.17
|
||||
# with dynamic highlight color, check that the face is
|
||||
# not highlighted
|
||||
vmoveto 280 290
|
||||
if {[vreadpixel 297 297 name] != "CYAN 1"} {
|
||||
puts "ERROR: zoom persistent box is not highlighted dynamically!"
|
||||
}
|
||||
if {[vreadpixel 372 210 name] != "GOLDENROD1 1"} {
|
||||
puts "ERROR: the shape behind zoom persistent object was highlighted instead!"
|
||||
}
|
||||
if {[vreadpixel 297 297 -rgb -name] != "CYAN"} { puts "ERROR: zoom persistent box is not highlighted dynamically!" }
|
||||
if {[vreadpixel 372 210 -rgb -name] != "GOLDENROD3"} { puts "ERROR: the shape behind zoom persistent object was highlighted instead!" }
|
||||
vdump ${imagedir}/${casename}_1.png
|
||||
|
||||
vmoveto 0 0
|
||||
@ -46,24 +38,14 @@ vviewparams -eye 0.96 1.053 0.31
|
||||
# will be highlighted dynamically
|
||||
vmoveto 264 135
|
||||
|
||||
if {[vreadpixel 275 142 name] != "CYAN 1"} {
|
||||
puts "ERROR: zoom persistent box is not highlighted dynamically in precision test!"
|
||||
}
|
||||
if {[vreadpixel 243 123 name] != "LIGHTGOLDENROD1 1"} {
|
||||
puts "ERROR: the shape behind zoom persistent object was highlighted instead in precision test!"
|
||||
}
|
||||
if {[vreadpixel 275 142 -rgb -name] != "CYAN"} { puts "ERROR: zoom persistent box is not highlighted dynamically in precision test!" }
|
||||
if {[vreadpixel 243 123 -rgb -name] != "BURLYWOOD2"} { puts "ERROR: the shape behind zoom persistent object was highlighted instead in precision test!" }
|
||||
vdump ${imagedir}/${casename}_2.png
|
||||
vmoveto 0 0
|
||||
|
||||
# move to a point on the face and check if it
|
||||
# will be highlighted dynamically
|
||||
vmoveto 259 135
|
||||
if {[vreadpixel 275 142 name] != "GOLDENROD3 1"} {
|
||||
puts "ERROR: zoom persistent box is highlighted instead in precision test!"
|
||||
}
|
||||
if {[vreadpixel 243 123 name] != "CYAN 1"} {
|
||||
puts "ERROR: the shape behind zoom persistent object was not highlighted dynamically in precision test!"
|
||||
}
|
||||
if {[vreadpixel 275 142 -rgb -name] != "DARKGOLDENROD"} { puts "ERROR: zoom persistent box is highlighted instead in precision test!" }
|
||||
if {[vreadpixel 243 123 -rgb -name] != "CYAN"} { puts "ERROR: the shape behind zoom persistent object was not highlighted dynamically in precision test!" }
|
||||
vdump ${imagedir}/${casename}_3.png
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
|
@ -4,24 +4,19 @@ puts "Tests capping plane rendering with connected structures"
|
||||
puts "============"
|
||||
puts ""
|
||||
|
||||
vinit View1
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vsetdispmode 1
|
||||
box b 1 1 1
|
||||
vdisplay b
|
||||
vfit
|
||||
|
||||
vclipplane create pln
|
||||
vclipplane set pln view Driver1/Viewer1/View1
|
||||
vclipplane change pln equation 0 1 0 -0.5
|
||||
vclipplane change pln capping on
|
||||
vclipplane pln -set Driver1/Viewer1/View1 -equation 0 1 0 -0.5 -capping on
|
||||
|
||||
vdump $imagedir/${casename}_normal.png
|
||||
set aColorNorm [vreadpixel 200 250 rgb name]
|
||||
if { "$aColorNorm" != "GRAY13" } {
|
||||
puts "Error: Expected color of capping plane is GRAY13 (normal presentation). Actial is $aColorNorm"
|
||||
}
|
||||
if { "$aColorNorm" != "GRAY14" } { puts "Error: Expected color of capping plane is GRAY14 (normal presentation). Actial is $aColorNorm" }
|
||||
|
||||
vclear
|
||||
|
||||
@ -29,6 +24,4 @@ vconnectto bb 0 0 0 b
|
||||
vdump $imagedir/${casename}_connected.png
|
||||
set aColorConn [vreadpixel 200 250 rgb name]
|
||||
|
||||
if { "$aColorConn" != "GRAY13" } {
|
||||
puts "Error: Expected color of capping plane is GRAY13 (connected presentation). Actial is $aColorConn"
|
||||
}
|
||||
if { "$aColorConn" != "GRAY14" } { puts "Error: Expected color of capping plane is GRAY14 (connected presentation). Actial is $aColorConn" }
|
||||
|
@ -1,10 +1,7 @@
|
||||
puts "========"
|
||||
puts "OCC26960"
|
||||
puts "0026960: Visualization, TKOpenGl - update transformation of dynamically highlighted presentation"
|
||||
puts "========"
|
||||
puts ""
|
||||
##################################################################
|
||||
puts "Visualization, TKOpenGl - update transformation of dynamically highlighted presentation"
|
||||
##################################################################
|
||||
|
||||
pload VISUALIZATION MODELING
|
||||
|
||||
@ -17,12 +14,8 @@ vdisplay -dispmode 1 -highmode 1 b
|
||||
vfit
|
||||
vselmode 4 1
|
||||
vmoveto 250 250
|
||||
if {[vreadpixel 350 140 rgb name] != "BLACK"} {
|
||||
puts "ERROR: wrong inital location"
|
||||
}
|
||||
if {[vreadpixel 350 140 rgb name] != "BLACK"} { puts "ERROR: wrong inital location" }
|
||||
vsetlocation b 0.5 0 0
|
||||
if {[vreadpixel 350 140 rgb name] != "DARKTURQUOISE"} {
|
||||
puts "ERROR: the transformation was not applied to highlight structure"
|
||||
}
|
||||
if {[vreadpixel 350 140 rgb name] != "CYAN2"} { puts "ERROR: the transformation was not applied to highlight structure" }
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -1,6 +1,5 @@
|
||||
puts "========"
|
||||
puts "OCC27083"
|
||||
puts "Visualization, Ray Tracing - shape with visible face boundaries disappears after turning the ray-tracing on"
|
||||
puts "0027083: Visualization, Ray Tracing - shape with visible face boundaries disappears after turning the ray-tracing on"
|
||||
puts "========"
|
||||
puts ""
|
||||
|
||||
@ -16,12 +15,7 @@ vfit
|
||||
vaspects b -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED -setFaceBoundaryWidth 3
|
||||
vraytrace 1
|
||||
|
||||
if {[vreadpixel 295 255 name] != "GOLDENROD4 0"} {
|
||||
puts "ERROR: the box with boundary aspect set is not shown in ray-tracing mode!"
|
||||
}
|
||||
|
||||
if {[vreadpixel 105 58 name] != "RED 1"} {
|
||||
puts "ERROR: the box's boundaries are not shown in ray-tracing mode!"
|
||||
}
|
||||
if {[vreadpixel 295 255 -rgb -name] != "DARKGOLDENROD"} { puts "ERROR: the box with boundary aspect set is not shown in ray-tracing mode!" }
|
||||
if {[vreadpixel 105 58 -rgb -name] != "RED"} { puts "ERROR: the box's boundaries are not shown in ray-tracing mode!" }
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -1,30 +1,21 @@
|
||||
puts "========"
|
||||
puts "OCC27536"
|
||||
puts "0027536: Visualization - incorrect behavior of zoom persisted objects"
|
||||
puts "========"
|
||||
puts ""
|
||||
##################################################################
|
||||
puts "Visualization - incorrect behavior of zoom persisted objects"
|
||||
##################################################################
|
||||
|
||||
set anImage1 $imagedir/${casename}_1.png
|
||||
set anImage2 $imagedir/${casename}_2.png
|
||||
|
||||
vinit
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
|
||||
box b -50 -50 -50 100 100 100
|
||||
vdisplay b -trsfPers zoom -trsfPersPos 0 0 0 -dispmode 1
|
||||
|
||||
vdump $anImage1
|
||||
vdump $imagedir/${casename}_1.png
|
||||
|
||||
vinit View2 w=200 h=400
|
||||
vaxo
|
||||
vfit
|
||||
|
||||
# Check that box was't resized in small view
|
||||
if {[vreadpixel 165 200 name] != "DARKGOLDENROD3 1"} {
|
||||
puts "ERROR: zoom persistent box is resized on view sizes changed!"
|
||||
}
|
||||
if {[vreadpixel 165 200 -rgb -name] != "DARKGOLDENROD"} { puts "ERROR: zoom persistent box is resized on view sizes changed!" }
|
||||
|
||||
vdump $anImage2
|
||||
vdump $imagedir/${casename}_2.png
|
||||
|
@ -21,8 +21,8 @@ vdisplay -2d topLeft -topmost pp
|
||||
vselmode pp 0 0
|
||||
vmoveto 245 190
|
||||
|
||||
if { [vreadpixel 235 140 rgb name] == "DARKTURQUOISE" } { puts "Error: top should NOT be highlighted" }
|
||||
if { [vreadpixel 235 190 rgb name] != "DARKTURQUOISE" } { puts "Error: bottom should be highlighted" }
|
||||
if { [vreadpixel 235 140 rgb name] == "CYAN2" } { puts "Error: top should NOT be highlighted" }
|
||||
if { [vreadpixel 235 190 rgb name] != "CYAN2" } { puts "Error: bottom should be highlighted" }
|
||||
vseldump $imagedir/${casename}_sel_depth.png -type depth
|
||||
vseldump $imagedir/${casename}_sel_entity.png -type entity
|
||||
|
||||
@ -30,8 +30,8 @@ vcamera -persp
|
||||
|
||||
vmoveto 0 0
|
||||
vmoveto 245 190
|
||||
if { [vreadpixel 235 140 rgb name] == "DARKTURQUOISE" } { puts "Error: top should NOT be highlighted" }
|
||||
if { [vreadpixel 235 190 rgb name] != "DARKTURQUOISE" } { puts "Error: bottom should be highlighted" }
|
||||
if { [vreadpixel 235 140 rgb name] == "CYAN2" } { puts "Error: top should NOT be highlighted" }
|
||||
if { [vreadpixel 235 190 rgb name] != "CYAN2" } { puts "Error: bottom should be highlighted" }
|
||||
|
||||
vseldump $imagedir/${casename}_perps_sel_depth.png -type depth
|
||||
vseldump $imagedir/${casename}_persp_sel_entity.png -type entity
|
||||
|
@ -1,19 +1,13 @@
|
||||
puts "========"
|
||||
puts "OCC27629"
|
||||
puts "0027629: Visualization - apply a correct model-world matrix to normals in fixed function pipeline with enabled zoom persistence"
|
||||
puts "========"
|
||||
puts ""
|
||||
##############################################################################################################################
|
||||
puts "Visualization - apply a correct model-world matrix to normals in fixed function pipeline with enabled zoom persistence."
|
||||
##############################################################################################################################
|
||||
|
||||
vinit
|
||||
vinit View1
|
||||
box b0 25 25 25
|
||||
vsetdispmode 1
|
||||
vdisplay b0 -trsfPers zoom
|
||||
vdisplay b0 -dispMode 1 -trsfPers zoom
|
||||
vzoom 10
|
||||
|
||||
if { [vreadpixel 220 200 name] != "DARKGOLDENROD3 1"} {
|
||||
puts "Error: normals aren't normalized!"
|
||||
}
|
||||
if { [vreadpixel 220 200 -rgb -name] != "DARKGOLDENROD"} { puts "Error: normals aren't normalized!" }
|
||||
|
||||
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
|
||||
vdump ${imagedir}/${test_image}.png
|
||||
|
@ -101,4 +101,4 @@ vdump $imagedir/${casename}_bl.png
|
||||
vmoveto 110 385
|
||||
vselect 110 385
|
||||
set aColor [vreadpixel 110 385 rgb name]
|
||||
if { $aColor != "WHITE" } { puts "Error: wrong object is highlighted" }
|
||||
if { $aColor != "GRAY89" } { puts "Error: wrong object is highlighted" }
|
||||
|
@ -26,7 +26,7 @@ vselect 100 300
|
||||
vmoveto 0 0
|
||||
|
||||
set aSelColor [vreadpixel 100 300 rgb name]
|
||||
if { $aSelColor != "GRAY72"} { puts "Error: wrong object has been selected" }
|
||||
if { $aSelColor != "GRAY76"} { puts "Error: wrong object has been selected" }
|
||||
|
||||
vdisplay -dispMode 0 -osd -2d -trsfPersPos -1 1 v
|
||||
|
||||
|
@ -12,6 +12,6 @@ box b 30 40 50
|
||||
vdisplay -trsfPers trihedron -trsfPersPos -1 -1 40 -dispMode 1 -highMode 1 b
|
||||
vselmode b 4 1
|
||||
vmoveto 50 350
|
||||
if { [vreadpixel 50 350 rgb name] != "DARKTURQUOISE" } { puts "Error: face is not highlighted" }
|
||||
if { [vreadpixel 50 350 rgb name] != "CYAN2" } { puts "Error: face is not highlighted" }
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -19,6 +19,6 @@ vfit
|
||||
|
||||
vviewparams -scale 6.66 -eye 48 43 -210 -at 50 45 -95
|
||||
|
||||
if { [vreadpixel 100 300 rgb name] != "GRAY74" } { puts "Error: gradient background is not displayed" }
|
||||
if { [vreadpixel 100 300 -rgb -name] != "GRAY75" } { puts "Error: gradient background is not displayed" }
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -66,7 +66,7 @@ vclipplane pln -equation -1 0 0 2 -set
|
||||
|
||||
set aColor1 [vreadpixel 320 160 rgb name]
|
||||
set aColor2 [vreadpixel 80 250 rgb name]
|
||||
if { "$aColor1" != "BLACK" } { puts "Error: zoom-persistent object is not clipped" }
|
||||
if { "$aColor2" != "GOLDENROD3" } { puts "Error: zoom-persistent object is clipped" }
|
||||
if { "$aColor1" != "BLACK" } { puts "Error: zoom-persistent object is not clipped" }
|
||||
if { "$aColor2" != "DARKGOLDENROD" } { puts "Error: zoom-persistent object is clipped" }
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
@ -18,6 +18,6 @@ vmoveto 250 250
|
||||
vsetlocation b 2 1 0
|
||||
set aColor1 [vreadpixel 220 200 rgb name]
|
||||
set aColor2 [vreadpixel 350 220 rgb name]
|
||||
if { "$aColor1" != "BLACK" || "$aColor2" != "DARKTURQUOISE" } { puts "Error: dynamic highlighting is not updated" }
|
||||
if { "$aColor1" != "BLACK" || "$aColor2" != "CYAN2" } { puts "Error: dynamic highlighting is not updated" }
|
||||
|
||||
vdump $imagedir/${casename}.png
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user