mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0023069: Cache GL_FEEDBACK mode per frame in TKOpenGl calls
This commit is contained in:
parent
1b1ab324bc
commit
664cae74a9
@ -60,6 +60,7 @@ OpenGl_Context::OpenGl_Context()
|
||||
myGlCore20 (NULL),
|
||||
myGlVerMajor (0),
|
||||
myGlVerMinor (0),
|
||||
myIsFeedback (Standard_False),
|
||||
myIsInitialized (Standard_False)
|
||||
{
|
||||
#if defined(MAC_OS_X_VERSION_10_3) && !defined(MACOSX_USE_GLX)
|
||||
@ -606,3 +607,21 @@ void OpenGl_Context::init()
|
||||
core20 = myGlCore20;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsFeedback
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_Context::IsFeedback() const
|
||||
{
|
||||
return myIsFeedback;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFeedback
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_Context::SetFeedback (const Standard_Boolean theFeedbackOn)
|
||||
{
|
||||
myIsFeedback = theFeedbackOn;
|
||||
}
|
||||
|
@ -124,6 +124,12 @@ public:
|
||||
//! Class should be initialized with appropriate info.
|
||||
Standard_EXPORT Standard_Boolean MakeCurrent();
|
||||
|
||||
//! Return true if active mode is GL_FEEDBACK (cached state)
|
||||
Standard_EXPORT Standard_Boolean IsFeedback() const;
|
||||
|
||||
//! Setup feedback mode cached state
|
||||
Standard_EXPORT void SetFeedback (const Standard_Boolean theFeedbackOn);
|
||||
|
||||
private:
|
||||
|
||||
//! Wrapper to system function to retrieve GL function pointer by name.
|
||||
@ -164,6 +170,7 @@ private:
|
||||
OpenGl_GlCore20* myGlCore20; //!< common structure for GL core functions upto 2.0
|
||||
Standard_Integer myGlVerMajor; //!< cached GL version major number
|
||||
Standard_Integer myGlVerMinor; //!< cached GL version minor number
|
||||
Standard_Boolean myIsFeedback; //!< flag indicates GL_FEEDBACK mode
|
||||
Standard_Boolean myIsInitialized; //!< flag to indicate initialization state
|
||||
|
||||
public:
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
#include <OpenGl_Marker.hxx>
|
||||
|
||||
@ -91,9 +92,8 @@ void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *)str );
|
||||
}
|
||||
}
|
||||
GLint mode;
|
||||
glGetIntegerv( GL_RENDER_MODE, &mode );
|
||||
if( mode==GL_FEEDBACK )
|
||||
|
||||
if (AWorkspace->GetGlContext()->IsFeedback())
|
||||
{
|
||||
glBegin( GL_POINTS );
|
||||
glVertex3fv( myPoint.xyz );
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
#include <OpenGl_MarkerSet.hxx>
|
||||
|
||||
@ -127,9 +128,8 @@ void OpenGl_MarkerSet::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
|
||||
}
|
||||
}
|
||||
}
|
||||
GLint mode;
|
||||
glGetIntegerv( GL_RENDER_MODE, &mode );
|
||||
if( mode==GL_FEEDBACK )
|
||||
|
||||
if (AWorkspace->GetGlContext()->IsFeedback())
|
||||
{
|
||||
glBegin( GL_POINTS );
|
||||
for( i = 0, ptr = myPoints; i < myNbPoints; i++, ptr++ )
|
||||
|
@ -280,7 +280,6 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
|
||||
Tint i,n;
|
||||
Tint transp = 0;
|
||||
GLint renderMode;
|
||||
// Following pointers have been provided for performance improvement
|
||||
tel_colour pfc = myPArray->fcolours;
|
||||
Tint* pvc = myPArray->vcolours;
|
||||
@ -349,11 +348,9 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
else
|
||||
glEnable (GL_LIGHTING);
|
||||
|
||||
glGetIntegerv (GL_RENDER_MODE, &renderMode);
|
||||
|
||||
if (myPArray->num_vertexs > 0
|
||||
&& myPArray->flagBufferVBO != VBO_OK
|
||||
&& renderMode != GL_FEEDBACK)
|
||||
&& !aGlContext->IsFeedback())
|
||||
{
|
||||
if (myPArray->vertices != NULL)
|
||||
{
|
||||
@ -462,7 +459,7 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
for (i = n = 0; i < myPArray->num_bounds; ++i)
|
||||
{
|
||||
if (pfc != NULL) glColor3fv (pfc[i].rgb);
|
||||
DrawElements (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawElements (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
myPArray->bounds[i], (GLenum* )&myPArray->edges[n]);
|
||||
n += myPArray->bounds[i];
|
||||
}
|
||||
@ -475,7 +472,7 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
{
|
||||
glColor3fv (pfc[i].rgb);
|
||||
}
|
||||
DrawArrays (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawArrays (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
n, myPArray->bounds[i]);
|
||||
n += myPArray->bounds[i];
|
||||
}
|
||||
@ -483,12 +480,12 @@ void OpenGl_PrimitiveArray::DrawArray (Tint theLightingModel,
|
||||
}
|
||||
else if (myPArray->num_edges > 0)
|
||||
{
|
||||
DrawElements (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawElements (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
myPArray->num_edges, (GLenum* )myPArray->edges);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawArrays (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawArrays (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
0, myPArray->num_vertexs);
|
||||
}
|
||||
}
|
||||
@ -577,7 +574,6 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
}
|
||||
|
||||
Tint i, j, n;
|
||||
GLint renderMode;
|
||||
|
||||
// OCC22236 NOTE: draw edges for all situations:
|
||||
// 1) draw elements with GL_LINE style as edges from myPArray->bufferVBO[VBOEdges] indicies array
|
||||
@ -630,7 +626,6 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
{
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
glVertexPointer (3, GL_FLOAT, 0, myPArray->vertices); // array of vertices
|
||||
glGetIntegerv (GL_RENDER_MODE, &renderMode);
|
||||
|
||||
glColor3fv (theEdgeColour->rgb);
|
||||
if (myPArray->num_bounds > 0)
|
||||
@ -651,7 +646,7 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawElements (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawElements (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
myPArray->bounds[i], (GLenum* )&myPArray->edges[n]);
|
||||
}
|
||||
n += myPArray->bounds[i];
|
||||
@ -661,7 +656,7 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
{
|
||||
for (i = n = 0 ; i < myPArray->num_bounds; ++i)
|
||||
{
|
||||
DrawArrays (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawArrays (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
n, myPArray->bounds[i]);
|
||||
n += myPArray->bounds[i];
|
||||
}
|
||||
@ -681,13 +676,13 @@ void OpenGl_PrimitiveArray::DrawEdges (const TEL_COLOUR* theEdgeCo
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawElements (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawElements (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
myPArray->num_edges, (GLenum* )myPArray->edges);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawArrays (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawArrays (theWorkspace, myPArray, aGlContext->IsFeedback(), myDrawMode,
|
||||
0, myPArray->num_vertexs);
|
||||
}
|
||||
}
|
||||
@ -1519,6 +1514,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsLines (const TEL_COLOUR*
|
||||
else
|
||||
{
|
||||
int i,n;
|
||||
Standard_Boolean isFeedback = theWorkspace->GetGlContext()->IsFeedback();
|
||||
glPushAttrib (GL_POLYGON_BIT);
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
@ -1540,16 +1536,13 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsLines (const TEL_COLOUR*
|
||||
|
||||
glVertexPointer (3, GL_FLOAT, 0, myPArray->vertices); // array of vertices
|
||||
|
||||
GLint renderMode;
|
||||
glGetIntegerv (GL_RENDER_MODE, &renderMode);
|
||||
|
||||
if (myPArray->num_bounds > 0)
|
||||
{
|
||||
if (myPArray->num_edges > 0)
|
||||
{
|
||||
for (i = n = 0; i < myPArray->num_bounds; ++i)
|
||||
{
|
||||
DrawElements (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawElements (theWorkspace, myPArray, isFeedback, myDrawMode,
|
||||
myPArray->bounds[i], (GLenum* )&myPArray->edges[n]);
|
||||
n += myPArray->bounds[i];
|
||||
}
|
||||
@ -1558,7 +1551,7 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsLines (const TEL_COLOUR*
|
||||
{
|
||||
for (i = n = 0; i < myPArray->num_bounds; ++i)
|
||||
{
|
||||
DrawArrays (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawArrays (theWorkspace, myPArray, isFeedback, myDrawMode,
|
||||
n, myPArray->bounds[i]);
|
||||
n += myPArray->bounds[i];
|
||||
}
|
||||
@ -1566,12 +1559,12 @@ void OpenGl_PrimitiveArray::DrawDegeneratesAsLines (const TEL_COLOUR*
|
||||
}
|
||||
else if (myPArray->num_edges > 0)
|
||||
{
|
||||
DrawElements (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawElements (theWorkspace, myPArray, isFeedback, myDrawMode,
|
||||
myPArray->num_edges, (GLenum* )myPArray->edges);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawArrays (theWorkspace, myPArray, (renderMode == GL_FEEDBACK), myDrawMode,
|
||||
DrawArrays (theWorkspace, myPArray, isFeedback, myDrawMode,
|
||||
0, myPArray->num_vertexs);
|
||||
}
|
||||
|
||||
|
@ -40,16 +40,22 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
|
||||
return;
|
||||
|
||||
// release pending GL resources
|
||||
OpenGl_ResourceCleaner::GetInstance()->Cleanup (GetGlContext());
|
||||
Handle(OpenGl_Context) aGlCtx = GetGlContext();
|
||||
OpenGl_ResourceCleaner::GetInstance()->Cleanup (aGlCtx);
|
||||
|
||||
Tint toSwap = 1; // swap buffers
|
||||
// cache render mode state
|
||||
GLint aRendMode = GL_RENDER;
|
||||
glGetIntegerv (GL_RENDER_MODE, &aRendMode);
|
||||
aGlCtx->SetFeedback (aRendMode == GL_FEEDBACK);
|
||||
|
||||
Tint toSwap = (aRendMode == GL_RENDER); // swap buffers
|
||||
GLint aViewPortBack[4];
|
||||
OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )theCView.ptrFBO;
|
||||
if (aFrameBuffer != NULL)
|
||||
{
|
||||
glGetIntegerv (GL_VIEWPORT, aViewPortBack);
|
||||
aFrameBuffer->SetupViewport();
|
||||
aFrameBuffer->BindBuffer (GetGlContext());
|
||||
aFrameBuffer->BindBuffer (aGlCtx);
|
||||
toSwap = 0; // no need to swap buffers
|
||||
}
|
||||
|
||||
@ -58,7 +64,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
|
||||
|
||||
if (aFrameBuffer != NULL)
|
||||
{
|
||||
aFrameBuffer->UnbindBuffer (GetGlContext());
|
||||
aFrameBuffer->UnbindBuffer (aGlCtx);
|
||||
// move back original viewport
|
||||
glViewport (aViewPortBack[0], aViewPortBack[1], aViewPortBack[2], aViewPortBack[3]);
|
||||
}
|
||||
@ -80,4 +86,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
|
||||
delete[] aDumpData;
|
||||
}
|
||||
#endif
|
||||
|
||||
// reset render mode state
|
||||
aGlCtx->SetFeedback (Standard_False);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user