5e27df78 |
1 | // Created by: Kirill GAVRILOV |
d5f74e42 |
2 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
5e27df78 |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
5e27df78 |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
5e27df78 |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
5e27df78 |
14 | |
15 | #ifndef _OpenGl_TextureBufferArb_H__ |
16 | #define _OpenGl_TextureBufferArb_H__ |
17 | |
18 | #include <OpenGl_VertexBuffer.hxx> |
19 | #include <OpenGl_ArbTBO.hxx> |
20 | |
21 | //! Texture Buffer Object. |
22 | //! This is a special 1D texture that VBO-style initialized. |
23 | //! The main differences from general 1D texture: |
24 | //! - no interpolation between field; |
25 | //! - greater sizes; |
26 | //! - special sampler object in GLSL shader to access data by index. |
27 | //! |
28 | //! Notice that though TBO is inherited from VBO this is to unify design |
29 | //! user shouldn't cast it to base class and all really useful methods |
30 | //! are declared in this class. |
31 | class OpenGl_TextureBufferArb : public OpenGl_VertexBuffer |
32 | { |
33 | |
34 | public: |
35 | |
36 | //! Helpful constants |
37 | static const GLuint NO_TEXTURE = 0; |
38 | |
39 | public: |
40 | |
41 | //! Create uninitialized TBO. |
42 | Standard_EXPORT OpenGl_TextureBufferArb(); |
43 | |
44 | //! Destroy object, will throw exception if GPU memory not released with Release() before. |
45 | Standard_EXPORT virtual ~OpenGl_TextureBufferArb(); |
46 | |
47 | //! Override VBO target |
79104795 |
48 | Standard_EXPORT virtual GLenum GetTarget() const Standard_OVERRIDE; |
5e27df78 |
49 | |
50 | //! Returns true if TBO is valid. |
51 | //! Notice that no any real GL call is performed! |
52 | bool IsValid() const |
53 | { |
54 | return OpenGl_VertexBuffer::IsValid() |
55 | && myTextureId != NO_TEXTURE; |
56 | } |
57 | |
58 | //! Destroy object - will release GPU memory if any. |
79104795 |
59 | Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE; |
5e27df78 |
60 | |
61 | //! Creates VBO and Texture names (ids) if not yet generated. |
62 | //! Data should be initialized by another method. |
79104795 |
63 | Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx) Standard_OVERRIDE; |
5e27df78 |
64 | |
65 | //! Perform TBO initialization with specified data. |
66 | //! Existing data will be deleted. |
67 | Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx, |
68 | const GLuint theComponentsNb, |
69 | const GLsizei theElemsNb, |
70 | const GLfloat* theData); |
71 | |
fc73a202 |
72 | //! Perform TBO initialization with specified data. |
73 | //! Existing data will be deleted. |
74 | Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx, |
75 | const GLuint theComponentsNb, |
76 | const GLsizei theElemsNb, |
77 | const GLuint* theData); |
78 | |
df45f8db |
79 | //! Perform TBO initialization with specified data. |
80 | //! Existing data will be deleted. |
81 | Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx, |
82 | const GLuint theComponentsNb, |
83 | const GLsizei theElemsNb, |
84 | const GLushort* theData); |
85 | |
86 | //! Perform TBO initialization with specified data. |
87 | //! Existing data will be deleted. |
88 | Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx, |
89 | const GLuint theComponentsNb, |
90 | const GLsizei theElemsNb, |
91 | const GLubyte* theData); |
92 | |
5e27df78 |
93 | //! Bind TBO to specified Texture Unit. |
94 | Standard_EXPORT void BindTexture (const Handle(OpenGl_Context)& theGlCtx, |
95 | const GLenum theTextureUnit = GL_TEXTURE0) const; |
96 | |
97 | //! Unbind TBO. |
98 | Standard_EXPORT void UnbindTexture (const Handle(OpenGl_Context)& theGlCtx, |
99 | const GLenum theTextureUnit = GL_TEXTURE0) const; |
100 | |
101 | protected: |
102 | |
103 | GLuint myTextureId; //!< texture id |
104 | GLenum myTexFormat; //!< internal texture format |
105 | |
106 | public: |
107 | |
92efcf78 |
108 | DEFINE_STANDARD_RTTIEXT(OpenGl_TextureBufferArb,OpenGl_VertexBuffer) // Type definition |
5e27df78 |
109 | |
110 | }; |
111 | |
112 | DEFINE_STANDARD_HANDLE(OpenGl_TextureBufferArb, OpenGl_VertexBuffer) |
113 | |
114 | #endif // _OpenGl_TextureBufferArb_H__ |