Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions include/Inventor/SoRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,24 @@

class SbViewportRegion;
class SoEvent;
class SoAction;
#if COIN_HAVE_LEGACY_GL_RENDERER
class SoGLRenderAction;
#endif
class SoAudioRenderAction;
class SoNode;
class SoCamera;
class SoIRRenderAction;
class SoRenderBackend;
class SoNodeSensor;
class SoOneShotSensor;
class SoSensor;
class SoRenderManagerP;

typedef void SoRenderManagerRenderCB(void * userdata, class SoRenderManager * mgr);
typedef void SoRenderManagerStageCB(void * userdata,
class SoRenderManager * mgr,
SoAction * action);

class COIN_DLL_API SoRenderManager {
public:
Expand Down Expand Up @@ -101,6 +107,16 @@ class COIN_DLL_API SoRenderManager {
SHADED_HIDDEN_LINES
};

enum LightingMode {
LIT,
UNLIT
};

enum RenderLayer {
RENDER_LAYER_BACKGROUND,
RENDER_LAYER_FOREGROUND
};

enum StereoMode {
MONO,
ANAGLYPH,
Expand Down Expand Up @@ -147,6 +163,16 @@ class COIN_DLL_API SoRenderManager {
void setCamera(SoCamera * camera);
SoCamera * getCamera(void) const;

/*!\brief Declare that the main scene graph contains the configured camera.

The retained renderer uses this to preserve scene-graph camera ordering:
state before the camera node starts from identity, just as in legacy
traversal. The default is FALSE, meaning the configured camera is
external to the scene graph.
*/
void setCameraInSceneGraph(SbBool inSceneGraph);
SbBool isCameraInSceneGraph(void) const;

void setAutoClipping(AutoClippingStrategy autoclipping);
AutoClippingStrategy getAutoClipping(void) const;
void setNearPlaneValue(float value);
Expand All @@ -157,6 +183,8 @@ class COIN_DLL_API SoRenderManager {
SbBool isDoubleBuffer(void) const;
void setRenderMode(const RenderMode mode);
RenderMode getRenderMode(void) const;
void setLightingMode(const LightingMode mode);
LightingMode getLightingMode(void) const;
void setStereoMode(const StereoMode mode);
StereoMode getStereoMode(void) const;
void setStereoOffset(const float offset);
Expand Down Expand Up @@ -199,6 +227,20 @@ class COIN_DLL_API SoRenderManager {
#endif
void setRenderPipeline(RenderPipeline pipeline);
RenderPipeline getRenderPipeline(void) const;

SoRenderBackend * getRenderBackend(void) const;
SoIRRenderAction * getIRRenderAction(void) const;

void invalidateSharedGLState(void);
void releaseRenderBackendResources(void);
void discardRenderBackendResources(void);

void setRenderLayerRoot(RenderLayer layer, SoNode * root);
SoNode * getRenderLayerRoot(RenderLayer layer) const;

void invalidateDrawList(void);
void invalidateScene(void);
void invalidateForeground(void);
void setAudioRenderAction(SoAudioRenderAction * const action);
SoAudioRenderAction * getAudioRenderAction(void) const;

Expand All @@ -212,6 +254,9 @@ class COIN_DLL_API SoRenderManager {
void addPostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
void removePostRenderCallback(SoRenderManagerRenderCB * cb, void * data);

void addAfterMainSceneCallback(SoRenderManagerStageCB * cb, void * data);
void removeAfterMainSceneCallback(SoRenderManagerStageCB * cb, void * data);

void reinitialize(void);

protected:
Expand Down
66 changes: 66 additions & 0 deletions include/Inventor/actions/SoIRRenderAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class COIN_DLL_API SoIRRenderAction : public SoAction {
SO_ACTION_HEADER(SoIRRenderAction);

public:
/*! Camera state policy used when starting a root traversal. */
enum class CameraPolicy {
//! Initialize the traversal from the camera configured on this action.
USE_CONFIGURED_CAMERA,
//! Start with the current state and let a camera node in the root set it.
CAMERA_IN_ROOT
};

/*!
\class SoIRRenderAction::PrimitiveCollector
\brief Callback interface for receiving primitives generated during traversal.
Expand Down Expand Up @@ -68,6 +76,8 @@ class COIN_DLL_API SoIRRenderAction : public SoAction {

void setCamera(SoCamera * camera) { this->camera = camera; }
SoCamera * getCamera(void) const { return this->camera; }
void setCameraPolicy(CameraPolicy policy) { this->cameraPolicy = policy; }
CameraPolicy getCameraPolicy(void) const { return this->cameraPolicy; }
void setDevicePixelRatio(float dpr) { this->devicePixelRatio = dpr; }
float getDevicePixelRatio(void) const { return this->devicePixelRatio; }

Expand All @@ -76,6 +86,37 @@ class COIN_DLL_API SoIRRenderAction : public SoAction {
virtual void apply(SoPath * path) override;
virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE) override;

//! Append a root without clearing the current retained frame.
void traverseAdditionalRoot(
SoNode * root,
CameraPolicy policy = CameraPolicy::USE_CONFIGURED_CAMERA);

//! Traverse a path without clearing the retained frame.
void traverseAdditionalPath(SoPath * path);
//! Traverse a path using a copied replay context.
void traverseAdditionalPath(SoPath * path,
const SoIRRenderContext & context);
//! Traverse a delayed subtree using a copied replay context.
void traverseAdditionalSubtree(SoNode * root,
const SoIRRenderContext & context);

//! Return the context currently forced for replayed commands.
const SoIRRenderContext * getRenderContextOverride() const
{
return this->hasRenderContextOverride
? &this->renderContextOverride : nullptr;
}

void beginAfterMainStage();
void endAfterMainStage();
bool isAfterMainStage() const { return this->afterMainStageDepth != 0; }
SoRenderStage getRenderStage() const { return this->renderStage; }
void setRenderStage(SoRenderStage stage) { this->renderStage = stage; }
void applyRenderStage(SoRenderCommand & command);

//! Append a command and resolve action-owned replay state consistently.
void addCommand(const SoRenderCommand & command);

//! Associate the commands emitted by a shape with its current scene path.
void storeCommandPath(int commandIndex, const SoPath * path);
//! Return the retained scene path for a command, or NULL when unavailable.
Expand Down Expand Up @@ -109,13 +150,38 @@ class COIN_DLL_API SoIRRenderAction : public SoAction {
virtual void endTraversal(SoNode * node) override;

private:
void initializeCameraState(CameraPolicy policy);
void resetFrameResources();
void traverseAdditionalPathInternal(
SoPath * path, const SoIRRenderContext * context);
void traverseAdditionalSubtreeInternal(
SoNode * root, const SoIRRenderContext * context);

SbViewportRegion vpRegion;
SoCamera * camera = nullptr;
CameraPolicy cameraPolicy = CameraPolicy::USE_CONFIGURED_CAMERA;
float devicePixelRatio = 1.0f;
SoDrawList drawlist;
SoIRRenderActionP * pimpl;
unsigned int afterMainStageDepth = 0;
bool afterMainDepthClearPending = false;
SoRenderStage renderStage = SoRenderStage::Main;
SoIRRenderContext renderContextOverride;
bool hasRenderContextOverride = false;
};

/*! \brief RAII guard for an action-local manager render stage. */
class COIN_DLL_API SoIRRenderStageScope {
public:
SoIRRenderStageScope(SoIRRenderAction & action, SoRenderStage stage);
~SoIRRenderStageScope();

SoIRRenderStageScope(const SoIRRenderStageScope &) = delete;
SoIRRenderStageScope & operator=(const SoIRRenderStageScope &) = delete;

private:
SoIRRenderAction * action;
SoRenderStage previousStage;
};

#endif // COIN_SOIRRENDERACTION_H
1 change: 1 addition & 0 deletions include/Inventor/nodes/Makefile.am

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions include/Inventor/nodes/SoNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include <Inventor/nodes/SoGroup.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoAnnotation.h>
#include <Inventor/nodes/SoRenderLayerGroup.h>
#include <Inventor/nodes/SoSelection.h>
#if COIN_HAVE_LEGACY_GL_RENDERER
#include <Inventor/nodes/SoExtSelection.h>
Expand Down
85 changes: 85 additions & 0 deletions include/Inventor/nodes/SoRenderLayerGroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef COIN_SORENDERLAYERGROUP_H
#define COIN_SORENDERLAYERGROUP_H

/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/

#define COIN_HAVE_RENDER_LAYER_GROUP 1

#include <Inventor/fields/SoSFBool.h>
#include <Inventor/fields/SoSFEnum.h>
#include <Inventor/fields/SoSFVec4f.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSubNode.h>

class COIN_DLL_API SoRenderLayerGroup : public SoSeparator {
typedef SoSeparator inherited;

SO_NODE_HEADER(SoRenderLayerGroup);

public:
static void initClass(void);
SoRenderLayerGroup(void);

enum Layer {
INHERIT,
FOREGROUND,
OVERLAY = FOREGROUND
};

// In retained rendering, FOREGROUND/OVERLAY places the subtree in the
// manager's foreground stage. LegacyGL does not reorder arbitrary child
// traversal from this field; its ordering is manager-driven by the
// background/main/foreground roots.
SoSFEnum layer;
SoSFBool viewportOverride;
SoSFVec4f viewportPixels;
SoSFBool clearDepthBuffer;

#if COIN_HAVE_LEGACY_GL_RENDERER
void GLRender(SoGLRenderAction * action) override;
void GLRenderBelowPath(SoGLRenderAction * action) override;
void GLRenderInPath(SoGLRenderAction * action) override;
void GLRenderOffPath(SoGLRenderAction * action) override;
#endif
void doAction(SoAction * action) override;

protected:
virtual ~SoRenderLayerGroup();

private:
#if COIN_HAVE_LEGACY_GL_RENDERER
void GLRenderLayer(SoGLRenderAction * action);
#endif
};

#endif // !COIN_SORENDERLAYERGROUP_H
Loading