1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0027354: Visualization: TKOpenGl - OpenGl_TextureBufferArb API should be extended

All variants of Init function of OpenGl_VertexBuffer are now also supported by OpenGl_TextureBufferArb.
Missing texture formats added to OpenGl_GlFunctions.hxx.
This commit is contained in:
duv 2016-04-05 12:25:13 +03:00 committed by bugmaster
parent 1d505bb0f8
commit df45f8db5f
3 changed files with 117 additions and 1 deletions

View File

@ -106,10 +106,30 @@
#define GL_RG16F 0x822F
#define GL_RG32F 0x8230
#define GL_R8I 0x8231
#define GL_R8UI 0x8232
#define GL_R16I 0x8233
#define GL_R16UI 0x8234
#define GL_R32I 0x8235
#define GL_R32UI 0x8236
#define GL_RG8I 0x8237
#define GL_RG8UI 0x8238
#define GL_RG16I 0x8239
#define GL_RG16UI 0x823A
#define GL_RG32I 0x823B
#define GL_RGB32I 0x8D83
#define GL_RG32UI 0x823C
#define GL_RGBA32UI 0x8D70
#define GL_RGB32UI 0x8D71
#define GL_RGBA16UI 0x8D76
#define GL_RGB16UI 0x8D77
#define GL_RGBA8UI 0x8D7C
#define GL_RGB8UI 0x8D7D
#define GL_RGBA32I 0x8D82
#define GL_RGB32I 0x8D83
#define GL_RGBA16I 0x8D88
#define GL_RGB16I 0x8D89
#define GL_RGBA8I 0x8D8E
#define GL_RGB8I 0x8D8F
// GL_OES_packed_depth_stencil
#define GL_DEPTH_STENCIL 0x84F9

View File

@ -181,6 +181,88 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
return true;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLushort* theData)
{
if (theGlCtx->arbTBO == NULL)
{
return false;
}
else if (theComponentsNb < 1
|| theComponentsNb > 4)
{
// unsupported format
return false;
}
else if (!Create (theGlCtx)
|| !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
{
return false;
}
switch (theComponentsNb)
{
case 1: myTexFormat = GL_R16I; break;
case 2: myTexFormat = GL_RG16I; break;
case 3: myTexFormat = GL_RGB16I; break;
case 4: myTexFormat = GL_RGBA16I; break;
}
Bind (theGlCtx);
BindTexture (theGlCtx);
theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
UnbindTexture (theGlCtx);
Unbind (theGlCtx);
return true;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLubyte* theData)
{
if (theGlCtx->arbTBO == NULL)
{
return false;
}
else if (theComponentsNb < 1
|| theComponentsNb > 4)
{
// unsupported format
return false;
}
else if (!Create (theGlCtx)
|| !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
{
return false;
}
switch (theComponentsNb)
{
case 1: myTexFormat = GL_R8; break;
case 2: myTexFormat = GL_RG8; break;
case 3: myTexFormat = GL_RGB8; break;
case 4: myTexFormat = GL_RGBA8; break;
}
Bind (theGlCtx);
BindTexture (theGlCtx);
theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
UnbindTexture (theGlCtx);
Unbind (theGlCtx);
return true;
}
// =======================================================================
// function : BindTexture
// purpose :

View File

@ -76,6 +76,20 @@ public:
const GLsizei theElemsNb,
const GLuint* theData);
//! Perform TBO initialization with specified data.
//! Existing data will be deleted.
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLushort* theData);
//! Perform TBO initialization with specified data.
//! Existing data will be deleted.
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLubyte* theData);
//! Bind TBO to specified Texture Unit.
Standard_EXPORT void BindTexture (const Handle(OpenGl_Context)& theGlCtx,
const GLenum theTextureUnit = GL_TEXTURE0) const;