Update ViewerTest and VoxelDemo to not use UserDraw callbacks.
OpenGl_View::blitBuffers() - set 0 GLSL program after blit
to avoid side effects on code that does not use shaders.
Drop interfaces Aspect_GraphicCallbackProc, Graphic3d_CUserDraw,
Graphic3d_Group::UserDraw(), OpenGl_GraphicDriver::UserDrawCallback().
V3d_View::SetWindow() - remove optional arguments initializing redraw callback.
OpenGl_View, declare following methods as virtual for inheritance:
redraw(), redrawImmediate(), render(), renderScene(), drawBackground(), renderStructs().
VocelClient_VisDrawer - do not include removed header
#include "Voxel_VisData.h"
#include <Graphic3d_BndBox4f.hxx>
-#include <OpenGl_GraphicDriver.hxx>
+#include <Voxel_Prs.hxx>
+
+//! Voxel presentation using UserDraw.
+class VoxelClient_PrsGl : public Voxel_Prs
+{
+
+public:
+
+ //! Empty constructor.
+ VoxelClient_PrsGl() {}
+
+protected:
+
+ //! Override compute to create UserDraw element.
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode) Standard_OVERRIDE;
+
+public:
+
+ DEFINE_STANDARD_RTTI(VoxelClient_PrsGl, Voxel_Prs)
+
+};
+
+DEFINE_STANDARD_HANDLE(VoxelClient_PrsGl, Voxel_Prs)
class VoxelClient_VisDrawer
{
public:
- Standard_EXPORT static void Init (Handle(OpenGl_GraphicDriver)& theDriver);
-
Standard_EXPORT VoxelClient_VisDrawer(Voxel_VisData* theData);
Standard_EXPORT virtual ~VoxelClient_VisDrawer();
myDisplayedZMin = -DBL_MAX;
myDisplayedZMax = DBL_MAX;
- VoxelClient_VisDrawer::Init(myViewer->getGraphicDriver());
-
resize( 450, 600 );
myViewer->getIC()->SetAutoActivateSelection (Standard_False);
{
if (myVoxels.IsNull())
{
- myVoxels = new Voxel_Prs;
+ myVoxels = new VoxelClient_PrsGl();
myVoxels->SetDisplayMode(Voxel_VDM_POINTS);
myVoxels->SetColor(Quantity_NOC_WHITE);
myVoxels->SetPointSize(1.0);
AIS_ListIteratorOfListOfInteractive itri(displayed);
for (; itri.More(); itri.Next())
{
- if (itri.Value()->DynamicType() == STANDARD_TYPE(Voxel_Prs))
+ Handle(Voxel_Prs) prs = Handle(Voxel_Prs)::DownCast(itri.Value());
+ if (!prs.IsNull())
{
- Handle(Voxel_Prs) prs = Handle(Voxel_Prs)::DownCast(itri.Value());
prs->SetDegenerateMode(on);
myView->Redraw();
break;
#include <gce_MakePln.hxx>
#include <Quantity_Color.hxx>
#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_CUserDraw.hxx>
+#include <Prs3d_Root.hxx>
#include <InterfaceGraphic_telem.hxx>
#include <OpenGl_Element.hxx>
//purpose : visdrawer element create callback, adds an element to graphic
// driver's structure
//=======================================================================
-
-static OpenGl_Element* VisDrawerCallBack (const Graphic3d_CUserDraw* theUserDraw)
+void VoxelClient_PrsGl::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
{
- if (theUserDraw == 0)
- return 0;
-
- // Retrieve the user structure
- Voxel_VisData* aUserData = (Voxel_VisData*) (theUserDraw->Data);
-
- if (aUserData == 0)
- return 0;
-
- VoxelClient_VisDrawer::VisElement *aElem =
- new VoxelClient_VisDrawer::VisElement (aUserData);
-
- if (theUserDraw->Bounds != 0)
- aElem->EvaluateBounds (*(theUserDraw->Bounds));
-
- return aElem;
-}
+ if (myVisData == NULL)
+ {
+ return;
+ }
+ Voxel_Prs::Compute (thePrsMgr, thePrs, theMode);
-/**************************************************************************/
-void VoxelClient_VisDrawer::Init (Handle(OpenGl_GraphicDriver)& theDriver)
-{
- static Standard_Boolean isInitializeded(Standard_False);
+ Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (Prs3d_Root::CurrentGroup (thePrs));
+ VoxelClient_VisDrawer::VisElement* anElem = new VoxelClient_VisDrawer::VisElement ((Voxel_VisData* )myVisData);
+ aGroup->AddElement (anElem);
- if (!isInitializeded)
- {
- isInitializeded = Standard_True;
- theDriver->UserDrawCallback() = VisDrawerCallBack;
- }
+ Graphic3d_BndBox4f aMinMax;
+ anElem->EvaluateBounds (aMinMax);
+ aGroup->SetMinMaxValues (aMinMax.CornerMin().x(), aMinMax.CornerMin().y(), aMinMax.CornerMin().z(),
+ aMinMax.CornerMax().x(), aMinMax.CornerMax().y(), aMinMax.CornerMax().z());
+ thePrsMgr->StructureManager()->Update (thePrsMgr->StructureManager()->UpdateMode());
}
/**************************************************************************/
+++ /dev/null
-// Copyright (c) 1999-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 _Aspect_GraphicCallbackProc_HeaderFile
-#define _Aspect_GraphicCallbackProc_HeaderFile
-
-// To manage client post display
-
-#include <Aspect_Display.hxx>
-#include <Aspect_Drawable.hxx>
-#include <Aspect_RenderingContext.hxx>
-#include <Standard_Handle.hxx>
-#include <Standard_Transient.hxx>
-
-// The flags below provide additional information to define the moment when
-// callback was invoked in redraw procedure. These flags are bitwise OR'ed
-// with the "reason" value of callback:
-// 1) OCC_PRE_REDRAW - callback was invoked before redrawing underlayer
-// ( at the beginning of redraw procedure );
-// 2) OCC_PRE_OVERLAY - callback was invoked before redrawing overlayer;
-// Otherwise, if no flags added to the "reason" value, the callback was
-// invoked at the end of redraw ( after the overlayer is redrawn )
-#define OCC_PRE_REDRAW 0x4000
-#define OCC_PRE_OVERLAY 0x8000
-
-// mask for all additional callbacks that invoked in process of redrawing
-#define OCC_REDRAW_ADDITIONAL_CALLBACKS ( OCC_PRE_REDRAW | OCC_PRE_OVERLAY )
-
-typedef struct
-{
- int reason;
- int wsID;
- int viewID;
- bool IsCoreProfile;
- Handle(Standard_Transient) glContext;
-} Aspect_GraphicCallbackStruct;
-
-// Prototype for callback function to perform custom drawing within the same window and GL context.
-typedef int (*Aspect_GraphicCallbackProc) (Aspect_Drawable theWindowID,
- void* theUserData,
- Aspect_GraphicCallbackStruct* theCallData);
-
-#endif /* _Aspect_GraphicCallbackProc_HeaderFile */
Aspect_GradientBackground.cxx
Aspect_GradientBackground.hxx
Aspect_GradientFillMethod.hxx
-Aspect_GraphicCallbackProc.hxx
Aspect_GraphicDeviceDefinitionError.hxx
Aspect_Grid.cxx
Aspect_Grid.hxx
Graphic3d_CStructure.hxx
Graphic3d_CStructurePtr.hxx
Graphic3d_CTexture.hxx
-Graphic3d_CUserDraw.hxx
Graphic3d_CView.cxx
Graphic3d_CView.hxx
Graphic3d_CycleError.hxx
+++ /dev/null
-// Copyright (c) 1999-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.
-
-/*============================================================================*/
-/*==== Titre: Graphic3d_CUserDraw.hxx */
-/*==== Role : The header file of primitive type "CUserDraw" from Graphic3d */
-/*==== */
-/*==== Implementation: This is a primitive type implemented with typedef */
-/*============================================================================*/
-
-#ifndef _Graphic3d_CUserDraw_HeaderFile
-#define _Graphic3d_CUserDraw_HeaderFile
-
-#include <InterfaceGraphic_Graphic3d.hxx>
-typedef CALL_DEF_USERDRAW Graphic3d_CUserDraw;
-
-#endif /*Graphic3d_CUserDraw_HeaderFile*/
#ifndef _Graphic3d_CView_HeaderFile
#define _Graphic3d_CView_HeaderFile
-#include <Aspect_GraphicCallbackProc.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Aspect_RenderingContext.hxx>
virtual Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) = 0;
//! Creates and maps rendering window to the view.
- //! @param theView [in] the view to associate with the window.
//! @param theWindow [in] the window.
//! @param theContext [in] the rendering context. If NULL the context will be created internally.
- //! @param theDisplayCB [in] the display callback function. If is not a NULL value, then the callback will be
- //! invoked at the end of the OCC graphic traversal and just before the swap of buffers.
- //! @param theClientData [in] the client data for the callback.
virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
- const Aspect_RenderingContext theContext = NULL,
- const Aspect_GraphicCallbackProc& theDisplayCB = NULL,
- const Standard_Address theClientData = NULL) = 0;
+ const Aspect_RenderingContext theContext = NULL) = 0;
//! Returns the window associated to the view.
virtual Handle(Aspect_Window) Window() const = 0;
AddPrimitiveArray (aPoints, theToEvalMinMax);
}
-// =======================================================================
-// function : UserDraw
-// purpose :
-// =======================================================================
-void Graphic3d_Group::UserDraw (const Standard_Address /*theObject*/,
- const Standard_Boolean /*theToEvalMinMax*/,
- const Standard_Boolean theContainsFacet)
-{
- if (IsDeleted())
- {
- return;
- }
-
- // Without this modification, the group assumes the primitive contains
- // no polygons and does not require the Z-buffer for display.
- if (!MyContainsFacet && theContainsFacet)
- {
- myStructure->GroupsWithFacet (1);
- MyContainsFacet = Standard_True;
- }
-
- Update();
-}
-
// =======================================================================
// function : Text
// purpose :
//! Creates a primitive array with single marker using AddPrimitiveArray().
Standard_EXPORT void Marker (const Graphic3d_Vertex& thePoint, const Standard_Boolean theToEvalMinMax = Standard_True);
- //! Creates a UserDraw primitive using obsolete API.
- Standard_EXPORT virtual void UserDraw (const Standard_Address theObject, const Standard_Boolean theToEvalMinMax = Standard_True, const Standard_Boolean theContainsFacet = Standard_False);
-
//! sets the stencil test to theIsEnabled state;
Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) = 0;
CALL_DEF_POINT Point;
} CALL_DEF_TRANSFORM_PERSISTENCE;
-/* USERDRAW DATA */
-
-typedef struct {
-
- void* Data;
- Graphic3d_BndBox4f* Bounds;
-
-} CALL_DEF_USERDRAW;
-
#endif /* InterfaceGraphic_Graphic3dHeader */
#endif
myCaps (new OpenGl_Caps()),
myMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator()),
- myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator()),
- myUserDrawCallback (NULL)
+ myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator())
{
#if !defined(_WIN32) && !defined(__ANDROID__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
if (myDisplayConnection.IsNull())
return aCtx.IsNull() ? 0 : Max (aCtx->MaxClipPlanes() - 2, 0);
}
-// =======================================================================
-// function : UserDrawCallback
-// purpose :
-// =======================================================================
-OpenGl_GraphicDriver::OpenGl_UserDrawCallback_t& OpenGl_GraphicDriver::UserDrawCallback()
-{
- return myUserDrawCallback;
-}
-
// =======================================================================
// function : DefaultTextHeight
// purpose :
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
-#include <Graphic3d_CUserDraw.hxx>
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_TypeOfComposition.hxx>
#include <Graphic3d_ExportFormat.hxx>
Standard_EXPORT Standard_Boolean MemoryInfo (Standard_Size& theFreeBytes,
TCollection_AsciiString& theInfo) const;
- //! UserDraw function prototype
- typedef OpenGl_Element* (*OpenGl_UserDrawCallback_t )(const CALL_DEF_USERDRAW* );
-
- //! Method to setup UserDraw callback
- Standard_EXPORT OpenGl_UserDrawCallback_t& UserDrawCallback();
-
public:
//! Method to retrieve valid GL context.
Handle(OpenGl_Caps) myCaps;
NCollection_Map<Handle(OpenGl_View)> myMapOfView;
NCollection_DataMap<Standard_Integer, OpenGl_Structure*> myMapOfStructure;
- OpenGl_UserDrawCallback_t myUserDrawCallback;
public:
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
-#include <Graphic3d_CUserDraw.hxx>
#include <Graphic3d_GroupDefinitionError.hxx>
}
-// =======================================================================
-// function : UserDraw
-// purpose :
-// =======================================================================
-void OpenGl_Group::UserDraw (const Standard_Address theObject,
- const Standard_Boolean theToEvalMinMax,
- const Standard_Boolean theContainsFacet)
-{
- if (IsDeleted())
- {
- return;
- }
-
- OpenGl_Structure* aStruct = GlStruct();
- if (aStruct->GlDriver()->UserDrawCallback() == NULL)
- {
- return;
- }
-
- Graphic3d_CUserDraw aUserDraw;
- aUserDraw.Data = theObject;
- aUserDraw.Bounds = theToEvalMinMax ? &myBounds : NULL;
- OpenGl_Element* aUserDrawElem = aStruct->GlDriver()->UserDrawCallback()(&aUserDraw);
- if (aUserDrawElem != NULL)
- {
- AddElement (aUserDrawElem);
- }
- Graphic3d_Group::UserDraw (theObject, theToEvalMinMax, theContainsFacet);
-}
-
// =======================================================================
// function : SetFlippingOptions
// purpose :
const Graphic3d_VerticalTextAlignment theVTA,
const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
- //! Add UserDraw element using obsolete API
- Standard_EXPORT virtual void UserDraw (const Standard_Address theObject,
- const Standard_Boolean theToEvalMinMax,
- const Standard_Boolean theContainsFacet);
-
//! Add flipping element
Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
const gp_Ax2& theRefPlane);
#include <OpenGl_View.hxx>
-#include <Aspect_GraphicCallbackProc.hxx>
#include <Aspect_RenderingContext.hxx>
#include <Aspect_Window.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
myMainSceneFbos[1] = new OpenGl_FrameBuffer();
myImmediateSceneFbos[0] = new OpenGl_FrameBuffer();
myImmediateSceneFbos[1] = new OpenGl_FrameBuffer();
-
- myDisplayCallback.Func = NULL;
- myDisplayCallback.Data = NULL;
}
// =======================================================================
// purpose :
// =======================================================================
void OpenGl_View::SetWindow (const Handle(Aspect_Window)& theWindow,
- const Aspect_RenderingContext theContext,
- const Aspect_GraphicCallbackProc& theDisplayCB,
- const Standard_Address theClientData)
+ const Aspect_RenderingContext theContext)
{
myWindow = myDriver->CreateRenderWindow (theWindow, theContext);
Standard_ASSERT_RAISE (!myWindow.IsNull(),
"OpenGl_View::SetWindow, "
"Failed to create OpenGl window.");
- myDisplayCallback.Func = theDisplayCB;
- myDisplayCallback.Data = theClientData;
-
myWorkspace = new OpenGl_Workspace (this, myWindow);
myWorldViewProjState.Reset();
myToUpdateEnvironmentMap = Standard_True;
Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) Standard_OVERRIDE;
//! Creates and maps rendering window to the view.
- //! @param theView [in] the view to associate with the window.
//! @param theWindow [in] the window.
//! @param theContext [in] the rendering context. If NULL the context will be created internally.
- //! @param theDisplayCB [in] the display callback function. If is not a NULL value, then the callback will be
- //! invoked at the end of the OCC graphic traversal and just before the swap of buffers.
- //! @param theClientData [in] the client data for the callback.
- Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
- const Aspect_RenderingContext theContext,
- const Aspect_GraphicCallbackProc& theDisplayCB,
- const Standard_Address theClientData) Standard_OVERRIDE;
+ Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
+ const Aspect_RenderingContext theContext) Standard_OVERRIDE;
//! Returns window associated with the view.
virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE { return myWindow->PlatformWindow(); }
void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
- void DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
-
//! Returns list of OpenGL Z-layers.
const OpenGl_LayerList& LayerList() const { return myZLayers; }
//! Initializes OpenGl resource for environment texture.
void initTextureEnv (const Handle(OpenGl_Context)& theContext);
-protected: //! @name Internal redrawing sub-routines
+protected: //! @name low-level redrawing sub-routines
//! Redraws view for the given monographic camera projection, or left/right eye.
- void redraw (const Graphic3d_Camera::Projection theProjection, OpenGl_FrameBuffer* theReadDrawFbo);
+ Standard_EXPORT virtual void redraw (const Graphic3d_Camera::Projection theProjection,
+ OpenGl_FrameBuffer* theReadDrawFbo);
//! Redraws view for the given monographic camera projection, or left/right eye.
//!
//!
//! @return false if immediate structures has been rendered directly into FrontBuffer
//! and Buffer Swap should not be called.
- bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
- OpenGl_FrameBuffer* theReadFbo,
- OpenGl_FrameBuffer* theDrawFbo,
- const Standard_Boolean theIsPartialUpdate = Standard_False);
-
- //! Copy content of Back buffer to the Front buffer.
- void copyBackToFront();
-
- //! Initialize blit quad.
- OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
+ Standard_EXPORT virtual bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
+ OpenGl_FrameBuffer* theReadFbo,
+ OpenGl_FrameBuffer* theDrawFbo,
+ const Standard_Boolean theIsPartialUpdate = Standard_False);
//! Blit image from/to specified buffers.
- bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
- OpenGl_FrameBuffer* theDrawFbo,
- const Standard_Boolean theToFlip = Standard_False);
+ Standard_EXPORT bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
+ OpenGl_FrameBuffer* theDrawFbo,
+ const Standard_Boolean theToFlip = Standard_False);
//! Setup default FBO.
- void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
-
- //! Blend together views pair into stereo image.
- void drawStereoPair();
-
- //! Invokes display callback.
- void displayCallback (const Standard_Integer theReason);
+ Standard_EXPORT void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
//! @param theProjection [in] the projection that should be used for rendering.
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
- void render (Graphic3d_Camera::Projection theProjection,
- OpenGl_FrameBuffer* theReadDrawFbo,
- const Standard_Boolean theToDrawImmediate);
+ Standard_EXPORT virtual void render (Graphic3d_Camera::Projection theProjection,
+ OpenGl_FrameBuffer* theReadDrawFbo,
+ const Standard_Boolean theToDrawImmediate);
//! Renders the graphical scene.
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
- void renderScene (OpenGl_FrameBuffer* theReadDrawFbo,
- const Standard_Boolean theToDrawImmediate);
+ Standard_EXPORT virtual void renderScene (OpenGl_FrameBuffer* theReadDrawFbo,
+ const Standard_Boolean theToDrawImmediate);
+
+ //! Draw background (gradient / image)
+ Standard_EXPORT virtual void drawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
//! Render set of structures presented in the view.
//! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
//! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
- void renderStructs (OpenGl_FrameBuffer* theReadDrawFbo,
- const Standard_Boolean theToDrawImmediate);
+ Standard_EXPORT virtual void renderStructs (OpenGl_FrameBuffer* theReadDrawFbo,
+ const Standard_Boolean theToDrawImmediate);
//! Renders trihedron.
void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
const Standard_Integer theNewPriority) Standard_OVERRIDE;
+private:
+
+ //! Copy content of Back buffer to the Front buffer.
+ void copyBackToFront();
+
+ //! Initialize blit quad.
+ OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
+
+ //! Blend together views pair into stereo image.
+ void drawStereoPair();
+
protected:
OpenGl_GraphicDriver* myDriver;
Handle(OpenGl_Texture) myTextureEnv;
- struct
- {
- Aspect_GraphicCallbackProc Func;
- Standard_Address Data;
- } myDisplayCallback;
-
protected: //! @name Rendering properties
//! Two framebuffers (left and right views) store cached main presentation
#endif
//=======================================================================
-//function : DrawBackground
+//function : drawBackground
//purpose :
//=======================================================================
-void OpenGl_View::DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
+void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
{
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// Render background
if (!theToDrawImmediate)
{
- DrawBackground (myWorkspace);
+ drawBackground (myWorkspace);
}
#if !defined(GL_ES_VERSION_2_0)
// Resetting GL parameters according to the default aspects
// in order to synchronize GL state with the graphic driver state
// before drawing auxiliary stuff (trihedrons, overlayer)
- // and invoking optional callbacks
myWorkspace->ResetAppliedAspect();
aContext->ChangeClipping().RemoveAll();
}
}
- // ==============================================================
- // Step 5: Invoke callback after redraw
- // ==============================================================
-
- displayCallback (0);
-
// ==============================================================
// Step 6: Keep shader manager informed about last View
// ==============================================================
aVerts->UnbindVertexAttrib (aCtx, Graphic3d_TOA_POS);
theReadFbo->DepthStencilTexture()->Unbind (aCtx, GL_TEXTURE0 + 1);
theReadFbo->ColorTexture() ->Unbind (aCtx, GL_TEXTURE0 + 0);
+ aCtx->BindProgram (NULL);
}
else
{
#endif
myIsImmediateDrawn = Standard_False;
}
-
-// =======================================================================
-// function : displayCallback
-// purpose :
-// =======================================================================
-void OpenGl_View::displayCallback (const Standard_Integer theReason)
-{
- if (myDisplayCallback.Func == NULL)
- {
- return;
- }
-
- Aspect_GraphicCallbackStruct aCallData;
- aCallData.reason = theReason;
- aCallData.glContext = myWorkspace->GetGlContext();
- aCallData.wsID = -1;
- aCallData.viewID = myId;
- aCallData.IsCoreProfile = (myWorkspace->GetGlContext()->core11 == NULL);
- myDisplayCallback.Func (myWindow->PlatformWindow()->NativeHandle(), myDisplayCallback.Data, &aCallData);
-}
//function : SetWindow
//purpose :
//=============================================================================
-void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
- const Aspect_RenderingContext theContext,
- const Aspect_GraphicCallbackProc& theDisplayCB,
- const Standard_Address theClientData)
+void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
+ const Aspect_RenderingContext theContext)
{
if (myView->IsRemoved())
{
// method V3d_View::SetWindow() should assign the field MyWindow before calling Redraw()
MyWindow = theWindow;
- myView->SetWindow (theWindow, theContext, theDisplayCB, theClientData);
+ myView->SetWindow (theWindow, theContext);
MyViewer->SetViewOn (this);
SetRatio();
Redraw();
#include <Aspect_FillMethod.hxx>
#include <Aspect_GradientBackground.hxx>
#include <Aspect_GradientFillMethod.hxx>
-#include <Aspect_GraphicCallbackProc.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Aspect_RenderingContext.hxx>
//! If <aContext> is not NULL the graphic context is used
//! to draw something in this view.
//! Otherwise an internal graphic context is created.
- //! If <aDisplayCB> is not NULL then a user display CB is
- //! call at the end of the OCC graphic traversal and just
- //! before the swap of buffers. The <aClientData> is pass
- //! to this call back.
- //! Warning! raises MultiplyDefined from Standard
- //! if the view is already activated in a window.
//! Warning: The view is centered and resized to preserve
//! the height/width ratio of the window.
Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& theWindow,
- const Aspect_RenderingContext theContext = NULL,
- const Aspect_GraphicCallbackProc& theDisplayCB = NULL,
- const Standard_Address theClientData = NULL);
+ const Aspect_RenderingContext theContext = NULL);
Standard_EXPORT void SetMagnify (const Handle(Aspect_Window)& theWindow,
const Handle(V3d_View)& thePreviousView,
Handle(VUserDrawObj) myIObj;
public:
- Element (const Handle(VUserDrawObj)& theIObj,
- Graphic3d_BndBox4f* theBounds)
- : myIObj( theIObj )
- {
- if (!myIObj.IsNull())
- myIObj->GetBounds(theBounds);
- }
+ Element (const Handle(VUserDrawObj)& theIObj) : myIObj (theIObj) {}
- virtual ~Element ()
- {
- }
+ virtual ~Element() {}
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
// Called by VUserDrawElement
void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
- void GetBounds(Graphic3d_BndBox4f* theBounds);
+private:
GLfloat myCoords[6];
-
friend class Element;
};
-void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
- const Handle(Prs3d_Presentation)& thePresentation,
+void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
+ const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer /*theMode*/)
{
- thePresentation->Clear();
-
- Handle(Graphic3d_Group) aGrp = Prs3d_Root::CurrentGroup(thePresentation);
- aGrp->UserDraw(this, Standard_True, Standard_True);
+ thePrs->Clear();
+
+ Graphic3d_Vec4 aBndMin (myCoords[0], myCoords[1], myCoords[2], 1.0f);
+ Graphic3d_Vec4 aBndMax (myCoords[3], myCoords[4], myCoords[5], 1.0f);
+ Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (thePrs->NewGroup());
+ aGroup->SetMinMaxValues (aBndMin.x(), aBndMin.y(), aBndMin.z(),
+ aBndMax.x(), aBndMax.y(), aBndMax.z());
+ VUserDrawObj::Element* anElem = new VUserDrawObj::Element (this);
+ aGroup->AddElement(anElem);
+
+ // invalidate bounding box of the scene
+ thePrsMgr->StructureManager()->Update (thePrsMgr->StructureManager()->UpdateMode());
}
void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
theSelection->Add(aSensitive);
}
-void VUserDrawObj::GetBounds(Graphic3d_BndBox4f* theBounds)
-{
- if (theBounds)
- {
- Graphic3d_Vec4 aMinPt (myCoords[0], myCoords[1], myCoords[2], 1.0f);
- Graphic3d_Vec4 aMaxPt (myCoords[3], myCoords[4], myCoords[5], 1.0f);
- if (!theBounds->IsValid())
- {
- theBounds->Combine (Graphic3d_BndBox4f (aMinPt, aMaxPt));
- }
- else
- {
- theBounds->CornerMin() = aMinPt;
- theBounds->CornerMax() = aMaxPt;
- }
- }
-}
-
void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
{
+ // this sample does not use GLSL programs - make sure it is disabled
+ Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext();
+ aCtx->BindProgram (NULL);
+
// To test linking against OpenGl_Workspace and all aspect classes
const OpenGl_AspectLine* aLA = theWorkspace->AspectLine(0);
const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker(0);
TEL_COLOUR aColor = theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT ?
*(theWorkspace->HighlightColor) : aLA->Color();
- // To test OpenGl_Window
- //Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext();
-
// Finally draw something to make sure UserDraw really works
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
} // end of anonymous namespace
-OpenGl_Element* VUserDrawCallback(const CALL_DEF_USERDRAW * theUserDraw)
-{
- Handle(VUserDrawObj) anIObj = (VUserDrawObj*)theUserDraw->Data;
- if (anIObj.IsNull())
- {
- std::cout << "VUserDrawCallback error: null object passed, the custom scene element will not be rendered" << std::endl;
- }
-
- return new VUserDrawObj::Element(anIObj, theUserDraw->Bounds);
-}
-
static Standard_Integer VUserDraw (Draw_Interpretor& di,
Standard_Integer argc,
const char ** argv)
TCollection_AsciiString aName (argv[1]);
VDisplayAISObject(aName, Handle(AIS_InteractiveObject)());
- // register the custom element factory function
- aDriver->UserDrawCallback() = VUserDrawCallback;
-
Handle(VUserDrawObj) anIObj = new VUserDrawObj();
VDisplayAISObject(aName, anIObj);
}
}
- G->UserDraw(myVisData);
+ ///Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (G);
+ ///aGroup->AddElement (myVisData);
}
void Voxel_Prs::ComputeSelection(const Handle(SelectMgr_Selection)& /*theSelection*/,
-private:
+protected:
Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);