OpenGl_CappingAlgo - move global variables to OpenGl_Workspace class fields.
OpenGl_View::ShaderSource::Source() - drop static for local variable.
OpenGl_Window - drop redundant global constant THE_DEFAULT_BG_COLOR.
IMPLEMENT_STANDARD_HANDLE(OpenGl_CappingAlgoFilter, OpenGl_RenderFilter)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_CappingAlgoFilter, OpenGl_RenderFilter)
-Handle(OpenGl_RenderFilter) OpenGl_CappingAlgo::myRenderFilter;
-OpenGl_AspectFace OpenGl_CappingAlgo::myFrontCulling;
-OpenGl_AspectFace OpenGl_CappingAlgo::myNoneCulling;
-Standard_Boolean OpenGl_CappingAlgo::myIsInit = Standard_False;
-
namespace
{
-
#if !defined(GL_ES_VERSION_2_0)
static const GLint THE_FILLPRIM_FROM = GL_TRIANGLES;
static const GLint THE_FILLPRIM_TO = GL_POLYGON;
return;
}
- // init internal data
- Init();
-
// remember current aspect face defined in workspace
const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace (Standard_False);
// replace primitive groups rendering filter
- static Handle(OpenGl_CappingAlgoFilter) aCappingFilter = new OpenGl_CappingAlgoFilter();
Handle(OpenGl_RenderFilter) aRenderFilter = theWorkspace->GetRenderFilter();
- theWorkspace->SetRenderFilter (aCappingFilter);
+ theWorkspace->SetRenderFilter (theWorkspace->DefaultCappingAlgoFilter());
// prepare for rendering the clip planes
glEnable (GL_STENCIL_TEST);
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// override aspects, disable culling
- theWorkspace->SetAspectFace (NoneCulling());
+ theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
theWorkspace->AspectFace (Standard_True);
// evaluate number of pair faces
}
// override material, cull back faces
- theWorkspace->SetAspectFace (FrontCulling());
+ theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
theWorkspace->AspectFace (Standard_True);
// enable all clip plane except the rendered one
aContext->ReleaseResource (aResId, Standard_True);
}
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void OpenGl_CappingAlgo::Init()
-{
- if (myIsInit)
- return;
-
- myRenderFilter = new OpenGl_CappingAlgoFilter();
- myNoneCulling.ChangeCullingMode() = TelCullNone;
- myNoneCulling.ChangeEdge() = 0;
-
- myFrontCulling.ChangeCullingMode() = TelCullBack;
- myFrontCulling.ChangeEdge() = 0;
-
- myIsInit = Standard_True;
-}
-
// =======================================================================
// function : CanRender
// purpose :
//! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
Standard_EXPORT static void RenderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
const Handle(Graphic3d_ClipPlane)& thePlane);
-
-private:
-
- //! Init algorithm.
- static void Init();
-
- //! @return capping algorithm rendering filter.
- static const Handle(OpenGl_RenderFilter)& CappingFilter() { return myRenderFilter; }
-
- //! @return face aspect for front face culling mode.
- static const OpenGl_AspectFace* FrontCulling() { return &myFrontCulling; }
-
- //! @return face aspect for none culling mode.
- static const OpenGl_AspectFace* NoneCulling() { return &myNoneCulling; }
-
-private:
-
- static Handle(OpenGl_RenderFilter) myRenderFilter;
- static OpenGl_AspectFace myFrontCulling;
- static OpenGl_AspectFace myNoneCulling;
- static Standard_Boolean myIsInit;
};
//! Graphical capping rendering algorithm filter.
0.0f, 0.0f,-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f
};
+
+ static const OpenGl_Matrix OpenGl_IdentityMatrix =
+ {
+ // mat[4][4]
+ { { 1.0f, 0.0f, 0.0f, 0.0f },
+ { 0.0f, 1.0f, 0.0f, 0.0f },
+ { 0.0f, 0.0f, 1.0f, 0.0f },
+ { 0.0f, 0.0f, 0.0f, 1.0f } }
+ };
+
}
IMPLEMENT_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
/*----------------------------------------------------------------------*/
-static const TEL_COLOUR myDefaultColor = {{ 1.F, 1.F, 1.F, 1.F }};
-static const CALL_DEF_CONTEXTTEXT myDefaultContextText =
+namespace
{
- 1, //IsDef
- 1, //IsSet
- "Courier", //Font
- 0.3F, //Space
- 1.F, //Expan
- { 1.F, 1.F, 1.F }, //Color
- (int)Aspect_TOST_NORMAL, //Style
- (int)Aspect_TODT_NORMAL, //DisplayType
- { 1.F, 1.F, 1.F }, //ColorSubTitle
- 0, //TextZoomable
- 0.F, //TextAngle
- (int)Font_FA_Regular //TextFontAspect
-};
-
-static Standard_Boolean TheLayerIsOpen = Standard_False;
-static OpenGl_LAYER_PROP TheLayerProp;
+ static const TEL_COLOUR myDefaultColor = {{ 1.F, 1.F, 1.F, 1.F }};
+ static const CALL_DEF_CONTEXTTEXT myDefaultContextText =
+ {
+ 1, //IsDef
+ 1, //IsSet
+ "Courier", //Font
+ 0.3F, //Space
+ 1.F, //Expan
+ { 1.F, 1.F, 1.F }, //Color
+ (int)Aspect_TOST_NORMAL, //Style
+ (int)Aspect_TODT_NORMAL, //DisplayType
+ { 1.F, 1.F, 1.F }, //ColorSubTitle
+ 0, //TextZoomable
+ 0.F, //TextAngle
+ (int)Font_FA_Regular //TextFontAspect
+ };
+
+ static Standard_Boolean TheLayerIsOpen = Standard_False;
+ static OpenGl_LAYER_PROP TheLayerProp;
+}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
-void OpenGl_Multiplymat3 (OpenGl_Matrix *c, const OpenGl_Matrix *a, const OpenGl_Matrix *b)
-{
- int row, col, i;
- for (row = 0; row < 4; row++) {
- for (col = 0; col < 4; col++) {
- float sum = 0.F;
- for (i = 0; i < 4; i++)
- sum += a->mat[row][i] * b->mat[i][col];
- c->mat[row][col] = sum;
- }
- }
-}
-
-/*----------------------------------------------------------------------*/
-
void OpenGl_Transposemat3 (OpenGl_Matrix *c, const OpenGl_Matrix *a)
{
Tint row, col;
DEFINE_STANDARD_ALLOC
};
-Standard_EXPORT void OpenGl_Multiplymat3 (OpenGl_Matrix *c, const OpenGl_Matrix *a, const OpenGl_Matrix *b);
Standard_EXPORT void OpenGl_Transposemat3 (OpenGl_Matrix *c, const OpenGl_Matrix *a);
-static const OpenGl_Matrix OpenGl_IdentityMatrix =
-{
- // mat[4][4]
- { { 1.0f, 0.0f, 0.0f, 0.0f },
- { 0.0f, 1.0f, 0.0f, 0.0f },
- { 0.0f, 0.0f, 1.0f, 0.0f },
- { 0.0f, 0.0f, 0.0f, 1.0f } }
-};
-
#endif //OpenGl_Matrix_Header
/*----------------------------------------------------------------------*/
-static const Tmatrix3 myDefaultMatrix = { { 1.F, 0.F, 0.F, 0.F }, { 0.F, 1.F, 0.F, 0.F }, { 0.F, 0.F, 1.F, 0.F }, { 0.F, 0.F, 0.F, 1.F } };
-static const OPENGL_ZCLIP myDefaultZClip = { { Standard_True, 0.F }, { Standard_True, 1.F } };
-
-static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } };
-static const TEL_TRANSFORM_PERSISTENCE myDefaultTransPers = { 0, 0.F, 0.F, 0.F };
-static const GLdouble THE_IDENTITY_MATRIX[4][4] =
+namespace
{
- {1.0, 0.0, 0.0, 0.0},
- {0.0, 1.0, 0.0, 0.0},
- {0.0, 0.0, 1.0, 0.0},
- {0.0, 0.0, 0.0, 1.0}
-};
+ static const Tmatrix3 myDefaultMatrix = { { 1.F, 0.F, 0.F, 0.F }, { 0.F, 1.F, 0.F, 0.F }, { 0.F, 0.F, 1.F, 0.F }, { 0.F, 0.F, 0.F, 1.F } };
+ static const OPENGL_ZCLIP myDefaultZClip = { { Standard_True, 0.F }, { Standard_True, 1.F } };
+
+ static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } };
+ static const TEL_TRANSFORM_PERSISTENCE myDefaultTransPers = { 0, 0.F, 0.F, 0.F };
+ static const GLdouble THE_IDENTITY_MATRIX[4][4] =
+ {
+ {1.0, 0.0, 0.0, 0.0},
+ {0.0, 1.0, 0.0, 0.0},
+ {0.0, 0.0, 1.0, 0.0},
+ {0.0, 0.0, 0.0, 1.0}
+ };
+}
/*----------------------------------------------------------------------*/
// =======================================================================
TCollection_AsciiString OpenGl_View::ShaderSource::Source() const
{
- static const TCollection_AsciiString aVersion = "#version 140";
+ const TCollection_AsciiString aVersion = "#version 140";
if (myPrefix.IsEmpty())
{
glEnable (GL_DEPTH_TEST);
return Standard_True;
-}
\ No newline at end of file
+}
namespace
{
- static const TEL_COLOUR THE_DEFAULT_BG_COLOR = { { 0.F, 0.F, 0.F, 1.F } };
#if defined(HAVE_EGL) || defined(__ANDROID__)
//
myOwnGContext (theGContext == 0),
myWidth (theCWindow.dx),
myHeight (theCWindow.dy),
- myBgColor (THE_DEFAULT_BG_COLOR),
mySwapInterval (theCaps->swapInterval)
{
myBgColor.rgb[0] = theCWindow.Background.r;
myBgColor.rgb[1] = theCWindow.Background.g;
myBgColor.rgb[2] = theCWindow.Background.b;
+ myBgColor.rgb[3] = 1.0f;
Standard_Boolean isCoreProfile = Standard_False;
#include <OpenGL/CGLRenderers.h>
#endif
-namespace
-{
- static const TEL_COLOUR THE_DEFAULT_BG_COLOR = { { 0.F, 0.F, 0.F, 1.F } };
-}
-
// =======================================================================
// function : OpenGl_Window
// purpose :
#endif
myWidth (theCWindow.dx),
myHeight (theCWindow.dy),
- myBgColor (THE_DEFAULT_BG_COLOR),
mySwapInterval (theCaps->swapInterval)
{
myBgColor.rgb[0] = theCWindow.Background.r;
myBgColor.rgb[1] = theCWindow.Background.g;
myBgColor.rgb[2] = theCWindow.Background.b;
+ myBgColor.rgb[3] = 1.0f;
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
EAGLContext* aGLContext = theGContext;
int v;
if (sscanf (anAaEnv, "%d", &v) > 0) myAntiAliasingMode = v;
}
+
+ myDefaultCappingAlgoFilter = new OpenGl_CappingAlgoFilter();
+ myNoneCulling.ChangeCullingMode() = TelCullNone;
+ myNoneCulling.ChangeEdge() = 0;
+ myFrontCulling.ChangeCullingMode() = TelCullBack;
+ myFrontCulling.ChangeEdge() = 0;
}
// =======================================================================
#include <OpenGl_RenderFilter.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_LineAttributes.hxx>
+#include <OpenGl_CappingAlgo.hxx>
#include <Handle_OpenGl_View.hxx>
#include <Handle_OpenGl_Texture.hxx>
//! @return true if clipping algorithm enabled
inline Standard_Boolean IsCullingEnabled() const { return myIsCullingEnabled; }
+ //! Returns capping algorithm rendering filter.
+ const Handle(OpenGl_CappingAlgoFilter)& DefaultCappingAlgoFilter() const
+ {
+ return myDefaultCappingAlgoFilter;
+ }
+
+ //! Returns face aspect for none culling mode.
+ const OpenGl_AspectFace& NoneCulling() const
+ {
+ return myNoneCulling;
+ }
+
+ //! Returns face aspect for front face culling mode.
+ const OpenGl_AspectFace& FrontCulling() const
+ {
+ return myFrontCulling;
+ }
+
protected:
//! Copy content of Back buffer to the Front buffer
unsigned int myFrameCounter; //!< redraw counter, for debugging
+ Handle(OpenGl_CappingAlgoFilter) myDefaultCappingAlgoFilter;
+ OpenGl_AspectFace myNoneCulling;
+ OpenGl_AspectFace myFrontCulling;
+
protected: //! @name fields related to status
Handle(OpenGl_RenderFilter) myRenderFilter;