OpenGl_Buffer - added new class as a base for OpenGl_VertexBuffer, OpenGl_IndexBuffer, OpenGl_TextureBuffer.
OpenGl_TextureBufferArb has been renamed to OpenGl_TextureBuffer.
OpenGl_FrameBuffer - added initializers taking vec2i instead of (int,int) for dimensions.
#include <OpenGl_GlCore20.hxx>
#include <OpenGl_ArbFBO.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_Texture.hxx>
#include <Standard_ProgramError.hxx>
-#include <TCollection_ExtendedString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(D3DHost_FrameBuffer,OpenGl_FrameBuffer)
const Standard_Boolean theIsD3dEx,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
- const GLint theDepthFormat)
+ const Standard_Integer theDepthFormat)
{
- const Standard_Boolean isGlInit = OpenGl_FrameBuffer::Init (theCtx, theSizeX, theSizeY, GL_RGBA8, theDepthFormat, 0);
+ const Standard_Boolean isGlInit = OpenGl_FrameBuffer::Init (theCtx, Graphic3d_Vec2i (theSizeX, theSizeY), GL_RGBA8, theDepthFormat, 0);
myD3dFallback = Standard_True;
const Standard_Integer aSizeX = theSizeX > 0 ? theSizeX : 2;
const Standard_Boolean theIsD3dEx,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
- const GLint theDepthFormat)
+ const Standard_Integer theDepthFormat)
{
Release (theCtx.operator->());
#if !defined(GL_ES_VERSION_2_0)
const Standard_Boolean theIsD3dEx,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
- const GLint theDepthFormat);
+ const Standard_Integer theDepthFormat);
//! Initializes OpenGL FBO + Direct3D surface for copying memory using fallback.
//! Color pixel format is always GL_RGBA8/D3DFMT_X8R8G8B8, no MSAA.
const Standard_Boolean theIsD3dEx,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
- const GLint theDepthFormat);
+ const Standard_Integer theDepthFormat);
//! Binds Direct3D color buffer to OpenGL texture.
Standard_EXPORT Standard_Boolean registerD3dBuffer (const Handle(OpenGl_Context)& theCtx);
#include <D3DHost_GraphicDriver.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <OpenGl_Window.hxx>
#include <Standard_WarningDisableFunctionCast.hxx>
OpenGl_AspectsSprite.hxx
OpenGl_AspectsTextureSet.cxx
OpenGl_AspectsTextureSet.hxx
+OpenGl_Buffer.cxx
+OpenGl_Buffer.hxx
+OpenGl_BufferCompatT.hxx
OpenGl_FrameStats.cxx
OpenGl_FrameStats.hxx
OpenGl_FrameStatsPrs.cxx
OpenGl_StencilTest.hxx
OpenGl_TileSampler.hxx
OpenGl_TileSampler.cxx
-OpenGl_TextureBufferArb.cxx
+OpenGl_TextureBuffer.cxx
+OpenGl_TextureBuffer.hxx
OpenGl_TextureBufferArb.hxx
+OpenGl_UniformBuffer.cxx
+OpenGl_UniformBuffer.hxx
OpenGl_Vec.hxx
OpenGl_VertexBuffer.cxx
OpenGl_VertexBuffer.hxx
-OpenGl_VertexBuffer.lxx
-OpenGl_VertexBufferCompat.cxx
OpenGl_VertexBufferCompat.hxx
OpenGl_VertexBufferEditor.hxx
OpenGl_TextBuilder.hxx
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_FillMethod.hxx>
+#include <Graphic3d_Camera.hxx>
#include <Graphic3d_TypeOfBackground.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Vec.hxx>
-#include <OpenGl_Workspace.hxx>
//! Tool class for generating reusable data for
//! gradient or texture background rendering.
--- /dev/null
+// Created by: Kirill GAVRILOV
+// 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <OpenGl_Buffer.hxx>
+
+#include <OpenGl_GlCore30.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_ShaderManager.hxx>
+#include <Standard_Assert.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Buffer, OpenGl_Resource)
+
+// =======================================================================
+// function : sizeOfGlType
+// purpose :
+// =======================================================================
+size_t OpenGl_Buffer::sizeOfGlType (unsigned int theType)
+{
+ switch (theType)
+ {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE: return sizeof(Standard_Byte);
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT: return sizeof(unsigned short);
+ #ifdef GL_INT
+ case GL_INT:
+ #endif
+ case GL_UNSIGNED_INT: return sizeof(unsigned int);
+ case GL_FLOAT: return sizeof(float);
+ #ifdef GL_DOUBLE
+ case GL_DOUBLE: return sizeof(double);
+ #endif
+ default: return 0;
+ }
+}
+
+// =======================================================================
+// function : FormatTarget
+// purpose :
+// =======================================================================
+TCollection_AsciiString OpenGl_Buffer::FormatTarget (unsigned int theTarget)
+{
+ switch (theTarget)
+ {
+ case GL_ARRAY_BUFFER: return "GL_ARRAY_BUFFER";
+ case GL_ELEMENT_ARRAY_BUFFER: return "GL_ELEMENT_ARRAY_BUFFER";
+ case GL_PIXEL_UNPACK_BUFFER: return "GL_PIXEL_UNPACK_BUFFER";
+ case GL_PIXEL_PACK_BUFFER: return "GL_PIXEL_PACK_BUFFER";
+ case GL_UNIFORM_BUFFER: return "GL_UNIFORM_BUFFER";
+ case GL_TEXTURE_BUFFER: return "GL_TEXTURE_BUFFER";
+ case GL_COPY_READ_BUFFER: return "GL_COPY_READ_BUFFER";
+ case GL_COPY_WRITE_BUFFER: return "GL_COPY_WRITE_BUFFER";
+ case GL_TRANSFORM_FEEDBACK_BUFFER: return "GL_TRANSFORM_FEEDBACK_BUFFER";
+ #ifdef GL_QUERY_BUFFER
+ case GL_QUERY_BUFFER: return "GL_QUERY_BUFFER";
+ case GL_DRAW_INDIRECT_BUFFER: return "GL_DRAW_INDIRECT_BUFFER";
+ case GL_ATOMIC_COUNTER_BUFFER: return "GL_ATOMIC_COUNTER_BUFFER";
+ case GL_DISPATCH_INDIRECT_BUFFER: return "GL_DISPATCH_INDIRECT_BUFFER";
+ case GL_SHADER_STORAGE_BUFFER: return "GL_SHADER_STORAGE_BUFFER";
+ #endif
+ }
+ return OpenGl_Context::FormatGlEnumHex (theTarget);
+}
+
+// =======================================================================
+// function : OpenGl_Buffer
+// purpose :
+// =======================================================================
+OpenGl_Buffer::OpenGl_Buffer()
+: OpenGl_Resource(),
+ myOffset (NULL),
+ myBufferId (NO_BUFFER),
+ myComponentsNb (4),
+ myElemsNb (0),
+ myDataType (GL_FLOAT)
+{
+ //
+}
+
+// =======================================================================
+// function : ~OpenGl_Buffer
+// purpose :
+// =======================================================================
+OpenGl_Buffer::~OpenGl_Buffer()
+{
+ Release (NULL);
+}
+
+// =======================================================================
+// function : Create
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::Create (const Handle(OpenGl_Context)& theGlCtx)
+{
+ if (myBufferId == NO_BUFFER && theGlCtx->core15fwd != NULL)
+ {
+ theGlCtx->core15fwd->glGenBuffers (1, &myBufferId);
+ }
+ return myBufferId != NO_BUFFER;
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::Release (OpenGl_Context* theGlCtx)
+{
+ if (myBufferId == NO_BUFFER)
+ {
+ return;
+ }
+
+ // application can not handle this case by exception - this is bug in code
+ Standard_ASSERT_RETURN (theGlCtx != NULL,
+ "OpenGl_Buffer destroyed without GL context! Possible GPU memory leakage...",);
+
+ if (theGlCtx->IsValid())
+ {
+ theGlCtx->core15fwd->glDeleteBuffers (1, &myBufferId);
+ }
+ myOffset = NULL;
+ myBufferId = NO_BUFFER;
+}
+
+// =======================================================================
+// function : Bind
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::Bind (const Handle(OpenGl_Context)& theGlCtx) const
+{
+ theGlCtx->core15fwd->glBindBuffer (GetTarget(), myBufferId);
+}
+
+// =======================================================================
+// function : Unbind
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::Unbind (const Handle(OpenGl_Context)& theGlCtx) const
+{
+ theGlCtx->core15fwd->glBindBuffer (GetTarget(), NO_BUFFER);
+}
+
+// =======================================================================
+// function : BindBufferBase
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::BindBufferBase (const Handle(OpenGl_Context)& theGlCtx,
+ unsigned int theIndex)
+{
+ theGlCtx->core30->glBindBufferBase (GetTarget(), theIndex, myBufferId);
+}
+
+// =======================================================================
+// function : UnbindBufferBase
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::UnbindBufferBase (const Handle(OpenGl_Context)& theGlCtx,
+ unsigned int theIndex)
+{
+ theGlCtx->core30->glBindBufferBase (GetTarget(), theIndex, NO_BUFFER);
+}
+
+// =======================================================================
+// function : BindBufferRange
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::BindBufferRange (const Handle(OpenGl_Context)& theGlCtx,
+ unsigned int theIndex,
+ const intptr_t theOffset,
+ const size_t theSize)
+{
+ theGlCtx->core30->glBindBufferRange (GetTarget(), theIndex, myBufferId, (GLintptr )theOffset, (GLsizeiptr )theSize);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const float* theData)
+{
+ return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_FLOAT);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned int* theData)
+{
+ return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_INT);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned short* theData)
+{
+ return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_SHORT);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const Standard_Byte* theData)
+{
+ return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_BYTE);
+}
+
+// =======================================================================
+// function : init
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType,
+ const Standard_Integer theStride)
+{
+ if (!Create (theGlCtx))
+ {
+ return false;
+ }
+
+ Bind (theGlCtx);
+ myDataType = theDataType;
+ myComponentsNb = theComponentsNb;
+ myElemsNb = theElemsNb;
+ theGlCtx->core15fwd->glBufferData (GetTarget(), GLsizeiptr(myElemsNb) * theStride, theData, GL_STATIC_DRAW);
+ const int anErr = theGlCtx->core15fwd->glGetError();
+ if (anErr != GL_NO_ERROR
+ && anErr != GL_OUT_OF_MEMORY) // pass-through out-of-memory error, but log unexpected errors
+ {
+ theGlCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+ TCollection_AsciiString ("Error: glBufferData (")
+ + FormatTarget (GetTarget()) + ","
+ + OpenGl_Context::FormatSize (GLsizeiptr(myElemsNb) * theStride) + ","
+ + OpenGl_Context::FormatPointer (theData) + ") Id: " + (int )myBufferId
+ + " failed with " + OpenGl_Context::FormatGlError (anErr));
+ }
+ Unbind (theGlCtx);
+ return anErr == GL_NO_ERROR;
+}
+
+// =======================================================================
+// function : SubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const float* theData)
+{
+ return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_FLOAT);
+}
+
+// =======================================================================
+// function : SubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const unsigned int* theData)
+{
+ return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_INT);
+}
+
+// =======================================================================
+// function : SubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const unsigned short* theData)
+{
+ return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_SHORT);
+}
+
+// =======================================================================
+// function : SubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const Standard_Byte* theData)
+{
+ return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_BYTE);
+}
+
+// =======================================================================
+// function : subData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::subData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType)
+{
+ if (!IsValid() || myDataType != theDataType ||
+ theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
+ {
+ return false;
+ }
+
+ Bind (theGlCtx);
+ const size_t aDataSize = sizeOfGlType (theDataType);
+ theGlCtx->core15fwd->glBufferSubData (GetTarget(),
+ GLintptr(theElemFrom) * GLintptr (myComponentsNb) * aDataSize, // offset in bytes
+ GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize, // size in bytes
+ theData);
+ const int anErr = theGlCtx->core15fwd->glGetError();
+ if (anErr != GL_NO_ERROR)
+ {
+ theGlCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+ TCollection_AsciiString ("Error: glBufferSubData (")
+ + FormatTarget (GetTarget()) + ","
+ + OpenGl_Context::FormatSize (GLintptr(theElemFrom) * GLintptr (myComponentsNb) * aDataSize) + ","
+ + OpenGl_Context::FormatSize (GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize) + ","
+ + OpenGl_Context::FormatPointer (theData) + ") Id: " + (int )myBufferId
+ + " failed with " + OpenGl_Context::FormatGlError (anErr));
+ }
+ Unbind (theGlCtx);
+ return anErr == GL_NO_ERROR;
+}
+
+// =======================================================================
+// function : subData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ float* theData)
+{
+ return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_FLOAT);
+}
+
+// =======================================================================
+// function : GetSubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ unsigned short* theData)
+{
+ return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_SHORT);
+}
+
+// =======================================================================
+// function : GetSubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ unsigned int* theData)
+{
+ return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_INT);
+}
+
+// =======================================================================
+// function : GetSubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ Standard_Byte* theData)
+{
+ return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_BYTE);
+}
+
+// =======================================================================
+// function : getSubData
+// purpose :
+// =======================================================================
+bool OpenGl_Buffer::getSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ void* theData,
+ const unsigned int theDataType)
+{
+ if (!IsValid() || myDataType != theDataType
+ || theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb)
+ || !theGlCtx->hasGetBufferData)
+ {
+ return false;
+ }
+
+ Bind (theGlCtx);
+ const size_t aDataSize = sizeOfGlType (theDataType);
+ const GLintptr anOffset = GLintptr (theElemFrom) * GLintptr (myComponentsNb) * aDataSize;
+ const GLsizeiptr aSize = GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize;
+ bool isDone = theGlCtx->GetBufferSubData (GetTarget(), anOffset, aSize, theData);
+ isDone = isDone && (theGlCtx->core15fwd->glGetError() == GL_NO_ERROR);
+ Unbind (theGlCtx);
+ return isDone;
+}
+
+// =======================================================================
+// function : DumpJson
+// purpose :
+// =======================================================================
+void OpenGl_Buffer::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, OpenGl_Resource)
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, GetTarget())
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOffset)
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBufferId)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComponentsNb)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myElemsNb)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDataType)
+}
--- /dev/null
+// Created by: Kirill GAVRILOV
+// 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _OpenGl_Buffer_H__
+#define _OpenGl_Buffer_H__
+
+#include <OpenGl_Resource.hxx>
+#include <TCollection_AsciiString.hxx>
+
+//! Buffer Object - is a general storage object for arbitrary data (see sub-classes).
+class OpenGl_Buffer : public OpenGl_Resource
+{
+ DEFINE_STANDARD_RTTIEXT(OpenGl_Buffer, OpenGl_Resource)
+public:
+
+ //! Helpful constants
+ static const unsigned int NO_BUFFER = 0;
+
+ //! Format VBO target enumeration value.
+ Standard_EXPORT static TCollection_AsciiString FormatTarget (unsigned int theTarget);
+
+public:
+
+ //! Create uninitialized buffer.
+ Standard_EXPORT OpenGl_Buffer();
+
+ //! Destroy object.
+ Standard_EXPORT virtual ~OpenGl_Buffer();
+
+ //! Return buffer target.
+ virtual unsigned int GetTarget() const = 0;
+
+ //! Return TRUE if this is a virtual (for backward compatibility) VBO object.
+ virtual bool IsVirtual() const { return false; }
+
+ //! @return true if current object was initialized
+ bool IsValid() const { return myBufferId != NO_BUFFER; }
+
+ //! @return the number of components per generic vertex attribute.
+ unsigned int GetComponentsNb() const { return myComponentsNb; }
+
+ //! @return number of vertex attributes / number of vertices specified within ::Init()
+ Standard_Integer GetElemsNb() const { return myElemsNb; }
+
+ //! Overrides the number of vertex attributes / number of vertexes.
+ //! It is up to user specifying this number correct (e.g. below initial value)!
+ void SetElemsNb (Standard_Integer theNbElems) { myElemsNb = theNbElems; }
+
+ //! @return data type of each component in the array.
+ unsigned int GetDataType() const { return myDataType; }
+
+ //! @return offset to data, NULL by default
+ Standard_Byte* GetDataOffset() const { return myOffset; }
+
+ //! Creates buffer object name (id) if not yet generated.
+ //! Data should be initialized by another method.
+ Standard_EXPORT virtual bool Create (const Handle(OpenGl_Context)& theGlCtx);
+
+ //! Destroy object - will release GPU memory if any.
+ Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
+
+ //! Bind this buffer object.
+ Standard_EXPORT virtual void Bind (const Handle(OpenGl_Context)& theGlCtx) const;
+
+ //! Unbind this buffer object.
+ Standard_EXPORT virtual void Unbind (const Handle(OpenGl_Context)& theGlCtx) const;
+
+ //! Notice that buffer object will be unbound after this call.
+ //! @param theComponentsNb [in] specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
+ //! @param theElemsNb [in] elements count;
+ //! @param theData [in] pointer to float data (vertices/normals etc.).
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const float* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! @param theComponentsNb [in] specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
+ //! @param theElemsNb [in] elements count;
+ //! @param theData [in] pointer to unsigned int data (indices etc.).
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned int* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! @param theComponentsNb [in] specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
+ //! @param theElemsNb [in] elements count;
+ //! @param theData [in] pointer to unsigned short data (indices etc.).
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned short* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! @param theComponentsNb [in] specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
+ //! @param theElemsNb [in] elements count;
+ //! @param theData [in] pointer to Standard_Byte data (indices/colors etc.).
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const Standard_Byte* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! Function replaces portion of data within this buffer object using glBufferSubData().
+ //! The buffer object should be initialized before call.
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [in] pointer to float data.
+ Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const float* theData);
+
+ //! Read back buffer sub-range.
+ //! Notice that buffer object will be unbound after this call.
+ //! Function reads portion of data from this buffer object using glGetBufferSubData().
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [out] destination pointer to float data.
+ Standard_EXPORT bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ float* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! Function replaces portion of data within this buffer object using glBufferSubData().
+ //! The buffer object should be initialized before call.
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [in] pointer to unsigned int data.
+ Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const unsigned int* theData);
+
+ //! Read back buffer sub-range.
+ //! Notice that buffer object will be unbound after this call.
+ //! Function reads portion of data from this buffer object using glGetBufferSubData().
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [out] destination pointer to unsigned int data.
+ Standard_EXPORT bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ unsigned int* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! Function replaces portion of data within this buffer object using glBufferSubData().
+ //! The buffer object should be initialized before call.
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [in] pointer to unsigned short data.
+ Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const unsigned short* theData);
+
+ //! Read back buffer sub-range.
+ //! Notice that buffer object will be unbound after this call.
+ //! Function reads portion of data from this buffer object using glGetBufferSubData().
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [out] destination pointer to unsigned short data.
+ Standard_EXPORT bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ unsigned short* theData);
+
+ //! Notice that buffer object will be unbound after this call.
+ //! Function replaces portion of data within this buffer object using glBufferSubData().
+ //! The buffer object should be initialized before call.
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [in] pointer to Standard_Byte data.
+ Standard_EXPORT bool SubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const Standard_Byte* theData);
+
+ //! Read back buffer sub-range.
+ //! Notice that buffer object will be unbound after this call.
+ //! Function reads portion of data from this buffer object using glGetBufferSubData().
+ //! @param theElemFrom [in] element id from which replace buffer data (>=0);
+ //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
+ //! @param theData [out] destination pointer to Standard_Byte data.
+ Standard_EXPORT bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ Standard_Byte* theData);
+
+public: //! @name advanced methods
+
+ //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
+ virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE
+ {
+ return IsValid()
+ ? sizeOfGlType (myDataType) * myComponentsNb * myElemsNb
+ : 0;
+ }
+
+ //! @return size of specified GL type
+ Standard_EXPORT static size_t sizeOfGlType (unsigned int theType);
+
+ //! Initialize buffer with new data.
+ Standard_EXPORT virtual bool init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType,
+ const Standard_Integer theStride);
+
+ //! Initialize buffer with new data.
+ bool init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType)
+ {
+ return init (theGlCtx, theComponentsNb, theElemsNb, theData, theDataType,
+ Standard_Integer(theComponentsNb) * Standard_Integer(sizeOfGlType (theDataType)));
+ }
+
+ //! Update part of the buffer with new data.
+ Standard_EXPORT virtual bool subData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType);
+
+ //! Read back buffer sub-range.
+ Standard_EXPORT virtual bool getSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ void* theData,
+ const unsigned int theDataType);
+
+public:
+
+ //! Dumps the content of me into the stream
+ Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+protected:
+
+ //! Binds a buffer object to an indexed buffer target.
+ //! Wrapper for glBindBufferBase().
+ //! @param theGlCtx [in] active OpenGL context
+ //! @param theIndex [in] index to bind
+ Standard_EXPORT void BindBufferBase (const Handle(OpenGl_Context)& theGlCtx,
+ unsigned int theIndex);
+
+ //! Unbinds a buffer object from an indexed buffer target.
+ //! Wrapper for glBindBufferBase().
+ //! @param theGlCtx [in] active OpenGL context
+ //! @param theIndex [in] index to bind
+ Standard_EXPORT void UnbindBufferBase (const Handle(OpenGl_Context)& theGlCtx,
+ unsigned int theIndex);
+
+ //! Binds a buffer object to an indexed buffer target with specified offset and size.
+ //! Wrapper for glBindBufferRange().
+ //! @param theGlCtx [in] active OpenGL context
+ //! @param theIndex [in] index to bind (@sa GL_MAX_UNIFORM_BUFFER_BINDINGS in case of uniform buffer)
+ //! @param theOffset [in] offset within the buffer (@sa GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT in case of uniform buffer)
+ //! @param theSize [in] sub-section length starting from offset
+ Standard_EXPORT void BindBufferRange (const Handle(OpenGl_Context)& theGlCtx,
+ unsigned int theIndex,
+ const intptr_t theOffset,
+ const size_t theSize);
+
+protected:
+
+ Standard_Byte* myOffset; //!< offset to data
+ unsigned int myBufferId; //!< VBO name (index)
+ unsigned int myComponentsNb; //!< Number of components per generic vertex attribute, must be 1, 2, 3, or 4
+ Standard_Integer myElemsNb; //!< Number of vertex attributes / number of vertices
+ unsigned int myDataType; //!< Data type (GL_FLOAT, GL_UNSIGNED_INT, GL_UNSIGNED_BYTE etc.)
+
+};
+
+DEFINE_STANDARD_HANDLE(OpenGl_Buffer, OpenGl_Resource)
+
+#endif // _OpenGl_Buffer_H__
--- /dev/null
+// Created by: Kirill GAVRILOV
+// Copyright (c) 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _OpenGl_BufferCompatT_HeaderFile
+#define _OpenGl_BufferCompatT_HeaderFile
+
+#include <NCollection_Buffer.hxx>
+#include <OpenGl_Buffer.hxx>
+
+//! Compatibility layer for old OpenGL without VBO.
+//! Make sure to pass pointer from GetDataOffset() instead of NULL.
+//! Method GetDataOffset() returns pointer to real data in this class
+//! (while base class OpenGl_VertexBuffer always return NULL).
+//!
+//! Methods Bind()/Unbind() do nothing (do not affect OpenGL state)
+//! and ::GetTarget() is never used.
+//! For this reason there is no analog for OpenGl_IndexBuffer.
+//! Just pass GetDataOffset() to glDrawElements() directly as last argument.
+//!
+//! Class overrides methods init() and subData() to copy data into own memory buffer.
+//! Extra method initLink() might be used to pass existing buffer through handle without copying the data.
+//!
+//! Method Create() creates dummy identifier for this object which should NOT be passed to OpenGL functions.
+template<class BaseBufferT>
+class OpenGl_BufferCompatT : public BaseBufferT
+{
+
+public:
+
+ //! Create uninitialized VBO.
+ OpenGl_BufferCompatT()
+ {
+ //
+ }
+
+ //! Destroy object.
+ virtual ~OpenGl_BufferCompatT()
+ {
+ Release (NULL);
+ }
+
+ //! Return TRUE.
+ virtual bool IsVirtual() const Standard_OVERRIDE { return true; }
+
+ //! Creates VBO name (id) if not yet generated.
+ //! Data should be initialized by another method.
+ inline bool Create (const Handle(OpenGl_Context)& theGlCtx) Standard_OVERRIDE;
+
+ //! Destroy object - will release memory if any.
+ inline virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
+
+ //! Bind this VBO.
+ virtual void Bind (const Handle(OpenGl_Context)& ) const Standard_OVERRIDE
+ {
+ //
+ }
+
+ //! Unbind this VBO.
+ virtual void Unbind (const Handle(OpenGl_Context)& ) const Standard_OVERRIDE
+ {
+ //
+ }
+
+public: //! @name advanced methods
+
+ //! Initialize buffer with existing data.
+ //! Data will NOT be copied by this method!
+ inline bool initLink (const Handle(NCollection_Buffer)& theData,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned int theDataType);
+
+ //! Initialize buffer with new data (data will be copied).
+ inline virtual bool init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType,
+ const Standard_Integer theStride) Standard_OVERRIDE;
+
+ //! Update part of the buffer with new data.
+ inline virtual bool subData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType) Standard_OVERRIDE;
+
+ //! Read back buffer sub-range.
+ inline virtual bool getSubData (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ void* theData,
+ const unsigned int theDataType) Standard_OVERRIDE;
+
+protected:
+
+ Handle(NCollection_Buffer) myData; //!< buffer data
+
+};
+
+// =======================================================================
+// function : Create
+// purpose :
+// =======================================================================
+template<class BaseBufferT>
+bool OpenGl_BufferCompatT<BaseBufferT>::Create (const Handle(OpenGl_Context)& )
+{
+ if (BaseBufferT::myBufferId == OpenGl_Buffer::NO_BUFFER)
+ {
+ BaseBufferT::myBufferId = (unsigned int )-1; // dummy identifier...
+ myData = new NCollection_Buffer (Graphic3d_Buffer::DefaultAllocator());
+ }
+ return BaseBufferT::myBufferId != OpenGl_Buffer::NO_BUFFER;
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+template<class BaseBufferT>
+void OpenGl_BufferCompatT<BaseBufferT>::Release (OpenGl_Context* )
+{
+ if (BaseBufferT::myBufferId == OpenGl_Buffer::NO_BUFFER)
+ {
+ return;
+ }
+
+ BaseBufferT::myOffset = NULL;
+ BaseBufferT::myBufferId = OpenGl_Buffer::NO_BUFFER;
+ myData.Nullify();
+}
+
+// =======================================================================
+// function : initLink
+// purpose :
+// =======================================================================
+template<class BaseBufferT>
+bool OpenGl_BufferCompatT<BaseBufferT>::initLink (const Handle(NCollection_Buffer)& theData,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned int theDataType)
+{
+ if (theData.IsNull())
+ {
+ BaseBufferT::myOffset = NULL;
+ return false;
+ }
+
+ if (BaseBufferT::myBufferId == OpenGl_Buffer::NO_BUFFER)
+ {
+ BaseBufferT::myBufferId = (unsigned int )-1; // dummy identifier...
+ }
+ myData = theData;
+ BaseBufferT::myDataType = theDataType;
+ BaseBufferT::myComponentsNb = theComponentsNb;
+ BaseBufferT::myElemsNb = theElemsNb;
+ BaseBufferT::myOffset = myData->ChangeData();
+ return true;
+}
+
+// =======================================================================
+// function : init
+// purpose :
+// =======================================================================
+template<class BaseBufferT>
+bool OpenGl_BufferCompatT<BaseBufferT>::init (const Handle(OpenGl_Context)& theCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType,
+ const Standard_Integer theStride)
+{
+ if (!Create (theCtx))
+ {
+ BaseBufferT::myOffset = NULL;
+ return false;
+ }
+
+ BaseBufferT::myDataType = theDataType;
+ BaseBufferT::myComponentsNb = theComponentsNb;
+ BaseBufferT::myElemsNb = theElemsNb;
+
+ const size_t aNbBytes = size_t(BaseBufferT::myElemsNb) * theStride;
+ if (!myData->Allocate (aNbBytes))
+ {
+ BaseBufferT::myOffset = NULL;
+ return false;
+ }
+
+ BaseBufferT::myOffset = myData->ChangeData();
+ if (theData != NULL)
+ {
+ memcpy (myData->ChangeData(), theData, aNbBytes);
+ }
+ return true;
+}
+
+// =======================================================================
+// function : subData
+// purpose :
+// =======================================================================
+template<class BaseBufferT>
+bool OpenGl_BufferCompatT<BaseBufferT>::subData (const Handle(OpenGl_Context)& ,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ const void* theData,
+ const unsigned int theDataType)
+{
+ if (!BaseBufferT::IsValid() || BaseBufferT::myDataType != theDataType
+ || theElemFrom < 0 || ((theElemFrom + theElemsNb) > BaseBufferT::myElemsNb))
+ {
+ return false;
+ }
+ else if (theData == NULL)
+ {
+ return true;
+ }
+
+ const size_t aDataSize = BaseBufferT::sizeOfGlType (theDataType);
+ const size_t anOffset = size_t(theElemFrom) * size_t(BaseBufferT::myComponentsNb) * aDataSize;
+ const size_t aNbBytes = size_t(theElemsNb) * size_t(BaseBufferT::myComponentsNb) * aDataSize;
+ memcpy (myData->ChangeData() + anOffset, theData, aNbBytes);
+ return true;
+}
+
+// =======================================================================
+// function : getSubData
+// purpose :
+// =======================================================================
+template<class BaseBufferT>
+bool OpenGl_BufferCompatT<BaseBufferT>::getSubData (const Handle(OpenGl_Context)& ,
+ const Standard_Integer theElemFrom,
+ const Standard_Integer theElemsNb,
+ void* theData,
+ const unsigned int theDataType)
+{
+ if (!BaseBufferT::IsValid() || BaseBufferT::myDataType != theDataType
+ || theElemFrom < 0 || ((theElemFrom + theElemsNb) > BaseBufferT::myElemsNb)
+ || theData == NULL)
+ {
+ return false;
+ }
+
+ const size_t aDataSize = BaseBufferT::sizeOfGlType (theDataType);
+ const size_t anOffset = size_t(theElemFrom) * size_t(BaseBufferT::myComponentsNb) * aDataSize;
+ const size_t aNbBytes = size_t(theElemsNb) * size_t(BaseBufferT::myComponentsNb) * aDataSize;
+ memcpy (theData, myData->Data() + anOffset, aNbBytes);
+ return true;
+}
+
+#endif // _OpenGl_VertexBufferCompat_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <OpenGl_ArbFBO.hxx>
#include <OpenGl_DepthPeeling.hxx>
+#include <OpenGl_ArbFBO.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_Texture.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_DepthPeeling, OpenGl_NamedResource)
//=======================================================================
#define _OpenGl_DepthPeeling_HeaderFile
#include <OpenGl_FrameBuffer.hxx>
+#include <OpenGl_NamedResource.hxx>
//! Class provides FBOs for dual depth peeling.
class OpenGl_DepthPeeling : public OpenGl_NamedResource
// commercial license or contractual agreement.
#include <OpenGl_FrameBuffer.hxx>
+
#include <OpenGl_ArbFBO.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_Texture.hxx>
#include <Standard_Assert.hxx>
#include <TCollection_ExtendedString.hxx>
Release (NULL);
}
+// =======================================================================
+// function : GetSizeX
+// purpose :
+// =======================================================================
+Standard_Integer OpenGl_FrameBuffer::GetSizeX() const
+{
+ return !myColorTextures.IsEmpty() ? myColorTextures.First()->SizeX() : 0;
+}
+
+// =======================================================================
+// function : GetSizeY
+// purpose :
+// =======================================================================
+Standard_Integer OpenGl_FrameBuffer::GetSizeY() const
+{
+ return !myColorTextures.IsEmpty() ? myColorTextures.First()->SizeY() : 0;
+}
+
// =======================================================================
// function : InitWrapper
// purpose :
// purpose :
// =======================================================================
Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlContext,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
- const GLint theColorFormat,
- const GLint theDepthFormat,
- const GLsizei theNbSamples)
+ const Graphic3d_Vec2i& theSize,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples)
{
OpenGl_ColorFormats aColorFormats;
if (theColorFormat != 0)
{
aColorFormats.Append (theColorFormat);
}
- return Init (theGlContext, theSizeX, theSizeY, aColorFormats, theDepthFormat, theNbSamples);
+ return Init (theGlContext, theSize, aColorFormats, theDepthFormat, theNbSamples);
}
// =======================================================================
// purpose :
// =======================================================================
Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlContext,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
+ const Graphic3d_Vec2i& theSize,
const OpenGl_ColorFormats& theColorFormats,
const Handle(OpenGl_Texture)& theDepthStencilTexture,
- const GLsizei theNbSamples)
+ const Standard_Integer theNbSamples)
{
myColorFormats = theColorFormats;
myIsOwnBuffer = true;
// setup viewport sizes as is
- myVPSizeX = theSizeX;
- myVPSizeY = theSizeY;
- const Standard_Integer aSizeX = theSizeX > 0 ? theSizeX : 2;
- const Standard_Integer aSizeY = theSizeY > 0 ? theSizeY : 2;
+ myVPSizeX = theSize.x();
+ myVPSizeY = theSize.y();
+ const Standard_Integer aSizeX = theSize.x() > 0 ? theSize.x() : 2;
+ const Standard_Integer aSizeY = theSize.y() > 0 ? theSize.y() : 2;
// Create the textures (will be used as color buffer and depth-stencil buffer)
if (theNbSamples != 0)
// purpose :
// =======================================================================
Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlContext,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
+ const Graphic3d_Vec2i& theSize,
const OpenGl_ColorFormats& theColorFormats,
- const GLint theDepthFormat,
- const GLsizei theNbSamples)
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples)
{
myColorFormats = theColorFormats;
myDepthFormat = theDepthFormat;
myNbSamples = theNbSamples;
- myInitVPSizeX = theSizeX;
- myInitVPSizeY = theSizeY;
+ myInitVPSizeX = theSize.x();
+ myInitVPSizeY = theSize.y();
if (theGlContext->arbFBO == NULL)
{
return Standard_False;
myIsOwnDepth = true;
// setup viewport sizes as is
- myVPSizeX = theSizeX;
- myVPSizeY = theSizeY;
- const Standard_Integer aSizeX = theSizeX > 0 ? theSizeX : 2;
- const Standard_Integer aSizeY = theSizeY > 0 ? theSizeY : 2;
+ myVPSizeX = theSize.x();
+ myVPSizeY = theSize.y();
+ const Standard_Integer aSizeX = theSize.x() > 0 ? theSize.x() : 2;
+ const Standard_Integer aSizeY = theSize.y() > 0 ? theSize.y() : 2;
bool hasStencilRB = false;
// Create the textures (will be used as color buffer and depth-stencil buffer)
// purpose :
// =======================================================================
Standard_Boolean OpenGl_FrameBuffer::InitLazy (const Handle(OpenGl_Context)& theGlContext,
- const GLsizei theViewportSizeX,
- const GLsizei theViewportSizeY,
- const GLint theColorFormat,
- const GLint theDepthFormat,
- const GLsizei theNbSamples)
+ const Graphic3d_Vec2i& theViewportSize,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples)
{
OpenGl_ColorFormats aColorFormats;
-
aColorFormats.Append (theColorFormat);
-
- return InitLazy (theGlContext, theViewportSizeX, theViewportSizeY, aColorFormats, theDepthFormat, theNbSamples);
+ return InitLazy (theGlContext, theViewportSize, aColorFormats, theDepthFormat, theNbSamples);
}
// =======================================================================
// purpose :
// =======================================================================
Standard_Boolean OpenGl_FrameBuffer::InitLazy (const Handle(OpenGl_Context)& theGlContext,
- const GLsizei theViewportSizeX,
- const GLsizei theViewportSizeY,
+ const Graphic3d_Vec2i& theViewportSize,
const OpenGl_ColorFormats& theColorFormats,
- const GLint theDepthFormat,
- const GLsizei theNbSamples)
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples)
{
- if (myVPSizeX == theViewportSizeX
- && myVPSizeY == theViewportSizeY
+ if (myVPSizeX == theViewportSize.x()
+ && myVPSizeY == theViewportSize.y()
&& myColorFormats == theColorFormats
&& myDepthFormat == theDepthFormat
&& myNbSamples == theNbSamples)
return IsValid();
}
- return Init (theGlContext, theViewportSizeX, theViewportSizeY, theColorFormats, theDepthFormat, theNbSamples);
+ return Init (theGlContext, theViewportSize, theColorFormats, theDepthFormat, theNbSamples);
}
// =======================================================================
// purpose :
// =======================================================================
Standard_Boolean OpenGl_FrameBuffer::InitWithRB (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
- const GLint theColorFormat,
- const GLint theDepthFormat,
- const GLuint theColorRBufferFromWindow)
+ const Graphic3d_Vec2i& theSize,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const unsigned int theColorRBufferFromWindow)
{
myColorFormats.Clear();
myColorFormats.Append (theColorFormat);
myDepthFormat = theDepthFormat;
myNbSamples = 0;
- myInitVPSizeX = theSizeX;
- myInitVPSizeY = theSizeY;
+ myInitVPSizeX = theSize.x();
+ myInitVPSizeY = theSize.y();
if (theGlCtx->arbFBO == NULL)
{
return Standard_False;
myIsOwnDepth = true;
// setup viewport sizes as is
- myVPSizeX = theSizeX;
- myVPSizeY = theSizeY;
- const Standard_Integer aSizeX = theSizeX > 0 ? theSizeX : 2;
- const Standard_Integer aSizeY = theSizeY > 0 ? theSizeY : 2;
+ myVPSizeX = theSize.x();
+ myVPSizeY = theSize.y();
+ const Standard_Integer aSizeX = theSize.x() > 0 ? theSize.x() : 2;
+ const Standard_Integer aSizeY = theSize.y() > 0 ? theSize.y() : 2;
// Create the render-buffers
if (theColorRBufferFromWindow != NO_RENDERBUFFER)
// function : ChangeViewport
// purpose :
// =======================================================================
-void OpenGl_FrameBuffer::ChangeViewport (const GLsizei theVPSizeX,
- const GLsizei theVPSizeY)
+void OpenGl_FrameBuffer::ChangeViewport (const Standard_Integer theVPSizeX,
+ const Standard_Integer theVPSizeY)
{
myVPSizeX = theVPSizeX;
myVPSizeY = theVPSizeY;
#ifndef OPENGL_FRAME_BUFFER_H
#define OPENGL_FRAME_BUFFER_H
-#include <OpenGl_Context.hxx>
#include <OpenGl_Resource.hxx>
-#include <OpenGl_Texture.hxx>
#include <Graphic3d_BufferType.hxx>
+#include <Graphic3d_Vec2.hxx>
#include <NCollection_Vector.hxx>
+#include <NCollection_Sequence.hxx>
+
+class Image_PixMap;
+class OpenGl_Texture;
-class OpenGl_FrameBuffer;
DEFINE_STANDARD_HANDLE(OpenGl_FrameBuffer, OpenGl_Resource)
//! Short declaration of useful collection types.
-typedef NCollection_Vector<GLint> OpenGl_ColorFormats;
+typedef NCollection_Vector<Standard_Integer> OpenGl_ColorFormats;
//! Class implements FrameBuffer Object (FBO) resource
//! intended for off-screen rendering.
public:
//! Helpful constants
- static const GLuint NO_FRAMEBUFFER = 0;
- static const GLuint NO_RENDERBUFFER = 0;
+ static const unsigned int NO_FRAMEBUFFER = 0;
+ static const unsigned int NO_RENDERBUFFER = 0;
public:
Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
//! Number of multisampling samples.
- GLsizei NbSamples() const
- {
- return myNbSamples;
- }
+ Standard_Integer NbSamples() const { return myNbSamples; }
//! Number of color buffers.
- GLsizei NbColorBuffers() const
- {
- return myColorTextures.Length();
- }
+ Standard_Integer NbColorBuffers() const { return myColorTextures.Length(); }
//! Return true if FBO has been created with color attachment.
- bool HasColor() const
- {
- return !myColorFormats.IsEmpty();
- }
+ bool HasColor() const { return !myColorFormats.IsEmpty(); }
//! Return true if FBO has been created with depth attachment.
- bool HasDepth() const
- {
- return myDepthFormat != 0;
- }
+ bool HasDepth() const { return myDepthFormat != 0; }
+
+ //! Return textures width x height.
+ Graphic3d_Vec2i GetSize() const { return Graphic3d_Vec2i (GetSizeX(), GetSizeY()); }
//! Textures width.
- GLsizei GetSizeX() const
- {
- return myColorTextures (0)->SizeX();
- }
+ Standard_EXPORT Standard_Integer GetSizeX() const;
//! Textures height.
- GLsizei GetSizeY() const
- {
- return myColorTextures (0)->SizeY();
- }
+ Standard_EXPORT Standard_Integer GetSizeY() const;
+
+ //! Return viewport width x height.
+ Graphic3d_Vec2i GetVPSize() const { return Graphic3d_Vec2i (myVPSizeX, myVPSizeY); }
//! Viewport width.
- GLsizei GetVPSizeX() const
- {
- return myVPSizeX;
- }
+ Standard_Integer GetVPSizeX() const { return myVPSizeX; }
//! Viewport height.
- GLsizei GetVPSizeY() const
- {
- return myVPSizeY;
- }
+ Standard_Integer GetVPSizeY() const { return myVPSizeY; }
+
+ //! Return viewport width x height.
+ Graphic3d_Vec2i GetInitVPSize() const { return Graphic3d_Vec2i (myInitVPSizeX, myInitVPSizeY); }
//! Viewport width.
- GLsizei GetInitVPSizeX() const
- {
- return myInitVPSizeX;
- }
+ Standard_Integer GetInitVPSizeX() const { return myInitVPSizeX; }
//! Viewport height.
- GLsizei GetInitVPSizeY() const
- {
- return myInitVPSizeY;
- }
+ Standard_Integer GetInitVPSizeY() const { return myInitVPSizeY; }
//! Returns true if current object was initialized
Standard_Boolean IsValid() const
//! Initialize FBO for rendering into single/multiple color buffer and depth textures.
//! @param theGlCtx currently bound OpenGL context
- //! @param theSizeX texture width
- //! @param theSizeY texture height
+ //! @param theSize texture width x height
//! @param theColorFormats list of color texture sized format (0 means no color attachment), e.g. GL_RGBA8
//! @param theDepthStencilTexture depth-stencil texture
//! @param theNbSamples MSAA number of samples (0 means normal texture)
//! @return true on success
Standard_EXPORT Standard_Boolean Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
+ const Graphic3d_Vec2i& theSize,
const OpenGl_ColorFormats& theColorFormats,
const Handle(OpenGl_Texture)& theDepthStencilTexture,
- const GLsizei theNbSamples = 0);
+ const Standard_Integer theNbSamples = 0);
//! Initialize FBO for rendering into textures.
//! @param theGlCtx currently bound OpenGL context
- //! @param theSizeX texture width
- //! @param theSizeY texture height
+ //! @param theSize texture width x height
//! @param theColorFormat color texture sized format (0 means no color attachment), e.g. GL_RGBA8
//! @param theDepthFormat depth-stencil texture sized format (0 means no depth attachment), e.g. GL_DEPTH24_STENCIL8
//! @param theNbSamples MSAA number of samples (0 means normal texture)
//! @return true on success
Standard_EXPORT Standard_Boolean Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
- const GLint theColorFormat,
- const GLint theDepthFormat,
- const GLsizei theNbSamples = 0);
+ const Graphic3d_Vec2i& theSize,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0);
//! Initialize FBO for rendering into single/multiple color buffer and depth textures.
//! @param theGlCtx currently bound OpenGL context
- //! @param theSizeX texture width
- //! @param theSizeY texture height
+ //! @param theSize texture width x height
//! @param theColorFormats list of color texture sized format (0 means no color attachment), e.g. GL_RGBA8
//! @param theDepthFormat depth-stencil texture sized format (0 means no depth attachment), e.g. GL_DEPTH24_STENCIL8
//! @param theNbSamples MSAA number of samples (0 means normal texture)
//! @return true on success
Standard_EXPORT Standard_Boolean Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
+ const Graphic3d_Vec2i& theSize,
const OpenGl_ColorFormats& theColorFormats,
- const GLint theDepthFormat,
- const GLsizei theNbSamples = 0);
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0);
//! (Re-)initialize FBO with specified dimensions.
Standard_EXPORT Standard_Boolean InitLazy (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theViewportSizeX,
- const GLsizei theViewportSizeY,
- const GLint theColorFormat,
- const GLint theDepthFormat,
- const GLsizei theNbSamples = 0);
+ const Graphic3d_Vec2i& theViewportSize,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0);
//! (Re-)initialize FBO with specified dimensions.
Standard_EXPORT Standard_Boolean InitLazy (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theViewportSizeX,
- const GLsizei theViewportSizeY,
+ const Graphic3d_Vec2i& theViewportSize,
const OpenGl_ColorFormats& theColorFormats,
- const GLint theDepthFormat,
- const GLsizei theNbSamples = 0);
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0);
//! (Re-)initialize FBO with properties taken from another FBO.
Standard_Boolean InitLazy (const Handle(OpenGl_Context)& theGlCtx,
const OpenGl_FrameBuffer& theFbo)
{
- return InitLazy (theGlCtx, theFbo.myVPSizeX, theFbo.myVPSizeY, theFbo.myColorFormats, theFbo.myDepthFormat, theFbo.myNbSamples);
+ return InitLazy (theGlCtx, Graphic3d_Vec2i (theFbo.myVPSizeX, theFbo.myVPSizeY), theFbo.myColorFormats, theFbo.myDepthFormat, theFbo.myNbSamples);
}
//! (Re-)initialize FBO with specified dimensions.
//! The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).
//! @param theGlCtx currently bound OpenGL context
- //! @param theSizeX render buffer width
- //! @param theSizeY render buffer height
+ //! @param theSize render buffer width x height
//! @param theColorFormat color render buffer sized format, e.g. GL_RGBA8
//! @param theDepthFormat depth-stencil render buffer sized format, e.g. GL_DEPTH24_STENCIL8
//! @param theColorRBufferFromWindow when specified - should be ID of already initialized RB object, which will be released within this class
Standard_EXPORT Standard_Boolean InitWithRB (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
- const GLint theColorFormat,
- const GLint theDepthFormat,
- const GLuint theColorRBufferFromWindow = 0);
+ const Graphic3d_Vec2i& theSize,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const unsigned int theColorRBufferFromWindow = 0);
//! Initialize class from currently bound FBO.
//! Retrieved OpenGL objects will not be destroyed on Release.
Standard_EXPORT void SetupViewport (const Handle(OpenGl_Context)& theGlCtx);
//! Override viewport settings
- Standard_EXPORT void ChangeViewport (const GLsizei theVPSizeX,
- const GLsizei theVPSizeY);
+ Standard_EXPORT void ChangeViewport (const Standard_Integer theVPSizeX,
+ const Standard_Integer theVPSizeY);
//! Bind frame buffer for drawing and reading (to render into the texture).
Standard_EXPORT virtual void BindBuffer (const Handle(OpenGl_Context)& theGlCtx);
Standard_EXPORT virtual void UnbindBuffer (const Handle(OpenGl_Context)& theGlCtx);
//! Returns the color texture for the given color buffer index.
- const Handle(OpenGl_Texture)& ColorTexture (const GLint theColorBufferIndex = 0) const
+ const Handle(OpenGl_Texture)& ColorTexture (const Standard_Integer theColorBufferIndex = 0) const
{
- return myColorTextures (theColorBufferIndex);
+ return myColorTextures.Value (theColorBufferIndex);
}
//! Returns the depth-stencil texture.
- const Handle(OpenGl_Texture)& DepthStencilTexture() const
+ const Handle(OpenGl_Texture)& DepthStencilTexture() const { return myDepthStencilTexture; }
+
+ //! Returns the color Render Buffer.
+ unsigned int ColorRenderBuffer() const { return myGlColorRBufferId; }
+
+ //! Returns the depth Render Buffer.
+ unsigned int DepthStencilRenderBuffer() const { return myGlDepthRBufferId; }
+
+ //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
+ Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
+
+public:
+
+ //! Initialize FBO for rendering into single/multiple color buffer and depth textures.
+ Standard_DEPRECATED("Obsolete method, use Init() taking Graphic3d_Vec2i")
+ bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY,
+ const OpenGl_ColorFormats& theColorFormats,
+ const Handle(OpenGl_Texture)& theDepthStencilTexture,
+ const Standard_Integer theNbSamples = 0)
{
- return myDepthStencilTexture;
+ return Init (theGlCtx, Graphic3d_Vec2i (theSizeX, theSizeY), theColorFormats, theDepthStencilTexture, theNbSamples);
}
- //! Returns the color Render Buffer.
- GLuint ColorRenderBuffer() const
+ //! Initialize FBO for rendering into textures.
+ Standard_DEPRECATED("Obsolete method, use Init() taking Graphic3d_Vec2i")
+ bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0)
{
- return myGlColorRBufferId;
+ return Init (theGlCtx, Graphic3d_Vec2i (theSizeX, theSizeY), theColorFormat, theDepthFormat, theNbSamples);
}
- //! Returns the depth Render Buffer.
- GLuint DepthStencilRenderBuffer() const
+ //! Initialize FBO for rendering into single/multiple color buffer and depth textures.
+ Standard_DEPRECATED("Obsolete method, use Init() taking Graphic3d_Vec2i")
+ bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY,
+ const OpenGl_ColorFormats& theColorFormats,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0)
{
- return myGlDepthRBufferId;
+ return Init (theGlCtx, Graphic3d_Vec2i (theSizeX, theSizeY), theColorFormats, theDepthFormat, theNbSamples);
}
- //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
- Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
+ //! (Re-)initialize FBO with specified dimensions.
+ Standard_DEPRECATED("Obsolete method, use InitLazy() taking Graphic3d_Vec2i")
+ bool InitLazy (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theViewportSizeX,
+ const Standard_Integer theViewportSizeY,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0)
+ {
+ return InitLazy (theGlCtx, Graphic3d_Vec2i (theViewportSizeX, theViewportSizeY), theColorFormat, theDepthFormat, theNbSamples);
+ }
+
+ //! (Re-)initialize FBO with specified dimensions.
+ Standard_DEPRECATED("Obsolete method, use InitLazy() taking Graphic3d_Vec2i")
+ bool InitLazy (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theViewportSizeX,
+ const Standard_Integer theViewportSizeY,
+ const OpenGl_ColorFormats& theColorFormats,
+ const Standard_Integer theDepthFormat,
+ const Standard_Integer theNbSamples = 0)
+ {
+ return InitLazy (theGlCtx, Graphic3d_Vec2i (theViewportSizeX, theViewportSizeY), theColorFormats, theDepthFormat, theNbSamples);
+ }
+
+ //! (Re-)initialize FBO with specified dimensions.
+ //! The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).
+ Standard_DEPRECATED("Obsolete method, use InitWithRB() taking Graphic3d_Vec2i")
+ bool InitWithRB (const Handle(OpenGl_Context)& theGlCtx,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY,
+ const Standard_Integer theColorFormat,
+ const Standard_Integer theDepthFormat,
+ const unsigned int theColorRBufferFromWindow = 0)
+ {
+ return InitWithRB (theGlCtx, Graphic3d_Vec2i (theSizeX, theSizeY), theColorFormat, theDepthFormat, theColorRBufferFromWindow);
+ }
protected:
protected:
- GLsizei myInitVPSizeX; //!< viewport width specified during initialization (kept even on failure)
- GLsizei myInitVPSizeY; //!< viewport height specified during initialization (kept even on failure)
- GLsizei myVPSizeX; //!< viewport width (should be <= texture width)
- GLsizei myVPSizeY; //!< viewport height (should be <= texture height)
- GLsizei myNbSamples; //!< number of MSAA samples
+ Standard_Integer myInitVPSizeX; //!< viewport width specified during initialization (kept even on failure)
+ Standard_Integer myInitVPSizeY; //!< viewport height specified during initialization (kept even on failure)
+ Standard_Integer myVPSizeX; //!< viewport width (should be <= texture width)
+ Standard_Integer myVPSizeY; //!< viewport height (should be <= texture height)
+ Standard_Integer myNbSamples; //!< number of MSAA samples
OpenGl_ColorFormats myColorFormats; //!< sized format for color texture, GL_RGBA8 by default
- GLint myDepthFormat; //!< sized format for depth-stencil texture, GL_DEPTH24_STENCIL8 by default
- GLuint myGlFBufferId; //!< FBO object ID
- GLuint myGlColorRBufferId; //!< color Render Buffer object (alternative to myColorTexture)
- GLuint myGlDepthRBufferId; //!< depth-stencil Render Buffer object (alternative to myDepthStencilTexture)
+ Standard_Integer myDepthFormat; //!< sized format for depth-stencil texture, GL_DEPTH24_STENCIL8 by default
+ unsigned int myGlFBufferId; //!< FBO object ID
+ unsigned int myGlColorRBufferId; //!< color Render Buffer object (alternative to myColorTexture)
+ unsigned int myGlDepthRBufferId; //!< depth-stencil Render Buffer object (alternative to myDepthStencilTexture)
bool myIsOwnBuffer; //!< flag indicating that FBO should be deallocated by this class
bool myIsOwnColor; //!< flag indicating that color textures should be deallocated by this class
bool myIsOwnDepth; //!< flag indicating that depth texture should be deallocated by this class
#include <OpenGl_View.hxx>
#include <OpenGl_DepthPeeling.hxx>
#include <OpenGl_ShadowMap.hxx>
+#include <OpenGl_TextureBuffer.hxx>
+#include <OpenGl_Window.hxx>
#include <OpenGl_Workspace.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_FrameStats, Graphic3d_FrameStats)
#include <OpenGl_FrameStatsPrs.hxx>
#include <OpenGl_View.hxx>
+#include <OpenGl_IndexBuffer.hxx>
+#include <OpenGl_VertexBuffer.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_StencilTest.hxx>
#include <OpenGl_Text.hxx>
+#include <OpenGl_Window.hxx>
#include <OpenGl_Workspace.hxx>
#include <Aspect_GraphicDeviceDefinitionError.hxx>
#include <OpenGl_Context.hxx>
#include <Standard_Assert.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(OpenGl_IndexBuffer,OpenGl_VertexBuffer)
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_IndexBuffer, OpenGl_Buffer)
// =======================================================================
// function : OpenGl_IndexBuffer
// purpose :
// =======================================================================
OpenGl_IndexBuffer::OpenGl_IndexBuffer()
-: OpenGl_VertexBuffer() {}
+: OpenGl_Buffer() {}
// =======================================================================
// function : GetTarget
// purpose :
// =======================================================================
-GLenum OpenGl_IndexBuffer::GetTarget() const
+unsigned int OpenGl_IndexBuffer::GetTarget() const
{
return GL_ELEMENT_ARRAY_BUFFER;
}
void OpenGl_IndexBuffer::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
- OCCT_DUMP_BASE_CLASS (theOStream, theDepth, OpenGl_VertexBuffer)
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, OpenGl_Buffer)
}
#ifndef _OpenGl_IndexBuffer_H__
#define _OpenGl_IndexBuffer_H__
-#include <OpenGl_VertexBuffer.hxx>
+#include <OpenGl_Buffer.hxx>
//! Index buffer is just a VBO with special target (GL_ELEMENT_ARRAY_BUFFER).
-class OpenGl_IndexBuffer : public OpenGl_VertexBuffer
+class OpenGl_IndexBuffer : public OpenGl_Buffer
{
public:
+ //! Empty constructor.
Standard_EXPORT OpenGl_IndexBuffer();
- Standard_EXPORT virtual GLenum GetTarget() const Standard_OVERRIDE;
+
+ //! Return buffer object target (GL_ELEMENT_ARRAY_BUFFER).
+ Standard_EXPORT virtual unsigned int GetTarget() const Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
public:
- DEFINE_STANDARD_RTTIEXT(OpenGl_IndexBuffer,OpenGl_VertexBuffer) // Type definition
+ DEFINE_STANDARD_RTTIEXT(OpenGl_IndexBuffer, OpenGl_Buffer)
};
-DEFINE_STANDARD_HANDLE(OpenGl_IndexBuffer, OpenGl_VertexBuffer)
+DEFINE_STANDARD_HANDLE(OpenGl_IndexBuffer, OpenGl_Buffer)
#endif // _OpenGl_IndexBuffer_H__
#include <OpenGl_ArbFBO.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_ShaderManager.hxx>
+#include <OpenGl_ShaderProgram.hxx>
#include <OSD_Timer.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
aVboAttribs->initLink (myAttribs, 0, myAttribs->NbElements, GL_NONE);
if (!myIndices.IsNull())
{
- Handle(OpenGl_VertexBufferCompat) aVboIndices = new OpenGl_VertexBufferCompat();
+ Handle(OpenGl_IndexBufferCompat) aVboIndices = new OpenGl_IndexBufferCompat();
switch (myIndices->Stride)
{
case 2:
#ifndef OpenGl_PrimitiveArray_Header
#define OpenGl_PrimitiveArray_Header
-#include <OpenGl_IndexBuffer.hxx>
-
#include <Aspect_InteriorStyle.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Graphic3d_TypeOfPrimitiveArray.hxx>
#include <OpenGl_Element.hxx>
+class OpenGl_IndexBuffer;
+class OpenGl_VertexBuffer;
class OpenGl_GraphicDriver;
//! Class for rendering of arbitrary primitive array.
void Invalidate() const { myIsVboInit = Standard_False; }
//! @return primitive type (GL_LINES, GL_TRIANGLES and others)
- GLint DrawMode() const { return myDrawMode; }
+ Standard_Integer DrawMode() const { return myDrawMode; }
//! Return TRUE if primitive type generates shaded triangulation.
virtual Standard_Boolean IsFillDrawMode() const Standard_OVERRIDE { return myIsFillType; }
public:
//! Returns index VBO.
- const Handle(OpenGl_VertexBuffer)& IndexVbo() const { return myVboIndices; }
+ const Handle(OpenGl_IndexBuffer)& IndexVbo() const { return myVboIndices; }
//! Returns attributes VBO.
const Handle(OpenGl_VertexBuffer)& AttributesVbo() const { return myVboAttribs; }
protected:
- mutable Handle(OpenGl_VertexBuffer) myVboIndices;
+ mutable Handle(OpenGl_IndexBuffer) myVboIndices;
mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
mutable Handle(Graphic3d_IndexBuffer) myIndices;
mutable Handle(Graphic3d_Buffer) myAttribs;
mutable Handle(Graphic3d_BoundBuffer) myBounds;
- GLshort myDrawMode;
+ short myDrawMode;
mutable Standard_Boolean myIsFillType;
mutable Standard_Boolean myIsVboInit;
#include <OpenGl_Sampler.hxx>
#include <OpenGl_ArbSamplerObject.hxx>
+#include <OpenGl_Context.hxx>
#include <OpenGl_Texture.hxx>
#include <Standard_Assert.hxx>
// purpose :
// =======================================================================
void OpenGl_Sampler::setParameter (const Handle(OpenGl_Context)& theCtx,
- OpenGl_Sampler* theSampler,
- GLenum theTarget,
- GLenum theParam,
- GLint theValue)
+ OpenGl_Sampler* theSampler,
+ unsigned int theTarget,
+ unsigned int theParam,
+ Standard_Integer theValue)
{
if (theSampler != NULL && theSampler->isValidSampler())
{
void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureParams)& theParams,
OpenGl_Sampler* theSampler,
- const GLenum theTarget,
+ const unsigned int theTarget,
const Standard_Integer theMaxMipLevels)
{
if (theSampler != NULL && theSampler->Parameters() == theParams)
#ifndef _OpenGl_Sampler_Header
#define _OpenGl_Sampler_Header
-#include <OpenGl_Context.hxx>
+#include <Graphic3d_TextureParams.hxx>
#include <OpenGl_Resource.hxx>
class OpenGl_Texture;
public:
//! Helpful constant defining invalid sampler identifier
- static const GLuint NO_SAMPLER = 0;
+ static const unsigned int NO_SAMPLER = 0;
public:
//! Sets specific sampler parameter.
void SetParameter (const Handle(OpenGl_Context)& theCtx,
- GLenum theTarget,
- GLenum theParam,
- GLint theValue)
+ unsigned int theTarget,
+ unsigned int theParam,
+ Standard_Integer theValue)
{
setParameter (theCtx, this, theTarget, theParam, theValue);
}
//! Returns OpenGL sampler ID.
- GLuint SamplerID() const
+ unsigned int SamplerID() const
{
return mySamplerID;
}
//! Sets specific sampler parameter.
Standard_EXPORT static void setParameter (const Handle(OpenGl_Context)& theContext,
OpenGl_Sampler* theSampler,
- GLenum theTarget,
- GLenum theParam,
- GLint theValue);
+ unsigned int theTarget,
+ unsigned int theParam,
+ Standard_Integer theValue);
//! Apply sampler parameters.
//! @param theCtx [in] active OpenGL context
Standard_EXPORT static void applySamplerParams (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureParams)& theParams,
OpenGl_Sampler* theSampler,
- const GLenum theTarget,
+ const unsigned int theTarget,
const Standard_Integer theMaxMipLevel);
//! Apply global texture state for deprecated OpenGL functionality.
Handle(Graphic3d_TextureParams) myParams; //!< texture parameters
unsigned int mySamplerRevision; //!< modification counter of parameters related to sampler state
- GLuint mySamplerID; //!< OpenGL sampler object ID
+ unsigned int mySamplerID; //!< OpenGL sampler object ID
bool myIsImmutable; //!< immutable flag preventing further modifications of sampler parameters, FALSE by default
};
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <OSD_Timer.hxx>
+#include <OpenGl_SceneGeometry.hxx>
+
+#include <Graphic3d_GraphicDriver.hxx>
#include <OSD_Parallel.hxx>
+#include <OSD_Timer.hxx>
#include <Standard_Assert.hxx>
#include <OpenGl_ArbTexBindless.hxx>
#include <OpenGl_PrimitiveArray.hxx>
-#include <OpenGl_SceneGeometry.hxx>
#include <OpenGl_Structure.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
+#include <OpenGl_TextureBuffer.hxx>
-//! Use this macro to output BVH profiling info
+// Use this macro to output BVH profiling info
// #define RAY_TRACE_PRINT_INFO
namespace
#include <BVH_Triangulation.hxx>
#include <BVH_BinnedBuilder.hxx>
#include <NCollection_StdAllocator.hxx>
-#include <OpenGl_TextureBufferArb.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_Sampler.hxx>
#include <Graphic3d_ShaderManager.hxx>
#include <NCollection_Sequence.hxx>
+#include <OpenGl_Aspects.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_MaterialState.hxx>
#include <OpenGl_PBREnvironment.hxx>
#include <OpenGl_SetOfShaderPrograms.hxx>
+#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_ShaderStates.hxx>
-#include <OpenGl_Aspects.hxx>
-#include <OpenGl_MaterialState.hxx>
#include <OpenGl_Texture.hxx>
+#include <OpenGl_TextureSet.hxx>
class OpenGl_View;
class OpenGl_VertexBuffer;
// purpose :
// =======================================================================
bool OpenGl_Texture::Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
- const GLsizei theNbSamples,
- const GLint theTextFormat,
- const GLsizei theSizeX,
- const GLsizei theSizeY)
+ const Standard_Integer theNbSamples,
+ const Standard_Integer theTextFormat,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY)
{
if (!Create (theCtx)
|| theNbSamples > theCtx->MaxMsaaSamples()
#define _OpenGl_Texture_H__
#include <Graphic3d_CubeMap.hxx>
+#include <Graphic3d_Vec3.hxx>
#include <OpenGl_TextureFormat.hxx>
#include <OpenGl_NamedResource.hxx>
#include <OpenGl_Sampler.hxx>
public:
//! Helpful constants
- static const GLuint NO_TEXTURE = 0;
+ static const unsigned int NO_TEXTURE = 0;
//! Return pixel size of pixel format in bytes.
//! Note that this method considers that OpenGL natively supports this pixel format,
virtual bool IsValid() const { return myTextureId != NO_TEXTURE; }
//! @return target to which the texture is bound (GL_TEXTURE_1D, GL_TEXTURE_2D)
- GLenum GetTarget() const { return myTarget; }
+ unsigned int GetTarget() const { return myTarget; }
//! @return texture width (0 LOD)
GLsizei SizeX() const { return mySizeX; }
GLsizei SizeY() const { return mySizeY; }
//! @return texture ID
- GLuint TextureId() const { return myTextureId; }
+ unsigned int TextureId() const { return myTextureId; }
//! @return texture format (not sized)
- GLenum GetFormat() const { return myTextFormat; }
+ unsigned int GetFormat() const { return myTextFormat; }
//! @return texture format (sized)
- GLint SizedFormat() const { return mySizedFormat; }
+ Standard_Integer SizedFormat() const { return mySizedFormat; }
//! Return true for GL_RED and GL_ALPHA formats.
bool IsAlpha() const { return myIsAlpha; }
//! Initialize the 2D multisampling texture using glTexImage2DMultisample().
Standard_EXPORT bool Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
- const GLsizei theNbSamples,
- const GLint theTextFormat,
- const GLsizei theSizeX,
- const GLsizei theSizeY);
+ const Standard_Integer theNbSamples,
+ const Standard_Integer theTextFormat,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY);
//! Allocates texture rectangle with specified format and size.
//! \note Texture data is not initialized (will contain trash).
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat::FindFormat() should be used instead")
static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
- const Image_Format theFormat,
- GLint& theTextFormat,
- GLenum& thePixelFormat,
- GLenum& theDataType)
+ const Image_Format theFormat,
+ Standard_Integer& theTextFormat,
+ unsigned int& thePixelFormat,
+ unsigned int& theDataType)
{
OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theFormat, false);
theTextFormat = aFormat.InternalFormat();
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat::FindFormat() should be used instead")
static bool GetDataFormat (const Handle(OpenGl_Context)& theCtx,
- const Image_PixMap& theData,
- GLint& theTextFormat,
- GLenum& thePixelFormat,
- GLenum& theDataType)
+ const Image_PixMap& theData,
+ Standard_Integer& theTextFormat,
+ unsigned int& thePixelFormat,
+ unsigned int& theDataType)
{
OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindFormat (theCtx, theData.Format(), false);
theTextFormat = aFormat.InternalFormat();
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat should be passed instead of separate parameters")
bool Init (const Handle(OpenGl_Context)& theCtx,
- const GLint theTextFormat,
- const GLenum thePixelFormat,
- const GLenum theDataType,
- const GLsizei theSizeX,
- const GLsizei theSizeY,
+ const Standard_Integer theTextFormat,
+ const unsigned int thePixelFormat,
+ const unsigned int theDataType,
+ const Standard_Integer theSizeX,
+ const Standard_Integer theSizeY,
const Graphic3d_TypeOfTexture theType,
const Image_PixMap* theImage = NULL)
{
Standard_DEPRECATED("Deprecated method, OpenGl_TextureFormat should be passed instead of separate parameters")
bool Init3D (const Handle(OpenGl_Context)& theCtx,
- const GLint theTextFormat,
- const GLenum thePixelFormat,
- const GLenum theDataType,
+ const Standard_Integer theTextFormat,
+ const unsigned int thePixelFormat,
+ const unsigned int theDataType,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
const Standard_Integer theSizeZ,
//! Initializes 6 sides of cubemap.
//! If theCubeMap is not NULL then size and format will be taken from it and corresponding arguments will be ignored.
- //! Otherwise this parametres will be taken from arguments.
+ //! Otherwise this parameters will be taken from arguments.
//! @param theCtx [in] active OpenGL context
//! @param theCubeMap [in] cubemap definition, can be NULL
//! @param theSize [in] cubemap dimensions
Handle(OpenGl_Sampler) mySampler; //!< texture sampler
Standard_Size myRevision; //!< revision of associated data source
- GLuint myTextureId; //!< GL resource ID
- GLenum myTarget; //!< GL_TEXTURE_1D/GL_TEXTURE_2D/GL_TEXTURE_3D
- GLsizei mySizeX; //!< texture width
- GLsizei mySizeY; //!< texture height
- GLsizei mySizeZ; //!< texture depth
- GLenum myTextFormat; //!< texture format - GL_RGB, GL_RGBA,...
- GLint mySizedFormat;//!< internal (sized) texture format
+ unsigned int myTextureId; //!< GL resource ID
+ unsigned int myTarget; //!< GL_TEXTURE_1D/GL_TEXTURE_2D/GL_TEXTURE_3D
+ Standard_Integer mySizeX; //!< texture width
+ Standard_Integer mySizeY; //!< texture height
+ Standard_Integer mySizeZ; //!< texture depth
+ unsigned int myTextFormat; //!< texture format - GL_RGB, GL_RGBA,...
+ Standard_Integer mySizedFormat;//!< internal (sized) texture format
Standard_Integer myNbSamples; //!< number of MSAA samples
Standard_Integer myMaxMipLevel;//!< upper mipmap level index (0 means no mipmaps)
bool myIsAlpha; //!< indicates alpha format
--- /dev/null
+// Created by: Kirill GAVRILOV
+// 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <OpenGl_TextureBuffer.hxx>
+
+#include <OpenGl_ArbTBO.hxx>
+#include <OpenGl_GlCore20.hxx>
+#include <OpenGl_Context.hxx>
+#include <Standard_Assert.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_TextureBuffer, OpenGl_Buffer)
+
+// =======================================================================
+// function : OpenGl_TextureBuffer
+// purpose :
+// =======================================================================
+OpenGl_TextureBuffer::OpenGl_TextureBuffer()
+: OpenGl_Buffer(),
+ myTextureId (NO_TEXTURE),
+ myTexFormat (GL_RGBA32F)
+{
+ //
+}
+
+// =======================================================================
+// function : ~OpenGl_TextureBuffer
+// purpose :
+// =======================================================================
+OpenGl_TextureBuffer::~OpenGl_TextureBuffer()
+{
+ Release (NULL);
+}
+
+// =======================================================================
+// function : GetTarget
+// purpose :
+// =======================================================================
+unsigned int OpenGl_TextureBuffer::GetTarget() const
+{
+ return GL_TEXTURE_BUFFER; // GL_TEXTURE_BUFFER for OpenGL 3.1+, OpenGL ES 3.2
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void OpenGl_TextureBuffer::Release (OpenGl_Context* theGlCtx)
+{
+ if (myTextureId != NO_TEXTURE)
+ {
+ // application can not handle this case by exception - this is bug in code
+ Standard_ASSERT_RETURN (theGlCtx != NULL,
+ "OpenGl_TextureBuffer destroyed without GL context! Possible GPU memory leakage...",);
+
+ if (theGlCtx->IsValid())
+ {
+ theGlCtx->core20fwd->glDeleteTextures (1, &myTextureId);
+ }
+ myTextureId = NO_TEXTURE;
+ }
+ base_type::Release (theGlCtx);
+}
+
+// =======================================================================
+// function : Create
+// purpose :
+// =======================================================================
+bool OpenGl_TextureBuffer::Create (const Handle(OpenGl_Context)& theGlCtx)
+{
+ if (!base_type::Create (theGlCtx))
+ {
+ return false;
+ }
+
+ if (myTextureId == NO_TEXTURE)
+ {
+ theGlCtx->core20fwd->glGenTextures (1, &myTextureId);
+ }
+ return myTextureId != NO_TEXTURE;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_TextureBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const float* theData)
+{
+ if (theGlCtx->arbTBO == NULL)
+ {
+ return false;
+ }
+ else if (theComponentsNb < 1
+ || theComponentsNb > 4)
+ {
+ // unsupported format
+ return false;
+ }
+ else if (theComponentsNb == 3
+ && !theGlCtx->arbTboRGB32)
+ {
+ return false;
+ }
+ else if (!Create (theGlCtx)
+ || !base_type::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
+ {
+ return false;
+ }
+
+ switch (theComponentsNb)
+ {
+ case 1: myTexFormat = GL_R32F; break;
+ case 2: myTexFormat = GL_RG32F; break;
+ case 3: myTexFormat = GL_RGB32F; break; // GL_ARB_texture_buffer_object_rgb32
+ case 4: myTexFormat = GL_RGBA32F; break;
+ }
+
+ Bind (theGlCtx);
+ BindTexture (theGlCtx, Graphic3d_TextureUnit_0);
+ theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
+ UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
+ Unbind (theGlCtx);
+ return true;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_TextureBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned int* theData)
+{
+ if (theGlCtx->arbTBO == NULL)
+ {
+ return false;
+ }
+ else if (theComponentsNb < 1
+ || theComponentsNb > 4)
+ {
+ // unsupported format
+ return false;
+ }
+ else if (theComponentsNb == 3
+ && !theGlCtx->arbTboRGB32)
+ {
+ return false;
+ }
+ else if (!Create (theGlCtx)
+ || !base_type::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
+ {
+ return false;
+ }
+
+ switch (theComponentsNb)
+ {
+ case 1: myTexFormat = GL_R32I; break;
+ case 2: myTexFormat = GL_RG32I; break;
+ case 3: myTexFormat = GL_RGB32I; break;
+ case 4: myTexFormat = GL_RGBA32I; break;
+ }
+
+ Bind (theGlCtx);
+ BindTexture (theGlCtx, Graphic3d_TextureUnit_0);
+ theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
+ UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
+ Unbind (theGlCtx);
+ return true;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_TextureBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned short* theData)
+{
+ if (theGlCtx->arbTBO == NULL)
+ {
+ return false;
+ }
+ else if (theComponentsNb < 1
+ || theComponentsNb > 4)
+ {
+ // unsupported format
+ return false;
+ }
+ else if (!Create (theGlCtx)
+ || !base_type::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, Graphic3d_TextureUnit_0);
+ theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
+ UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
+ Unbind (theGlCtx);
+ return true;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+bool OpenGl_TextureBuffer::Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const Standard_Byte* theData)
+{
+ if (theGlCtx->arbTBO == NULL)
+ {
+ return false;
+ }
+ else if (theComponentsNb < 1
+ || theComponentsNb > 4)
+ {
+ // unsupported format
+ return false;
+ }
+ else if (!Create (theGlCtx)
+ || !base_type::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, Graphic3d_TextureUnit_0);
+ theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
+ UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
+ Unbind (theGlCtx);
+ return true;
+}
+
+// =======================================================================
+// function : BindTexture
+// purpose :
+// =======================================================================
+void OpenGl_TextureBuffer::BindTexture (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TextureUnit theTextureUnit) const
+{
+ theGlCtx->core20fwd->glActiveTexture (GL_TEXTURE0 + theTextureUnit);
+ theGlCtx->core20fwd->glBindTexture (GetTarget(), myTextureId);
+}
+
+// =======================================================================
+// function : UnbindTexture
+// purpose :
+// =======================================================================
+void OpenGl_TextureBuffer::UnbindTexture (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TextureUnit theTextureUnit) const
+{
+ theGlCtx->core20fwd->glActiveTexture (GL_TEXTURE0 + theTextureUnit);
+ theGlCtx->core20fwd->glBindTexture (GetTarget(), NO_TEXTURE);
+}
--- /dev/null
+// Created by: Kirill GAVRILOV
+// 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _OpenGl_TextureBuffer_H__
+#define _OpenGl_TextureBuffer_H__
+
+#include <Graphic3d_TextureUnit.hxx>
+#include <OpenGl_Buffer.hxx>
+
+//! Texture Buffer Object.
+//! This is a special 1D texture that VBO-style initialized.
+//! The main differences from general 1D texture:
+//! - no interpolation between field;
+//! - greater sizes;
+//! - special sampler object in GLSL shader to access data by index.
+//!
+//! Notice that though TBO is inherited from VBO this is to unify design
+//! user shouldn't cast it to base class and all really useful methods
+//! are declared in this class.
+class OpenGl_TextureBuffer : public OpenGl_Buffer
+{
+ DEFINE_STANDARD_RTTIEXT(OpenGl_TextureBuffer, OpenGl_Buffer)
+public:
+
+ //! Helpful constants
+ static const unsigned int NO_TEXTURE = 0;
+
+public:
+
+ //! Create uninitialized TBO.
+ Standard_EXPORT OpenGl_TextureBuffer();
+
+ //! Destroy object, will throw exception if GPU memory not released with Release() before.
+ Standard_EXPORT virtual ~OpenGl_TextureBuffer();
+
+ //! Override VBO target
+ Standard_EXPORT virtual unsigned int GetTarget() const Standard_OVERRIDE;
+
+ //! Returns true if TBO is valid.
+ //! Notice that no any real GL call is performed!
+ bool IsValid() const
+ {
+ return OpenGl_Buffer::IsValid()
+ && myTextureId != NO_TEXTURE;
+ }
+
+ //! Destroy object - will release GPU memory if any.
+ Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
+
+ //! Creates VBO and Texture names (ids) if not yet generated.
+ //! Data should be initialized by another method.
+ Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx) Standard_OVERRIDE;
+
+ //! Perform TBO initialization with specified data.
+ //! Existing data will be deleted.
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const float* theData);
+
+ //! Perform TBO initialization with specified data.
+ //! Existing data will be deleted.
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned int* theData);
+
+ //! Perform TBO initialization with specified data.
+ //! Existing data will be deleted.
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const unsigned short* theData);
+
+ //! Perform TBO initialization with specified data.
+ //! Existing data will be deleted.
+ Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theComponentsNb,
+ const Standard_Integer theElemsNb,
+ const Standard_Byte* theData);
+
+ //! Bind TBO to specified Texture Unit.
+ Standard_EXPORT void BindTexture (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TextureUnit theTextureUnit) const;
+
+ //! Unbind TBO.
+ Standard_EXPORT void UnbindTexture (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TextureUnit theTextureUnit) const;
+
+ //! Returns name of TBO.
+ unsigned int TextureId() const { return myTextureId; }
+
+ //! Returns internal texture format.
+ unsigned int TextureFormat() const { return myTexFormat; }
+
+protected:
+
+ unsigned int myTextureId; //!< texture id
+ unsigned int myTexFormat; //!< internal texture format
+
+};
+
+DEFINE_STANDARD_HANDLE(OpenGl_TextureBuffer, OpenGl_Buffer)
+
+#endif // _OpenGl_TextureBuffer_H__
+++ /dev/null
-// Created by: Kirill GAVRILOV
-// 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 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.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <OpenGl_TextureBufferArb.hxx>
-
-#include <OpenGl_Context.hxx>
-#include <Standard_Assert.hxx>
-
-
-IMPLEMENT_STANDARD_RTTIEXT(OpenGl_TextureBufferArb,OpenGl_VertexBuffer)
-
-// =======================================================================
-// function : OpenGl_TextureBufferArb
-// purpose :
-// =======================================================================
-OpenGl_TextureBufferArb::OpenGl_TextureBufferArb()
-: OpenGl_VertexBuffer(),
- myTextureId (NO_TEXTURE),
- myTexFormat (GL_RGBA32F)
-{
- //
-}
-
-// =======================================================================
-// function : ~OpenGl_TextureBufferArb
-// purpose :
-// =======================================================================
-OpenGl_TextureBufferArb::~OpenGl_TextureBufferArb()
-{
- Release (NULL);
-}
-
-// =======================================================================
-// function : GetTarget
-// purpose :
-// =======================================================================
-GLenum OpenGl_TextureBufferArb::GetTarget() const
-{
- return GL_TEXTURE_BUFFER; // GL_TEXTURE_BUFFER for OpenGL 3.1+, OpenGL ES 3.2
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void OpenGl_TextureBufferArb::Release (OpenGl_Context* theGlCtx)
-{
- if (myTextureId != NO_TEXTURE)
- {
- // application can not handle this case by exception - this is bug in code
- Standard_ASSERT_RETURN (theGlCtx != NULL,
- "OpenGl_TextureBufferExt destroyed without GL context! Possible GPU memory leakage...",);
-
- if (theGlCtx->IsValid())
- {
- glDeleteTextures (1, &myTextureId);
- }
- myTextureId = NO_TEXTURE;
- }
- OpenGl_VertexBuffer::Release (theGlCtx);
-}
-
-// =======================================================================
-// function : Create
-// purpose :
-// =======================================================================
-bool OpenGl_TextureBufferArb::Create (const Handle(OpenGl_Context)& theGlCtx)
-{
- if (!OpenGl_VertexBuffer::Create (theGlCtx))
- {
- return false;
- }
-
- if (myTextureId == NO_TEXTURE)
- {
- glGenTextures (1, &myTextureId);
- }
- return myTextureId != NO_TEXTURE;
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLfloat* theData)
-{
- if (theGlCtx->arbTBO == NULL)
- {
- return false;
- }
- else if (theComponentsNb < 1
- || theComponentsNb > 4)
- {
- // unsupported format
- return false;
- }
- else if (theComponentsNb == 3
- && !theGlCtx->arbTboRGB32)
- {
- return false;
- }
- else if (!Create (theGlCtx)
- || !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
- {
- return false;
- }
-
- switch (theComponentsNb)
- {
- case 1: myTexFormat = GL_R32F; break;
- case 2: myTexFormat = GL_RG32F; break;
- case 3: myTexFormat = GL_RGB32F; break; // GL_ARB_texture_buffer_object_rgb32
- case 4: myTexFormat = GL_RGBA32F; break;
- }
-
- Bind (theGlCtx);
- BindTexture (theGlCtx, Graphic3d_TextureUnit_0);
- theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
- UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
- Unbind (theGlCtx);
- return true;
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLuint* theData)
-{
- if (theGlCtx->arbTBO == NULL)
- {
- return false;
- }
- else if (theComponentsNb < 1
- || theComponentsNb > 4)
- {
- // unsupported format
- return false;
- }
- else if (theComponentsNb == 3
- && !theGlCtx->arbTboRGB32)
- {
- return false;
- }
- else if (!Create (theGlCtx)
- || !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
- {
- return false;
- }
-
- switch (theComponentsNb)
- {
- case 1: myTexFormat = GL_R32I; break;
- case 2: myTexFormat = GL_RG32I; break;
- case 3: myTexFormat = GL_RGB32I; break;
- case 4: myTexFormat = GL_RGBA32I; break;
- }
-
- Bind (theGlCtx);
- BindTexture (theGlCtx, Graphic3d_TextureUnit_0);
- theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
- UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
- Unbind (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, Graphic3d_TextureUnit_0);
- theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
- UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
- 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, Graphic3d_TextureUnit_0);
- theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
- UnbindTexture(theGlCtx, Graphic3d_TextureUnit_0);
- Unbind (theGlCtx);
- return true;
-}
-
-// =======================================================================
-// function : BindTexture
-// purpose :
-// =======================================================================
-void OpenGl_TextureBufferArb::BindTexture (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TextureUnit theTextureUnit) const
-{
- theGlCtx->core20fwd->glActiveTexture (GL_TEXTURE0 + theTextureUnit);
- glBindTexture (GetTarget(), myTextureId);
-}
-
-// =======================================================================
-// function : UnbindTexture
-// purpose :
-// =======================================================================
-void OpenGl_TextureBufferArb::UnbindTexture (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TextureUnit theTextureUnit) const
-{
- theGlCtx->core20fwd->glActiveTexture (GL_TEXTURE0 + theTextureUnit);
- glBindTexture (GetTarget(), NO_TEXTURE);
-}
#ifndef _OpenGl_TextureBufferArb_H__
#define _OpenGl_TextureBufferArb_H__
-#include <OpenGl_VertexBuffer.hxx>
-#include <OpenGl_ArbTBO.hxx>
+#include <OpenGl_TextureBuffer.hxx>
-//! Texture Buffer Object.
-//! This is a special 1D texture that VBO-style initialized.
-//! The main differences from general 1D texture:
-//! - no interpolation between field;
-//! - greater sizes;
-//! - special sampler object in GLSL shader to access data by index.
-//!
-//! Notice that though TBO is inherited from VBO this is to unify design
-//! user shouldn't cast it to base class and all really useful methods
-//! are declared in this class.
-class OpenGl_TextureBufferArb : public OpenGl_VertexBuffer
-{
- DEFINE_STANDARD_RTTIEXT(OpenGl_TextureBufferArb, OpenGl_VertexBuffer)
-public:
-
- //! Helpful constants
- static const GLuint NO_TEXTURE = 0;
-
-public:
-
- //! Create uninitialized TBO.
- Standard_EXPORT OpenGl_TextureBufferArb();
-
- //! Destroy object, will throw exception if GPU memory not released with Release() before.
- Standard_EXPORT virtual ~OpenGl_TextureBufferArb();
-
- //! Override VBO target
- Standard_EXPORT virtual GLenum GetTarget() const Standard_OVERRIDE;
-
- //! Returns true if TBO is valid.
- //! Notice that no any real GL call is performed!
- bool IsValid() const
- {
- return OpenGl_VertexBuffer::IsValid()
- && myTextureId != NO_TEXTURE;
- }
-
- //! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
-
- //! Creates VBO and Texture names (ids) if not yet generated.
- //! Data should be initialized by another method.
- Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx) Standard_OVERRIDE;
-
- //! 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 GLfloat* 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 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 Graphic3d_TextureUnit theTextureUnit) const;
-
- //! Unbind TBO.
- Standard_EXPORT void UnbindTexture (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TextureUnit theTextureUnit) const;
-
- //! Returns name of TBO.
- GLuint TextureId() const { return myTextureId; }
-
- //! Returns internal texture format.
- GLenum TextureFormat() const { return myTexFormat; }
-
-protected:
-
- GLuint myTextureId; //!< texture id
- GLenum myTexFormat; //!< internal texture format
-
-};
-
-DEFINE_STANDARD_HANDLE(OpenGl_TextureBufferArb, OpenGl_VertexBuffer)
+Standard_DEPRECATED("Obsolete alias - OpenGl_TextureBuffer should be used instead")
+typedef OpenGl_TextureBuffer OpenGl_TextureBufferArb;
#endif // _OpenGl_TextureBufferArb_H__
--- /dev/null
+// Copyright (c) 2021 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <OpenGl_UniformBuffer.hxx>
+
+#include <OpenGl_Context.hxx>
+#include <Standard_Assert.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_UniformBuffer, OpenGl_Buffer)
+
+// =======================================================================
+// function : OpenGl_UniformBuffer
+// purpose :
+// =======================================================================
+OpenGl_UniformBuffer::OpenGl_UniformBuffer()
+: OpenGl_Buffer() {}
+
+// =======================================================================
+// function : GetTarget
+// purpose :
+// =======================================================================
+unsigned int OpenGl_UniformBuffer::GetTarget() const
+{
+ return GL_UNIFORM_BUFFER;
+}
--- /dev/null
+// Copyright (c) 2021 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 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.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _OpenGl_UniformBuffer_H__
+#define _OpenGl_UniformBuffer_H__
+
+#include <OpenGl_Buffer.hxx>
+
+//! Uniform buffer object.
+class OpenGl_UniformBuffer : public OpenGl_Buffer
+{
+ DEFINE_STANDARD_RTTIEXT(OpenGl_UniformBuffer, OpenGl_Buffer)
+public:
+
+ //! Empty constructor.
+ Standard_EXPORT OpenGl_UniformBuffer();
+
+ //! Return buffer object target (GL_UNIFORM_BUFFER).
+ Standard_EXPORT virtual unsigned int GetTarget() const Standard_OVERRIDE;
+
+ using OpenGl_Buffer::BindBufferBase;
+ using OpenGl_Buffer::UnbindBufferBase;
+ using OpenGl_Buffer::BindBufferRange;
+
+};
+
+#endif // _OpenGl_UniformBuffer_H__
#include <OpenGl_ShaderManager.hxx>
#include <Standard_Assert.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(OpenGl_VertexBuffer,OpenGl_Resource)
-
-// =======================================================================
-// function : FormatTarget
-// purpose :
-// =======================================================================
-TCollection_AsciiString OpenGl_VertexBuffer::FormatTarget (GLenum theTarget)
-{
- switch (theTarget)
- {
- case GL_ARRAY_BUFFER: return "GL_ARRAY_BUFFER";
- case GL_ELEMENT_ARRAY_BUFFER: return "GL_ELEMENT_ARRAY_BUFFER";
- case GL_TEXTURE_BUFFER: return "GL_TEXTURE_BUFFER";
- }
- return OpenGl_Context::FormatGlEnumHex (theTarget);
-}
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_VertexBuffer, OpenGl_Buffer)
// =======================================================================
// function : OpenGl_VertexBuffer
// purpose :
// =======================================================================
OpenGl_VertexBuffer::OpenGl_VertexBuffer()
-: OpenGl_Resource(),
- myOffset (NULL),
- myBufferId (NO_BUFFER),
- myComponentsNb (4),
- myElemsNb (0),
- myDataType (GL_FLOAT)
{
//
}
// =======================================================================
OpenGl_VertexBuffer::~OpenGl_VertexBuffer()
{
- Release (NULL);
+ //
}
// =======================================================================
// function : GetTarget
// purpose :
// =======================================================================
-GLenum OpenGl_VertexBuffer::GetTarget() const
+unsigned int OpenGl_VertexBuffer::GetTarget() const
{
return GL_ARRAY_BUFFER;
}
// =======================================================================
-// function : Create
+// function : BindVertexAttrib
// purpose :
// =======================================================================
-bool OpenGl_VertexBuffer::Create (const Handle(OpenGl_Context)& theGlCtx)
+void OpenGl_VertexBuffer::BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theAttribLoc) const
{
- if (myBufferId == NO_BUFFER && theGlCtx->core15fwd != NULL)
+ if (!IsValid() || theAttribLoc == GLuint (-1))
{
- theGlCtx->core15fwd->glGenBuffers (1, &myBufferId);
+ return;
}
- return myBufferId != NO_BUFFER;
+ Bind (theGlCtx);
+ theGlCtx->core20fwd->glEnableVertexAttribArray (theAttribLoc);
+ theGlCtx->core20fwd->glVertexAttribPointer (theAttribLoc, GLint (myComponentsNb), myDataType, GL_FALSE, 0, myOffset);
}
// =======================================================================
-// function : Release
+// function : UnbindVertexAttrib
// purpose :
// =======================================================================
-void OpenGl_VertexBuffer::Release (OpenGl_Context* theGlCtx)
+void OpenGl_VertexBuffer::UnbindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
+ const unsigned int theAttribLoc) const
{
- if (myBufferId == NO_BUFFER)
+ if (!IsValid() || theAttribLoc == GLuint (-1))
{
return;
}
-
- // application can not handle this case by exception - this is bug in code
- Standard_ASSERT_RETURN (theGlCtx != NULL,
- "OpenGl_VertexBuffer destroyed without GL context! Possible GPU memory leakage...",);
-
- if (theGlCtx->IsValid())
- {
- theGlCtx->core15fwd->glDeleteBuffers (1, &myBufferId);
- }
- myOffset = NULL;
- myBufferId = NO_BUFFER;
+ theGlCtx->core20fwd->glDisableVertexAttribArray (theAttribLoc);
+ Unbind (theGlCtx);
}
// =======================================================================
-// function : Bind
+// function : BindAllAttributes
// purpose :
// =======================================================================
-void OpenGl_VertexBuffer::Bind (const Handle(OpenGl_Context)& theGlCtx) const
+void OpenGl_VertexBuffer::BindAllAttributes (const Handle(OpenGl_Context)& ) const
{
- theGlCtx->core15fwd->glBindBuffer (GetTarget(), myBufferId);
+ //
}
// =======================================================================
-// function : Unbind
+// function : BindPositionAttribute
// purpose :
// =======================================================================
-void OpenGl_VertexBuffer::Unbind (const Handle(OpenGl_Context)& theGlCtx) const
+void OpenGl_VertexBuffer::BindPositionAttribute (const Handle(OpenGl_Context)& ) const
{
- theGlCtx->core15fwd->glBindBuffer (GetTarget(), NO_BUFFER);
+ //
}
// =======================================================================
-// function : init
+// function : UnbindAllAttributes
// purpose :
// =======================================================================
-bool OpenGl_VertexBuffer::init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType,
- const GLsizei theStride)
+void OpenGl_VertexBuffer::UnbindAllAttributes (const Handle(OpenGl_Context)& ) const
{
- if (!Create (theGlCtx))
- {
- return false;
- }
-
- Bind (theGlCtx);
- myDataType = theDataType;
- myComponentsNb = theComponentsNb;
- myElemsNb = theElemsNb;
- theGlCtx->core15fwd->glBufferData (GetTarget(), GLsizeiptr(myElemsNb) * theStride, theData, GL_STATIC_DRAW);
- const int anErr = theGlCtx->core15fwd->glGetError();
- if (anErr != GL_NO_ERROR
- && anErr != GL_OUT_OF_MEMORY) // pass-through out-of-memory error, but log unexpected errors
- {
- theGlCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
- TCollection_AsciiString ("Error: glBufferData (")
- + FormatTarget (GetTarget()) + ","
- + OpenGl_Context::FormatSize (GLsizeiptr(myElemsNb) * theStride) + ","
- + OpenGl_Context::FormatPointer (theData) + ") Id: " + (int )myBufferId
- + " failed with " + OpenGl_Context::FormatGlError (anErr));
- }
- Unbind (theGlCtx);
- return anErr == GL_NO_ERROR;
+ //
}
// =======================================================================
-// function : subData
+// function : HasColorAttribute
// purpose :
// =======================================================================
-bool OpenGl_VertexBuffer::subData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType)
+bool OpenGl_VertexBuffer::HasColorAttribute() const
{
- if (!IsValid() || myDataType != theDataType ||
- theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
- {
- return false;
- }
-
- Bind (theGlCtx);
- const size_t aDataSize = sizeOfGlType (theDataType);
- theGlCtx->core15fwd->glBufferSubData (GetTarget(),
- GLintptr(theElemFrom) * GLintptr (myComponentsNb) * aDataSize, // offset in bytes
- GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize, // size in bytes
- theData);
- const int anErr = theGlCtx->core15fwd->glGetError();
- if (anErr != GL_NO_ERROR)
- {
- theGlCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
- TCollection_AsciiString ("Error: glBufferSubData (")
- + FormatTarget (GetTarget()) + ","
- + OpenGl_Context::FormatSize (GLintptr(theElemFrom) * GLintptr (myComponentsNb) * aDataSize) + ","
- + OpenGl_Context::FormatSize (GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize) + ","
- + OpenGl_Context::FormatPointer (theData) + ") Id: " + (int )myBufferId
- + " failed with " + OpenGl_Context::FormatGlError (anErr));
- }
- Unbind (theGlCtx);
- return anErr == GL_NO_ERROR;
+ return false;
}
// =======================================================================
-// function : getSubData
+// function : HasNormalAttribute
// purpose :
// =======================================================================
-bool OpenGl_VertexBuffer::getSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- void* theData,
- const GLenum theDataType)
+bool OpenGl_VertexBuffer::HasNormalAttribute() const
{
- if (!IsValid() || myDataType != theDataType
- || theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb)
- || !theGlCtx->hasGetBufferData)
- {
- return false;
- }
-
- Bind (theGlCtx);
- const size_t aDataSize = sizeOfGlType (theDataType);
- const GLintptr anOffset = GLintptr (theElemFrom) * GLintptr (myComponentsNb) * aDataSize;
- const GLsizeiptr aSize = GLsizeiptr(theElemsNb) * GLsizeiptr(myComponentsNb) * aDataSize;
- bool isDone = theGlCtx->GetBufferSubData (GetTarget(), anOffset, aSize, theData);
- isDone = isDone && (glGetError() == GL_NO_ERROR);
- Unbind (theGlCtx);
- return isDone;
+ return false;
}
// =======================================================================
-// function : BindVertexAttrib
+// function : bindAttribute
// purpose :
// =======================================================================
-void OpenGl_VertexBuffer::BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theAttribLoc) const
+void OpenGl_VertexBuffer::bindAttribute (const Handle(OpenGl_Context)& theCtx,
+ const Graphic3d_TypeOfAttribute theAttribute,
+ const Standard_Integer theNbComp,
+ const unsigned int theDataType,
+ const Standard_Integer theStride,
+ const void* theOffset)
{
- if (!IsValid() || theAttribLoc == GLuint (-1))
+ if (theCtx->ActiveProgram().IsNull())
{
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11ffp != NULL)
+ {
+ bindFixed (theCtx, theAttribute, theNbComp, theDataType, theStride, theOffset);
+ }
+ else
+ #endif
+ {
+ // OpenGL handles vertex attribute setup independently from active GLSL program,
+ // but OCCT historically requires program to be bound beforehand (this check could be removed in future).
+ Message::SendFail ("Error: OpenGl_VertexBuffer::bindAttribute() does nothing without active GLSL program");
+ }
return;
}
- Bind (theGlCtx);
- theGlCtx->core20fwd->glEnableVertexAttribArray (theAttribLoc);
- theGlCtx->core20fwd->glVertexAttribPointer (theAttribLoc, GLint (myComponentsNb), myDataType, GL_FALSE, 0, myOffset);
+
+ theCtx->core20fwd->glEnableVertexAttribArray (theAttribute);
+ theCtx->core20fwd->glVertexAttribPointer (theAttribute, theNbComp, theDataType, theDataType != GL_FLOAT, theStride, theOffset);
}
// =======================================================================
-// function : UnbindVertexAttrib
+// function : unbindAttribute
// purpose :
// =======================================================================
-void OpenGl_VertexBuffer::UnbindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theAttribLoc) const
+void OpenGl_VertexBuffer::unbindAttribute (const Handle(OpenGl_Context)& theCtx,
+ const Graphic3d_TypeOfAttribute theAttribute)
{
- if (!IsValid() || theAttribLoc == GLuint (-1))
+ if (theCtx->ActiveProgram().IsNull())
{
+ #if !defined(GL_ES_VERSION_2_0)
+ if (theCtx->core11ffp != NULL)
+ {
+ unbindFixed (theCtx, theAttribute);
+ }
+ #endif
return;
}
- theGlCtx->core20fwd->glDisableVertexAttribArray (theAttribLoc);
- Unbind (theGlCtx);
-}
-
-// =======================================================================
-// function : BindAllAttributes
-// purpose :
-// =======================================================================
-void OpenGl_VertexBuffer::BindAllAttributes (const Handle(OpenGl_Context)& ) const
-{
- //
-}
-
-// =======================================================================
-// function : BindPositionAttribute
-// purpose :
-// =======================================================================
-void OpenGl_VertexBuffer::BindPositionAttribute (const Handle(OpenGl_Context)& ) const
-{
- //
-}
-// =======================================================================
-// function : UnbindAllAttributes
-// purpose :
-// =======================================================================
-void OpenGl_VertexBuffer::UnbindAllAttributes (const Handle(OpenGl_Context)& ) const
-{
- //
+ theCtx->core20fwd->glDisableVertexAttribArray (theAttribute);
}
+#if !defined(GL_ES_VERSION_2_0)
// =======================================================================
-// function : HasColorAttribute
+// function : bindFixed
// purpose :
// =======================================================================
-bool OpenGl_VertexBuffer::HasColorAttribute() const
+void OpenGl_VertexBuffer::bindFixed (const Handle(OpenGl_Context)& theCtx,
+ const Graphic3d_TypeOfAttribute theMode,
+ const Standard_Integer theNbComp,
+ const unsigned int theDataType,
+ const Standard_Integer theStride,
+ const void* theOffset)
{
- return false;
+ switch (theMode)
+ {
+ case Graphic3d_TOA_POS:
+ {
+ theCtx->core11ffp->glEnableClientState (GL_VERTEX_ARRAY);
+ theCtx->core11ffp->glVertexPointer (theNbComp, theDataType, theStride, theOffset);
+ return;
+ }
+ case Graphic3d_TOA_NORM:
+ {
+ theCtx->core11ffp->glEnableClientState (GL_NORMAL_ARRAY);
+ theCtx->core11ffp->glNormalPointer (theDataType, theStride, theOffset);
+ return;
+ }
+ case Graphic3d_TOA_UV:
+ {
+ theCtx->core11ffp->glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+ theCtx->core11ffp->glTexCoordPointer (theNbComp, theDataType, theStride, theOffset);
+ return;
+ }
+ case Graphic3d_TOA_COLOR:
+ {
+ theCtx->core11ffp->glEnableClientState (GL_COLOR_ARRAY);
+ theCtx->core11ffp->glColorPointer (theNbComp, theDataType, theStride, theOffset);
+ theCtx->core11ffp->glColorMaterial (GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
+ theCtx->core11fwd->glEnable (GL_COLOR_MATERIAL);
+ return;
+ }
+ case Graphic3d_TOA_CUSTOM:
+ {
+ return;
+ }
+ }
}
// =======================================================================
-// function : HasNormalAttribute
+// function : unbindFixed
// purpose :
// =======================================================================
-bool OpenGl_VertexBuffer::HasNormalAttribute() const
+void OpenGl_VertexBuffer::unbindFixed (const Handle(OpenGl_Context)& theCtx,
+ const Graphic3d_TypeOfAttribute theMode)
{
- return false;
+ switch (theMode)
+ {
+ case Graphic3d_TOA_POS: theCtx->core11ffp->glDisableClientState (GL_VERTEX_ARRAY); return;
+ case Graphic3d_TOA_NORM: theCtx->core11ffp->glDisableClientState (GL_NORMAL_ARRAY); return;
+ case Graphic3d_TOA_UV: theCtx->core11ffp->glDisableClientState (GL_TEXTURE_COORD_ARRAY); return;
+ case Graphic3d_TOA_COLOR: unbindFixedColor (theCtx); return;
+ case Graphic3d_TOA_CUSTOM:
+ {
+ return;
+ }
+ }
}
-#if !defined(GL_ES_VERSION_2_0)
// =======================================================================
// function : unbindFixedColor
// purpose :
theCtx->ShaderManager()->UpdateMaterialState();
}
#endif
-
-// =======================================================================
-// function : DumpJson
-// purpose :
-// =======================================================================
-void OpenGl_VertexBuffer::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
-{
- OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
- OCCT_DUMP_BASE_CLASS (theOStream, theDepth, OpenGl_Resource)
-
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, GetTarget())
- OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOffset)
-
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBufferId)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComponentsNb)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myElemsNb)
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDataType)
-}
#ifndef _OpenGl_VertexBuffer_H__
#define _OpenGl_VertexBuffer_H__
-#include <OpenGl_GlCore20.hxx>
-#include <OpenGl_Resource.hxx>
-#include <OpenGl_Context.hxx>
-#include <OpenGl_ShaderProgram.hxx>
-
-#include <Graphic3d_IndexBuffer.hxx>
+#include <OpenGl_Buffer.hxx>
+#include <Graphic3d_Buffer.hxx>
//! Vertex Buffer Object - is a general storage object for vertex attributes (position, normal, color).
//! Notice that you should use OpenGl_IndexBuffer specialization for array of indices.
-class OpenGl_VertexBuffer : public OpenGl_Resource
+class OpenGl_VertexBuffer : public OpenGl_Buffer
{
-
-public:
-
- //! Helpful constants
- static const GLuint NO_BUFFER = 0;
-
- //! Format VBO target enumeration value.
- Standard_EXPORT static TCollection_AsciiString FormatTarget (GLenum theTarget);
-
public:
//! Create uninitialized VBO.
//! Destroy object.
Standard_EXPORT virtual ~OpenGl_VertexBuffer();
- Standard_EXPORT virtual GLenum GetTarget() const;
-
- //! Return TRUE if this is a virtual (for backward compatibility) VBO object.
- virtual bool IsVirtual() const { return false; }
-
- //! @return true if current object was initialized
- inline bool IsValid() const
- {
- return myBufferId != NO_BUFFER;
- }
-
- //! @return the number of components per generic vertex attribute.
- inline GLuint GetComponentsNb() const
- {
- return myComponentsNb;
- }
-
- //! @return number of vertex attributes / number of vertices specified within ::Init()
- inline GLsizei GetElemsNb() const
- {
- return myElemsNb;
- }
-
- //! Overrides the number of vertex attributes / number of vertexes.
- //! It is up to user specifying this number correct (e.g. below initial value)!
- void SetElemsNb (GLsizei theNbElems) { myElemsNb = theNbElems; }
-
- //! @return data type of each component in the array.
- inline GLenum GetDataType() const
- {
- return myDataType;
- }
-
- //! @return offset to data, NULL by default
- inline GLubyte* GetDataOffset() const
- {
- return myOffset;
- }
-
- //! Creates VBO name (id) if not yet generated.
- //! Data should be initialized by another method.
- Standard_EXPORT virtual bool Create (const Handle(OpenGl_Context)& theGlCtx);
-
- //! Destroy object - will release GPU memory if any.
- Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
-
- //! Bind this VBO.
- Standard_EXPORT virtual void Bind (const Handle(OpenGl_Context)& theGlCtx) const;
-
- //! Unbind this VBO.
- Standard_EXPORT virtual void Unbind (const Handle(OpenGl_Context)& theGlCtx) const;
-
- //! Notice that VBO will be unbound after this call.
- //! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
- //! @param theElemsNb - elements count;
- //! @param theData - pointer to GLfloat data (vertices/normals etc.).
- bool Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLfloat* theData)
- {
- return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_FLOAT);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
- //! @param theElemsNb - elements count;
- //! @param theData - pointer to GLuint data (indices etc.).
- bool Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLuint* theData)
- {
- return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_INT);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
- //! @param theElemsNb - elements count;
- //! @param theData - pointer to GLushort data (indices etc.).
- bool Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLushort* theData)
- {
- return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_SHORT);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! @param theComponentsNb - specifies the number of components per generic vertex attribute; must be 1, 2, 3, or 4;
- //! @param theElemsNb - elements count;
- //! @param theData - pointer to GLubyte data (indices/colors etc.).
- bool Init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLubyte* theData)
- {
- return init (theGlCtx, theComponentsNb, theElemsNb, theData, GL_UNSIGNED_BYTE);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! Function replaces portion of data within this VBO using glBufferSubData().
- //! The VBO should be initialized before call.
- //! @param theElemFrom - element id from which replace buffer data (>=0);
- //! @param theElemsNb - elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData - pointer to GLfloat data.
- bool SubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const GLfloat* theData)
- {
- return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_FLOAT);
- }
-
- //! Read back buffer sub-range.
- //! Notice that VBO will be unbound after this call.
- //! Function reads portion of data from this VBO using glGetBufferSubData().
- //! @param theElemFrom [in] element id from which replace buffer data (>=0);
- //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData [out] destination pointer to GLfloat data.
- bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- GLfloat* theData)
- {
- return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_FLOAT);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! Function replaces portion of data within this VBO using glBufferSubData().
- //! The VBO should be initialized before call.
- //! @param theElemFrom element id from which replace buffer data (>=0);
- //! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData pointer to GLuint data.
- bool SubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const GLuint* theData)
- {
- return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_INT);
- }
-
- //! Read back buffer sub-range.
- //! Notice that VBO will be unbound after this call.
- //! Function reads portion of data from this VBO using glGetBufferSubData().
- //! @param theElemFrom [in] element id from which replace buffer data (>=0);
- //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData [out] destination pointer to GLuint data.
- bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- GLuint* theData)
- {
- return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_INT);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! Function replaces portion of data within this VBO using glBufferSubData().
- //! The VBO should be initialized before call.
- //! @param theElemFrom element id from which replace buffer data (>=0);
- //! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData pointer to GLushort data.
- bool SubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const GLushort* theData)
- {
- return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_SHORT);
- }
-
- //! Read back buffer sub-range.
- //! Notice that VBO will be unbound after this call.
- //! Function reads portion of data from this VBO using glGetBufferSubData().
- //! @param theElemFrom [in] element id from which replace buffer data (>=0);
- //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData [out] destination pointer to GLushort data.
- bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- GLushort* theData)
- {
- return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_SHORT);
- }
-
- //! Notice that VBO will be unbound after this call.
- //! Function replaces portion of data within this VBO using glBufferSubData().
- //! The VBO should be initialized before call.
- //! @param theElemFrom element id from which replace buffer data (>=0);
- //! @param theElemsNb elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData pointer to GLubyte data.
- bool SubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const GLubyte* theData)
- {
- return subData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_BYTE);
- }
-
- //! Read back buffer sub-range.
- //! Notice that VBO will be unbound after this call.
- //! Function reads portion of data from this VBO using glGetBufferSubData().
- //! @param theElemFrom [in] element id from which replace buffer data (>=0);
- //! @param theElemsNb [in] elements count (theElemFrom + theElemsNb <= GetElemsNb());
- //! @param theData [out] destination pointer to GLubyte data.
- bool GetSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- GLubyte* theData)
- {
- return getSubData (theGlCtx, theElemFrom, theElemsNb, theData, GL_UNSIGNED_BYTE);
- }
+ //! Return buffer target GL_ARRAY_BUFFER.
+ Standard_EXPORT virtual unsigned int GetTarget() const Standard_OVERRIDE;
//! Bind this VBO to active GLSL program.
Standard_EXPORT void BindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theAttribLoc) const;
+ const unsigned int theAttribLoc) const;
//! Unbind any VBO from active GLSL program.
Standard_EXPORT void UnbindVertexAttrib (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theAttribLoc) const;
+ const unsigned int theAttribLoc) const;
//! Bind this VBO and enable specified attribute in OpenGl_Context::ActiveProgram() or FFP.
//! @param theGlCtx - handle to bound GL context;
if (IsValid())
{
Bind (theCtx);
- bindAttribute (theCtx, theMode, static_cast<GLint> (myComponentsNb), myDataType, 0, myOffset);
+ bindAttribute (theCtx, theMode, static_cast<int> (myComponentsNb), myDataType, 0, myOffset);
}
}
public: //! @name advanced methods
- //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
- virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE
- {
- return IsValid()
- ? sizeOfGlType (myDataType) * myComponentsNb * myElemsNb
- : 0;
- }
-
- //! @return size of specified GL type
- static size_t sizeOfGlType (const GLenum theType)
- {
- switch (theType)
- {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
- case GL_SHORT:
- case GL_UNSIGNED_SHORT: return sizeof(GLushort);
- #ifdef GL_INT
- case GL_INT:
- #endif
- case GL_UNSIGNED_INT: return sizeof(GLuint);
- case GL_FLOAT: return sizeof(GLfloat);
- #ifdef GL_DOUBLE
- case GL_DOUBLE: return sizeof(GLdouble);
- #endif
- default: return 0;
- }
- }
-
- //! Initialize buffer with new data.
- Standard_EXPORT virtual bool init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType,
- const GLsizei theStride);
-
- //! Initialize buffer with new data.
- bool init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType)
- {
- return init (theGlCtx, theComponentsNb, theElemsNb, theData, theDataType, GLsizei(theComponentsNb) * GLsizei(sizeOfGlType (theDataType)));
- }
-
- //! Update part of the buffer with new data.
- Standard_EXPORT virtual bool subData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType);
-
- //! Read back buffer sub-range.
- Standard_EXPORT virtual bool getSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- void* theData,
- const GLenum theDataType);
-
//! Setup array pointer - either for active GLSL program OpenGl_Context::ActiveProgram()
//! or for FFP using bindFixed() when no program bound.
- static void bindAttribute (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TypeOfAttribute theMode,
- const GLint theNbComp,
- const GLenum theDataType,
- const GLsizei theStride,
- const GLvoid* theOffset);
+ Standard_EXPORT static void bindAttribute (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TypeOfAttribute theMode,
+ const Standard_Integer theNbComp,
+ const unsigned int theDataType,
+ const Standard_Integer theStride,
+ const void* theOffset);
//! Disable GLSL array pointer - either for active GLSL program OpenGl_Context::ActiveProgram()
//! or for FFP using unbindFixed() when no program bound.
- static void unbindAttribute (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TypeOfAttribute theMode);
+ Standard_EXPORT static void unbindAttribute (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TypeOfAttribute theMode);
private:
#if !defined(GL_ES_VERSION_2_0)
//! Setup FFP array pointer.
- static void bindFixed (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TypeOfAttribute theMode,
- const GLint theNbComp,
- const GLenum theDataType,
- const GLsizei theStride,
- const GLvoid* theOffset);
+ Standard_EXPORT static void bindFixed (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TypeOfAttribute theMode,
+ const Standard_Integer theNbComp,
+ const unsigned int theDataType,
+ const Standard_Integer theStride,
+ const void* theOffset);
//! Disable FFP array pointer.
- static void unbindFixed (const Handle(OpenGl_Context)& theGlCtx,
- const Graphic3d_TypeOfAttribute theMode);
+ Standard_EXPORT static void unbindFixed (const Handle(OpenGl_Context)& theGlCtx,
+ const Graphic3d_TypeOfAttribute theMode);
//! Disable FFP color array pointer.
Standard_EXPORT static void unbindFixedColor (const Handle(OpenGl_Context)& theCtx);
//! Unbind all vertex attributes. Default implementation does nothing.
Standard_EXPORT virtual void UnbindAllAttributes (const Handle(OpenGl_Context)& theGlCtx) const;
- //! Dumps the content of me into the stream
- Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
-
-protected:
-
- GLubyte* myOffset; //!< offset to data
- GLuint myBufferId; //!< VBO name (index)
- GLuint myComponentsNb; //!< Number of components per generic vertex attribute, must be 1, 2, 3, or 4
- GLsizei myElemsNb; //!< Number of vertex attributes / number of vertices
- GLenum myDataType; //!< Data type (GL_FLOAT, GL_UNSIGNED_INT, GL_UNSIGNED_BYTE etc.)
-
public:
- DEFINE_STANDARD_RTTIEXT(OpenGl_VertexBuffer,OpenGl_Resource) // Type definition
+ DEFINE_STANDARD_RTTIEXT(OpenGl_VertexBuffer, OpenGl_Buffer)
};
-DEFINE_STANDARD_HANDLE(OpenGl_VertexBuffer, OpenGl_Resource)
-
-#include <OpenGl_VertexBuffer.lxx>
+DEFINE_STANDARD_HANDLE(OpenGl_VertexBuffer, OpenGl_Buffer)
#endif // _OpenGl_VertexBuffer_H__
+++ /dev/null
-// Created by: Kirill GAVRILOV
-// Copyright (c) 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 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.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-// =======================================================================
-// function : bindAttribute
-// purpose :
-// =======================================================================
-inline void OpenGl_VertexBuffer::bindAttribute (const Handle(OpenGl_Context)& theCtx,
- const Graphic3d_TypeOfAttribute theAttribute,
- const GLint theNbComp,
- const GLenum theDataType,
- const GLsizei theStride,
- const GLvoid* theOffset)
-{
- if (theCtx->ActiveProgram().IsNull())
- {
- #if !defined(GL_ES_VERSION_2_0)
- if (theCtx->core11ffp != NULL)
- {
- bindFixed (theCtx, theAttribute, theNbComp, theDataType, theStride, theOffset);
- }
- else
- #endif
- {
- // OpenGL handles vertex attribute setup independently from active GLSL program,
- // but OCCT historically requires program to be bound beforehand (this check could be removed in future).
- Message::SendFail ("Error: OpenGl_VertexBuffer::bindAttribute() does nothing without active GLSL program");
- }
- return;
- }
-
- theCtx->core20fwd->glEnableVertexAttribArray (theAttribute);
- theCtx->core20fwd->glVertexAttribPointer (theAttribute, theNbComp, theDataType, theDataType != GL_FLOAT, theStride, theOffset);
-}
-
-#if !defined(GL_ES_VERSION_2_0)
-// =======================================================================
-// function : bindFixed
-// purpose :
-// =======================================================================
-inline void OpenGl_VertexBuffer::bindFixed (const Handle(OpenGl_Context)& theCtx,
- const Graphic3d_TypeOfAttribute theMode,
- const GLint theNbComp,
- const GLenum theDataType,
- const GLsizei theStride,
- const GLvoid* theOffset)
-{
- switch (theMode)
- {
- case Graphic3d_TOA_POS:
- {
- theCtx->core11ffp->glEnableClientState (GL_VERTEX_ARRAY);
- theCtx->core11ffp->glVertexPointer (theNbComp, theDataType, theStride, theOffset);
- return;
- }
- case Graphic3d_TOA_NORM:
- {
- theCtx->core11ffp->glEnableClientState (GL_NORMAL_ARRAY);
- theCtx->core11ffp->glNormalPointer (theDataType, theStride, theOffset);
- return;
- }
- case Graphic3d_TOA_UV:
- {
- theCtx->core11ffp->glEnableClientState (GL_TEXTURE_COORD_ARRAY);
- theCtx->core11ffp->glTexCoordPointer (theNbComp, theDataType, theStride, theOffset);
- return;
- }
- case Graphic3d_TOA_COLOR:
- {
- theCtx->core11ffp->glEnableClientState (GL_COLOR_ARRAY);
- theCtx->core11ffp->glColorPointer (theNbComp, theDataType, theStride, theOffset);
- theCtx->core11ffp->glColorMaterial (GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
- theCtx->core11fwd->glEnable (GL_COLOR_MATERIAL);
- return;
- }
- case Graphic3d_TOA_CUSTOM:
- {
- return;
- }
- }
-}
-#endif
-
-// =======================================================================
-// function : unbindAttribute
-// purpose :
-// =======================================================================
-inline void OpenGl_VertexBuffer::unbindAttribute (const Handle(OpenGl_Context)& theCtx,
- const Graphic3d_TypeOfAttribute theAttribute)
-{
- if (theCtx->ActiveProgram().IsNull())
- {
- #if !defined(GL_ES_VERSION_2_0)
- if (theCtx->core11ffp != NULL)
- {
- unbindFixed (theCtx, theAttribute);
- }
- #endif
- return;
- }
-
- theCtx->core20fwd->glDisableVertexAttribArray (theAttribute);
-}
-
-#if !defined(GL_ES_VERSION_2_0)
-// =======================================================================
-// function : unbindFixed
-// purpose :
-// =======================================================================
-inline void OpenGl_VertexBuffer::unbindFixed (const Handle(OpenGl_Context)& theCtx,
- const Graphic3d_TypeOfAttribute theMode)
-{
- switch (theMode)
- {
- case Graphic3d_TOA_POS: theCtx->core11ffp->glDisableClientState (GL_VERTEX_ARRAY); return;
- case Graphic3d_TOA_NORM: theCtx->core11ffp->glDisableClientState (GL_NORMAL_ARRAY); return;
- case Graphic3d_TOA_UV: theCtx->core11ffp->glDisableClientState (GL_TEXTURE_COORD_ARRAY); return;
- case Graphic3d_TOA_COLOR: unbindFixedColor (theCtx); return;
- case Graphic3d_TOA_CUSTOM:
- {
- return;
- }
- }
-}
-#endif
+++ /dev/null
-// Created by: Kirill GAVRILOV
-// 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 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.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <OpenGl_VertexBufferCompat.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(OpenGl_VertexBufferCompat,OpenGl_VertexBuffer)
-
-// =======================================================================
-// function : OpenGl_VertexBufferCompat
-// purpose :
-// =======================================================================
-OpenGl_VertexBufferCompat::OpenGl_VertexBufferCompat()
-{
- //
-}
-
-// =======================================================================
-// function : ~OpenGl_VertexBufferCompat
-// purpose :
-// =======================================================================
-OpenGl_VertexBufferCompat::~OpenGl_VertexBufferCompat()
-{
- Release (NULL);
-}
-
-// =======================================================================
-// function : Create
-// purpose :
-// =======================================================================
-bool OpenGl_VertexBufferCompat::Create (const Handle(OpenGl_Context)& )
-{
- if (myBufferId == NO_BUFFER)
- {
- myBufferId = (GLuint )-1; // dummy identifier...
- myData = new NCollection_Buffer (Graphic3d_Buffer::DefaultAllocator());
- }
- return myBufferId != NO_BUFFER;
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void OpenGl_VertexBufferCompat::Release (OpenGl_Context* )
-{
- if (myBufferId == NO_BUFFER)
- {
- return;
- }
-
- myOffset = NULL;
- myBufferId = NO_BUFFER;
- myData.Nullify();
-}
-
-// =======================================================================
-// function : Bind
-// purpose :
-// =======================================================================
-void OpenGl_VertexBufferCompat::Bind (const Handle(OpenGl_Context)& ) const
-{
- //
-}
-
-// =======================================================================
-// function : Unbind
-// purpose :
-// =======================================================================
-void OpenGl_VertexBufferCompat::Unbind (const Handle(OpenGl_Context)& ) const
-{
- //
-}
-
-// =======================================================================
-// function : initLink
-// purpose :
-// =======================================================================
-bool OpenGl_VertexBufferCompat::initLink (const Handle(NCollection_Buffer)& theData,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLenum theDataType)
-{
- if (theData.IsNull())
- {
- myOffset = NULL;
- return false;
- }
-
- if (myBufferId == NO_BUFFER)
- {
- myBufferId = (GLuint )-1; // dummy identifier...
- }
- myData = theData;
- myDataType = theDataType;
- myComponentsNb = theComponentsNb;
- myElemsNb = theElemsNb;
- myOffset = myData->ChangeData();
- return true;
-}
-
-// =======================================================================
-// function : init
-// purpose :
-// =======================================================================
-bool OpenGl_VertexBufferCompat::init (const Handle(OpenGl_Context)& theCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType,
- const GLsizei theStride)
-{
- if (!Create (theCtx))
- {
- myOffset = NULL;
- return false;
- }
-
- myDataType = theDataType;
- myComponentsNb = theComponentsNb;
- myElemsNb = theElemsNb;
-
- const size_t aNbBytes = size_t(myElemsNb) * theStride;
- if (!myData->Allocate (aNbBytes))
- {
- myOffset = NULL;
- return false;
- }
-
- myOffset = myData->ChangeData();
- if (theData != NULL)
- {
- memcpy (myData->ChangeData(), theData, aNbBytes);
- }
- return true;
-}
-
-// =======================================================================
-// function : subData
-// purpose :
-// =======================================================================
-bool OpenGl_VertexBufferCompat::subData (const Handle(OpenGl_Context)& ,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType)
-{
- if (!IsValid() || myDataType != theDataType ||
- theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb))
- {
- return false;
- }
- else if (theData == NULL)
- {
- return true;
- }
-
- const size_t aDataSize = sizeOfGlType (theDataType);
- const size_t anOffset = size_t(theElemFrom) * size_t(myComponentsNb) * aDataSize;
- const size_t aNbBytes = size_t(theElemsNb) * size_t(myComponentsNb) * aDataSize;
- memcpy (myData->ChangeData() + anOffset, theData, aNbBytes);
- return true;
-}
-
-// =======================================================================
-// function : getSubData
-// purpose :
-// =======================================================================
-bool OpenGl_VertexBufferCompat::getSubData (const Handle(OpenGl_Context)& ,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- void* theData,
- const GLenum theDataType)
-{
- if (!IsValid() || myDataType != theDataType
- || theElemFrom < 0 || ((theElemFrom + theElemsNb) > myElemsNb)
- || theData == NULL)
- {
- return false;
- }
-
- const size_t aDataSize = sizeOfGlType (theDataType);
- const size_t anOffset = size_t(theElemFrom) * size_t(myComponentsNb) * aDataSize;
- const size_t aNbBytes = size_t(theElemsNb) * size_t(myComponentsNb) * aDataSize;
- memcpy (theData, myData->Data() + anOffset, aNbBytes);
- return true;
-}
#ifndef _OpenGl_VertexBufferCompat_HeaderFile
#define _OpenGl_VertexBufferCompat_HeaderFile
+#include <OpenGl_BufferCompatT.hxx>
#include <OpenGl_VertexBuffer.hxx>
+#include <OpenGl_IndexBuffer.hxx>
-//! Compatibility layer for old OpenGL without VBO.
-//! Make sure to pass pointer from GetDataOffset() instead of NULL.
-//! Method GetDataOffset() returns pointer to real data in this class
-//! (while base class OpenGl_VertexBuffer always return NULL).
-//!
-//! Methods Bind()/Unbind() do nothing (do not affect OpenGL state)
-//! and ::GetTarget() is never used.
-//! For this reason there is no analog for OpenGl_IndexBuffer.
-//! Just pass GetDataOffset() to glDrawElements() directly as last argument.
-//!
-//! Class overrides methods init() and subData() to copy data into own memory buffer.
-//! Extra method initLink() might be used to pass existing buffer through handle without copying the data.
-//!
-//! Method Create() creates dummy identifier for this object which should NOT be passed to OpenGL functions.
-class OpenGl_VertexBufferCompat : public OpenGl_VertexBuffer
-{
-
-public:
-
- //! Create uninitialized VBO.
- Standard_EXPORT OpenGl_VertexBufferCompat();
-
- //! Destroy object.
- Standard_EXPORT virtual ~OpenGl_VertexBufferCompat();
-
- //! Return TRUE.
- virtual bool IsVirtual() const Standard_OVERRIDE { return true; }
-
- //! Creates VBO name (id) if not yet generated.
- //! Data should be initialized by another method.
- Standard_EXPORT bool Create (const Handle(OpenGl_Context)& theGlCtx) Standard_OVERRIDE;
-
- //! Destroy object - will release memory if any.
- Standard_EXPORT virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
-
- //! Bind this VBO.
- Standard_EXPORT virtual void Bind (const Handle(OpenGl_Context)& theGlCtx) const Standard_OVERRIDE;
-
- //! Unbind this VBO.
- Standard_EXPORT virtual void Unbind (const Handle(OpenGl_Context)& theGlCtx) const Standard_OVERRIDE;
-
-public: //! @name advanced methods
-
- //! Initialize buffer with existing data.
- //! Data will NOT be copied by this method!
- Standard_EXPORT bool initLink (const Handle(NCollection_Buffer)& theData,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const GLenum theDataType);
-
- //! Initialize buffer with new data (data will be copied).
- Standard_EXPORT virtual bool init (const Handle(OpenGl_Context)& theGlCtx,
- const GLuint theComponentsNb,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType,
- const GLsizei theStride) Standard_OVERRIDE;
-
- //! Update part of the buffer with new data.
- Standard_EXPORT virtual bool subData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- const void* theData,
- const GLenum theDataType) Standard_OVERRIDE;
-
- //! Read back buffer sub-range.
- Standard_EXPORT virtual bool getSubData (const Handle(OpenGl_Context)& theGlCtx,
- const GLsizei theElemFrom,
- const GLsizei theElemsNb,
- void* theData,
- const GLenum theDataType) Standard_OVERRIDE;
-
-protected:
-
- Handle(NCollection_Buffer) myData; //!< buffer data
-
-public:
-
- DEFINE_STANDARD_RTTIEXT(OpenGl_VertexBufferCompat,OpenGl_VertexBuffer) // Type definition
-
-};
-
-DEFINE_STANDARD_HANDLE(OpenGl_VertexBufferCompat, OpenGl_VertexBuffer)
+typedef OpenGl_BufferCompatT<OpenGl_VertexBuffer> OpenGl_VertexBufferCompat;
+typedef OpenGl_BufferCompatT<OpenGl_IndexBuffer> OpenGl_IndexBufferCompat;
#endif // _OpenGl_VertexBufferCompat_HeaderFile
#ifndef _OpenGl_VertexBufferEditor_H__
#define _OpenGl_VertexBufferEditor_H__
-#include <OpenGl_VertexBuffer.hxx>
+#include <OpenGl_Buffer.hxx>
#include <OpenGl_Context.hxx>
#include <NCollection_Array1.hxx>
public:
//! Creates empty editor
- //! theTmpBufferLength - temporary buffer length
- OpenGl_VertexBufferEditor (const Standard_Integer theTmpBufferLength = 0)
+ //! theTmpBufferLength [in] temporary buffer length
+ explicit OpenGl_VertexBufferEditor (const Standard_Integer theTmpBufferLength = 0)
: myElemFrom (0),
myElemsNb (0),
myTmpBuffer (0, theTmpBufferLength > 0 ? (theTmpBufferLength - 1) : 2047) {}
//! Creates empty editor
- //! theTmpBuffer - pointer to temporary buffer
- //! theTmpBufferLength - temporary buffer length
+ //! theTmpBuffer [in] pointer to temporary buffer
+ //! theTmpBufferLength [in] temporary buffer length
OpenGl_VertexBufferEditor (theVec_t* theTmpBuffer,
const Standard_Integer theTmpBufferLength)
: myElemFrom (0),
myElemsNb (0),
myTmpBuffer (theTmpBuffer[0], 0, theTmpBufferLength - 1) {}
- //! Initialize editor for specified VBO.
- //! theGlCtx - bound OpenGL context to edit VBO
- //! theVbo - VBO to edit
- Standard_Boolean Init (const Handle(OpenGl_Context)& theGlCtx,
- const Handle(OpenGl_VertexBuffer)& theVbo)
+ //! Initialize editor for specified buffer object.
+ //! theGlCtx [in] bound OpenGL context to edit buffer object
+ //! theVbo [in] buffer to edit
+ Standard_Boolean Init (const Handle(OpenGl_Context)& theGlCtx,
+ const Handle(OpenGl_Buffer)& theVbo)
{
myGlCtx = theGlCtx;
myVbo = theVbo;
}
//! @return assigned VBO
- inline const Handle(OpenGl_VertexBuffer)& GetVBO() const
- {
- return myVbo;
- }
+ const Handle(OpenGl_Buffer)& GetVBO() const { return myVbo; }
private:
Handle(OpenGl_Context) myGlCtx; //!< handle to current OpenGL context
- Handle(OpenGl_VertexBuffer) myVbo; //!< edited VBO
+ Handle(OpenGl_Buffer) myVbo; //!< edited VBO
Standard_Integer myElemFrom; //!< element in VBO to upload from
Standard_Integer myElemsNb; //!< current element in temporary buffer
NCollection_Array1<theVec_t> myTmpBuffer; //!< temporary array
#include <Graphic3d_Mat4d.hxx>
#include <Image_AlienPixMap.hxx>
#include <OpenGl_ArbFBO.hxx>
+#include <OpenGl_BackgroundArray.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_DepthPeeling.hxx>
#include <OpenGl_FrameBuffer.hxx>
{
return checkWasFailedFbo (theFboToCheck, theFboRef->GetVPSizeX(), theFboRef->GetVPSizeY(), theFboRef->NbSamples());
}
+
+ //! Chooses compatible internal color format for OIT frame buffer.
+ static bool chooseOitColorConfiguration (const Handle(OpenGl_Context)& theGlContext,
+ const Standard_Integer theConfigIndex,
+ OpenGl_ColorFormats& theFormats)
+ {
+ theFormats.Clear();
+ switch (theConfigIndex)
+ {
+ case 0: // choose best applicable color format combination
+ {
+ theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_RGBA16F : GL_RGBA32F);
+ theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_R16F : GL_R32F);
+ return true;
+ }
+ case 1: // choose non-optimal applicable color format combination
+ {
+ theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_RGBA16F : GL_RGBA32F);
+ theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_RGBA16F : GL_RGBA32F);
+ return true;
+ }
+ }
+ return false; // color combination does not exist
+ }
}
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView)
return aPrevMode;
}
+// =======================================================================
+// function : Window
+// purpose :
+// =======================================================================
+Handle(Aspect_Window) OpenGl_View::Window() const
+{
+ return myWindow->PlatformWindow();
+}
+
// =======================================================================
// function : SetWindow
// purpose :
aSizeY = myWindow->Height();
}
- const Standard_Integer aRendSizeX = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeX + 0.5f);
- const Standard_Integer aRendSizeY = Standard_Integer(myRenderParams.RenderResolutionScale * aSizeY + 0.5f);
+ const Graphic3d_Vec2i aRendSize (Standard_Integer(myRenderParams.RenderResolutionScale * aSizeX + 0.5f),
+ Standard_Integer(myRenderParams.RenderResolutionScale * aSizeY + 0.5f));
if (aSizeX < 1
|| aSizeY < 1
- || aRendSizeX < 1
- || aRendSizeY < 1)
+ || aRendSize.x() < 1
+ || aRendSize.y() < 1)
{
myBackBufferRestored = Standard_False;
myIsImmediateDrawn = Standard_False;
}
// determine multisampling parameters
- Standard_Integer aNbSamples = !myToDisableMSAA && aSizeX == aRendSizeX
+ Standard_Integer aNbSamples = !myToDisableMSAA && aSizeX == aRendSize.x()
? Max (Min (myRenderParams.NbMsaaSamples, aCtx->MaxMsaaSamples()), 0)
: 0;
if (aNbSamples != 0)
|| theProj == Graphic3d_Camera::Projection_Stereo
|| aNbSamples != 0
|| toUseOit
- || aSizeX != aRendSizeX))
+ || aSizeX != aRendSize.x()))
{
- if (myMainSceneFbos[0]->GetVPSizeX() != aRendSizeX
- || myMainSceneFbos[0]->GetVPSizeY() != aRendSizeY
- || myMainSceneFbos[0]->NbSamples() != aNbSamples)
+ if (myMainSceneFbos[0]->GetVPSize() != aRendSize
+ || myMainSceneFbos[0]->NbSamples() != aNbSamples)
{
if (!myTransientDrawToFront)
{
// for further blitting and rendering immediate presentations on top
if (aCtx->core20fwd != NULL)
{
- const bool wasFailedMain0 = checkWasFailedFbo (myMainSceneFbos[0], aRendSizeX, aRendSizeY, aNbSamples);
- if (!myMainSceneFbos[0]->Init (aCtx, aRendSizeX, aRendSizeY, myFboColorFormat, myFboDepthFormat, aNbSamples)
+ const bool wasFailedMain0 = checkWasFailedFbo (myMainSceneFbos[0], aRendSize.x(), aRendSize.y(), aNbSamples);
+ if (!myMainSceneFbos[0]->Init (aCtx, aRendSize, myFboColorFormat, myFboDepthFormat, aNbSamples)
&& !wasFailedMain0)
{
TCollection_ExtendedString aMsg = TCollection_ExtendedString() + "Error! Main FBO "
&& myMainSceneFbos[0]->IsValid())
{
if (aNbSamples != 0
- || aSizeX != aRendSizeX)
+ || aSizeX != aRendSize.x())
{
- hasXRBlitFbo = myXrSceneFbo->InitLazy (aCtx, aSizeX, aSizeY, myFboColorFormat, myFboDepthFormat, 0);
+ hasXRBlitFbo = myXrSceneFbo->InitLazy (aCtx, Graphic3d_Vec2i (aSizeX, aSizeY), myFboColorFormat, myFboDepthFormat, 0);
if (!hasXRBlitFbo)
{
TCollection_ExtendedString aMsg = TCollection_ExtendedString() + "Error! VR FBO "
if (toUseOit
&& myRenderParams.TransparencyMethod == Graphic3d_RTM_DEPTH_PEELING_OIT)
{
- if (myDepthPeelingFbos->BlendBackFboOit()->GetSizeX() != aRendSizeX
- || myDepthPeelingFbos->BlendBackFboOit()->GetSizeY() != aRendSizeY)
+ if (myDepthPeelingFbos->BlendBackFboOit()->GetSize() != aRendSize)
{
- if (myDepthPeelingFbos->BlendBackFboOit()->Init (aCtx, aRendSizeX, aRendSizeY, GL_RGBA16F, 0))
+ if (myDepthPeelingFbos->BlendBackFboOit()->Init (aCtx, aRendSize, GL_RGBA16F, 0))
{
for (int aPairIter = 0; aPairIter < 2; ++aPairIter)
{
aColorFormats.Append (GL_RG32F);
aColorFormats.Append (GL_RGBA16F);
aColorFormats.Append (GL_RGBA16F);
- myDepthPeelingFbos->DepthPeelFbosOit()[aPairIter]->Init (aCtx, aRendSizeX, aRendSizeY, aColorFormats, 0);
+ myDepthPeelingFbos->DepthPeelFbosOit()[aPairIter]->Init (aCtx, aRendSize, aColorFormats, 0);
NCollection_Sequence<Handle(OpenGl_Texture)> anAttachments;
anAttachments.Append (myDepthPeelingFbos->DepthPeelFbosOit()[aPairIter]->ColorTexture (1));
Handle(OpenGl_FrameBuffer)& anImmediateSceneFbo = myImmediateSceneFbos [anFboIt];
Handle(OpenGl_FrameBuffer)& anImmediateSceneFboOit = myImmediateSceneFbosOit[anFboIt];
if (aMainSceneFbo->IsValid()
- && (aMainSceneFboOit->GetVPSizeX() != aRendSizeX
- || aMainSceneFboOit->GetVPSizeY() != aRendSizeY
- || aMainSceneFboOit->NbSamples() != aNbSamples))
+ && (aMainSceneFboOit->GetVPSize() != aRendSize
+ || aMainSceneFboOit->NbSamples() != aNbSamples))
{
Standard_Integer aColorConfig = 0;
for (;;) // seemly responding to driver limitation (GL_FRAMEBUFFER_UNSUPPORTED)
break;
}
}
- if (aMainSceneFboOit->Init (aCtx, aRendSizeX, aRendSizeY, myFboOitColorConfig, aMainSceneFbo->DepthStencilTexture(), aNbSamples))
+ if (aMainSceneFboOit->Init (aCtx, aRendSize, myFboOitColorConfig, aMainSceneFbo->DepthStencilTexture(), aNbSamples))
{
break;
}
}
if (anImmediateSceneFbo->IsValid()
- && (anImmediateSceneFboOit->GetVPSizeX() != aRendSizeX
- || anImmediateSceneFboOit->GetVPSizeY() != aRendSizeY
- || anImmediateSceneFboOit->NbSamples() != aNbSamples))
+ && (anImmediateSceneFboOit->GetVPSize() != aRendSize
+ || anImmediateSceneFboOit->NbSamples() != aNbSamples))
{
- if (!anImmediateSceneFboOit->Init (aCtx, aRendSizeX, aRendSizeY, myFboOitColorConfig,
+ if (!anImmediateSceneFboOit->Init (aCtx, aRendSize, myFboOitColorConfig,
anImmediateSceneFbo->DepthStencilTexture(), aNbSamples))
{
break;
&& toUseShadowMap)
{
OpenGl_ColorFormats aDummy;
- if (!aShadowFbo->Init (aCtx, myRenderParams.ShadowMapResolution, myRenderParams.ShadowMapResolution, aDummy, myFboDepthFormat, 0))
+ if (!aShadowFbo->Init (aCtx, Graphic3d_Vec2i (myRenderParams.ShadowMapResolution), aDummy, myFboDepthFormat, 0))
{
toUseShadowMap = false;
}
if (!toRenderGL)
{
- const Standard_Integer aSizeX = theReadDrawFbo != NULL ? theReadDrawFbo->GetVPSizeX() : myWindow->Width();
- const Standard_Integer aSizeY = theReadDrawFbo != NULL ? theReadDrawFbo->GetVPSizeY() : myWindow->Height();
+ const Graphic3d_Vec2i aSizeXY = theReadDrawFbo != NULL
+ ? theReadDrawFbo->GetVPSize()
+ : Graphic3d_Vec2i (myWindow->Width(), myWindow->Height());
- toRenderGL = !initRaytraceResources (aSizeX, aSizeY, aCtx)
+ toRenderGL = !initRaytraceResources (aSizeXY.x(), aSizeXY.y(), aCtx)
|| !updateRaytraceGeometry (OpenGl_GUM_CHECK, myId, aCtx);
toRenderGL |= !myIsRaytraceDataValid; // if no ray-trace data use OpenGL
if (!toRenderGL)
{
- myOpenGlFBO ->InitLazy (aCtx, aSizeX, aSizeY, myFboColorFormat, myFboDepthFormat, 0);
-
+ myOpenGlFBO ->InitLazy (aCtx, aSizeXY, myFboColorFormat, myFboDepthFormat, 0);
if (theReadDrawFbo != NULL)
+ {
theReadDrawFbo->UnbindBuffer (aCtx);
+ }
// Prepare preliminary OpenGL output
if (aCtx->arbFBOBlit != NULL)
myWorkspace->ResetAppliedAspect();
// Ray-tracing polygonal primitive arrays
- raytrace (aSizeX, aSizeY, theProjection, theReadDrawFbo, aCtx);
+ raytrace (aSizeXY.x(), aSizeXY.y(), theProjection, theReadDrawFbo, aCtx);
// Render upper (top and topmost) OpenGL layers
myZLayers.Render (myWorkspace, theToDrawImmediate, OpenGl_LF_Upper, theReadDrawFbo, theOitAccumFbo);
if (aPair[0]->NbSamples() != 0)
{
// resolve MSAA buffers before drawing
- if (!myOpenGlFBO ->InitLazy (aCtx, aPair[0]->GetVPSizeX(), aPair[0]->GetVPSizeY(), myFboColorFormat, myFboDepthFormat, 0)
- || !myOpenGlFBO2->InitLazy (aCtx, aPair[0]->GetVPSizeX(), aPair[0]->GetVPSizeY(), myFboColorFormat, 0, 0))
+ if (!myOpenGlFBO ->InitLazy (aCtx, aPair[0]->GetVPSize(), myFboColorFormat, myFboDepthFormat, 0)
+ || !myOpenGlFBO2->InitLazy (aCtx, aPair[0]->GetVPSize(), myFboColorFormat, 0, 0))
{
aCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_ERROR,
return Standard_False;
}
-// =======================================================================
-// function : chooseOitColorConfiguration
-// purpose :
-// =======================================================================
-bool OpenGl_View::chooseOitColorConfiguration (const Handle(OpenGl_Context)& theGlContext,
- const Standard_Integer theConfigIndex,
- OpenGl_ColorFormats& theFormats)
-{
- theFormats.Clear();
- switch (theConfigIndex)
- {
- case 0: // choose best applicable color format combination
- {
- theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_RGBA16F : GL_RGBA32F);
- theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_R16F : GL_R32F);
- return true;
- }
- case 1: // choose non-optimal applicable color format combination
- {
- theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_RGBA16F : GL_RGBA32F);
- theFormats.Append (theGlContext->hasHalfFloatBuffer != OpenGl_FeatureNotAvailable ? GL_RGBA16F : GL_RGBA32F);
- return true;
- }
- }
- return false; // color combination does not exist
-}
-
// =======================================================================
// function : checkPBRAvailability
// purpose :
#ifndef _OpenGl_View_Header
#define _OpenGl_View_Header
-#include <Standard_Transient.hxx>
-#include <Standard_Type.hxx>
-
-#include <TColStd_Array2OfReal.hxx>
-#include <NCollection_List.hxx>
-#include <math_BullardGenerator.hxx>
-
-#include <Quantity_NameOfColor.hxx>
#include <Aspect_FillMethod.hxx>
#include <Aspect_GradientFillMethod.hxx>
-
#include <Graphic3d_CView.hxx>
#include <Graphic3d_CullingTool.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_ToneMappingMethod.hxx>
+#include <Graphic3d_TypeOfBackground.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
#include <Graphic3d_WorldViewProjState.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
+#include <math_BullardGenerator.hxx>
#include <OpenGl_Aspects.hxx>
-#include <OpenGl_BackgroundArray.hxx>
-#include <OpenGl_Context.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_FrameStatsPrs.hxx>
#include <OpenGl_GraduatedTrihedron.hxx>
#include <OpenGl_LayerList.hxx>
-#include <OpenGl_LineAttributes.hxx>
#include <OpenGl_SceneGeometry.hxx>
#include <OpenGl_Structure.hxx>
-#include <OpenGl_Window.hxx>
-#include <OpenGl_Workspace.hxx>
#include <OpenGl_TileSampler.hxx>
#include <map>
#include <set>
class Graphic3d_StructureManager;
+class OpenGl_BackgroundArray;
class OpenGl_DepthPeeling;
class OpenGl_GraphicDriver;
class OpenGl_PBREnvironment;
+struct OpenGl_RaytraceMaterial;
class OpenGl_StateCounter;
class OpenGl_ShadowMap;
class OpenGl_ShadowMapArray;
+class OpenGl_ShaderObject;
+class OpenGl_TextureBuffer;
class OpenGl_TriangleSet;
class OpenGl_Workspace;
-class OpenGl_View;
DEFINE_STANDARD_HANDLE(OpenGl_View,Graphic3d_CView)
const Aspect_RenderingContext theContext) Standard_OVERRIDE;
//! Returns window associated with the view.
- virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE
- { return myWindow->PlatformWindow(); }
+ Standard_EXPORT virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE;
//! Returns True if the window associated to the view is defined.
virtual Standard_Boolean IsDefined() const Standard_OVERRIDE
bool checkOitCompatibility (const Handle(OpenGl_Context)& theGlContext,
const Standard_Boolean theMSAA);
- //! Chooses compatible internal color format for OIT frame buffer.
- bool chooseOitColorConfiguration (const Handle(OpenGl_Context)& theGlContext,
- const Standard_Integer theConfigIndex,
- OpenGl_ColorFormats& theFormats);
-
protected:
OpenGl_GraphicDriver* myDriver;
Handle(OpenGl_ShaderProgram) myOutImageProgram;
//! Texture buffer of data records of bottom-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneNodeInfoTexture;
+ Handle(OpenGl_TextureBuffer) mySceneNodeInfoTexture;
//! Texture buffer of minimum points of bottom-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneMinPointTexture;
+ Handle(OpenGl_TextureBuffer) mySceneMinPointTexture;
//! Texture buffer of maximum points of bottom-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneMaxPointTexture;
+ Handle(OpenGl_TextureBuffer) mySceneMaxPointTexture;
//! Texture buffer of transformations of high-level BVH nodes.
- Handle(OpenGl_TextureBufferArb) mySceneTransformTexture;
+ Handle(OpenGl_TextureBuffer) mySceneTransformTexture;
//! Texture buffer of vertex coords.
- Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
+ Handle(OpenGl_TextureBuffer) myGeometryVertexTexture;
//! Texture buffer of vertex normals.
- Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
+ Handle(OpenGl_TextureBuffer) myGeometryNormalTexture;
//! Texture buffer of vertex UV coords.
- Handle(OpenGl_TextureBufferArb) myGeometryTexCrdTexture;
+ Handle(OpenGl_TextureBuffer) myGeometryTexCrdTexture;
//! Texture buffer of triangle indices.
- Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
+ Handle(OpenGl_TextureBuffer) myGeometryTriangTexture;
//! Texture buffer of material properties.
- Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
+ Handle(OpenGl_TextureBuffer) myRaytraceMaterialTexture;
//! Texture buffer of light source properties.
- Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
+ Handle(OpenGl_TextureBuffer) myRaytraceLightSrcTexture;
//! 1st framebuffer (FBO) to perform adaptive FSAA.
//! Used in compatibility mode (no adaptive sampling).
#include <OpenGl_View.hxx>
#include <Graphic3d_TextureParams.hxx>
+#include <OpenGl_BackgroundArray.hxx>
+#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_VertexBuffer.hxx>
+#include <OpenGl_SceneGeometry.hxx>
+#include <OpenGl_ShaderProgram.hxx>
+#include <OpenGl_TextureBuffer.hxx>
#include <OpenGl_GlCore44.hxx>
#include <OSD_Protection.hxx>
#include <OSD_File.hxx>
if (myRaytraceParameters.AdaptiveScreenSampling)
{
Graphic3d_Vec2i aMaxViewport = myTileSampler.OffsetTilesViewportMax().cwiseMax (Graphic3d_Vec2i (theSizeX, theSizeY));
- myRaytraceFBO1[0]->InitLazy (theGlContext, aMaxViewport.x(), aMaxViewport.y(), GL_RGBA32F, myFboDepthFormat);
- myRaytraceFBO2[0]->InitLazy (theGlContext, aMaxViewport.x(), aMaxViewport.y(), GL_RGBA32F, myFboDepthFormat);
+ myRaytraceFBO1[0]->InitLazy (theGlContext, aMaxViewport, GL_RGBA32F, myFboDepthFormat);
+ myRaytraceFBO2[0]->InitLazy (theGlContext, aMaxViewport, GL_RGBA32F, myFboDepthFormat);
if (myRaytraceFBO1[1]->IsValid()) // second FBO not needed
{
myRaytraceFBO1[1]->Release (theGlContext.operator->());
myAccumFrames = 0; // accumulation should be restarted
}
- myRaytraceFBO1[aViewIter]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
- myRaytraceFBO2[aViewIter]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
+ myRaytraceFBO1[aViewIter]->InitLazy (theGlContext, Graphic3d_Vec2i (theSizeX, theSizeY), GL_RGBA32F, myFboDepthFormat);
+ myRaytraceFBO2[aViewIter]->InitLazy (theGlContext, Graphic3d_Vec2i (theSizeX, theSizeY), GL_RGBA32F, myFboDepthFormat);
}
}
return Standard_True;
if (mySceneNodeInfoTexture.IsNull()) // create scene BVH buffers
{
- mySceneNodeInfoTexture = new OpenGl_TextureBufferArb;
- mySceneMinPointTexture = new OpenGl_TextureBufferArb;
- mySceneMaxPointTexture = new OpenGl_TextureBufferArb;
- mySceneTransformTexture = new OpenGl_TextureBufferArb;
+ mySceneNodeInfoTexture = new OpenGl_TextureBuffer();
+ mySceneMinPointTexture = new OpenGl_TextureBuffer();
+ mySceneMaxPointTexture = new OpenGl_TextureBuffer();
+ mySceneTransformTexture = new OpenGl_TextureBuffer();
if (!mySceneNodeInfoTexture->Create (theGlContext)
|| !mySceneMinPointTexture->Create (theGlContext)
if (myGeometryVertexTexture.IsNull()) // create geometry buffers
{
- myGeometryVertexTexture = new OpenGl_TextureBufferArb;
- myGeometryNormalTexture = new OpenGl_TextureBufferArb;
- myGeometryTexCrdTexture = new OpenGl_TextureBufferArb;
- myGeometryTriangTexture = new OpenGl_TextureBufferArb;
+ myGeometryVertexTexture = new OpenGl_TextureBuffer();
+ myGeometryNormalTexture = new OpenGl_TextureBuffer();
+ myGeometryTexCrdTexture = new OpenGl_TextureBuffer();
+ myGeometryTriangTexture = new OpenGl_TextureBuffer();
if (!myGeometryVertexTexture->Create (theGlContext)
|| !myGeometryNormalTexture->Create (theGlContext)
if (myRaytraceMaterialTexture.IsNull()) // create material buffer
{
- myRaytraceMaterialTexture = new OpenGl_TextureBufferArb();
+ myRaytraceMaterialTexture = new OpenGl_TextureBuffer();
if (!myRaytraceMaterialTexture->Create (theGlContext))
{
Message::SendTrace() << "Error: Failed to create buffers for material data";
if (myRaytraceLightSrcTexture.IsNull()) // create light source buffer
{
- myRaytraceLightSrcTexture = new OpenGl_TextureBufferArb;
+ myRaytraceLightSrcTexture = new OpenGl_TextureBuffer();
}
if (myRaytraceGeometry.Sources.size() != 0 && wasUpdated)
aDefFbo = new OpenGl_FrameBuffer();
}
- if (!aDefFbo->InitWithRB (myGlContext, myWidth, myHeight, GL_RGBA8, GL_DEPTH24_STENCIL8))
+ if (!aDefFbo->InitWithRB (myGlContext, Graphic3d_Vec2i (myWidth, myHeight), GL_RGBA8, GL_DEPTH24_STENCIL8))
{
TCollection_AsciiString aMsg ("OpenGl_Window::CreateWindow: default FBO creation failed");
throw Aspect_GraphicDeviceDefinitionError(aMsg.ToCString());
::glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &myHeight);
::glBindRenderbuffer (GL_RENDERBUFFER, 0);
- if (!aDefFbo->InitWithRB (myGlContext, myWidth, myHeight, GL_RGBA8, GL_DEPTH24_STENCIL8, aWinRBColor))
+ if (!aDefFbo->InitWithRB (myGlContext, Graphic3d_Vec2i (myWidth, myHeight), GL_RGBA8, GL_DEPTH24_STENCIL8, aWinRBColor))
{
TCollection_AsciiString aMsg ("OpenGl_Window::CreateWindow: default FBO creation failed");
throw Aspect_GraphicDeviceDefinitionError(aMsg.ToCString());
#include <OpenGl_Workspace.hxx>
-#include <OpenGl_ArbFBO.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
const Handle(OpenGl_Context)& aCtx = GetGlContext();
aCtx->BindTextures (Handle(OpenGl_TextureSet)(), Handle(OpenGl_ShaderProgram)());
Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer();
- if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_SRGB8_ALPHA8, GL_DEPTH24_STENCIL8, 0))
+ if (!aFrameBuffer->Init (aCtx, Graphic3d_Vec2i (theWidth, theHeight), GL_SRGB8_ALPHA8, GL_DEPTH24_STENCIL8, 0))
{
aFrameBuffer->Release (aCtx.operator->());
return Handle(OpenGl_FrameBuffer)();
#define _OpenGl_Workspace_Header
#include <Graphic3d_BufferType.hxx>
+#include <Graphic3d_PresentationAttributes.hxx>
#include <OpenGl_Aspects.hxx>
-#include <OpenGl_CappingAlgo.hxx>
-#include <OpenGl_FrameBuffer.hxx>
-#include <OpenGl_Material.hxx>
-#include <OpenGl_ShaderObject.hxx>
-#include <OpenGl_ShaderProgram.hxx>
-#include <OpenGl_TextureBufferArb.hxx>
-#include <OpenGl_RenderFilter.hxx>
#include <OpenGl_Vec.hxx>
-#include <OpenGl_Window.hxx>
+class OpenGl_FrameBuffer;
+class OpenGl_Group;
class OpenGl_View;
+class OpenGl_Window;
class Image_PixMap;
class OpenGl_Workspace;