Test for 0022778: Bug in BRepMesh
[occt.git] / src / OpenGl / OpenGl_TextureBufferArb.hxx
CommitLineData
5e27df78 1// Created by: Kirill GAVRILOV
2// Copyright (c) 2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
19#ifndef _OpenGl_TextureBufferArb_H__
20#define _OpenGl_TextureBufferArb_H__
21
22#include <OpenGl_VertexBuffer.hxx>
23#include <OpenGl_ArbTBO.hxx>
24
25//! Texture Buffer Object.
26//! This is a special 1D texture that VBO-style initialized.
27//! The main differences from general 1D texture:
28//! - no interpolation between field;
29//! - greater sizes;
30//! - special sampler object in GLSL shader to access data by index.
31//!
32//! Notice that though TBO is inherited from VBO this is to unify design
33//! user shouldn't cast it to base class and all really useful methods
34//! are declared in this class.
35class OpenGl_TextureBufferArb : public OpenGl_VertexBuffer
36{
37
38public:
39
40 //! Helpful constants
41 static const GLuint NO_TEXTURE = 0;
42
43public:
44
45 //! Create uninitialized TBO.
46 Standard_EXPORT OpenGl_TextureBufferArb();
47
48 //! Destroy object, will throw exception if GPU memory not released with Release() before.
49 Standard_EXPORT virtual ~OpenGl_TextureBufferArb();
50
51 //! Override VBO target
52 Standard_EXPORT virtual GLenum GetTarget() const;
53
54 //! Returns true if TBO is valid.
55 //! Notice that no any real GL call is performed!
56 bool IsValid() const
57 {
58 return OpenGl_VertexBuffer::IsValid()
59 && myTextureId != NO_TEXTURE;
60 }
61
62 //! Destroy object - will release GPU memory if any.
63 Standard_EXPORT virtual void Release (const OpenGl_Context* theGlCtx);
64
65 //! Creates VBO and Texture names (ids) if not yet generated.
66 //! Data should be initialized by another method.
67 Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx);
68
69 //! Perform TBO initialization with specified data.
70 //! Existing data will be deleted.
71 Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
72 const GLuint theComponentsNb,
73 const GLsizei theElemsNb,
74 const GLfloat* theData);
75
76 //! Bind TBO to specified Texture Unit.
77 Standard_EXPORT void BindTexture (const Handle(OpenGl_Context)& theGlCtx,
78 const GLenum theTextureUnit = GL_TEXTURE0) const;
79
80 //! Unbind TBO.
81 Standard_EXPORT void UnbindTexture (const Handle(OpenGl_Context)& theGlCtx,
82 const GLenum theTextureUnit = GL_TEXTURE0) const;
83
84protected:
85
86 GLuint myTextureId; //!< texture id
87 GLenum myTexFormat; //!< internal texture format
88
89public:
90
91 DEFINE_STANDARD_RTTI(OpenGl_TextureBufferArb) // Type definition
92
93};
94
95DEFINE_STANDARD_HANDLE(OpenGl_TextureBufferArb, OpenGl_VertexBuffer)
96
97#endif // _OpenGl_TextureBufferArb_H__