mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Line endings
This commit is contained in:
160
Jenkinsfile
vendored
160
Jenkinsfile
vendored
@@ -1,80 +1,80 @@
|
||||
def modules = [
|
||||
"base",
|
||||
"debugging",
|
||||
"fieldlines",
|
||||
"galaxy",
|
||||
"globebrowsing",
|
||||
"iswa",
|
||||
"kameleon",
|
||||
"kameleonvolume",
|
||||
"multiresvolume",
|
||||
"newhorizons",
|
||||
"onscreengui",
|
||||
"space",
|
||||
"toyvolume",
|
||||
"volume"
|
||||
];
|
||||
|
||||
def flags = "-DGHOUL_USE_DEVIL=OFF "
|
||||
|
||||
for (module in modules) {
|
||||
flags += "-DOPENSPACE_OPENSPACE_MODULE_" + module.toUpperCase() + "=ON "
|
||||
}
|
||||
|
||||
echo flags
|
||||
|
||||
stage('Build') {
|
||||
parallel linux: {
|
||||
node('linux') {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
checkout scm
|
||||
sh 'git submodule update --init --recursive'
|
||||
sh '''
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. ''' +
|
||||
flags + ''' ..
|
||||
make
|
||||
'''
|
||||
}
|
||||
}
|
||||
},
|
||||
windows: {
|
||||
node('windows') {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
checkout scm
|
||||
bat '''
|
||||
git submodule update --init --recursive
|
||||
if not exist "build" mkdir "build"
|
||||
cd build
|
||||
cmake -G "Visual Studio 15 2017 Win64" .. ''' +
|
||||
flags + ''' ..
|
||||
msbuild.exe OpenSpace.sln /nologo /verbosity:minimal /m:2 /p:Configuration=Debug
|
||||
'''
|
||||
}
|
||||
}
|
||||
},
|
||||
osx: {
|
||||
node('osx') {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
checkout scm
|
||||
sh 'git submodule update --init --recursive'
|
||||
sh '''
|
||||
export PATH=${PATH}:/usr/local/bin:/Applications/CMake.app/Contents/bin
|
||||
export CMAKE_BUILD_TOOL=/Applications/CMake.app/Contents/bin/CMake
|
||||
srcDir=$PWD
|
||||
if [ ! -d ${srcDir} ]; then
|
||||
mkdir ${srcDir}
|
||||
fi
|
||||
if [ ! -d ${srcDir}/build ]; then
|
||||
mkdir ${srcDir}/build
|
||||
fi
|
||||
cd ${srcDir}/build
|
||||
/Applications/CMake.app/Contents/bin/cmake -G Xcode -D NASM=/usr/local/bin/nasm ${srcDir} .. ''' +
|
||||
flags + '''
|
||||
xcodebuild -quiet
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
def modules = [
|
||||
"base",
|
||||
"debugging",
|
||||
"fieldlines",
|
||||
"galaxy",
|
||||
"globebrowsing",
|
||||
"iswa",
|
||||
"kameleon",
|
||||
"kameleonvolume",
|
||||
"multiresvolume",
|
||||
"newhorizons",
|
||||
"onscreengui",
|
||||
"space",
|
||||
"toyvolume",
|
||||
"volume"
|
||||
];
|
||||
|
||||
def flags = "-DGHOUL_USE_DEVIL=OFF "
|
||||
|
||||
for (module in modules) {
|
||||
flags += "-DOPENSPACE_OPENSPACE_MODULE_" + module.toUpperCase() + "=ON "
|
||||
}
|
||||
|
||||
echo flags
|
||||
|
||||
stage('Build') {
|
||||
parallel linux: {
|
||||
node('linux') {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
checkout scm
|
||||
sh 'git submodule update --init --recursive'
|
||||
sh '''
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. ''' +
|
||||
flags + ''' ..
|
||||
make
|
||||
'''
|
||||
}
|
||||
}
|
||||
},
|
||||
windows: {
|
||||
node('windows') {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
checkout scm
|
||||
bat '''
|
||||
git submodule update --init --recursive
|
||||
if not exist "build" mkdir "build"
|
||||
cd build
|
||||
cmake -G "Visual Studio 15 2017 Win64" .. ''' +
|
||||
flags + ''' ..
|
||||
msbuild.exe OpenSpace.sln /nologo /verbosity:minimal /m:2 /p:Configuration=Debug
|
||||
'''
|
||||
}
|
||||
}
|
||||
},
|
||||
osx: {
|
||||
node('osx') {
|
||||
timeout(time: 30, unit: 'MINUTES') {
|
||||
checkout scm
|
||||
sh 'git submodule update --init --recursive'
|
||||
sh '''
|
||||
export PATH=${PATH}:/usr/local/bin:/Applications/CMake.app/Contents/bin
|
||||
export CMAKE_BUILD_TOOL=/Applications/CMake.app/Contents/bin/CMake
|
||||
srcDir=$PWD
|
||||
if [ ! -d ${srcDir} ]; then
|
||||
mkdir ${srcDir}
|
||||
fi
|
||||
if [ ! -d ${srcDir}/build ]; then
|
||||
mkdir ${srcDir}/build
|
||||
fi
|
||||
cd ${srcDir}/build
|
||||
/Applications/CMake.app/Contents/bin/cmake -G Xcode -D NASM=/usr/local/bin/nasm ${srcDir} .. ''' +
|
||||
flags + '''
|
||||
xcodebuild -quiet
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Node address="localhost" port="20401">
|
||||
<Window tags="OpenVR" fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="side_by_side" />
|
||||
<!-- Res is equal to the Recommend target size -->
|
||||
<Size x="1332" y="840" />
|
||||
<Res x="3024" y="1680" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Projectionplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-1.7156" y="-0.965" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-1.7156" y="0.965" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="1.7156" y="0.965" z="0.0" />
|
||||
</Projectionplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
</Cluster>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Node address="localhost" port="20401">
|
||||
<Window tags="OpenVR" fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="side_by_side" />
|
||||
<!-- Res is equal to the Recommend target size -->
|
||||
<Size x="1332" y="840" />
|
||||
<Res x="3024" y="1680" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Projectionplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-1.7156" y="-0.965" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-1.7156" y="0.965" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="1.7156" y="0.965" z="0.0" />
|
||||
</Projectionplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
</Cluster>
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Node address="localhost" port="20401">
|
||||
<Window tags="OpenVR" fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="side_by_side" />
|
||||
<!-- Res is equal to the Recommend target size -->
|
||||
<Size x="1332" y="793" />
|
||||
<Res x="2664" y="1586" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Projectionplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-1.7156" y="-0.965" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-1.7156" y="0.965" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="1.7156" y="0.965" z="0.0" />
|
||||
</Projectionplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
</Cluster>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Node address="localhost" port="20401">
|
||||
<Window tags="OpenVR" fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="side_by_side" />
|
||||
<!-- Res is equal to the Recommend target size -->
|
||||
<Size x="1332" y="793" />
|
||||
<Res x="2664" y="1586" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Projectionplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-1.7156" y="-0.965" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-1.7156" y="0.965" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="1.7156" y="0.965" z="0.0" />
|
||||
</Projectionplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
</Cluster>
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost" externalControlPort="20500">
|
||||
<Settings>
|
||||
<Display swapInterval="0" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" fxaa="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost" externalControlPort="20500">
|
||||
<Settings>
|
||||
<Display swapInterval="0" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" fxaa="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<!-- <Scene>
|
||||
<Orientation yaw="0.0" pitch="-27.0" roll="0.0" />
|
||||
<Offset x="0.0" y="0.0" z="0.0" />
|
||||
<Scale value="1.0" />
|
||||
</Scene> -->
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1024" y="1024" />
|
||||
<!-- Frame buffer resolution
|
||||
<Res x="4096" y="4096" /> -->
|
||||
<!--
|
||||
quality options (cubemap size):
|
||||
- low (256)
|
||||
- medium (512)
|
||||
- high/1k (1024)
|
||||
- 2k (2048)
|
||||
- 4k (4096)
|
||||
- 8k (8192)
|
||||
tilt specifies the dome tilt angle in degrees from the horizontal
|
||||
-->
|
||||
<Viewport name="fisheye">
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<FisheyeProjection fov="180" quality="1k" tilt="27.0">
|
||||
<Background r="0.1" g="0.1" b="0.1" a="1.0" />
|
||||
</FisheyeProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.06">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<!-- <Scene>
|
||||
<Orientation yaw="0.0" pitch="-27.0" roll="0.0" />
|
||||
<Offset x="0.0" y="0.0" z="0.0" />
|
||||
<Scale value="1.0" />
|
||||
</Scene> -->
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1024" y="1024" />
|
||||
<!-- Frame buffer resolution
|
||||
<Res x="4096" y="4096" /> -->
|
||||
<!--
|
||||
quality options (cubemap size):
|
||||
- low (256)
|
||||
- medium (512)
|
||||
- high/1k (1024)
|
||||
- 2k (2048)
|
||||
- 4k (4096)
|
||||
- 8k (8192)
|
||||
tilt specifies the dome tilt angle in degrees from the horizontal
|
||||
-->
|
||||
<Viewport name="fisheye">
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<FisheyeProjection fov="180" quality="1k" tilt="27.0">
|
||||
<Background r="0.1" g="0.1" b="0.1" a="1.0" />
|
||||
</FisheyeProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.06">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost" externalControlPort="20500">
|
||||
<Settings>
|
||||
<Display swapInterval="0" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="false" numberOfSamples="8" name="GUI" tags="GUI">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost" externalControlPort="20500">
|
||||
<Settings>
|
||||
<Display swapInterval="0" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="false" numberOfSamples="8" name="GUI" tags="GUI">
|
||||
<Stereo type="none" />
|
||||
<Size x="1280" y="720" />
|
||||
<Pos x="50" y="50" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="0.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="127.0.0.1">
|
||||
<Node address="127.0.0.1" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" border="true">
|
||||
<Pos x="10" y="100" />
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="false" numberOfSamples="8" border="false">
|
||||
<Pos x="340" y="100" />
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="4.0" />
|
||||
</User>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="127.0.0.1">
|
||||
<Node address="127.0.0.1" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" border="true">
|
||||
<Pos x="10" y="100" />
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="false" numberOfSamples="8" border="false">
|
||||
<Pos x="340" y="100" />
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="4.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
@@ -1,36 +1,36 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="127.0.0.1">
|
||||
<Node address="127.0.0.1" port="20401">
|
||||
<Window fullScreen="false">
|
||||
<Pos x="0" y="300" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<Node address="127.0.0.2" port="20402">
|
||||
<Window fullScreen="false">
|
||||
<Pos x="640" y="300" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="4.0" />
|
||||
</User>
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="127.0.0.1">
|
||||
<Node address="127.0.0.1" port="20401">
|
||||
<Window fullScreen="false">
|
||||
<Pos x="0" y="300" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<Node address="127.0.0.2" port="20402">
|
||||
<Window fullScreen="false">
|
||||
<Pos x="640" y="300" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1280" y="720" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<PlanarProjection>
|
||||
<FOV down="16.875" left="30.0" right="30.0" up="16.875" />
|
||||
<Orientation heading="0.0" pitch="0.0" roll="0.0" />
|
||||
</PlanarProjection>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="4.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
@@ -1,63 +1,63 @@
|
||||
function preInitialization()
|
||||
--[[
|
||||
The scripts in this function are executed after the scene is loaded but before the
|
||||
scene elements have been initialized, thus they should be used to set the time at
|
||||
which the scene should start and other settings that might determine initialization
|
||||
critical objects.
|
||||
]]--
|
||||
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2016-07-05T10:05:00.00")
|
||||
|
||||
dofile(openspace.absPath('${SCRIPTS}/common.lua'))
|
||||
openspace.clearKeys()
|
||||
helper.setCommonKeys()
|
||||
helper.setDeltaTimeKeys({
|
||||
1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400,
|
||||
28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600
|
||||
})
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
--[[
|
||||
The scripts in this function are executed after all objects in the scene have been
|
||||
created and initialized, but before the first render call. This is the place to set
|
||||
graphical settings for the renderables.
|
||||
]]--
|
||||
openspace.printInfo("Setting default values")
|
||||
openspace.setPropertyValue("Sun.renderable.enabled", false)
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", true)
|
||||
openspace.setPropertyValue("EarthMarker.renderable.enabled", true)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
openspace.setPropertyValue('Jupiter.renderable.performShading', false);
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
end
|
||||
|
||||
return {
|
||||
ScenePath = ".",
|
||||
CommonFolder = "common",
|
||||
Camera = {
|
||||
Focus = "Juno",
|
||||
Position = {1, 0, 0, 5},
|
||||
},
|
||||
Modules = {
|
||||
"sun",
|
||||
"mercury",
|
||||
"venus",
|
||||
"earth",
|
||||
"mars",
|
||||
"jupiter",
|
||||
"saturn/saturn",
|
||||
"uranus",
|
||||
"neptune",
|
||||
"stars",
|
||||
"milkyway",
|
||||
"missions/juno"
|
||||
}
|
||||
}
|
||||
|
||||
function preInitialization()
|
||||
--[[
|
||||
The scripts in this function are executed after the scene is loaded but before the
|
||||
scene elements have been initialized, thus they should be used to set the time at
|
||||
which the scene should start and other settings that might determine initialization
|
||||
critical objects.
|
||||
]]--
|
||||
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2016-07-05T10:05:00.00")
|
||||
|
||||
dofile(openspace.absPath('${SCRIPTS}/common.lua'))
|
||||
openspace.clearKeys()
|
||||
helper.setCommonKeys()
|
||||
helper.setDeltaTimeKeys({
|
||||
1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400,
|
||||
28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600
|
||||
})
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
--[[
|
||||
The scripts in this function are executed after all objects in the scene have been
|
||||
created and initialized, but before the first render call. This is the place to set
|
||||
graphical settings for the renderables.
|
||||
]]--
|
||||
openspace.printInfo("Setting default values")
|
||||
openspace.setPropertyValue("Sun.renderable.enabled", false)
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", true)
|
||||
openspace.setPropertyValue("EarthMarker.renderable.enabled", true)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
openspace.setPropertyValue('Jupiter.renderable.performShading', false);
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
end
|
||||
|
||||
return {
|
||||
ScenePath = ".",
|
||||
CommonFolder = "common",
|
||||
Camera = {
|
||||
Focus = "Juno",
|
||||
Position = {1, 0, 0, 5},
|
||||
},
|
||||
Modules = {
|
||||
"sun",
|
||||
"mercury",
|
||||
"venus",
|
||||
"earth",
|
||||
"mars",
|
||||
"jupiter",
|
||||
"saturn/saturn",
|
||||
"uranus",
|
||||
"neptune",
|
||||
"stars",
|
||||
"milkyway",
|
||||
"missions/juno"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,303 +1,303 @@
|
||||
/* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; -*-
|
||||
Copyright (c) 2010-2012 Marcus Geelnard
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include "tinythread.h"
|
||||
|
||||
#if defined(_TTHREAD_POSIX_)
|
||||
#include <unistd.h>
|
||||
#include <map>
|
||||
#elif defined(_TTHREAD_WIN32_)
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace tthread {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// condition_variable
|
||||
//------------------------------------------------------------------------------
|
||||
// NOTE 1: The Win32 implementation of the condition_variable class is based on
|
||||
// the corresponding implementation in GLFW, which in turn is based on a
|
||||
// description by Douglas C. Schmidt and Irfan Pyarali:
|
||||
// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
|
||||
//
|
||||
// NOTE 2: Windows Vista actually has native support for condition variables
|
||||
// (InitializeConditionVariable, WakeConditionVariable, etc), but we want to
|
||||
// be portable with pre-Vista Windows versions, so TinyThread++ does not use
|
||||
// Vista condition variables.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
#define _CONDITION_EVENT_ONE 0
|
||||
#define _CONDITION_EVENT_ALL 1
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
condition_variable::condition_variable() : mWaitersCount(0)
|
||||
{
|
||||
mEvents[_CONDITION_EVENT_ONE] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
mEvents[_CONDITION_EVENT_ALL] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
InitializeCriticalSection(&mWaitersCountLock);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
condition_variable::~condition_variable()
|
||||
{
|
||||
CloseHandle(mEvents[_CONDITION_EVENT_ONE]);
|
||||
CloseHandle(mEvents[_CONDITION_EVENT_ALL]);
|
||||
DeleteCriticalSection(&mWaitersCountLock);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
void condition_variable::_wait()
|
||||
{
|
||||
// Wait for either event to become signaled due to notify_one() or
|
||||
// notify_all() being called
|
||||
int result = WaitForMultipleObjects(2, mEvents, FALSE, INFINITE);
|
||||
|
||||
// Check if we are the last waiter
|
||||
EnterCriticalSection(&mWaitersCountLock);
|
||||
-- mWaitersCount;
|
||||
bool lastWaiter = (result == (WAIT_OBJECT_0 + _CONDITION_EVENT_ALL)) &&
|
||||
(mWaitersCount == 0);
|
||||
LeaveCriticalSection(&mWaitersCountLock);
|
||||
|
||||
// If we are the last waiter to be notified to stop waiting, reset the event
|
||||
if(lastWaiter)
|
||||
ResetEvent(mEvents[_CONDITION_EVENT_ALL]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
void condition_variable::notify_one()
|
||||
{
|
||||
// Are there any waiters?
|
||||
EnterCriticalSection(&mWaitersCountLock);
|
||||
bool haveWaiters = (mWaitersCount > 0);
|
||||
LeaveCriticalSection(&mWaitersCountLock);
|
||||
|
||||
// If we have any waiting threads, send them a signal
|
||||
if(haveWaiters)
|
||||
SetEvent(mEvents[_CONDITION_EVENT_ONE]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
void condition_variable::notify_all()
|
||||
{
|
||||
// Are there any waiters?
|
||||
EnterCriticalSection(&mWaitersCountLock);
|
||||
bool haveWaiters = (mWaitersCount > 0);
|
||||
LeaveCriticalSection(&mWaitersCountLock);
|
||||
|
||||
// If we have any waiting threads, send them a signal
|
||||
if(haveWaiters)
|
||||
SetEvent(mEvents[_CONDITION_EVENT_ALL]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// POSIX pthread_t to unique thread::id mapping logic.
|
||||
// Note: Here we use a global thread safe std::map to convert instances of
|
||||
// pthread_t to small thread identifier numbers (unique within one process).
|
||||
// This method should be portable across different POSIX implementations.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_TTHREAD_POSIX_)
|
||||
static thread::id _pthread_t_to_ID(const pthread_t &aHandle)
|
||||
{
|
||||
static mutex idMapLock;
|
||||
static std::map<pthread_t, unsigned long int> idMap;
|
||||
static unsigned long int idCount(1);
|
||||
|
||||
lock_guard<mutex> guard(idMapLock);
|
||||
if(idMap.find(aHandle) == idMap.end())
|
||||
idMap[aHandle] = idCount ++;
|
||||
return thread::id(idMap[aHandle]);
|
||||
}
|
||||
#endif // _TTHREAD_POSIX_
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// thread
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/// Information to pass to the new thread (what to run).
|
||||
struct _thread_start_info {
|
||||
void (*mFunction)(void *); ///< Pointer to the function to be executed.
|
||||
void * mArg; ///< Function argument for the thread function.
|
||||
thread * mThread; ///< Pointer to the thread object.
|
||||
};
|
||||
|
||||
// Thread wrapper function.
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
unsigned WINAPI thread::wrapper_function(void * aArg)
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
void * thread::wrapper_function(void * aArg)
|
||||
#endif
|
||||
{
|
||||
// Get thread startup information
|
||||
_thread_start_info * ti = (_thread_start_info *) aArg;
|
||||
|
||||
try
|
||||
{
|
||||
// Call the actual client thread function
|
||||
ti->mFunction(ti->mArg);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// Uncaught exceptions will terminate the application (default behavior
|
||||
// according to C++11)
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
// The thread is no longer executing
|
||||
lock_guard<mutex> guard(ti->mThread->mDataMutex);
|
||||
ti->mThread->mNotAThread = true;
|
||||
|
||||
// The thread is responsible for freeing the startup information
|
||||
delete ti;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
thread::thread(void (*aFunction)(void *), void * aArg)
|
||||
{
|
||||
// Serialize access to this thread structure
|
||||
lock_guard<mutex> guard(mDataMutex);
|
||||
|
||||
// Fill out the thread startup information (passed to the thread wrapper,
|
||||
// which will eventually free it)
|
||||
_thread_start_info * ti = new _thread_start_info;
|
||||
ti->mFunction = aFunction;
|
||||
ti->mArg = aArg;
|
||||
ti->mThread = this;
|
||||
|
||||
// The thread is now alive
|
||||
mNotAThread = false;
|
||||
|
||||
// Create the thread
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
mHandle = (HANDLE) _beginthreadex(0, 0, wrapper_function, (void *) ti, 0, &mWin32ThreadID);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
if(pthread_create(&mHandle, NULL, wrapper_function, (void *) ti) != 0)
|
||||
mHandle = 0;
|
||||
#endif
|
||||
|
||||
// Did we fail to create the thread?
|
||||
if(!mHandle)
|
||||
{
|
||||
mNotAThread = true;
|
||||
delete ti;
|
||||
}
|
||||
}
|
||||
|
||||
thread::~thread()
|
||||
{
|
||||
if(joinable())
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
void thread::join()
|
||||
{
|
||||
if(joinable())
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
WaitForSingleObject(mHandle, INFINITE);
|
||||
CloseHandle(mHandle);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
pthread_join(mHandle, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool thread::joinable() const
|
||||
{
|
||||
mDataMutex.lock();
|
||||
bool result = !mNotAThread;
|
||||
mDataMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
void thread::detach()
|
||||
{
|
||||
mDataMutex.lock();
|
||||
if(!mNotAThread)
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
CloseHandle(mHandle);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
pthread_detach(mHandle);
|
||||
#endif
|
||||
mNotAThread = true;
|
||||
}
|
||||
mDataMutex.unlock();
|
||||
}
|
||||
|
||||
thread::id thread::get_id() const
|
||||
{
|
||||
if(!joinable())
|
||||
return id();
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
return id((unsigned long int) mWin32ThreadID);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
return _pthread_t_to_ID(mHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned thread::hardware_concurrency()
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
return (int) si.dwNumberOfProcessors;
|
||||
#elif defined(_SC_NPROCESSORS_ONLN)
|
||||
return (int) sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined(_SC_NPROC_ONLN)
|
||||
return (int) sysconf(_SC_NPROC_ONLN);
|
||||
#else
|
||||
// The standard requires this function to return zero if the number of
|
||||
// hardware cores could not be determined.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// this_thread
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
thread::id this_thread::get_id()
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
return thread::id((unsigned long int) GetCurrentThreadId());
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
return _pthread_t_to_ID(pthread_self());
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
/* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; -*-
|
||||
Copyright (c) 2010-2012 Marcus Geelnard
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include "tinythread.h"
|
||||
|
||||
#if defined(_TTHREAD_POSIX_)
|
||||
#include <unistd.h>
|
||||
#include <map>
|
||||
#elif defined(_TTHREAD_WIN32_)
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace tthread {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// condition_variable
|
||||
//------------------------------------------------------------------------------
|
||||
// NOTE 1: The Win32 implementation of the condition_variable class is based on
|
||||
// the corresponding implementation in GLFW, which in turn is based on a
|
||||
// description by Douglas C. Schmidt and Irfan Pyarali:
|
||||
// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
|
||||
//
|
||||
// NOTE 2: Windows Vista actually has native support for condition variables
|
||||
// (InitializeConditionVariable, WakeConditionVariable, etc), but we want to
|
||||
// be portable with pre-Vista Windows versions, so TinyThread++ does not use
|
||||
// Vista condition variables.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
#define _CONDITION_EVENT_ONE 0
|
||||
#define _CONDITION_EVENT_ALL 1
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
condition_variable::condition_variable() : mWaitersCount(0)
|
||||
{
|
||||
mEvents[_CONDITION_EVENT_ONE] = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
mEvents[_CONDITION_EVENT_ALL] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
InitializeCriticalSection(&mWaitersCountLock);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
condition_variable::~condition_variable()
|
||||
{
|
||||
CloseHandle(mEvents[_CONDITION_EVENT_ONE]);
|
||||
CloseHandle(mEvents[_CONDITION_EVENT_ALL]);
|
||||
DeleteCriticalSection(&mWaitersCountLock);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
void condition_variable::_wait()
|
||||
{
|
||||
// Wait for either event to become signaled due to notify_one() or
|
||||
// notify_all() being called
|
||||
int result = WaitForMultipleObjects(2, mEvents, FALSE, INFINITE);
|
||||
|
||||
// Check if we are the last waiter
|
||||
EnterCriticalSection(&mWaitersCountLock);
|
||||
-- mWaitersCount;
|
||||
bool lastWaiter = (result == (WAIT_OBJECT_0 + _CONDITION_EVENT_ALL)) &&
|
||||
(mWaitersCount == 0);
|
||||
LeaveCriticalSection(&mWaitersCountLock);
|
||||
|
||||
// If we are the last waiter to be notified to stop waiting, reset the event
|
||||
if(lastWaiter)
|
||||
ResetEvent(mEvents[_CONDITION_EVENT_ALL]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
void condition_variable::notify_one()
|
||||
{
|
||||
// Are there any waiters?
|
||||
EnterCriticalSection(&mWaitersCountLock);
|
||||
bool haveWaiters = (mWaitersCount > 0);
|
||||
LeaveCriticalSection(&mWaitersCountLock);
|
||||
|
||||
// If we have any waiting threads, send them a signal
|
||||
if(haveWaiters)
|
||||
SetEvent(mEvents[_CONDITION_EVENT_ONE]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
void condition_variable::notify_all()
|
||||
{
|
||||
// Are there any waiters?
|
||||
EnterCriticalSection(&mWaitersCountLock);
|
||||
bool haveWaiters = (mWaitersCount > 0);
|
||||
LeaveCriticalSection(&mWaitersCountLock);
|
||||
|
||||
// If we have any waiting threads, send them a signal
|
||||
if(haveWaiters)
|
||||
SetEvent(mEvents[_CONDITION_EVENT_ALL]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// POSIX pthread_t to unique thread::id mapping logic.
|
||||
// Note: Here we use a global thread safe std::map to convert instances of
|
||||
// pthread_t to small thread identifier numbers (unique within one process).
|
||||
// This method should be portable across different POSIX implementations.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_TTHREAD_POSIX_)
|
||||
static thread::id _pthread_t_to_ID(const pthread_t &aHandle)
|
||||
{
|
||||
static mutex idMapLock;
|
||||
static std::map<pthread_t, unsigned long int> idMap;
|
||||
static unsigned long int idCount(1);
|
||||
|
||||
lock_guard<mutex> guard(idMapLock);
|
||||
if(idMap.find(aHandle) == idMap.end())
|
||||
idMap[aHandle] = idCount ++;
|
||||
return thread::id(idMap[aHandle]);
|
||||
}
|
||||
#endif // _TTHREAD_POSIX_
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// thread
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/// Information to pass to the new thread (what to run).
|
||||
struct _thread_start_info {
|
||||
void (*mFunction)(void *); ///< Pointer to the function to be executed.
|
||||
void * mArg; ///< Function argument for the thread function.
|
||||
thread * mThread; ///< Pointer to the thread object.
|
||||
};
|
||||
|
||||
// Thread wrapper function.
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
unsigned WINAPI thread::wrapper_function(void * aArg)
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
void * thread::wrapper_function(void * aArg)
|
||||
#endif
|
||||
{
|
||||
// Get thread startup information
|
||||
_thread_start_info * ti = (_thread_start_info *) aArg;
|
||||
|
||||
try
|
||||
{
|
||||
// Call the actual client thread function
|
||||
ti->mFunction(ti->mArg);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// Uncaught exceptions will terminate the application (default behavior
|
||||
// according to C++11)
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
// The thread is no longer executing
|
||||
lock_guard<mutex> guard(ti->mThread->mDataMutex);
|
||||
ti->mThread->mNotAThread = true;
|
||||
|
||||
// The thread is responsible for freeing the startup information
|
||||
delete ti;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
thread::thread(void (*aFunction)(void *), void * aArg)
|
||||
{
|
||||
// Serialize access to this thread structure
|
||||
lock_guard<mutex> guard(mDataMutex);
|
||||
|
||||
// Fill out the thread startup information (passed to the thread wrapper,
|
||||
// which will eventually free it)
|
||||
_thread_start_info * ti = new _thread_start_info;
|
||||
ti->mFunction = aFunction;
|
||||
ti->mArg = aArg;
|
||||
ti->mThread = this;
|
||||
|
||||
// The thread is now alive
|
||||
mNotAThread = false;
|
||||
|
||||
// Create the thread
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
mHandle = (HANDLE) _beginthreadex(0, 0, wrapper_function, (void *) ti, 0, &mWin32ThreadID);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
if(pthread_create(&mHandle, NULL, wrapper_function, (void *) ti) != 0)
|
||||
mHandle = 0;
|
||||
#endif
|
||||
|
||||
// Did we fail to create the thread?
|
||||
if(!mHandle)
|
||||
{
|
||||
mNotAThread = true;
|
||||
delete ti;
|
||||
}
|
||||
}
|
||||
|
||||
thread::~thread()
|
||||
{
|
||||
if(joinable())
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
void thread::join()
|
||||
{
|
||||
if(joinable())
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
WaitForSingleObject(mHandle, INFINITE);
|
||||
CloseHandle(mHandle);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
pthread_join(mHandle, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool thread::joinable() const
|
||||
{
|
||||
mDataMutex.lock();
|
||||
bool result = !mNotAThread;
|
||||
mDataMutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
void thread::detach()
|
||||
{
|
||||
mDataMutex.lock();
|
||||
if(!mNotAThread)
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
CloseHandle(mHandle);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
pthread_detach(mHandle);
|
||||
#endif
|
||||
mNotAThread = true;
|
||||
}
|
||||
mDataMutex.unlock();
|
||||
}
|
||||
|
||||
thread::id thread::get_id() const
|
||||
{
|
||||
if(!joinable())
|
||||
return id();
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
return id((unsigned long int) mWin32ThreadID);
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
return _pthread_t_to_ID(mHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned thread::hardware_concurrency()
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
return (int) si.dwNumberOfProcessors;
|
||||
#elif defined(_SC_NPROCESSORS_ONLN)
|
||||
return (int) sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined(_SC_NPROC_ONLN)
|
||||
return (int) sysconf(_SC_NPROC_ONLN);
|
||||
#else
|
||||
// The standard requires this function to return zero if the number of
|
||||
// hardware cores could not be determined.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// this_thread
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
thread::id this_thread::get_id()
|
||||
{
|
||||
#if defined(_TTHREAD_WIN32_)
|
||||
return thread::id((unsigned long int) GetCurrentThreadId());
|
||||
#elif defined(_TTHREAD_POSIX_)
|
||||
return _pthread_t_to_ID(pthread_self());
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1428
ext/tinythread.h
1428
ext/tinythread.h
File diff suppressed because it is too large
Load Diff
@@ -1,84 +1,84 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/other/pixelbuffer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
const char* _loggerCat = "PixelBuffer";
|
||||
};
|
||||
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
PixelBuffer::PixelBuffer(size_t numBytes, Usage usage)
|
||||
: _numBytes(numBytes)
|
||||
, _usage(usage)
|
||||
, _isMapped(false)
|
||||
{
|
||||
glGenBuffers(1, &_id);
|
||||
bind();
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, 0, static_cast<GLenum>(_usage));
|
||||
unbind();
|
||||
}
|
||||
|
||||
PixelBuffer::~PixelBuffer() {
|
||||
glDeleteBuffers(1, &_id);
|
||||
}
|
||||
|
||||
void* PixelBuffer::mapBuffer(Access access) {
|
||||
void* dataPtr = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, static_cast<GLenum>(access));
|
||||
_isMapped = dataPtr ? true : false;
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
void* PixelBuffer::mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access) {
|
||||
void* dataPtr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, offset, length, access);
|
||||
_isMapped = dataPtr ? true : false;
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
bool PixelBuffer::unMapBuffer() {
|
||||
GLboolean success = glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
if (!success) {
|
||||
LERROR("Unable to unmap pixel buffer, data may be corrupt!");
|
||||
}
|
||||
_isMapped = false;
|
||||
return success == GL_TRUE;
|
||||
}
|
||||
|
||||
void PixelBuffer::bind() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _id);
|
||||
}
|
||||
|
||||
void PixelBuffer::unbind() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
}
|
||||
|
||||
bool PixelBuffer::isMapped() const {
|
||||
return _isMapped;
|
||||
}
|
||||
|
||||
PixelBuffer::operator GLuint() const {
|
||||
return _id;
|
||||
}
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/other/pixelbuffer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
const char* _loggerCat = "PixelBuffer";
|
||||
};
|
||||
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
PixelBuffer::PixelBuffer(size_t numBytes, Usage usage)
|
||||
: _numBytes(numBytes)
|
||||
, _usage(usage)
|
||||
, _isMapped(false)
|
||||
{
|
||||
glGenBuffers(1, &_id);
|
||||
bind();
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, 0, static_cast<GLenum>(_usage));
|
||||
unbind();
|
||||
}
|
||||
|
||||
PixelBuffer::~PixelBuffer() {
|
||||
glDeleteBuffers(1, &_id);
|
||||
}
|
||||
|
||||
void* PixelBuffer::mapBuffer(Access access) {
|
||||
void* dataPtr = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, static_cast<GLenum>(access));
|
||||
_isMapped = dataPtr ? true : false;
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
void* PixelBuffer::mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access) {
|
||||
void* dataPtr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, offset, length, access);
|
||||
_isMapped = dataPtr ? true : false;
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
bool PixelBuffer::unMapBuffer() {
|
||||
GLboolean success = glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
if (!success) {
|
||||
LERROR("Unable to unmap pixel buffer, data may be corrupt!");
|
||||
}
|
||||
_isMapped = false;
|
||||
return success == GL_TRUE;
|
||||
}
|
||||
|
||||
void PixelBuffer::bind() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _id);
|
||||
}
|
||||
|
||||
void PixelBuffer::unbind() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
}
|
||||
|
||||
bool PixelBuffer::isMapped() const {
|
||||
return _isMapped;
|
||||
}
|
||||
|
||||
PixelBuffer::operator GLuint() const {
|
||||
return _id;
|
||||
}
|
||||
|
||||
@@ -1,140 +1,140 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER___H__
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/**
|
||||
* Handles an OpenGL pixel buffer which contains data allocated on the GPU. A simple
|
||||
* class that wraps the standard functionality of OpenGL pixel buffer objects. Once
|
||||
* the PixelBuffer is created, data is allocated on the GPU. When mapping data to a
|
||||
* address pointer, the user needs to ensure the data is unmapped before the data can
|
||||
* be used on the GPU / CPU depending on Usage.
|
||||
*/
|
||||
class PixelBuffer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* All kinds of usage for pixel buffer objects as defined by the OpenGL standard.
|
||||
* See: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml
|
||||
*/
|
||||
enum class Usage : std::underlying_type_t<GLenum> {
|
||||
StreamDraw = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_DRAW),
|
||||
StreamRead = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_READ),
|
||||
StreamCopy = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_COPY),
|
||||
StaticDraw = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_DRAW),
|
||||
StaticRead = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_READ),
|
||||
StaticCopy = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_COPY),
|
||||
DynamicDraw = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_DRAW),
|
||||
DynamicRead = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_READ),
|
||||
DynamicCopy = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_COPY)
|
||||
};
|
||||
|
||||
/**
|
||||
* Access hints for OpenGL buffer mapping
|
||||
* See: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glMapBuffer.xml
|
||||
*/
|
||||
enum class Access : std::underlying_type_t<GLenum> {
|
||||
ReadOnly = static_cast<std::underlying_type_t<GLenum>>(GL_READ_ONLY),
|
||||
WriteOnly = static_cast<std::underlying_type_t<GLenum>>(GL_WRITE_ONLY),
|
||||
ReadWrite = static_cast<std::underlying_type_t<GLenum>>(GL_READ_WRITE)
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocates <code>numBytes</code> bytes on the GPU and creates an ID for the pixel
|
||||
* buffer object.
|
||||
* \param numBytes is the number of bytes to be allocated on GPU memory
|
||||
* \param usage is the <code>Usage</code> for the pixel buffer
|
||||
*/
|
||||
PixelBuffer(size_t numBytes, Usage usage);
|
||||
|
||||
/**
|
||||
* calls glDeleteBuffers().
|
||||
*/
|
||||
~PixelBuffer();
|
||||
|
||||
/**
|
||||
* Maps an address pointer to GPU direct memory access. The user must make sure the
|
||||
* buffer is bound before calling this function.
|
||||
* \param access is the access to which can be any of <code>GL_READ_ONLY</code>,
|
||||
* <code>GL_WRITE_ONLY</code>, or <code>GL_READ_WRITE</code>
|
||||
* \returns the DMA address to the mapped buffer. Returns nullptr if the mapping
|
||||
* failed
|
||||
*/
|
||||
void* mapBuffer(Access access);
|
||||
|
||||
/**
|
||||
* Maps an address pointer to GPU direct memory access. Gives access to a range of
|
||||
* the buffer. The user must make sure the buffer is bound before calling this
|
||||
* function.
|
||||
* \param offet is the number of bytes to the first address to get in the buffer
|
||||
* \param length is the number of bytes to access in the buffer
|
||||
* \param access is a bitfield describing the access as described in:
|
||||
* https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glMapBufferRange.xhtml
|
||||
* \returns the DMA address to the mapped buffer. Returns nullptr if the mapping
|
||||
* failed
|
||||
*/
|
||||
void* mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access);
|
||||
|
||||
/**
|
||||
* Maps the default buffer and makes the data available on the GPU
|
||||
*/
|
||||
bool unMapBuffer();
|
||||
|
||||
/**
|
||||
* Calls glBindBuffer()
|
||||
*/
|
||||
void bind();
|
||||
|
||||
/**
|
||||
* Calls glBindBuffer() with argument 0 to unmap any pixel buffer
|
||||
*/
|
||||
void unbind();
|
||||
|
||||
/**
|
||||
* \returns true of the buffer is mapped, otherwise false
|
||||
*/
|
||||
bool isMapped() const;
|
||||
|
||||
/**
|
||||
* \returns the OpenGL id of the pixel buffer object
|
||||
*/
|
||||
operator GLuint() const;
|
||||
|
||||
private:
|
||||
GLuint _id;
|
||||
const size_t _numBytes;
|
||||
const Usage _usage;
|
||||
bool _isMapped;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER___H__
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER___H__
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/**
|
||||
* Handles an OpenGL pixel buffer which contains data allocated on the GPU. A simple
|
||||
* class that wraps the standard functionality of OpenGL pixel buffer objects. Once
|
||||
* the PixelBuffer is created, data is allocated on the GPU. When mapping data to a
|
||||
* address pointer, the user needs to ensure the data is unmapped before the data can
|
||||
* be used on the GPU / CPU depending on Usage.
|
||||
*/
|
||||
class PixelBuffer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* All kinds of usage for pixel buffer objects as defined by the OpenGL standard.
|
||||
* See: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml
|
||||
*/
|
||||
enum class Usage : std::underlying_type_t<GLenum> {
|
||||
StreamDraw = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_DRAW),
|
||||
StreamRead = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_READ),
|
||||
StreamCopy = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_COPY),
|
||||
StaticDraw = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_DRAW),
|
||||
StaticRead = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_READ),
|
||||
StaticCopy = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_COPY),
|
||||
DynamicDraw = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_DRAW),
|
||||
DynamicRead = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_READ),
|
||||
DynamicCopy = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_COPY)
|
||||
};
|
||||
|
||||
/**
|
||||
* Access hints for OpenGL buffer mapping
|
||||
* See: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glMapBuffer.xml
|
||||
*/
|
||||
enum class Access : std::underlying_type_t<GLenum> {
|
||||
ReadOnly = static_cast<std::underlying_type_t<GLenum>>(GL_READ_ONLY),
|
||||
WriteOnly = static_cast<std::underlying_type_t<GLenum>>(GL_WRITE_ONLY),
|
||||
ReadWrite = static_cast<std::underlying_type_t<GLenum>>(GL_READ_WRITE)
|
||||
};
|
||||
|
||||
/**
|
||||
* Allocates <code>numBytes</code> bytes on the GPU and creates an ID for the pixel
|
||||
* buffer object.
|
||||
* \param numBytes is the number of bytes to be allocated on GPU memory
|
||||
* \param usage is the <code>Usage</code> for the pixel buffer
|
||||
*/
|
||||
PixelBuffer(size_t numBytes, Usage usage);
|
||||
|
||||
/**
|
||||
* calls glDeleteBuffers().
|
||||
*/
|
||||
~PixelBuffer();
|
||||
|
||||
/**
|
||||
* Maps an address pointer to GPU direct memory access. The user must make sure the
|
||||
* buffer is bound before calling this function.
|
||||
* \param access is the access to which can be any of <code>GL_READ_ONLY</code>,
|
||||
* <code>GL_WRITE_ONLY</code>, or <code>GL_READ_WRITE</code>
|
||||
* \returns the DMA address to the mapped buffer. Returns nullptr if the mapping
|
||||
* failed
|
||||
*/
|
||||
void* mapBuffer(Access access);
|
||||
|
||||
/**
|
||||
* Maps an address pointer to GPU direct memory access. Gives access to a range of
|
||||
* the buffer. The user must make sure the buffer is bound before calling this
|
||||
* function.
|
||||
* \param offet is the number of bytes to the first address to get in the buffer
|
||||
* \param length is the number of bytes to access in the buffer
|
||||
* \param access is a bitfield describing the access as described in:
|
||||
* https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glMapBufferRange.xhtml
|
||||
* \returns the DMA address to the mapped buffer. Returns nullptr if the mapping
|
||||
* failed
|
||||
*/
|
||||
void* mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access);
|
||||
|
||||
/**
|
||||
* Maps the default buffer and makes the data available on the GPU
|
||||
*/
|
||||
bool unMapBuffer();
|
||||
|
||||
/**
|
||||
* Calls glBindBuffer()
|
||||
*/
|
||||
void bind();
|
||||
|
||||
/**
|
||||
* Calls glBindBuffer() with argument 0 to unmap any pixel buffer
|
||||
*/
|
||||
void unbind();
|
||||
|
||||
/**
|
||||
* \returns true of the buffer is mapped, otherwise false
|
||||
*/
|
||||
bool isMapped() const;
|
||||
|
||||
/**
|
||||
* \returns the OpenGL id of the pixel buffer object
|
||||
*/
|
||||
operator GLuint() const;
|
||||
|
||||
private:
|
||||
GLuint _id;
|
||||
const size_t _numBytes;
|
||||
const Usage _usage;
|
||||
bool _isMapped;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER___H__
|
||||
|
||||
@@ -1,115 +1,115 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER_CONTAINER___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER_CONTAINER___H__
|
||||
|
||||
#include <modules/globebrowsing/other/pixelbuffer.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/**
|
||||
* Templated class which owns one or many <code>PixelBuffer</code>s. The
|
||||
* <code>KeyType</code> is used to map a pixel buffer but only if it is not already
|
||||
* mapped.
|
||||
*/
|
||||
template <class KeyType>
|
||||
class PixelBufferContainer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates numPixelBuffers pixel buffer objects, each with numBytesPerBuffer bytes
|
||||
* allocated on the GPU.
|
||||
* \param numBytesPerBuffer is the number of bytes per pixel buffer. All pixel
|
||||
* buffers within a <code>PixelBufferContainer</code> have the same number of bytes
|
||||
* \param usage is the <code>Usage</code> as described by <code>PixelBuffer</code>
|
||||
* \param numPixelBuffers is the number of pixel buffers to create for this container.
|
||||
* If numPixelBuffers is omitted, no pixel buffers are created.
|
||||
*/
|
||||
PixelBufferContainer(size_t numBytesPerBuffer,
|
||||
globebrowsing::PixelBuffer::Usage usage, size_t numPixelBuffers = 0);
|
||||
~PixelBufferContainer() = default;
|
||||
|
||||
/**
|
||||
* Finds a Pixel buffer and maps it if it is available.
|
||||
* \param key is the identifier for the pixel buffer which can be used later when
|
||||
* unmapping the mapped pixel buffer.
|
||||
* \param access is the access as described by <code>PixelBuffer</code>
|
||||
* \returns an address pointer to DMA if the mapping succeeded. Otherwise a nullptr
|
||||
* is returned. The mapping can fail if the buffer identified with <code>key</code>
|
||||
* is already mapped or if something else failed.
|
||||
*/
|
||||
void* mapBuffer(KeyType key, PixelBuffer::Access access);
|
||||
|
||||
/**
|
||||
* Finds a Pixel buffer and maps a range of it if it is available.
|
||||
* \param key is the identifier for the pixel buffer which can be used later when
|
||||
* unmapping the mapped pixel buffer.
|
||||
* \param offet is the number of bytes to the first address to get in the buffer
|
||||
* \param length is the number of bytes to access in the buffer
|
||||
* \param access is the access as described by <code>PixelBuffer</code>
|
||||
* \returns an address pointer to DMA if the mapping succeeded. Otherwise a nullptr
|
||||
* is returned. The mapping can fail if the buffer identified with <code>key</code>
|
||||
* is already mapped or if something else failed.
|
||||
*/
|
||||
void* mapBufferRange(KeyType key, GLintptr offset, GLsizeiptr length,
|
||||
BufferAccessMask access);
|
||||
|
||||
/**
|
||||
* Unmaps all buffers in the PixelBufferContainer.
|
||||
* \returns true if the unmapping succeeded, otherwise false.
|
||||
*/
|
||||
bool resetMappedBuffers();
|
||||
|
||||
/**
|
||||
* Unmaps a buffer that has previously been mapped. This buffer is identified using
|
||||
* <code>key</code>.
|
||||
* \param key is the identifier of the mapped buffer.
|
||||
* \returns true if the unmapping succeeded, otherwise false.
|
||||
*/
|
||||
bool unMapBuffer(KeyType key);
|
||||
|
||||
/**
|
||||
* \returns the <code>GLuint</code> id of a pixel buffer identified by <code>key</code>
|
||||
* if it currently is mapped.
|
||||
*/
|
||||
GLuint idOfMappedBuffer(KeyType key);
|
||||
private:
|
||||
const globebrowsing::PixelBuffer::Usage _usage;
|
||||
|
||||
std::vector<std::unique_ptr<PixelBuffer>> _pixelBuffers;
|
||||
|
||||
// Maps from KeyType to index of mapped buffers
|
||||
std::map<KeyType, int> _indexMap;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#include "pixelbuffercontainer.inl"
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER_CONTAINER___H__
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER_CONTAINER___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER_CONTAINER___H__
|
||||
|
||||
#include <modules/globebrowsing/other/pixelbuffer.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/**
|
||||
* Templated class which owns one or many <code>PixelBuffer</code>s. The
|
||||
* <code>KeyType</code> is used to map a pixel buffer but only if it is not already
|
||||
* mapped.
|
||||
*/
|
||||
template <class KeyType>
|
||||
class PixelBufferContainer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates numPixelBuffers pixel buffer objects, each with numBytesPerBuffer bytes
|
||||
* allocated on the GPU.
|
||||
* \param numBytesPerBuffer is the number of bytes per pixel buffer. All pixel
|
||||
* buffers within a <code>PixelBufferContainer</code> have the same number of bytes
|
||||
* \param usage is the <code>Usage</code> as described by <code>PixelBuffer</code>
|
||||
* \param numPixelBuffers is the number of pixel buffers to create for this container.
|
||||
* If numPixelBuffers is omitted, no pixel buffers are created.
|
||||
*/
|
||||
PixelBufferContainer(size_t numBytesPerBuffer,
|
||||
globebrowsing::PixelBuffer::Usage usage, size_t numPixelBuffers = 0);
|
||||
~PixelBufferContainer() = default;
|
||||
|
||||
/**
|
||||
* Finds a Pixel buffer and maps it if it is available.
|
||||
* \param key is the identifier for the pixel buffer which can be used later when
|
||||
* unmapping the mapped pixel buffer.
|
||||
* \param access is the access as described by <code>PixelBuffer</code>
|
||||
* \returns an address pointer to DMA if the mapping succeeded. Otherwise a nullptr
|
||||
* is returned. The mapping can fail if the buffer identified with <code>key</code>
|
||||
* is already mapped or if something else failed.
|
||||
*/
|
||||
void* mapBuffer(KeyType key, PixelBuffer::Access access);
|
||||
|
||||
/**
|
||||
* Finds a Pixel buffer and maps a range of it if it is available.
|
||||
* \param key is the identifier for the pixel buffer which can be used later when
|
||||
* unmapping the mapped pixel buffer.
|
||||
* \param offet is the number of bytes to the first address to get in the buffer
|
||||
* \param length is the number of bytes to access in the buffer
|
||||
* \param access is the access as described by <code>PixelBuffer</code>
|
||||
* \returns an address pointer to DMA if the mapping succeeded. Otherwise a nullptr
|
||||
* is returned. The mapping can fail if the buffer identified with <code>key</code>
|
||||
* is already mapped or if something else failed.
|
||||
*/
|
||||
void* mapBufferRange(KeyType key, GLintptr offset, GLsizeiptr length,
|
||||
BufferAccessMask access);
|
||||
|
||||
/**
|
||||
* Unmaps all buffers in the PixelBufferContainer.
|
||||
* \returns true if the unmapping succeeded, otherwise false.
|
||||
*/
|
||||
bool resetMappedBuffers();
|
||||
|
||||
/**
|
||||
* Unmaps a buffer that has previously been mapped. This buffer is identified using
|
||||
* <code>key</code>.
|
||||
* \param key is the identifier of the mapped buffer.
|
||||
* \returns true if the unmapping succeeded, otherwise false.
|
||||
*/
|
||||
bool unMapBuffer(KeyType key);
|
||||
|
||||
/**
|
||||
* \returns the <code>GLuint</code> id of a pixel buffer identified by <code>key</code>
|
||||
* if it currently is mapped.
|
||||
*/
|
||||
GLuint idOfMappedBuffer(KeyType key);
|
||||
private:
|
||||
const globebrowsing::PixelBuffer::Usage _usage;
|
||||
|
||||
std::vector<std::unique_ptr<PixelBuffer>> _pixelBuffers;
|
||||
|
||||
// Maps from KeyType to index of mapped buffers
|
||||
std::map<KeyType, int> _indexMap;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#include "pixelbuffercontainer.inl"
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___PIXEL_BUFFER_CONTAINER___H__
|
||||
|
||||
@@ -1,130 +1,130 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
template <class KeyType>
|
||||
PixelBufferContainer<KeyType>::PixelBufferContainer(size_t numBytesPerBuffer,
|
||||
PixelBuffer::Usage usage, size_t numPixelBuffers)
|
||||
: _usage(usage)
|
||||
{
|
||||
for (size_t i = 0; i < numPixelBuffers; ++i) {
|
||||
_pixelBuffers.push_back(std::make_unique<PixelBuffer>(numBytesPerBuffer, _usage));
|
||||
}
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
void* PixelBufferContainer<KeyType>::mapBuffer(KeyType key, PixelBuffer::Access access) {
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
const bool notFoundAmongMappedBuffers = (iter == _indexMap.end());
|
||||
|
||||
if (!notFoundAmongMappedBuffers) { // This PBO is already mapped
|
||||
ghoul_assert(_pixelBuffers[iter->second], "Incorrect index map");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Find a pixel buffer that is unmapped
|
||||
for (size_t i = 0; i < _pixelBuffers.size(); ++i) {
|
||||
if (!_pixelBuffers[i]->isMapped()) {
|
||||
_pixelBuffers[i]->bind();
|
||||
void* dataPtr = _pixelBuffers[i]->mapBuffer(access);
|
||||
_pixelBuffers[i]->unbind();
|
||||
if (dataPtr) { // Success in mapping
|
||||
// Add this index to the map of mapped pixel buffers
|
||||
_indexMap.emplace(key, i);
|
||||
return dataPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
void* PixelBufferContainer<KeyType>::mapBufferRange(KeyType key, GLintptr offset,
|
||||
GLsizeiptr length, BufferAccessMask access)
|
||||
{
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
bool notFoundAmongMappedBuffers = iter == _indexMap.end();
|
||||
|
||||
if (!notFoundAmongMappedBuffers) { // This PBO is already mapped
|
||||
ghoul_assert(_pixelBuffers[iter->second], "Incorrect index map");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Find a pixel buffer that is unmapped
|
||||
for (int i = 0; i < _pixelBuffers.size(); ++i) {
|
||||
bool bufferIsMapped = _pixelBuffers[i]->isMapped();
|
||||
if (!bufferIsMapped) {
|
||||
_pixelBuffers[i]->bind();
|
||||
void* dataPtr = _pixelBuffers[i]->mapBufferRange(offset, length, access);
|
||||
_pixelBuffers[i]->unbind();
|
||||
if (dataPtr) { // Success in mapping
|
||||
_indexMap.emplace(key, i);
|
||||
return dataPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
bool PixelBufferContainer<KeyType>::resetMappedBuffers() {
|
||||
bool success = true;
|
||||
for (auto iter = _indexMap.begin(); iter != _indexMap.end(); iter++) {
|
||||
int index = iter->second; // Index where the mapped buffer is stored
|
||||
_pixelBuffers[index]->bind();
|
||||
success &= _pixelBuffers[index]->unMapBuffer();
|
||||
_pixelBuffers[index]->unbind();
|
||||
_indexMap.erase(iter); // This key should no longer be among the mapped buffers
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
bool PixelBufferContainer<KeyType>::unMapBuffer(KeyType key) {
|
||||
bool success = false;
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
if (iter != _indexMap.end()) { // Found a mapped pixel buffer
|
||||
int index = iter->second; // Index where the mapped buffer is stored
|
||||
_pixelBuffers[index]->bind();
|
||||
success = _pixelBuffers[index]->unMapBuffer();
|
||||
_pixelBuffers[index]->unbind();
|
||||
_indexMap.erase(iter); // This key should no longer be among the mapped buffers
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
GLuint PixelBufferContainer<KeyType>::idOfMappedBuffer(KeyType key) {
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
if (iter != _indexMap.end()) { // Found a mapped pixel buffer
|
||||
int index = iter->second; // Index where the mapped buffer is stored
|
||||
return *_pixelBuffers[index];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
template <class KeyType>
|
||||
PixelBufferContainer<KeyType>::PixelBufferContainer(size_t numBytesPerBuffer,
|
||||
PixelBuffer::Usage usage, size_t numPixelBuffers)
|
||||
: _usage(usage)
|
||||
{
|
||||
for (size_t i = 0; i < numPixelBuffers; ++i) {
|
||||
_pixelBuffers.push_back(std::make_unique<PixelBuffer>(numBytesPerBuffer, _usage));
|
||||
}
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
void* PixelBufferContainer<KeyType>::mapBuffer(KeyType key, PixelBuffer::Access access) {
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
const bool notFoundAmongMappedBuffers = (iter == _indexMap.end());
|
||||
|
||||
if (!notFoundAmongMappedBuffers) { // This PBO is already mapped
|
||||
ghoul_assert(_pixelBuffers[iter->second], "Incorrect index map");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Find a pixel buffer that is unmapped
|
||||
for (size_t i = 0; i < _pixelBuffers.size(); ++i) {
|
||||
if (!_pixelBuffers[i]->isMapped()) {
|
||||
_pixelBuffers[i]->bind();
|
||||
void* dataPtr = _pixelBuffers[i]->mapBuffer(access);
|
||||
_pixelBuffers[i]->unbind();
|
||||
if (dataPtr) { // Success in mapping
|
||||
// Add this index to the map of mapped pixel buffers
|
||||
_indexMap.emplace(key, i);
|
||||
return dataPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
void* PixelBufferContainer<KeyType>::mapBufferRange(KeyType key, GLintptr offset,
|
||||
GLsizeiptr length, BufferAccessMask access)
|
||||
{
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
bool notFoundAmongMappedBuffers = iter == _indexMap.end();
|
||||
|
||||
if (!notFoundAmongMappedBuffers) { // This PBO is already mapped
|
||||
ghoul_assert(_pixelBuffers[iter->second], "Incorrect index map");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Find a pixel buffer that is unmapped
|
||||
for (int i = 0; i < _pixelBuffers.size(); ++i) {
|
||||
bool bufferIsMapped = _pixelBuffers[i]->isMapped();
|
||||
if (!bufferIsMapped) {
|
||||
_pixelBuffers[i]->bind();
|
||||
void* dataPtr = _pixelBuffers[i]->mapBufferRange(offset, length, access);
|
||||
_pixelBuffers[i]->unbind();
|
||||
if (dataPtr) { // Success in mapping
|
||||
_indexMap.emplace(key, i);
|
||||
return dataPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
bool PixelBufferContainer<KeyType>::resetMappedBuffers() {
|
||||
bool success = true;
|
||||
for (auto iter = _indexMap.begin(); iter != _indexMap.end(); iter++) {
|
||||
int index = iter->second; // Index where the mapped buffer is stored
|
||||
_pixelBuffers[index]->bind();
|
||||
success &= _pixelBuffers[index]->unMapBuffer();
|
||||
_pixelBuffers[index]->unbind();
|
||||
_indexMap.erase(iter); // This key should no longer be among the mapped buffers
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
bool PixelBufferContainer<KeyType>::unMapBuffer(KeyType key) {
|
||||
bool success = false;
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
if (iter != _indexMap.end()) { // Found a mapped pixel buffer
|
||||
int index = iter->second; // Index where the mapped buffer is stored
|
||||
_pixelBuffers[index]->bind();
|
||||
success = _pixelBuffers[index]->unMapBuffer();
|
||||
_pixelBuffers[index]->unbind();
|
||||
_indexMap.erase(iter); // This key should no longer be among the mapped buffers
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
template <class KeyType>
|
||||
GLuint PixelBufferContainer<KeyType>::idOfMappedBuffer(KeyType key) {
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
if (iter != _indexMap.end()) { // Found a mapped pixel buffer
|
||||
int index = iter->second; // Index where the mapped buffer is stored
|
||||
return *_pixelBuffers[index];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,61 +1,61 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__
|
||||
|
||||
#include <modules/globebrowsing/tile/tile.h>
|
||||
#include <modules/globebrowsing/tile/textureformat.h>
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
#include <gdal.h>
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
namespace tiledatatype {
|
||||
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
GLenum getOpenGLDataType(GDALDataType gdalType);
|
||||
GDALDataType getGdalDataType(GLenum glType);
|
||||
TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType);
|
||||
TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType);
|
||||
size_t getMaximumValue(GDALDataType gdalType);
|
||||
size_t numberOfBytes(GDALDataType gdalType);
|
||||
float interpretFloat(GDALDataType gdalType, const char* src);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format);
|
||||
size_t numberOfRasters(ghoul::opengl::Texture::Format format);
|
||||
size_t numberOfBytes(GLenum glType);
|
||||
size_t getMaximumValue(GLenum glType);
|
||||
float interpretFloat(GLenum glType, const char* src);
|
||||
|
||||
} // namespace tiledatatype
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__
|
||||
|
||||
#include <modules/globebrowsing/tile/tile.h>
|
||||
#include <modules/globebrowsing/tile/textureformat.h>
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
#include <gdal.h>
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
namespace tiledatatype {
|
||||
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
GLenum getOpenGLDataType(GDALDataType gdalType);
|
||||
GDALDataType getGdalDataType(GLenum glType);
|
||||
TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType);
|
||||
TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType);
|
||||
size_t getMaximumValue(GDALDataType gdalType);
|
||||
size_t numberOfBytes(GDALDataType gdalType);
|
||||
float interpretFloat(GDALDataType gdalType, const char* src);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format);
|
||||
size_t numberOfRasters(ghoul::opengl::Texture::Format format);
|
||||
size_t numberOfBytes(GLenum glType);
|
||||
size_t getMaximumValue(GLenum glType);
|
||||
float interpretFloat(GLenum glType, const char* src);
|
||||
|
||||
} // namespace tiledatatype
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_DATA_TYPE___H__
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
struct TextureFormat {
|
||||
ghoul::opengl::Texture::Format ghoulFormat;
|
||||
GLenum glFormat;
|
||||
};
|
||||
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
struct TextureFormat {
|
||||
ghoul::opengl::Texture::Format ghoulFormat;
|
||||
GLenum glFormat;
|
||||
};
|
||||
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TEXTUREFORMAT___H__
|
||||
|
||||
@@ -1,152 +1,152 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/tile/tiletextureinitdata.h>
|
||||
#include <modules/globebrowsing/tile/rawtiledatareader/tiledatatype.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
const glm::ivec2 TileTextureInitData::tilePixelStartOffset = glm::ivec2(-2);
|
||||
const glm::ivec2 TileTextureInitData::tilePixelSizeDifference = glm::ivec2(4);
|
||||
|
||||
TileTextureInitData::TileTextureInitData(size_t width, size_t height, GLenum glType,
|
||||
Format textureFormat, ShouldAllocateDataOnCPU shouldAllocateDataOnCPU)
|
||||
: _glType(glType)
|
||||
, _ghoulTextureFormat(textureFormat)
|
||||
, _shouldAllocateDataOnCPU(shouldAllocateDataOnCPU)
|
||||
{
|
||||
_dimensionsWithoutPadding = glm::ivec3(width, height, 1);
|
||||
_dimensionsWithPadding = glm::ivec3(
|
||||
width + tilePixelSizeDifference.x, height + tilePixelSizeDifference.y, 1);
|
||||
_nRasters = tiledatatype::numberOfRasters(_ghoulTextureFormat);
|
||||
_bytesPerDatum = tiledatatype::numberOfBytes(glType);
|
||||
_bytesPerPixel = _nRasters * _bytesPerDatum;
|
||||
_bytesPerLine = _bytesPerPixel * _dimensionsWithPadding.x;
|
||||
_totalNumBytes = _bytesPerLine * _dimensionsWithPadding.y;
|
||||
_glTextureFormat = tiledatatype::glTextureFormat(_glType,
|
||||
_ghoulTextureFormat);
|
||||
calculateHashKey();
|
||||
};
|
||||
|
||||
TileTextureInitData::TileTextureInitData(const TileTextureInitData& original)
|
||||
: TileTextureInitData(
|
||||
original.dimensionsWithoutPadding().x,
|
||||
original.dimensionsWithoutPadding().y,
|
||||
original.glType(),
|
||||
original.ghoulTextureFormat(),
|
||||
original.shouldAllocateDataOnCPU() ? ShouldAllocateDataOnCPU::Yes : ShouldAllocateDataOnCPU::No)
|
||||
{ };
|
||||
|
||||
glm::ivec3 TileTextureInitData::dimensionsWithPadding() const {
|
||||
return _dimensionsWithPadding;
|
||||
}
|
||||
|
||||
glm::ivec3 TileTextureInitData::dimensionsWithoutPadding() const {
|
||||
return _dimensionsWithoutPadding;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::nRasters() const {
|
||||
return _nRasters;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::bytesPerDatum() const {
|
||||
return _bytesPerDatum;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::bytesPerPixel() const {
|
||||
return _bytesPerPixel;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::bytesPerLine() const {
|
||||
return _bytesPerLine;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::totalNumBytes() const {
|
||||
return _totalNumBytes;
|
||||
}
|
||||
|
||||
GLenum TileTextureInitData::glType() const {
|
||||
return _glType;
|
||||
}
|
||||
|
||||
TileTextureInitData::Format TileTextureInitData::ghoulTextureFormat() const {
|
||||
return _ghoulTextureFormat;
|
||||
}
|
||||
|
||||
GLenum TileTextureInitData::glTextureFormat() const {
|
||||
return _glTextureFormat;
|
||||
}
|
||||
|
||||
bool TileTextureInitData::shouldAllocateDataOnCPU() const {
|
||||
return _shouldAllocateDataOnCPU;
|
||||
}
|
||||
|
||||
TileTextureInitData::HashKey TileTextureInitData::hashKey() const {
|
||||
return _hashKey;
|
||||
}
|
||||
|
||||
void TileTextureInitData::calculateHashKey() {
|
||||
ghoul_assert(_dimensionsWithoutPadding.x > 0, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.y > 0, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.x <= 1024, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.y <= 1024, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.z == 1, "Incorrect dimension");
|
||||
unsigned int format = getUniqueIdFromTextureFormat(_ghoulTextureFormat);
|
||||
ghoul_assert(format < 256, "Incorrect format");
|
||||
|
||||
_hashKey = 0LL;
|
||||
|
||||
_hashKey |= _dimensionsWithoutPadding.x;
|
||||
_hashKey |= _dimensionsWithoutPadding.y << 10;
|
||||
_hashKey |= static_cast<std::underlying_type_t<GLenum>>(_glType) << (10 + 16);
|
||||
_hashKey |= format << (10 + 16 + 4);
|
||||
};
|
||||
|
||||
unsigned int TileTextureInitData::getUniqueIdFromTextureFormat(
|
||||
Format textureFormat) const
|
||||
{
|
||||
using Format = Format;
|
||||
switch (textureFormat) {
|
||||
case Format::Red:
|
||||
return 0;
|
||||
case Format::RG:
|
||||
return 1;
|
||||
case Format::RGB:
|
||||
return 2;
|
||||
case Format::BGR:
|
||||
return 3;
|
||||
case Format::RGBA:
|
||||
return 4;
|
||||
case Format::BGRA:
|
||||
return 5;
|
||||
case Format::DepthComponent:
|
||||
return 6;
|
||||
default:
|
||||
ghoul_assert(false, "Unknown texture format");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/globebrowsing/tile/tiletextureinitdata.h>
|
||||
#include <modules/globebrowsing/tile/rawtiledatareader/tiledatatype.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
const glm::ivec2 TileTextureInitData::tilePixelStartOffset = glm::ivec2(-2);
|
||||
const glm::ivec2 TileTextureInitData::tilePixelSizeDifference = glm::ivec2(4);
|
||||
|
||||
TileTextureInitData::TileTextureInitData(size_t width, size_t height, GLenum glType,
|
||||
Format textureFormat, ShouldAllocateDataOnCPU shouldAllocateDataOnCPU)
|
||||
: _glType(glType)
|
||||
, _ghoulTextureFormat(textureFormat)
|
||||
, _shouldAllocateDataOnCPU(shouldAllocateDataOnCPU)
|
||||
{
|
||||
_dimensionsWithoutPadding = glm::ivec3(width, height, 1);
|
||||
_dimensionsWithPadding = glm::ivec3(
|
||||
width + tilePixelSizeDifference.x, height + tilePixelSizeDifference.y, 1);
|
||||
_nRasters = tiledatatype::numberOfRasters(_ghoulTextureFormat);
|
||||
_bytesPerDatum = tiledatatype::numberOfBytes(glType);
|
||||
_bytesPerPixel = _nRasters * _bytesPerDatum;
|
||||
_bytesPerLine = _bytesPerPixel * _dimensionsWithPadding.x;
|
||||
_totalNumBytes = _bytesPerLine * _dimensionsWithPadding.y;
|
||||
_glTextureFormat = tiledatatype::glTextureFormat(_glType,
|
||||
_ghoulTextureFormat);
|
||||
calculateHashKey();
|
||||
};
|
||||
|
||||
TileTextureInitData::TileTextureInitData(const TileTextureInitData& original)
|
||||
: TileTextureInitData(
|
||||
original.dimensionsWithoutPadding().x,
|
||||
original.dimensionsWithoutPadding().y,
|
||||
original.glType(),
|
||||
original.ghoulTextureFormat(),
|
||||
original.shouldAllocateDataOnCPU() ? ShouldAllocateDataOnCPU::Yes : ShouldAllocateDataOnCPU::No)
|
||||
{ };
|
||||
|
||||
glm::ivec3 TileTextureInitData::dimensionsWithPadding() const {
|
||||
return _dimensionsWithPadding;
|
||||
}
|
||||
|
||||
glm::ivec3 TileTextureInitData::dimensionsWithoutPadding() const {
|
||||
return _dimensionsWithoutPadding;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::nRasters() const {
|
||||
return _nRasters;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::bytesPerDatum() const {
|
||||
return _bytesPerDatum;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::bytesPerPixel() const {
|
||||
return _bytesPerPixel;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::bytesPerLine() const {
|
||||
return _bytesPerLine;
|
||||
}
|
||||
|
||||
size_t TileTextureInitData::totalNumBytes() const {
|
||||
return _totalNumBytes;
|
||||
}
|
||||
|
||||
GLenum TileTextureInitData::glType() const {
|
||||
return _glType;
|
||||
}
|
||||
|
||||
TileTextureInitData::Format TileTextureInitData::ghoulTextureFormat() const {
|
||||
return _ghoulTextureFormat;
|
||||
}
|
||||
|
||||
GLenum TileTextureInitData::glTextureFormat() const {
|
||||
return _glTextureFormat;
|
||||
}
|
||||
|
||||
bool TileTextureInitData::shouldAllocateDataOnCPU() const {
|
||||
return _shouldAllocateDataOnCPU;
|
||||
}
|
||||
|
||||
TileTextureInitData::HashKey TileTextureInitData::hashKey() const {
|
||||
return _hashKey;
|
||||
}
|
||||
|
||||
void TileTextureInitData::calculateHashKey() {
|
||||
ghoul_assert(_dimensionsWithoutPadding.x > 0, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.y > 0, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.x <= 1024, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.y <= 1024, "Incorrect dimension");
|
||||
ghoul_assert(_dimensionsWithoutPadding.z == 1, "Incorrect dimension");
|
||||
unsigned int format = getUniqueIdFromTextureFormat(_ghoulTextureFormat);
|
||||
ghoul_assert(format < 256, "Incorrect format");
|
||||
|
||||
_hashKey = 0LL;
|
||||
|
||||
_hashKey |= _dimensionsWithoutPadding.x;
|
||||
_hashKey |= _dimensionsWithoutPadding.y << 10;
|
||||
_hashKey |= static_cast<std::underlying_type_t<GLenum>>(_glType) << (10 + 16);
|
||||
_hashKey |= format << (10 + 16 + 4);
|
||||
};
|
||||
|
||||
unsigned int TileTextureInitData::getUniqueIdFromTextureFormat(
|
||||
Format textureFormat) const
|
||||
{
|
||||
using Format = Format;
|
||||
switch (textureFormat) {
|
||||
case Format::Red:
|
||||
return 0;
|
||||
case Format::RG:
|
||||
return 1;
|
||||
case Format::RGB:
|
||||
return 2;
|
||||
case Format::BGR:
|
||||
return 3;
|
||||
case Format::RGBA:
|
||||
return 4;
|
||||
case Format::BGRA:
|
||||
return 5;
|
||||
case Format::DepthComponent:
|
||||
return 6;
|
||||
default:
|
||||
ghoul_assert(false, "Unknown texture format");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_TEXTURE_INIT_DATA___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_TEXTURE_INIT_DATA___H__
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/**
|
||||
* All information needed to create a texture used for a Tile.
|
||||
*/
|
||||
class TileTextureInitData
|
||||
{
|
||||
public:
|
||||
using HashKey = unsigned long long;
|
||||
using ShouldAllocateDataOnCPU = ghoul::Boolean;
|
||||
using Format = ghoul::opengl::Texture::Format;
|
||||
|
||||
TileTextureInitData(size_t width, size_t height, GLenum glType, Format textureFormat,
|
||||
ShouldAllocateDataOnCPU shouldAllocateDataOnCPU = ShouldAllocateDataOnCPU::No);
|
||||
|
||||
TileTextureInitData(const TileTextureInitData& original);
|
||||
|
||||
~TileTextureInitData() = default;
|
||||
|
||||
glm::ivec3 dimensionsWithPadding() const;
|
||||
glm::ivec3 dimensionsWithoutPadding() const;
|
||||
size_t nRasters() const;
|
||||
size_t bytesPerDatum() const;
|
||||
size_t bytesPerPixel() const;
|
||||
size_t bytesPerLine() const;
|
||||
size_t totalNumBytes() const;
|
||||
GLenum glType() const;
|
||||
Format ghoulTextureFormat() const;
|
||||
GLenum glTextureFormat() const;
|
||||
bool shouldAllocateDataOnCPU() const;
|
||||
HashKey hashKey() const;
|
||||
|
||||
const static glm::ivec2 tilePixelStartOffset;
|
||||
const static glm::ivec2 tilePixelSizeDifference;
|
||||
|
||||
private:
|
||||
void calculateHashKey();
|
||||
unsigned int getUniqueIdFromTextureFormat(Format textureFormat) const;
|
||||
|
||||
HashKey _hashKey;
|
||||
glm::ivec3 _dimensionsWithPadding;
|
||||
glm::ivec3 _dimensionsWithoutPadding;
|
||||
GLenum _glType;
|
||||
Format _ghoulTextureFormat;
|
||||
GLenum _glTextureFormat;
|
||||
size_t _nRasters;
|
||||
size_t _bytesPerDatum;
|
||||
size_t _bytesPerPixel;
|
||||
size_t _bytesPerLine;
|
||||
size_t _totalNumBytes;
|
||||
bool _shouldAllocateDataOnCPU;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_TEXTURE_INIT_DATA___H__
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_GLOBEBROWSING___TILE_TEXTURE_INIT_DATA___H__
|
||||
#define __OPENSPACE_MODULE_GLOBEBROWSING___TILE_TEXTURE_INIT_DATA___H__
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
/**
|
||||
* All information needed to create a texture used for a Tile.
|
||||
*/
|
||||
class TileTextureInitData
|
||||
{
|
||||
public:
|
||||
using HashKey = unsigned long long;
|
||||
using ShouldAllocateDataOnCPU = ghoul::Boolean;
|
||||
using Format = ghoul::opengl::Texture::Format;
|
||||
|
||||
TileTextureInitData(size_t width, size_t height, GLenum glType, Format textureFormat,
|
||||
ShouldAllocateDataOnCPU shouldAllocateDataOnCPU = ShouldAllocateDataOnCPU::No);
|
||||
|
||||
TileTextureInitData(const TileTextureInitData& original);
|
||||
|
||||
~TileTextureInitData() = default;
|
||||
|
||||
glm::ivec3 dimensionsWithPadding() const;
|
||||
glm::ivec3 dimensionsWithoutPadding() const;
|
||||
size_t nRasters() const;
|
||||
size_t bytesPerDatum() const;
|
||||
size_t bytesPerPixel() const;
|
||||
size_t bytesPerLine() const;
|
||||
size_t totalNumBytes() const;
|
||||
GLenum glType() const;
|
||||
Format ghoulTextureFormat() const;
|
||||
GLenum glTextureFormat() const;
|
||||
bool shouldAllocateDataOnCPU() const;
|
||||
HashKey hashKey() const;
|
||||
|
||||
const static glm::ivec2 tilePixelStartOffset;
|
||||
const static glm::ivec2 tilePixelSizeDifference;
|
||||
|
||||
private:
|
||||
void calculateHashKey();
|
||||
unsigned int getUniqueIdFromTextureFormat(Format textureFormat) const;
|
||||
|
||||
HashKey _hashKey;
|
||||
glm::ivec3 _dimensionsWithPadding;
|
||||
glm::ivec3 _dimensionsWithoutPadding;
|
||||
GLenum _glType;
|
||||
Format _ghoulTextureFormat;
|
||||
GLenum _glTextureFormat;
|
||||
size_t _nRasters;
|
||||
size_t _bytesPerDatum;
|
||||
size_t _bytesPerPixel;
|
||||
size_t _bytesPerLine;
|
||||
size_t _totalNumBytes;
|
||||
bool _shouldAllocateDataOnCPU;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_GLOBEBROWSING___TILE_TEXTURE_INIT_DATA___H__
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,57 +1,57 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
|
||||
#define __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <modules/volume/rawvolume.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
template <typename VoxelType>
|
||||
class RawVolumeWriter {
|
||||
public:
|
||||
RawVolumeWriter(std::string path, size_t bufferSize = 1024);
|
||||
void setPath(const std::string& path);
|
||||
glm::uvec3 dimensions() const;
|
||||
void setDimensions(const glm::uvec3& dimensions);
|
||||
void write(const std::function<VoxelType(const glm::uvec3&)>& fn,
|
||||
const std::function<void(float t)>& onProgress = [](float t) {});
|
||||
void write(const RawVolume<VoxelType>& volume);
|
||||
|
||||
size_t coordsToIndex(const glm::uvec3& coords) const;
|
||||
glm::ivec3 indexToCoords(size_t linear) const;
|
||||
private:
|
||||
glm::ivec3 _dimensions;
|
||||
std::string _path;
|
||||
size_t _bufferSize;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#include "rawvolumewriter.inl"
|
||||
|
||||
#endif // __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
|
||||
#define __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <modules/volume/rawvolume.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
template <typename VoxelType>
|
||||
class RawVolumeWriter {
|
||||
public:
|
||||
RawVolumeWriter(std::string path, size_t bufferSize = 1024);
|
||||
void setPath(const std::string& path);
|
||||
glm::uvec3 dimensions() const;
|
||||
void setDimensions(const glm::uvec3& dimensions);
|
||||
void write(const std::function<VoxelType(const glm::uvec3&)>& fn,
|
||||
const std::function<void(float t)>& onProgress = [](float t) {});
|
||||
void write(const RawVolume<VoxelType>& volume);
|
||||
|
||||
size_t coordsToIndex(const glm::uvec3& coords) const;
|
||||
glm::ivec3 indexToCoords(size_t linear) const;
|
||||
private:
|
||||
glm::ivec3 _dimensions;
|
||||
std::string _path;
|
||||
size_t _bufferSize;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#include "rawvolumewriter.inl"
|
||||
|
||||
#endif // __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
|
||||
|
||||
194
openspace.cfg
194
openspace.cfg
@@ -1,97 +1,97 @@
|
||||
-- The configuration has an implict
|
||||
-- require('scripts/configuration_helper.lua')
|
||||
-- which defines helper functions useful to customize the configuration
|
||||
|
||||
return {
|
||||
-- Determines which SGCT configuration file is loaded, that is, if there rendering
|
||||
-- occurs in a single window, a fisheye projection, or a dome cluster system
|
||||
|
||||
-- A regular 1280x720 window
|
||||
SGCTConfig = sgct.config.single{},
|
||||
|
||||
-- A regular 1920x1080 window
|
||||
-- SGCTConfig = sgct.config.single{1920, 1080},
|
||||
|
||||
-- A 1k fisheye rendering
|
||||
-- SGCTConfig = sgct.config.fisheye{1024, 1024},
|
||||
|
||||
-- A 4k fisheye rendering in a 1024x1024 window
|
||||
-- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27},
|
||||
|
||||
-- Streaming OpenSpace via Spout to OBS
|
||||
-- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"},
|
||||
|
||||
|
||||
--SGCTConfig = "${CONFIG}/openvr_oculusRiftCv1.xml",
|
||||
--SGCTConfig = "${CONFIG}/openvr_htcVive.xml",
|
||||
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
Scene = "${SCENE}/default.scene",
|
||||
-- Scene = "${SCENE}/globebrowsing.scene",
|
||||
-- Scene = "${SCENE}/rosetta.scene",
|
||||
-- Scene = "${SCENE}/dawn.scene",
|
||||
-- Scene = "${SCENE}/newhorizons.scene",
|
||||
-- Scene = "${SCENE}/osirisrex.scene",
|
||||
|
||||
Task = "${TASKS}/default.task",
|
||||
|
||||
Paths = {
|
||||
SCRIPTS = "${BASE_PATH}/scripts",
|
||||
SHADERS = "${BASE_PATH}/shaders",
|
||||
OPENSPACE_DATA = "${BASE_PATH}/data",
|
||||
SCENE = "${OPENSPACE_DATA}/scene",
|
||||
TASKS = "${OPENSPACE_DATA}/tasks",
|
||||
SPICE = "${OPENSPACE_DATA}/spice",
|
||||
MODULES = "${BASE_PATH}/modules",
|
||||
TESTDIR = "${BASE_PATH}/tests",
|
||||
CONFIG = "${BASE_PATH}/config",
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
DOCUMENTATION = "${BASE_PATH}/documentation",
|
||||
LOGS = "${BASE_PATH}/logs"
|
||||
},
|
||||
Fonts = {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf",
|
||||
Console = "${FONTS}/Inconsolata/Inconsolata-Regular.ttf"
|
||||
},
|
||||
Logging = {
|
||||
LogDir = "${LOGS}",
|
||||
-- LogLevel = "Trace",
|
||||
LogLevel = "Debug",
|
||||
ImmediateFlush = true,
|
||||
Logs = {
|
||||
{ Type = "html", File = "${LOGS}/log.html", Append = false }
|
||||
},
|
||||
CapabilitiesVerbosity = "Full"
|
||||
},
|
||||
Launcher = {
|
||||
LogLevel = "None"
|
||||
},
|
||||
LuaDocumentation = "${DOCUMENTATION}/LuaScripting.html",
|
||||
PropertyDocumentation = "${DOCUMENTATION}/Properties.html",
|
||||
ScriptLog = "${LOGS}/ScriptLog.txt",
|
||||
KeyboardShortcuts = "${DOCUMENTATION}/KeyboardMapping.html",
|
||||
Documentation = "${DOCUMENTATION}/Documentation.html",
|
||||
FactoryDocumentation = "${DOCUMENTATION}/FactoryDocumentation.html",
|
||||
|
||||
ShutdownCountdown = 3,
|
||||
-- OnScreenTextScaling = "framebuffer",
|
||||
-- PerSceneCache = true,
|
||||
-- DisableRenderingOnMaster = true,
|
||||
-- DisableSceneOnMaster = true,
|
||||
DownloadRequestURL = "http://data.openspaceproject.com/request.cgi",
|
||||
RenderingMethod = "Framebuffer",
|
||||
OpenGLDebugContext = {
|
||||
Activate = true,
|
||||
FilterIdentifier = {
|
||||
{ Type = "Other", Source = "API", Identifier = 131185 },
|
||||
{ Type = "Performance", Source = "API", Identifier = 131186 }, --Buffer performance warning: "copied/moved from VIDEO memory to HOST memory"
|
||||
{ Type = "Deprecated", Source = "API", Identifier = 7} -- API_ID_LINE_WIDTH deprecated behavior warning has been generated
|
||||
},
|
||||
-- FilterSeverity = { }
|
||||
|
||||
}
|
||||
--RenderingMethod = "ABuffer" -- alternative: "Framebuffer"
|
||||
}
|
||||
-- The configuration has an implict
|
||||
-- require('scripts/configuration_helper.lua')
|
||||
-- which defines helper functions useful to customize the configuration
|
||||
|
||||
return {
|
||||
-- Determines which SGCT configuration file is loaded, that is, if there rendering
|
||||
-- occurs in a single window, a fisheye projection, or a dome cluster system
|
||||
|
||||
-- A regular 1280x720 window
|
||||
SGCTConfig = sgct.config.single{},
|
||||
|
||||
-- A regular 1920x1080 window
|
||||
-- SGCTConfig = sgct.config.single{1920, 1080},
|
||||
|
||||
-- A 1k fisheye rendering
|
||||
-- SGCTConfig = sgct.config.fisheye{1024, 1024},
|
||||
|
||||
-- A 4k fisheye rendering in a 1024x1024 window
|
||||
-- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27},
|
||||
|
||||
-- Streaming OpenSpace via Spout to OBS
|
||||
-- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"},
|
||||
|
||||
|
||||
--SGCTConfig = "${CONFIG}/openvr_oculusRiftCv1.xml",
|
||||
--SGCTConfig = "${CONFIG}/openvr_htcVive.xml",
|
||||
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
Scene = "${SCENE}/default.scene",
|
||||
-- Scene = "${SCENE}/globebrowsing.scene",
|
||||
-- Scene = "${SCENE}/rosetta.scene",
|
||||
-- Scene = "${SCENE}/dawn.scene",
|
||||
-- Scene = "${SCENE}/newhorizons.scene",
|
||||
-- Scene = "${SCENE}/osirisrex.scene",
|
||||
|
||||
Task = "${TASKS}/default.task",
|
||||
|
||||
Paths = {
|
||||
SCRIPTS = "${BASE_PATH}/scripts",
|
||||
SHADERS = "${BASE_PATH}/shaders",
|
||||
OPENSPACE_DATA = "${BASE_PATH}/data",
|
||||
SCENE = "${OPENSPACE_DATA}/scene",
|
||||
TASKS = "${OPENSPACE_DATA}/tasks",
|
||||
SPICE = "${OPENSPACE_DATA}/spice",
|
||||
MODULES = "${BASE_PATH}/modules",
|
||||
TESTDIR = "${BASE_PATH}/tests",
|
||||
CONFIG = "${BASE_PATH}/config",
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
DOCUMENTATION = "${BASE_PATH}/documentation",
|
||||
LOGS = "${BASE_PATH}/logs"
|
||||
},
|
||||
Fonts = {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf",
|
||||
Console = "${FONTS}/Inconsolata/Inconsolata-Regular.ttf"
|
||||
},
|
||||
Logging = {
|
||||
LogDir = "${LOGS}",
|
||||
-- LogLevel = "Trace",
|
||||
LogLevel = "Debug",
|
||||
ImmediateFlush = true,
|
||||
Logs = {
|
||||
{ Type = "html", File = "${LOGS}/log.html", Append = false }
|
||||
},
|
||||
CapabilitiesVerbosity = "Full"
|
||||
},
|
||||
Launcher = {
|
||||
LogLevel = "None"
|
||||
},
|
||||
LuaDocumentation = "${DOCUMENTATION}/LuaScripting.html",
|
||||
PropertyDocumentation = "${DOCUMENTATION}/Properties.html",
|
||||
ScriptLog = "${LOGS}/ScriptLog.txt",
|
||||
KeyboardShortcuts = "${DOCUMENTATION}/KeyboardMapping.html",
|
||||
Documentation = "${DOCUMENTATION}/Documentation.html",
|
||||
FactoryDocumentation = "${DOCUMENTATION}/FactoryDocumentation.html",
|
||||
|
||||
ShutdownCountdown = 3,
|
||||
-- OnScreenTextScaling = "framebuffer",
|
||||
-- PerSceneCache = true,
|
||||
-- DisableRenderingOnMaster = true,
|
||||
-- DisableSceneOnMaster = true,
|
||||
DownloadRequestURL = "http://data.openspaceproject.com/request.cgi",
|
||||
RenderingMethod = "Framebuffer",
|
||||
OpenGLDebugContext = {
|
||||
Activate = true,
|
||||
FilterIdentifier = {
|
||||
{ Type = "Other", Source = "API", Identifier = 131185 },
|
||||
{ Type = "Performance", Source = "API", Identifier = 131186 }, --Buffer performance warning: "copied/moved from VIDEO memory to HOST memory"
|
||||
{ Type = "Deprecated", Source = "API", Identifier = 7} -- API_ID_LINE_WIDTH deprecated behavior warning has been generated
|
||||
},
|
||||
-- FilterSeverity = { }
|
||||
|
||||
}
|
||||
--RenderingMethod = "ABuffer" -- alternative: "Framebuffer"
|
||||
}
|
||||
|
||||
@@ -1,248 +1,248 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/wrapper/sgctwindowwrapper.h>
|
||||
|
||||
#include "sgct.h"
|
||||
|
||||
#undef near
|
||||
#undef far
|
||||
|
||||
namespace {
|
||||
const char* GuiWindowTag = "GUI";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SGCTWindowWrapper::SGCTWindowWrapper()
|
||||
: _eyeSeparation("eyeSeparation", "Eye Separation", 0.f, 0.f, 10.f)
|
||||
, _showStatsGraph("showStatsGraph", "Show Stats Graph", false)
|
||||
{
|
||||
_showStatsGraph.onChange([this](){
|
||||
sgct::Engine::instance()->setStatsGraphVisibility(_showStatsGraph);
|
||||
});
|
||||
addProperty(_showStatsGraph);
|
||||
|
||||
addProperty(_eyeSeparation);
|
||||
_eyeSeparation.onChange([this](){
|
||||
setEyeSeparationDistance(_eyeSeparation);
|
||||
});
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::terminate() {
|
||||
sgct::Engine::instance()->terminate();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setBarrier(bool enabled) {
|
||||
sgct::SGCTWindow::setBarrier(enabled);
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setSynchronization(bool enabled) {
|
||||
sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled);
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::clearAllWindows(const glm::vec4& clearColor) {
|
||||
size_t n = sgct::Engine::instance()->getNumberOfWindows();
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
GLFWwindow* win = sgct::Engine::instance()->getWindowPtr(i)->getWindowHandle();
|
||||
glfwSwapBuffers(win);
|
||||
}
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::windowHasResized() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized();
|
||||
}
|
||||
|
||||
double SGCTWindowWrapper::averageDeltaTime() const {
|
||||
return sgct::Engine::instance()->getAvgDt();
|
||||
}
|
||||
|
||||
double SGCTWindowWrapper::deltaTime() const {
|
||||
return sgct::Engine::instance()->getDt();
|
||||
}
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::mousePosition() const {
|
||||
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
|
||||
double posX, posY;
|
||||
sgct::Engine::instance()->getMousePos(id, &posX, &posY);
|
||||
return glm::vec2(posX, posY);
|
||||
}
|
||||
|
||||
uint32_t SGCTWindowWrapper::mouseButtons(int maxNumber) const {
|
||||
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
|
||||
uint32_t result = 0;
|
||||
for (int i = 0; i < maxNumber; ++i) {
|
||||
bool button = (sgct::Engine::instance()->getMouseButton(id, i) != 0);
|
||||
if (button)
|
||||
result |= (1 << i);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentWindowSize() const {
|
||||
auto window = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
switch (window->getStereoMode()) {
|
||||
case sgct::SGCTWindow::Side_By_Side_Stereo:
|
||||
case sgct::SGCTWindow::Side_By_Side_Inverted_Stereo:
|
||||
return glm::ivec2(
|
||||
window->getXResolution() / 2,
|
||||
window->getYResolution());
|
||||
case sgct::SGCTWindow::Top_Bottom_Stereo:
|
||||
case sgct::SGCTWindow::Top_Bottom_Inverted_Stereo:
|
||||
return glm::ivec2(
|
||||
window->getXResolution(),
|
||||
window->getYResolution() / 2);
|
||||
default:
|
||||
return glm::ivec2(
|
||||
window->getXResolution(),
|
||||
window->getYResolution());
|
||||
}
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentWindowResolution() const {
|
||||
int x, y;
|
||||
auto window = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
window->getFinalFBODimensions(x, y);
|
||||
return glm::ivec2(x, y);
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentDrawBufferResolution() const {
|
||||
sgct_core::Viewport* viewport = sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0);
|
||||
if (viewport != nullptr){
|
||||
if (viewport->hasSubViewports() && viewport->getNonLinearProjectionPtr()) {
|
||||
int res = viewport->getNonLinearProjectionPtr()->getCubemapResolution();
|
||||
return glm::ivec2(res, res);
|
||||
} else {
|
||||
return currentWindowResolution();
|
||||
}
|
||||
}
|
||||
throw WindowWrapperException("No viewport available");
|
||||
}
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::dpiScaling() const {
|
||||
return glm::vec2(
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(),
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getYScale()
|
||||
);
|
||||
}
|
||||
|
||||
int SGCTWindowWrapper::currentNumberOfAaSamples() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples();
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isRegularRendering() const {
|
||||
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
std::size_t nViewports = w->getNumberOfViewports();
|
||||
(void)nViewports; // Unused in Release mode
|
||||
ghoul_assert(nViewports > 0, "At least one viewport must exist at this time");
|
||||
sgct_core::Viewport* vp = w->getViewport(0);
|
||||
sgct_core::NonLinearProjection* nlp = vp->getNonLinearProjectionPtr();
|
||||
return nlp == nullptr;
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::hasGuiWindow() const {
|
||||
auto engine = sgct::Engine::instance();
|
||||
for (size_t i = 0; i < engine->getNumberOfWindows(); ++i) {
|
||||
if (engine->getWindowPtr(i)->checkIfTagExists(GuiWindowTag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isGuiWindow() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->checkIfTagExists(
|
||||
GuiWindowTag
|
||||
);
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isMaster() const {
|
||||
return sgct::Engine::instance()->isMaster();
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isSwapGroupMaster() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isSwapGroupMaster();
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isUsingSwapGroups() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isUsingSwapGroups();
|
||||
}
|
||||
|
||||
glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
|
||||
return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix();
|
||||
}
|
||||
|
||||
glm::mat4 SGCTWindowWrapper::modelMatrix() const {
|
||||
return sgct::Engine::instance()->getModelMatrix();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) {
|
||||
sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane);
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setEyeSeparationDistance(float distance) {
|
||||
sgct::Engine::instance()->setEyeSeparation(distance);
|
||||
}
|
||||
|
||||
glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const {
|
||||
int x1, xSize, y1, ySize;
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1,
|
||||
y1,
|
||||
xSize,
|
||||
ySize);
|
||||
return glm::ivec4(x1, xSize, y1, ySize);
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isExternalControlConnected() const {
|
||||
return sgct::Engine::instance()->isExternalControlConnected();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
|
||||
sgct::Engine::instance()->sendMessageToExternalControl(
|
||||
message.data(),
|
||||
static_cast<int>(message.size())
|
||||
);
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isSimpleRendering() const {
|
||||
return (sgct::Engine::instance()->getCurrentRenderTarget() != sgct::Engine::NonLinearBuffer);
|
||||
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::takeScreenshot(bool applyWarping) const {
|
||||
sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping);
|
||||
sgct::Engine::instance()->takeScreenshot();
|
||||
}
|
||||
|
||||
//void forEachWindow(std::function<void (void)> function) {
|
||||
// size_t n = sgct::Engine::instance()->getNumberOfWindows();
|
||||
// for (size_t i = 0; i < n; ++i)
|
||||
// function();
|
||||
//}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/wrapper/sgctwindowwrapper.h>
|
||||
|
||||
#include "sgct.h"
|
||||
|
||||
#undef near
|
||||
#undef far
|
||||
|
||||
namespace {
|
||||
const char* GuiWindowTag = "GUI";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SGCTWindowWrapper::SGCTWindowWrapper()
|
||||
: _eyeSeparation("eyeSeparation", "Eye Separation", 0.f, 0.f, 10.f)
|
||||
, _showStatsGraph("showStatsGraph", "Show Stats Graph", false)
|
||||
{
|
||||
_showStatsGraph.onChange([this](){
|
||||
sgct::Engine::instance()->setStatsGraphVisibility(_showStatsGraph);
|
||||
});
|
||||
addProperty(_showStatsGraph);
|
||||
|
||||
addProperty(_eyeSeparation);
|
||||
_eyeSeparation.onChange([this](){
|
||||
setEyeSeparationDistance(_eyeSeparation);
|
||||
});
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::terminate() {
|
||||
sgct::Engine::instance()->terminate();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setBarrier(bool enabled) {
|
||||
sgct::SGCTWindow::setBarrier(enabled);
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setSynchronization(bool enabled) {
|
||||
sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled);
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::clearAllWindows(const glm::vec4& clearColor) {
|
||||
size_t n = sgct::Engine::instance()->getNumberOfWindows();
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
GLFWwindow* win = sgct::Engine::instance()->getWindowPtr(i)->getWindowHandle();
|
||||
glfwSwapBuffers(win);
|
||||
}
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::windowHasResized() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized();
|
||||
}
|
||||
|
||||
double SGCTWindowWrapper::averageDeltaTime() const {
|
||||
return sgct::Engine::instance()->getAvgDt();
|
||||
}
|
||||
|
||||
double SGCTWindowWrapper::deltaTime() const {
|
||||
return sgct::Engine::instance()->getDt();
|
||||
}
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::mousePosition() const {
|
||||
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
|
||||
double posX, posY;
|
||||
sgct::Engine::instance()->getMousePos(id, &posX, &posY);
|
||||
return glm::vec2(posX, posY);
|
||||
}
|
||||
|
||||
uint32_t SGCTWindowWrapper::mouseButtons(int maxNumber) const {
|
||||
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
|
||||
uint32_t result = 0;
|
||||
for (int i = 0; i < maxNumber; ++i) {
|
||||
bool button = (sgct::Engine::instance()->getMouseButton(id, i) != 0);
|
||||
if (button)
|
||||
result |= (1 << i);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentWindowSize() const {
|
||||
auto window = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
switch (window->getStereoMode()) {
|
||||
case sgct::SGCTWindow::Side_By_Side_Stereo:
|
||||
case sgct::SGCTWindow::Side_By_Side_Inverted_Stereo:
|
||||
return glm::ivec2(
|
||||
window->getXResolution() / 2,
|
||||
window->getYResolution());
|
||||
case sgct::SGCTWindow::Top_Bottom_Stereo:
|
||||
case sgct::SGCTWindow::Top_Bottom_Inverted_Stereo:
|
||||
return glm::ivec2(
|
||||
window->getXResolution(),
|
||||
window->getYResolution() / 2);
|
||||
default:
|
||||
return glm::ivec2(
|
||||
window->getXResolution(),
|
||||
window->getYResolution());
|
||||
}
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentWindowResolution() const {
|
||||
int x, y;
|
||||
auto window = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
window->getFinalFBODimensions(x, y);
|
||||
return glm::ivec2(x, y);
|
||||
}
|
||||
|
||||
glm::ivec2 SGCTWindowWrapper::currentDrawBufferResolution() const {
|
||||
sgct_core::Viewport* viewport = sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0);
|
||||
if (viewport != nullptr){
|
||||
if (viewport->hasSubViewports() && viewport->getNonLinearProjectionPtr()) {
|
||||
int res = viewport->getNonLinearProjectionPtr()->getCubemapResolution();
|
||||
return glm::ivec2(res, res);
|
||||
} else {
|
||||
return currentWindowResolution();
|
||||
}
|
||||
}
|
||||
throw WindowWrapperException("No viewport available");
|
||||
}
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::dpiScaling() const {
|
||||
return glm::vec2(
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(),
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getYScale()
|
||||
);
|
||||
}
|
||||
|
||||
int SGCTWindowWrapper::currentNumberOfAaSamples() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples();
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isRegularRendering() const {
|
||||
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
std::size_t nViewports = w->getNumberOfViewports();
|
||||
(void)nViewports; // Unused in Release mode
|
||||
ghoul_assert(nViewports > 0, "At least one viewport must exist at this time");
|
||||
sgct_core::Viewport* vp = w->getViewport(0);
|
||||
sgct_core::NonLinearProjection* nlp = vp->getNonLinearProjectionPtr();
|
||||
return nlp == nullptr;
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::hasGuiWindow() const {
|
||||
auto engine = sgct::Engine::instance();
|
||||
for (size_t i = 0; i < engine->getNumberOfWindows(); ++i) {
|
||||
if (engine->getWindowPtr(i)->checkIfTagExists(GuiWindowTag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isGuiWindow() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->checkIfTagExists(
|
||||
GuiWindowTag
|
||||
);
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isMaster() const {
|
||||
return sgct::Engine::instance()->isMaster();
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isSwapGroupMaster() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isSwapGroupMaster();
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isUsingSwapGroups() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isUsingSwapGroups();
|
||||
}
|
||||
|
||||
glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
|
||||
return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix();
|
||||
}
|
||||
|
||||
glm::mat4 SGCTWindowWrapper::modelMatrix() const {
|
||||
return sgct::Engine::instance()->getModelMatrix();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) {
|
||||
sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane);
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setEyeSeparationDistance(float distance) {
|
||||
sgct::Engine::instance()->setEyeSeparation(distance);
|
||||
}
|
||||
|
||||
glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const {
|
||||
int x1, xSize, y1, ySize;
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1,
|
||||
y1,
|
||||
xSize,
|
||||
ySize);
|
||||
return glm::ivec4(x1, xSize, y1, ySize);
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isExternalControlConnected() const {
|
||||
return sgct::Engine::instance()->isExternalControlConnected();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
|
||||
sgct::Engine::instance()->sendMessageToExternalControl(
|
||||
message.data(),
|
||||
static_cast<int>(message.size())
|
||||
);
|
||||
}
|
||||
|
||||
bool SGCTWindowWrapper::isSimpleRendering() const {
|
||||
return (sgct::Engine::instance()->getCurrentRenderTarget() != sgct::Engine::NonLinearBuffer);
|
||||
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::takeScreenshot(bool applyWarping) const {
|
||||
sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping);
|
||||
sgct::Engine::instance()->takeScreenshot();
|
||||
}
|
||||
|
||||
//void forEachWindow(std::function<void (void)> function) {
|
||||
// size_t n = sgct::Engine::instance()->getNumberOfWindows();
|
||||
// for (size_t i = 0; i < n; ++i)
|
||||
// function();
|
||||
//}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,62 +1,62 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
|
||||
#include <sgct/SharedData.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SyncBuffer::SyncBuffer(size_t n)
|
||||
: _n(n)
|
||||
, _encodeOffset(0)
|
||||
, _decodeOffset(0)
|
||||
, _synchronizationBuffer(new sgct::SharedVector<char>())
|
||||
{
|
||||
_dataStream.resize(_n);
|
||||
}
|
||||
|
||||
SyncBuffer::~SyncBuffer() {
|
||||
// The destructor is defined here, so that the otherwise default inlined destructor is
|
||||
// not created (which would make it impossible to use a forward declaration with
|
||||
// unique_ptr
|
||||
}
|
||||
|
||||
void SyncBuffer::write() {
|
||||
_dataStream.resize(_encodeOffset);
|
||||
_synchronizationBuffer->setVal(_dataStream);
|
||||
sgct::SharedData::instance()->writeVector(_synchronizationBuffer.get());
|
||||
_dataStream.resize(_n);
|
||||
_encodeOffset = 0;
|
||||
_decodeOffset = 0;
|
||||
}
|
||||
|
||||
void SyncBuffer::read() {
|
||||
sgct::SharedData::instance()->readVector(_synchronizationBuffer.get());
|
||||
_dataStream = _synchronizationBuffer->getVal();
|
||||
_encodeOffset = 0;
|
||||
_decodeOffset = 0;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
|
||||
#include <sgct/SharedData.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SyncBuffer::SyncBuffer(size_t n)
|
||||
: _n(n)
|
||||
, _encodeOffset(0)
|
||||
, _decodeOffset(0)
|
||||
, _synchronizationBuffer(new sgct::SharedVector<char>())
|
||||
{
|
||||
_dataStream.resize(_n);
|
||||
}
|
||||
|
||||
SyncBuffer::~SyncBuffer() {
|
||||
// The destructor is defined here, so that the otherwise default inlined destructor is
|
||||
// not created (which would make it impossible to use a forward declaration with
|
||||
// unique_ptr
|
||||
}
|
||||
|
||||
void SyncBuffer::write() {
|
||||
_dataStream.resize(_encodeOffset);
|
||||
_synchronizationBuffer->setVal(_dataStream);
|
||||
sgct::SharedData::instance()->writeVector(_synchronizationBuffer.get());
|
||||
_dataStream.resize(_n);
|
||||
_encodeOffset = 0;
|
||||
_decodeOffset = 0;
|
||||
}
|
||||
|
||||
void SyncBuffer::read() {
|
||||
sgct::SharedData::instance()->readVector(_synchronizationBuffer.get());
|
||||
_dataStream = _synchronizationBuffer->getVal();
|
||||
_encodeOffset = 0;
|
||||
_decodeOffset = 0;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user