mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0028095: Draw Harness, ViewerTest - use RGBA format instead of BGRA within vreadpixel
OpenGl_Workspace::BufferDump() now implicitly converts RGBA dump into requested BGR, BGRA and RGB image. DRAW command dversion is improved to report OpenGL variant used (desktop or ES); reporting of version of MSVC is corrected for VC14 and above; reporting of HAVE_OPENCL option is removed. Usage of command vdump is corrected in some tests to specify extension .png for an image file. Compiler warning is eliminated in OpenGl_Text.cxx (OpenGL ES mode only).
This commit is contained in:
parent
564c82b4f2
commit
f9f740d6b0
@ -293,10 +293,10 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
|
|||||||
#else
|
#else
|
||||||
di << "FreeImage disabled\n";
|
di << "FreeImage disabled\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_GLES2
|
||||||
di << "OpenCL enabled (HAVE_OPENCL)\n";
|
di << "OpenGL: ES2\n";
|
||||||
#else
|
#else
|
||||||
di << "OpenCL disabled\n";
|
di << "OpenGL: desktop\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_VTK
|
#ifdef HAVE_VTK
|
||||||
di << "VTK enabled (HAVE_VTK)\n";
|
di << "VTK enabled (HAVE_VTK)\n";
|
||||||
@ -323,7 +323,11 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
|
|||||||
#elif defined(__SUNPRO_C)
|
#elif defined(__SUNPRO_C)
|
||||||
di << "Compiler: Sun Studio (__SUNPRO_C = " << __SUNPROC_C << ")\n";
|
di << "Compiler: Sun Studio (__SUNPRO_C = " << __SUNPROC_C << ")\n";
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
di << "Compiler: MS Visual C++ " << (int)(_MSC_VER/100-6) << "." << (int)((_MSC_VER/10)-60-10*(int)(_MSC_VER/100-6)) << " (_MSC_FULL_VER = " << _MSC_FULL_VER << ")\n";
|
#if _MSC_VER < 1900
|
||||||
|
di << "Compiler: MS Visual C++ " << (int)(_MSC_VER/100-6) << "." << (int)((_MSC_VER/10)-60-10*(int)(_MSC_VER/100-6)) << " (_MSC_FULL_VER = " << _MSC_FULL_VER << ")\n";
|
||||||
|
#else
|
||||||
|
di << "Compiler: MS Visual C++ " << (int)(_MSC_VER/100-5) << "." << (int)((_MSC_VER/10)-50-10*(int)(_MSC_VER/100-5)) << " (_MSC_FULL_VER = " << _MSC_FULL_VER << ")\n";
|
||||||
|
#endif
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
di << "Compiler: GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "\n";
|
di << "Compiler: GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "\n";
|
||||||
#else
|
#else
|
||||||
|
@ -338,3 +338,73 @@ Quantity_Color Image_PixMap::PixelColor (const Standard_Integer theX,
|
|||||||
theAlpha = 0.0; // transparent
|
theAlpha = 0.0; // transparent
|
||||||
return Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB);
|
return Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : SwapRgbaBgra
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
bool Image_PixMap::SwapRgbaBgra (Image_PixMap& theImage)
|
||||||
|
{
|
||||||
|
switch (theImage.Format())
|
||||||
|
{
|
||||||
|
case Image_PixMap::ImgBGR32:
|
||||||
|
case Image_PixMap::ImgRGB32:
|
||||||
|
case Image_PixMap::ImgBGRA:
|
||||||
|
case Image_PixMap::ImgRGBA:
|
||||||
|
{
|
||||||
|
const bool toResetAlpha = theImage.Format() == Image_PixMap::ImgBGR32
|
||||||
|
|| theImage.Format() == Image_PixMap::ImgRGB32;
|
||||||
|
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||||
|
{
|
||||||
|
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||||
|
{
|
||||||
|
Image_ColorRGBA& aPixel = theImage.ChangeValue<Image_ColorRGBA> (aRow, aCol);
|
||||||
|
Image_ColorBGRA aPixelCopy = theImage.Value <Image_ColorBGRA> (aRow, aCol);
|
||||||
|
aPixel.r() = aPixelCopy.r();
|
||||||
|
aPixel.g() = aPixelCopy.g();
|
||||||
|
aPixel.b() = aPixelCopy.b();
|
||||||
|
if (toResetAlpha)
|
||||||
|
{
|
||||||
|
aPixel.a() = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case Image_PixMap::ImgBGR:
|
||||||
|
case Image_PixMap::ImgRGB:
|
||||||
|
{
|
||||||
|
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||||
|
{
|
||||||
|
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||||
|
{
|
||||||
|
Image_ColorRGB& aPixel = theImage.ChangeValue<Image_ColorRGB> (aRow, aCol);
|
||||||
|
Image_ColorBGR aPixelCopy = theImage.Value <Image_ColorBGR> (aRow, aCol);
|
||||||
|
aPixel.r() = aPixelCopy.r();
|
||||||
|
aPixel.g() = aPixelCopy.g();
|
||||||
|
aPixel.b() = aPixelCopy.b();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case Image_PixMap::ImgBGRF:
|
||||||
|
case Image_PixMap::ImgRGBF:
|
||||||
|
case Image_PixMap::ImgBGRAF:
|
||||||
|
case Image_PixMap::ImgRGBAF:
|
||||||
|
{
|
||||||
|
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||||
|
{
|
||||||
|
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
|
||||||
|
{
|
||||||
|
Image_ColorRGBF& aPixel = theImage.ChangeValue<Image_ColorRGBF> (aRow, aCol);
|
||||||
|
Image_ColorBGRF aPixelCopy = theImage.Value <Image_ColorBGRF> (aRow, aCol);
|
||||||
|
aPixel.r() = aPixelCopy.r();
|
||||||
|
aPixel.g() = aPixelCopy.g();
|
||||||
|
aPixel.b() = aPixelCopy.b();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -53,6 +53,16 @@ public:
|
|||||||
return !aUnion.myChar[0];
|
return !aUnion.myChar[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Auxiliary method for swapping bytes between RGB and BGR formats.
|
||||||
|
//! This method modifies the image data but does not change pixel format!
|
||||||
|
//! Method will fail if pixel format is not one of the following:
|
||||||
|
//! - ImgRGB32 / ImgBGR32
|
||||||
|
//! - ImgRGBA / ImgBGRA
|
||||||
|
//! - ImgRGB / ImgBGR
|
||||||
|
//! - ImgRGBF / ImgBGRF
|
||||||
|
//! - ImgRGBAF / ImgBGRAF
|
||||||
|
Standard_EXPORT static bool SwapRgbaBgra (Image_PixMap& theImage);
|
||||||
|
|
||||||
public: // high-level API
|
public: // high-level API
|
||||||
|
|
||||||
inline ImgFormat Format() const
|
inline ImgFormat Format() const
|
||||||
|
@ -812,17 +812,18 @@ Standard_Boolean OpenGl_Context::Init (const Aspect_Drawable theWindow,
|
|||||||
// function : ResetErrors
|
// function : ResetErrors
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void OpenGl_Context::ResetErrors (const bool theToPrintErrors)
|
bool OpenGl_Context::ResetErrors (const bool theToPrintErrors)
|
||||||
{
|
{
|
||||||
int aPrevErr = 0;
|
int aPrevErr = 0;
|
||||||
int anErr = ::glGetError();
|
int anErr = ::glGetError();
|
||||||
|
const bool hasError = anErr != GL_NO_ERROR;
|
||||||
if (!theToPrintErrors)
|
if (!theToPrintErrors)
|
||||||
{
|
{
|
||||||
for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = ::glGetError())
|
for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = ::glGetError())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
return;
|
return hasError;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = ::glGetError())
|
for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = ::glGetError())
|
||||||
@ -849,6 +850,7 @@ void OpenGl_Context::ResetErrors (const bool theToPrintErrors)
|
|||||||
const TCollection_ExtendedString aMsg = TCollection_ExtendedString ("Unhandled GL error: ") + anErrId;
|
const TCollection_ExtendedString aMsg = TCollection_ExtendedString ("Unhandled GL error: ") + anErrId;
|
||||||
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0, GL_DEBUG_SEVERITY_LOW, aMsg);
|
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0, GL_DEBUG_SEVERITY_LOW, aMsg);
|
||||||
}
|
}
|
||||||
|
return hasError;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@ -318,7 +318,8 @@ public:
|
|||||||
const OpenGl_GlFunctions* Functions() const { return myFuncs.operator->(); }
|
const OpenGl_GlFunctions* Functions() const { return myFuncs.operator->(); }
|
||||||
|
|
||||||
//! Clean up errors stack for this GL context (glGetError() in loop).
|
//! Clean up errors stack for this GL context (glGetError() in loop).
|
||||||
Standard_EXPORT void ResetErrors (const bool theToPrintErrors = false);
|
//! @return true if some error has been cleared
|
||||||
|
Standard_EXPORT bool ResetErrors (const bool theToPrintErrors = false);
|
||||||
|
|
||||||
//! This method uses system-dependent API to retrieve information
|
//! This method uses system-dependent API to retrieve information
|
||||||
//! about GL context bound to the current thread.
|
//! about GL context bound to the current thread.
|
||||||
|
@ -115,6 +115,7 @@ namespace
|
|||||||
char aPsFont[64];
|
char aPsFont[64];
|
||||||
getGL2PSFontName (theAspect.Aspect()->Font().ToCString(), aPsFont);
|
getGL2PSFontName (theAspect.Aspect()->Font().ToCString(), aPsFont);
|
||||||
|
|
||||||
|
(void)theIs2d;
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
if (theIs2d)
|
if (theIs2d)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <Graphic3d_TextureParams.hxx>
|
#include <Graphic3d_TextureParams.hxx>
|
||||||
#include <Graphic3d_TransformUtils.hxx>
|
#include <Graphic3d_TransformUtils.hxx>
|
||||||
|
#include <NCollection_AlignedAllocator.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_RaytraceFilter,OpenGl_RenderFilter)
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_RaytraceFilter,OpenGl_RenderFilter)
|
||||||
@ -1012,76 +1013,6 @@ void OpenGl_Workspace::FBORelease (Handle(OpenGl_FrameBuffer)& theFbo)
|
|||||||
theFbo.Nullify();
|
theFbo.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool getDataFormat (const Image_PixMap& theData,
|
|
||||||
GLenum& thePixelFormat,
|
|
||||||
GLenum& theDataType)
|
|
||||||
{
|
|
||||||
thePixelFormat = GL_RGB;
|
|
||||||
theDataType = GL_UNSIGNED_BYTE;
|
|
||||||
switch (theData.Format())
|
|
||||||
{
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
|
||||||
case Image_PixMap::ImgGray:
|
|
||||||
thePixelFormat = GL_DEPTH_COMPONENT;
|
|
||||||
theDataType = GL_UNSIGNED_BYTE;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgGrayF:
|
|
||||||
thePixelFormat = GL_DEPTH_COMPONENT;
|
|
||||||
theDataType = GL_FLOAT;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgBGR:
|
|
||||||
thePixelFormat = GL_BGR;
|
|
||||||
theDataType = GL_UNSIGNED_BYTE;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgBGRA:
|
|
||||||
case Image_PixMap::ImgBGR32:
|
|
||||||
thePixelFormat = GL_BGRA;
|
|
||||||
theDataType = GL_UNSIGNED_BYTE;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgBGRF:
|
|
||||||
thePixelFormat = GL_BGR;
|
|
||||||
theDataType = GL_FLOAT;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgBGRAF:
|
|
||||||
thePixelFormat = GL_BGRA;
|
|
||||||
theDataType = GL_FLOAT;
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
case Image_PixMap::ImgGray:
|
|
||||||
case Image_PixMap::ImgGrayF:
|
|
||||||
case Image_PixMap::ImgBGR:
|
|
||||||
case Image_PixMap::ImgBGRA:
|
|
||||||
case Image_PixMap::ImgBGR32:
|
|
||||||
case Image_PixMap::ImgBGRF:
|
|
||||||
case Image_PixMap::ImgBGRAF:
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
case Image_PixMap::ImgRGB:
|
|
||||||
thePixelFormat = GL_RGB;
|
|
||||||
theDataType = GL_UNSIGNED_BYTE;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgRGBA:
|
|
||||||
case Image_PixMap::ImgRGB32:
|
|
||||||
thePixelFormat = GL_RGBA;
|
|
||||||
theDataType = GL_UNSIGNED_BYTE;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgRGBF:
|
|
||||||
thePixelFormat = GL_RGB;
|
|
||||||
theDataType = GL_FLOAT;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgRGBAF:
|
|
||||||
thePixelFormat = GL_RGBA;
|
|
||||||
theDataType = GL_FLOAT;
|
|
||||||
return true;
|
|
||||||
case Image_PixMap::ImgAlpha:
|
|
||||||
case Image_PixMap::ImgAlphaF:
|
|
||||||
return false; // GL_ALPHA is no more supported in core context
|
|
||||||
case Image_PixMap::ImgUNKNOWN:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : getAligned
|
// function : getAligned
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -1092,6 +1023,21 @@ inline Standard_Size getAligned (const Standard_Size theNumber,
|
|||||||
return theNumber + theAlignment - 1 - (theNumber - 1) % theAlignment;
|
return theNumber + theAlignment - 1 - (theNumber - 1) % theAlignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline void convertRowFromRgba (T* theRgbRow,
|
||||||
|
const Image_ColorRGBA* theRgbaRow,
|
||||||
|
const Standard_Size theWidth)
|
||||||
|
{
|
||||||
|
for (Standard_Size aCol = 0; aCol < theWidth; ++aCol)
|
||||||
|
{
|
||||||
|
const Image_ColorRGBA& anRgba = theRgbaRow[aCol];
|
||||||
|
T& anRgb = theRgbRow[aCol];
|
||||||
|
anRgb.r() = anRgba.r();
|
||||||
|
anRgb.g() = anRgba.g();
|
||||||
|
anRgb.b() = anRgba.b();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : BufferDump
|
// function : BufferDump
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -1100,13 +1046,92 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
|||||||
Image_PixMap& theImage,
|
Image_PixMap& theImage,
|
||||||
const Graphic3d_BufferType& theBufferType)
|
const Graphic3d_BufferType& theBufferType)
|
||||||
{
|
{
|
||||||
GLenum aFormat, aType;
|
|
||||||
if (theImage.IsEmpty()
|
if (theImage.IsEmpty()
|
||||||
|| !getDataFormat (theImage, aFormat, aType)
|
|| !Activate())
|
||||||
|| !Activate())
|
|
||||||
{
|
{
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLenum aFormat = 0;
|
||||||
|
GLenum aType = 0;
|
||||||
|
bool toSwapRgbaBgra = false;
|
||||||
|
bool toConvRgba2Rgb = false;
|
||||||
|
switch (theImage.Format())
|
||||||
|
{
|
||||||
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
|
case Image_PixMap::ImgGray:
|
||||||
|
aFormat = GL_DEPTH_COMPONENT;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgGrayF:
|
||||||
|
aFormat = GL_DEPTH_COMPONENT;
|
||||||
|
aType = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgRGB:
|
||||||
|
aFormat = GL_RGB;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgBGR:
|
||||||
|
aFormat = GL_BGR;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgBGRA:
|
||||||
|
case Image_PixMap::ImgBGR32:
|
||||||
|
aFormat = GL_BGRA;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgBGRF:
|
||||||
|
aFormat = GL_BGR;
|
||||||
|
aType = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgBGRAF:
|
||||||
|
aFormat = GL_BGRA;
|
||||||
|
aType = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
case Image_PixMap::ImgGray:
|
||||||
|
case Image_PixMap::ImgGrayF:
|
||||||
|
case Image_PixMap::ImgBGRF:
|
||||||
|
case Image_PixMap::ImgBGRAF:
|
||||||
|
return Standard_False;
|
||||||
|
case Image_PixMap::ImgBGRA:
|
||||||
|
case Image_PixMap::ImgBGR32:
|
||||||
|
aFormat = GL_RGBA;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
toSwapRgbaBgra = true;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgBGR:
|
||||||
|
case Image_PixMap::ImgRGB:
|
||||||
|
aFormat = GL_RGBA;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
toConvRgba2Rgb = true;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case Image_PixMap::ImgRGBA:
|
||||||
|
case Image_PixMap::ImgRGB32:
|
||||||
|
aFormat = GL_RGBA;
|
||||||
|
aType = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgRGBF:
|
||||||
|
aFormat = GL_RGB;
|
||||||
|
aType = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgRGBAF:
|
||||||
|
aFormat = GL_RGBA;
|
||||||
|
aType = GL_FLOAT;
|
||||||
|
break;
|
||||||
|
case Image_PixMap::ImgAlpha:
|
||||||
|
case Image_PixMap::ImgAlphaF:
|
||||||
|
return Standard_False; // GL_ALPHA is no more supported in core context
|
||||||
|
case Image_PixMap::ImgUNKNOWN:
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aFormat == 0)
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
GLint aReadBufferPrev = GL_BACK;
|
GLint aReadBufferPrev = GL_BACK;
|
||||||
if (theBufferType == Graphic3d_BT_Depth
|
if (theBufferType == Graphic3d_BT_Depth
|
||||||
@ -1158,8 +1183,33 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
|||||||
isBatchCopy = false;
|
isBatchCopy = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (toConvRgba2Rgb)
|
||||||
|
{
|
||||||
|
Handle(NCollection_BaseAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||||
|
const Standard_Size aRowSize = theImage.SizeX() * 4;
|
||||||
|
NCollection_Buffer aRowBuffer (anAlloc);
|
||||||
|
if (!aRowBuffer.Allocate (aRowSize))
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isBatchCopy)
|
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||||
|
{
|
||||||
|
// Image_PixMap rows indexation always starts from the upper corner
|
||||||
|
// while order in memory depends on the flag and processed by ChangeRow() method
|
||||||
|
glReadPixels (0, GLint(theImage.SizeY() - aRow - 1), GLsizei (theImage.SizeX()), 1, aFormat, aType, aRowBuffer.ChangeData());
|
||||||
|
const Image_ColorRGBA* aRowDataRgba = (const Image_ColorRGBA* )aRowBuffer.Data();
|
||||||
|
if (theImage.Format() == Image_PixMap::ImgBGR)
|
||||||
|
{
|
||||||
|
convertRowFromRgba ((Image_ColorBGR* )theImage.ChangeRow (aRow), aRowDataRgba, theImage.SizeX());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
convertRowFromRgba ((Image_ColorRGB* )theImage.ChangeRow (aRow), aRowDataRgba, theImage.SizeX());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!isBatchCopy)
|
||||||
{
|
{
|
||||||
// copy row by row
|
// copy row by row
|
||||||
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
|
||||||
@ -1173,6 +1223,7 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
|||||||
{
|
{
|
||||||
glReadPixels (0, 0, GLsizei (theImage.SizeX()), GLsizei (theImage.SizeY()), aFormat, aType, theImage.ChangeData());
|
glReadPixels (0, 0, GLsizei (theImage.SizeX()), GLsizei (theImage.SizeY()), aFormat, aType, theImage.ChangeData());
|
||||||
}
|
}
|
||||||
|
const bool hasErrors = myGlContext->ResetErrors (true);
|
||||||
|
|
||||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
@ -1189,7 +1240,13 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)&
|
|||||||
glReadBuffer (aReadBufferPrev);
|
glReadBuffer (aReadBufferPrev);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return Standard_True;
|
|
||||||
|
if (toSwapRgbaBgra)
|
||||||
|
{
|
||||||
|
Image_PixMap::SwapRgbaBgra (theImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return !hasErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@ -2826,12 +2826,11 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
|
|||||||
|| theImage.SizeX() != Standard_Size(aTargetSize.x())
|
|| theImage.SizeX() != Standard_Size(aTargetSize.x())
|
||||||
|| theImage.SizeY() != Standard_Size(aTargetSize.y()))
|
|| theImage.SizeY() != Standard_Size(aTargetSize.y()))
|
||||||
{
|
{
|
||||||
const bool isBigEndian = Image_PixMap::IsBigEndianHost();
|
|
||||||
Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
|
Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
|
||||||
switch (theParams.BufferType)
|
switch (theParams.BufferType)
|
||||||
{
|
{
|
||||||
case Graphic3d_BT_RGB: aFormat = isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; break;
|
case Graphic3d_BT_RGB: aFormat = Image_PixMap::ImgRGB; break;
|
||||||
case Graphic3d_BT_RGBA: aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break;
|
case Graphic3d_BT_RGBA: aFormat = Image_PixMap::ImgRGBA; break;
|
||||||
case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
|
case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,13 +924,11 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Image_AlienPixMap aPixMap;
|
Image_AlienPixMap aPixMap;
|
||||||
|
|
||||||
bool isBigEndian = Image_PixMap::IsBigEndianHost();
|
|
||||||
Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
|
Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgUNKNOWN;
|
||||||
switch (aParams.BufferType)
|
switch (aParams.BufferType)
|
||||||
{
|
{
|
||||||
case Graphic3d_BT_RGB: aFormat = isBigEndian ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR; break;
|
case Graphic3d_BT_RGB: aFormat = Image_PixMap::ImgRGB; break;
|
||||||
case Graphic3d_BT_RGBA: aFormat = isBigEndian ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA; break;
|
case Graphic3d_BT_RGBA: aFormat = Image_PixMap::ImgRGBA; break;
|
||||||
case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
|
case Graphic3d_BT_Depth: aFormat = Image_PixMap::ImgGrayF; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,9 +983,9 @@ static Standard_Integer VDump (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Image_PixMap aPixMapL, aPixMapR;
|
Image_PixMap aPixMapL, aPixMapR;
|
||||||
aPixMapL.InitWrapper (aFormat, aPixMap.ChangeData(),
|
aPixMapL.InitWrapper (aPixMap.Format(), aPixMap.ChangeData(),
|
||||||
aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
|
aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
|
||||||
aPixMapR.InitWrapper (aFormat, aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
|
aPixMapR.InitWrapper (aPixMap.Format(), aPixMap.ChangeData() + aPixMap.SizeRowBytes() * aParams.Height,
|
||||||
aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
|
aParams.Width, aParams.Height, aPixMap.SizeRowBytes());
|
||||||
|
|
||||||
aParams.StereoOptions = V3d_SDO_LEFT_EYE;
|
aParams.StereoOptions = V3d_SDO_LEFT_EYE;
|
||||||
|
@ -5736,7 +5736,7 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image_PixMap::ImgFormat aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA;
|
Image_PixMap::ImgFormat aFormat = Image_PixMap::ImgRGBA;
|
||||||
Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
|
Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
|
||||||
|
|
||||||
Standard_Integer aWidth, aHeight;
|
Standard_Integer aWidth, aHeight;
|
||||||
@ -5756,12 +5756,12 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
|||||||
const char* aParam = theArgVec[anIter];
|
const char* aParam = theArgVec[anIter];
|
||||||
if ( strcasecmp( aParam, "rgb" ) == 0 )
|
if ( strcasecmp( aParam, "rgb" ) == 0 )
|
||||||
{
|
{
|
||||||
aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR;
|
aFormat = Image_PixMap::ImgRGB;
|
||||||
aBufferType = Graphic3d_BT_RGB;
|
aBufferType = Graphic3d_BT_RGB;
|
||||||
}
|
}
|
||||||
else if ( strcasecmp( aParam, "hls" ) == 0 )
|
else if ( strcasecmp( aParam, "hls" ) == 0 )
|
||||||
{
|
{
|
||||||
aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR;
|
aFormat = Image_PixMap::ImgRGB;
|
||||||
aBufferType = Graphic3d_BT_RGB;
|
aBufferType = Graphic3d_BT_RGB;
|
||||||
toShowHls = Standard_True;
|
toShowHls = Standard_True;
|
||||||
}
|
}
|
||||||
@ -5772,7 +5772,7 @@ static int VReadPixel (Draw_Interpretor& theDI,
|
|||||||
}
|
}
|
||||||
else if ( strcasecmp( aParam, "rgba" ) == 0 )
|
else if ( strcasecmp( aParam, "rgba" ) == 0 )
|
||||||
{
|
{
|
||||||
aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA;
|
aFormat = Image_PixMap::ImgRGBA;
|
||||||
aBufferType = Graphic3d_BT_RGBA;
|
aBufferType = Graphic3d_BT_RGBA;
|
||||||
}
|
}
|
||||||
else if ( strcasecmp( aParam, "rgbaf" ) == 0 )
|
else if ( strcasecmp( aParam, "rgbaf" ) == 0 )
|
||||||
|
@ -57,4 +57,4 @@ if {$aNbSelected4 != 13} {
|
|||||||
puts "ERROR: Wrong number of entities in vertice-edge-face shift selection with overlap allowed!"
|
puts "ERROR: Wrong number of entities in vertice-edge-face shift selection with overlap allowed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
vdump $imagedir/${casename}
|
vdump $imagedir/${casename}.png
|
||||||
|
@ -20,4 +20,4 @@ checkcolor 58 324 0 1 1
|
|||||||
|
|
||||||
# to print tolerance in case of failure:
|
# to print tolerance in case of failure:
|
||||||
puts [vselprops -print]
|
puts [vselprops -print]
|
||||||
vdump $imagedir/${casename}
|
vdump $imagedir/${casename}.png
|
||||||
|
@ -77,4 +77,4 @@ vmoveto ${x_tol} ${y_tol}
|
|||||||
checkcolor ${x_on_edge} ${y_on_edge} 1 1 0
|
checkcolor ${x_on_edge} ${y_on_edge} 1 1 0
|
||||||
checkcolor $x_on_vert $y_on_vert 0 1 1
|
checkcolor $x_on_vert $y_on_vert 0 1 1
|
||||||
|
|
||||||
vdump ${imagedir}/${casename}
|
vdump ${imagedir}/${casename}.png
|
||||||
|
@ -43,4 +43,4 @@ if {$aNbSelected != 14} {
|
|||||||
puts "ERROR: Vertex was not selected!"
|
puts "ERROR: Vertex was not selected!"
|
||||||
}
|
}
|
||||||
|
|
||||||
vdump ${imagedir}/${casename}
|
vdump ${imagedir}/${casename}.png
|
||||||
|
Loading…
x
Reference in New Issue
Block a user