-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInputModule.cpp
More file actions
68 lines (62 loc) · 2.68 KB
/
UserInputModule.cpp
File metadata and controls
68 lines (62 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <osg/io_utils>
#include <osg/BlendFunc>
#include <osg/ComputeBoundsVisitor>
#include <osgDB/ReadFile>
#include <iostream>
#include "UserInputModule.h"
#include "Utilities.h"
namespace osgVerse
{
UserInputModule::UserInputModule(const std::string& name, Pipeline* pipeline, int samples)
: _pipeline(pipeline), _coverageSamples(0) // FIXME
{
setName(name);
if (pipeline) pipeline->addModule(name, this);
}
UserInputModule::~UserInputModule()
{}
Pipeline::Stage* UserInputModule::createStages(osg::Shader* vs, osg::Shader* fs,
Pipeline::Stage* bypass, unsigned int cullMask,
const std::string& cName, osg::Texture* colorBuffer,
const std::string& dName, osg::Texture* depthBuffer)
{
if (colorBuffer != NULL || depthBuffer != NULL)
{
Pipeline::BufferDescriptions buffers;
{
Pipeline::BufferDescription desc0(cName, osgVerse::Pipeline::RGB_INT8);
#ifdef VERSE_EMBEDDED
Pipeline::BufferDescription desc1(dName, osgVerse::Pipeline::DEPTH32);
#else
Pipeline::BufferDescription desc1(dName, osgVerse::Pipeline::DEPTH24_STENCIL8);
#endif
if (colorBuffer != NULL) desc0.bufferToShare = colorBuffer;
if (depthBuffer != NULL) desc1.bufferToShare = depthBuffer;
buffers.push_back(desc0); buffers.push_back(desc1);
}
// Draw on existing buffers, no clear masks... This requires single-threaded only!!
int flags = Pipeline::NO_DEFAULT_TEXTURES | _coverageSamples;
Pipeline::Stage* stage = _pipeline->addInputStage(getName(), cullMask, flags, vs, fs, buffers);
CustomData* customData = new CustomData(true);
if (bypass != NULL) customData->bypassCamera = bypass->camera.get();
stage->camera->setUserData(customData); stage->camera->setClearMask(0);
stage->parentModule = this; return stage;
}
else
{
Pipeline::Stage* stage = _pipeline->addInputStage(
getName(), cullMask, _coverageSamples, vs, fs, 2, cName.c_str(), osgVerse::Pipeline::RGB_INT8,
#ifdef VERSE_EMBEDDED
dName.c_str(), osgVerse::Pipeline::DEPTH32);
#else
dName.c_str(), osgVerse::Pipeline::DEPTH24_STENCIL8);
#endif
// TODO: combine this with pipeline color/depth?
stage->parentModule = this; return stage;
}
}
void UserInputModule::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
traverse(node, nv);
}
}