0025133: TKOpenGl - Crash on closing a view containing presentations with capping
[occt.git] / src / OpenGl / OpenGl_Texture.hxx
index b6c7083..6240ab6 100644 (file)
@@ -1,10 +1,10 @@
 // Created by: Kirill GAVRILOV
-// Copyright (c) 2014 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 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 version 2.1 as published
+// 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.
@@ -136,20 +136,16 @@ public:
 private:
 
   //! Creates new texture format.
-  OpenGl_TextureFormat (const GLint theChannels, const GLint theInternal)
-    : myChannels (theChannels),
-      myInternal (theInternal)
-  {
-    //
-  }
+  OpenGl_TextureFormat (const GLint theChannels,
+                        const GLint theInternal)
+  : myInternal (theInternal),
+    myChannels (theChannels) {}
 
 private:
 
-  //! OpenGL internal format of the pixel data. 
-  GLint myInternal;
+  GLint myInternal; //!< OpenGL internal format of the pixel data
+  GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
 
-  //! Number of channels for each pixel (from 1 to 4).
-  GLint myChannels;
 };
 
 //! Texture resource.
@@ -210,7 +206,7 @@ public:
   Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theCtx);
 
   //! Destroy object - will release GPU memory if any.
-  Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
+  Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
 
   //! Bind this Texture to specified unit.
   Standard_EXPORT void Bind (const Handle(OpenGl_Context)& theCtx,
@@ -225,6 +221,18 @@ public:
                              const Image_PixMap&           theImage,
                              const Graphic3d_TypeOfTexture theType);
 
+  //! 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 Graphic3d_TypeOfTexture theType,
+                             const Image_PixMap*           theImage = NULL);
+
   //! Allocates texture rectangle with specified format and size.
   //! \note Texture data is not initialized (will contain trash).
   Standard_EXPORT bool InitRectangle (const Handle(OpenGl_Context)& theCtx,
@@ -241,6 +249,13 @@ public:
   //! @param texture parameters
   Standard_EXPORT void SetParams (const Handle(Graphic3d_TextureParams)& theParams);
 
+  //! Return texture type and format by Image_PixMap data format.
+  Standard_EXPORT static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
+                                             const Image_PixMap&           theData,
+                                             GLint&                        theTextFormat,
+                                             GLenum&                       thePixelFormat,
+                                             GLenum&                       theDataType);
+
 protected:
 
   GLuint           myTextureId;  //!< GL resource ID