From 90fd614536913a34592ba270d8505ca48bd417cb Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 17 Oct 2018 14:01:30 +0300 Subject: [PATCH] 0030248: Volume Rendering - importing volume with default parameters leads to crashes within OpenGl_Texture::Init3D() --- src/OpenGl/OpenGl_Texture.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index c4de253714..6256e1f150 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -30,7 +30,7 @@ struct OpenGl_UnpackAlignmentSentry { //! Reset unpack alignment settings to safe values - void Reset() + static void Reset() { glPixelStorei (GL_UNPACK_ALIGNMENT, 1); #if !defined(GL_ES_VERSION_2_0) @@ -38,6 +38,8 @@ struct OpenGl_UnpackAlignmentSentry #endif } + OpenGl_UnpackAlignmentSentry() {} + ~OpenGl_UnpackAlignmentSentry() { Reset(); @@ -840,6 +842,9 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx, myTextFormat = theFormat.Format(); mySizedFormat = theFormat.Internal(); + // setup the alignment + OpenGl_UnpackAlignmentSentry::Reset(); + glTexImage2D (GL_PROXY_TEXTURE_RECTANGLE, 0, mySizedFormat, aSizeX, aSizeY, 0, myTextFormat, GL_FLOAT, NULL); @@ -938,6 +943,9 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx, mySizedFormat = theTextFormat; + // 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,