mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-26 05:58:58 -06:00
merge master
This commit is contained in:
@@ -15,6 +15,7 @@ asset.require('scene/solarsystem/missions/dawn/vesta')
|
||||
asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
|
||||
asset.require('util/webgui')
|
||||
|
||||
local DawnAsset = asset.require('scene/solarsystem/missions/dawn/dawn')
|
||||
|
||||
|
||||
19
data/assets/examples/debugcoordinateaxes.asset
Normal file
19
data/assets/examples/debugcoordinateaxes.asset
Normal file
@@ -0,0 +1,19 @@
|
||||
local transforms = asset.require('scene/solarsystem/planets/earth/transforms')
|
||||
local debugHelper = asset.require('util/debug_helper')
|
||||
|
||||
local earthRadius = 6.371E6
|
||||
|
||||
debugHelper.registerCartesianAxes(asset, {
|
||||
Parent = transforms.EarthBarycenter.Identifier,
|
||||
Scale = earthRadius * 3.5
|
||||
})
|
||||
|
||||
debugHelper.registerCartesianAxes(asset, {
|
||||
Parent = transforms.EarthInertial.Identifier,
|
||||
Scale = earthRadius * 2.5
|
||||
})
|
||||
|
||||
debugHelper.registerCartesianAxes(asset, {
|
||||
Parent = transforms.EarthIAU.Identifier,
|
||||
Scale = earthRadius * 1.5
|
||||
})
|
||||
@@ -14,6 +14,8 @@ asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('util/default_joystick')
|
||||
|
||||
asset.require('util/webgui')
|
||||
|
||||
local junoAsset = asset.require('scene/solarsystem/missions/juno/juno')
|
||||
|
||||
asset.onInitialize(function ()
|
||||
|
||||
@@ -13,6 +13,8 @@ asset.request('scene/digitaluniverse/milkyway')
|
||||
asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
|
||||
asset.require('util/webgui')
|
||||
|
||||
local MessengerAsset = asset.require('scene/solarsystem/missions/messenger/messengerSC')
|
||||
|
||||
if not openspace.modules.isLoaded("Volume") then
|
||||
|
||||
@@ -16,6 +16,8 @@ asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('util/default_joystick')
|
||||
|
||||
asset.require('util/webgui')
|
||||
|
||||
-- Custom Keybindings
|
||||
local Keybindings = {
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@ asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('util/default_joystick')
|
||||
|
||||
asset.require('util/webgui')
|
||||
|
||||
-- Custom Keybindings
|
||||
local Keybindings = {
|
||||
{
|
||||
|
||||
@@ -17,6 +17,8 @@ asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('util/default_joystick')
|
||||
|
||||
asset.require('util/webgui')
|
||||
|
||||
-- Custom Keybindings
|
||||
local Keybindings = {
|
||||
{
|
||||
|
||||
133
data/assets/util/debug_helper.asset
Normal file
133
data/assets/util/debug_helper.asset
Normal file
@@ -0,0 +1,133 @@
|
||||
local identifierGeneratorFunction = function (suffix)
|
||||
local nextIndex = 0
|
||||
return function (specification)
|
||||
nextIndex = nextIndex + 1
|
||||
return specification.Identifier or
|
||||
(specification.Parent .. suffix .. nextIndex)
|
||||
end
|
||||
end
|
||||
|
||||
local generateGridIdentifier = identifierGeneratorFunction("Grid")
|
||||
|
||||
local addGrid = function (specification)
|
||||
local identifier = specification.Identifier or
|
||||
generateGridIdentifier(specification)
|
||||
|
||||
local name = specification.Name
|
||||
local color = specification.Color
|
||||
local parent = specification.Parent
|
||||
local scale = specification.Scale
|
||||
local position = specification.Position
|
||||
local rotation = specification.Rotation
|
||||
|
||||
local grid = {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = scale;
|
||||
},
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = position
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = rotation
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableSphericalGrid",
|
||||
Enabled = true,
|
||||
LineWidth = 2.0,
|
||||
GridColor = color
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = "/Other/Grids"
|
||||
}
|
||||
}
|
||||
openspace.addSceneGraphNode(grid)
|
||||
return identifier;
|
||||
end
|
||||
|
||||
local generateAxesIdentifier = identifierGeneratorFunction("Axes")
|
||||
|
||||
local addCartesianAxes = function (specification)
|
||||
local identifier = specification.Identifier or
|
||||
generateAxesIdentifier(specification)
|
||||
|
||||
local name = specification.Name or specification.Identifier
|
||||
local parent = specification.Parent or "Root"
|
||||
local scale = specification.Scale or 1.0
|
||||
local position = specification.Position or {0.0, 0.0, 0.0}
|
||||
local rotation = specification.Rotation or {0.0, 0.0, 0.0}
|
||||
|
||||
local axes = {
|
||||
Identifier = identifier,
|
||||
Parent = parent,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = scale;
|
||||
},
|
||||
Translation = {
|
||||
Type = "StaticTranslation",
|
||||
Position = position
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = rotation
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableCartesianAxes",
|
||||
Enabled = true,
|
||||
XColor = {1.0, 0.0, 0.0, 1.0},
|
||||
YColor = {0.0, 1.0, 0.0, 1.0},
|
||||
ZColor = {0.0, 0.0, 1.0, 1.0}
|
||||
},
|
||||
GUI = {
|
||||
Name = name,
|
||||
Path = "/Other/Coordinate Systems"
|
||||
}
|
||||
}
|
||||
openspace.addSceneGraphNode(axes)
|
||||
return identifier;
|
||||
end
|
||||
|
||||
|
||||
local registerNode = function(
|
||||
containerAsset,
|
||||
nodeCreationFunction,
|
||||
identifierGeneratorFunction,
|
||||
specification
|
||||
)
|
||||
local identifier = specification.Identifier or
|
||||
identifierGeneratorFunction(specification)
|
||||
|
||||
specification.Identifier = identifier
|
||||
|
||||
containerAsset.onInitialize(function ()
|
||||
nodeCreationFunction(specification)
|
||||
end)
|
||||
containerAsset.onDeinitialize(function ()
|
||||
openspace.removeSceneGraphNode(identifier)
|
||||
end)
|
||||
end
|
||||
|
||||
local registerGrid = function(gridAsset, specification)
|
||||
registerNode(gridAsset, addGrid, generateGridIdentifier, specification)
|
||||
end
|
||||
|
||||
local registerCartesianAxes = function(axesAsset, specification)
|
||||
registerNode(axesAsset, addCartesianAxes, generateAxesIdentifier, specification)
|
||||
end
|
||||
|
||||
asset.export("addGrid", addGrid)
|
||||
asset.export("registerGrid", registerGrid)
|
||||
|
||||
asset.export("addCartesianAxes", addGrid)
|
||||
asset.export("registerCartesianAxes", registerCartesianAxes)
|
||||
|
||||
@@ -127,6 +127,14 @@ openspace.setPropertyValueSingle("RenderEngine.ShowCamera", not isEnabled)]],
|
||||
Documentation = "Toggles the dashboard and overlays",
|
||||
GuiPath = "/GUI",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "Alt+Tab",
|
||||
Name = "Toggle rendering on master",
|
||||
Command = propertyHelper.invert('RenderEngine.DisableMasterRendering'),
|
||||
Documentation = "Toggles the rendering on master",
|
||||
GuiPath = "/Rendering",
|
||||
Local = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,15 @@ asset.require('scene/solarsystem/missions/voyager1/trails')
|
||||
asset.require('scene/solarsystem/missions/voyager2/voyager2')
|
||||
asset.require('scene/solarsystem/missions/voyager2/trails')
|
||||
|
||||
|
||||
-- Load default key bindings applicable to most scenes
|
||||
asset.require('util/default_keybindings')
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('util/default_joystick')
|
||||
|
||||
local VoyagerAsset = asset.require('scene/solarsystem/missions/voyager1/voyager1')
|
||||
asset.require('util/webgui')
|
||||
|
||||
local VoyagerAsset = asset.require('scene/solarsystem/missions/voyager/voyager1')
|
||||
|
||||
|
||||
assetHelper.registerDashboardItems(asset, {
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
|
||||
// Guaranteed to return a valid pointer
|
||||
AssetManager& assetManager();
|
||||
LoadingScreen& loadingScreen();
|
||||
LoadingScreen* loadingScreen();
|
||||
|
||||
void writeSceneDocumentation();
|
||||
void writeStaticDocumentation();
|
||||
|
||||
@@ -39,6 +39,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lightsource/scenegraphlightsource.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecartesianaxes.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplane.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneimagelocal.h
|
||||
@@ -81,6 +82,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lightsource/scenegraphlightsource.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecartesianaxes.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplane.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneimagelocal.cpp
|
||||
@@ -109,6 +111,10 @@ set(SOURCE_FILES
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/axes_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/axes_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/grid_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/grid_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/imageplane_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/model_fs.glsl
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <modules/base/dashboard/dashboarditemvelocity.h>
|
||||
#include <modules/base/lightsource/cameralightsource.h>
|
||||
#include <modules/base/lightsource/scenegraphlightsource.h>
|
||||
#include <modules/base/rendering/renderablecartesianaxes.h>
|
||||
#include <modules/base/rendering/renderablemodel.h>
|
||||
#include <modules/base/rendering/renderablesphere.h>
|
||||
#include <modules/base/rendering/renderablesphericalgrid.h>
|
||||
@@ -116,6 +117,7 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "Renderable factory was not created");
|
||||
|
||||
fRenderable->registerClass<RenderableCartesianAxes>("RenderableCartesianAxes");
|
||||
fRenderable->registerClass<RenderableModel>("RenderableModel");
|
||||
fRenderable->registerClass<RenderablePlaneImageLocal>("RenderablePlaneImageLocal");
|
||||
fRenderable->registerClass<RenderablePlaneImageOnline>("RenderablePlaneImageOnline");
|
||||
|
||||
275
modules/base/rendering/renderablecartesianaxes.cpp
Normal file
275
modules/base/rendering/renderablecartesianaxes.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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/base/rendering/renderablecartesianaxes.h>
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "CartesianAxesProgram";
|
||||
const int NVertexIndices = 6;
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo XColorInfo = {
|
||||
"XColor",
|
||||
"X Color",
|
||||
"This value determines the color of the x axis."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo YColorInfo = {
|
||||
"YColor",
|
||||
"Y Color",
|
||||
"This value determines the color of the y axis."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ZColorInfo = {
|
||||
"ZColor",
|
||||
"Z Color",
|
||||
"This value determines the color of the z axis."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableCartesianAxes::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"CartesianAxesProgram",
|
||||
"base_renderable_cartesianaxes",
|
||||
{
|
||||
{
|
||||
XColorInfo.identifier,
|
||||
new DoubleVector4Verifier,
|
||||
Optional::Yes,
|
||||
XColorInfo.description
|
||||
},
|
||||
{
|
||||
YColorInfo.identifier,
|
||||
new DoubleVector4Verifier,
|
||||
Optional::Yes,
|
||||
YColorInfo.description
|
||||
},
|
||||
{
|
||||
ZColorInfo.identifier,
|
||||
new DoubleVector4Verifier,
|
||||
Optional::Yes,
|
||||
ZColorInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _program(nullptr)
|
||||
, _xColor(
|
||||
XColorInfo,
|
||||
glm::vec4(0.f, 0.f, 0.f, 1.f),
|
||||
glm::vec4(0.f),
|
||||
glm::vec4(1.f)
|
||||
)
|
||||
, _yColor(
|
||||
YColorInfo,
|
||||
glm::vec4(0.f, 1.f, 0.f, 1.f),
|
||||
glm::vec4(0.f),
|
||||
glm::vec4(1.f)
|
||||
)
|
||||
, _zColor(
|
||||
ZColorInfo,
|
||||
glm::vec4(0.f, 0.f, 1.f, 1.f),
|
||||
glm::vec4(0.f),
|
||||
glm::vec4(1.f)
|
||||
)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableCartesianAxes"
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(XColorInfo.identifier)) {
|
||||
_xColor = dictionary.value<glm::vec4>(XColorInfo.identifier);
|
||||
}
|
||||
_xColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_xColor);
|
||||
|
||||
if (dictionary.hasKey(XColorInfo.identifier)) {
|
||||
_yColor = dictionary.value<glm::vec4>(YColorInfo.identifier);
|
||||
}
|
||||
_yColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_yColor);
|
||||
|
||||
if (dictionary.hasKey(ZColorInfo.identifier)) {
|
||||
_zColor = dictionary.value<glm::vec4>(ZColorInfo.identifier);
|
||||
}
|
||||
_zColor.setViewOption(properties::Property::ViewOptions::Color);
|
||||
addProperty(_zColor);
|
||||
}
|
||||
|
||||
bool RenderableCartesianAxes::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= (_program != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
void RenderableCartesianAxes::initializeGL() {
|
||||
_program = BaseModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return global::renderEngine.buildRenderProgram(
|
||||
ProgramName,
|
||||
absPath("${MODULE_BASE}/shaders/axes_vs.glsl"),
|
||||
absPath("${MODULE_BASE}/shaders/axes_fs.glsl")
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
glGenVertexArrays(1, &_vaoId);
|
||||
glGenBuffers(1, &_vBufferId);
|
||||
glGenBuffers(1, &_iBufferId);
|
||||
|
||||
glBindVertexArray(_vaoId);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferId);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferId);
|
||||
glEnableVertexAttribArray(0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
std::vector<Vertex> vertices({
|
||||
Vertex{0.f, 0.f, 0.f},
|
||||
Vertex{1.f, 0.f, 0.f},
|
||||
Vertex{0.f, 1.f, 0.f},
|
||||
Vertex{0.f, 0.f, 1.f}
|
||||
});
|
||||
|
||||
std::vector<int> indices = {
|
||||
0, 1,
|
||||
0, 2,
|
||||
0, 3
|
||||
};
|
||||
|
||||
glBindVertexArray(_vaoId);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferId);
|
||||
glBufferData(
|
||||
GL_ARRAY_BUFFER,
|
||||
vertices.size() * sizeof(Vertex),
|
||||
vertices.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferId);
|
||||
glBufferData(
|
||||
GL_ELEMENT_ARRAY_BUFFER,
|
||||
indices.size() * sizeof(int),
|
||||
indices.data(),
|
||||
GL_STATIC_DRAW
|
||||
);
|
||||
}
|
||||
|
||||
void RenderableCartesianAxes::deinitializeGL() {
|
||||
glDeleteVertexArrays(1, &_vaoId);
|
||||
_vaoId = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vBufferId);
|
||||
_vBufferId = 0;
|
||||
|
||||
glDeleteBuffers(1, &_iBufferId);
|
||||
_iBufferId = 0;
|
||||
|
||||
BaseModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
global::renderEngine.removeRenderProgram(p);
|
||||
}
|
||||
);
|
||||
_program = nullptr;
|
||||
}
|
||||
|
||||
void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){
|
||||
_program->activate();
|
||||
|
||||
const glm::dmat4 modelTransform =
|
||||
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
|
||||
glm::dmat4(data.modelTransform.rotation) *
|
||||
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
|
||||
|
||||
const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() *
|
||||
modelTransform;
|
||||
|
||||
_program->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
|
||||
_program->setUniform("projectionTransform", data.camera.projectionMatrix());
|
||||
|
||||
_program->setUniform("xColor", _xColor);
|
||||
_program->setUniform("yColor", _yColor);
|
||||
_program->setUniform("zColor", _zColor);
|
||||
|
||||
// Saves current state:
|
||||
GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0);
|
||||
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
|
||||
GLfloat currentLineWidth;
|
||||
glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth);
|
||||
|
||||
GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha,
|
||||
blendDestRGB, blendSrcAlpha, blendSrcRGB;
|
||||
glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB);
|
||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
|
||||
|
||||
// Changes GL state:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnablei(GL_BLEND, 0);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
glBindVertexArray(_vaoId);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferId);
|
||||
glDrawElements(GL_LINES, NVertexIndices, GL_UNSIGNED_INT, nullptr);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_program->deactivate();
|
||||
|
||||
// Restores GL State
|
||||
glLineWidth(currentLineWidth);
|
||||
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
|
||||
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
|
||||
if (!isBlendEnabled) {
|
||||
glDisablei(GL_BLEND, 0);
|
||||
}
|
||||
if (!isLineSmoothEnabled) {
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
75
modules/base/rendering/renderablecartesianaxes.h
Normal file
75
modules/base/rendering/renderablecartesianaxes.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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_BASE___RENDERABLECARTESIANAXES___H__
|
||||
#define __OPENSPACE_MODULE_BASE___RENDERABLECARTESIANAXES___H__
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/matrix/dmat4property.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/scalar/intproperty.h>
|
||||
#include <openspace/properties/vector/vec4property.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace ghoul::opengl { class ProgramObject; }
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableCartesianAxes : public Renderable {
|
||||
public:
|
||||
RenderableCartesianAxes(const ghoul::Dictionary& dictionary);
|
||||
~RenderableCartesianAxes() = default;
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
protected:
|
||||
struct Vertex {
|
||||
float location[3];
|
||||
};
|
||||
|
||||
ghoul::opengl::ProgramObject* _program;
|
||||
|
||||
properties::Vec4Property _xColor;
|
||||
properties::Vec4Property _yColor;
|
||||
properties::Vec4Property _zColor;
|
||||
|
||||
GLuint _vaoId = 0;
|
||||
GLuint _vBufferId = 0;
|
||||
GLuint _iBufferId = 0;
|
||||
};
|
||||
|
||||
}// namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_BASE___RENDERABLECARTESIANAXES___H__
|
||||
49
modules/base/shaders/axes_fs.glsl
Normal file
49
modules/base/shaders/axes_fs.glsl
Normal file
@@ -0,0 +1,49 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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 "fragment.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
in float vs_screenSpaceDepth;
|
||||
in vec4 vs_positionViewSpace;
|
||||
in vec3 vs_positionModelSpace;
|
||||
|
||||
uniform vec4 xColor;
|
||||
uniform vec4 yColor;
|
||||
uniform vec4 zColor;
|
||||
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
|
||||
vec3 colorComponents = step(0.01f, vs_positionModelSpace);
|
||||
|
||||
frag.color = colorComponents.x * xColor +
|
||||
colorComponents.y * yColor +
|
||||
colorComponents.z * zColor;
|
||||
|
||||
frag.depth = vs_screenSpaceDepth;
|
||||
frag.gPosition = vs_positionViewSpace;
|
||||
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
return frag;
|
||||
}
|
||||
46
modules/base/shaders/axes_vs.glsl
Normal file
46
modules/base/shaders/axes_vs.glsl
Normal file
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout(location = 0) in vec3 in_position;
|
||||
|
||||
out float vs_screenSpaceDepth;
|
||||
out vec4 vs_positionViewSpace;
|
||||
out vec3 vs_positionModelSpace;
|
||||
|
||||
uniform mat4 modelViewTransform;
|
||||
uniform mat4 projectionTransform;
|
||||
|
||||
void main() {
|
||||
vec4 positionViewSpace = modelViewTransform * vec4(in_position, 1.0);
|
||||
vec4 positionClipSpace = projectionTransform * positionViewSpace;
|
||||
vec4 positionScreenSpace = positionClipSpace;
|
||||
positionScreenSpace.z = 0.f;
|
||||
vs_positionModelSpace = in_position;
|
||||
vs_screenSpaceDepth = positionScreenSpace.w;
|
||||
vs_positionViewSpace = positionViewSpace;
|
||||
|
||||
gl_Position = positionScreenSpace;
|
||||
}
|
||||
@@ -74,10 +74,16 @@ void GUIRenderHandler::draw() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isTextureReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_programObject->isDirty()) {
|
||||
_programObject->rebuildFromFile();
|
||||
}
|
||||
|
||||
updateTexture();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -591,7 +591,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
|
||||
_program->setUniform(_uniformCache.galaxyTexture, unit);
|
||||
int currentTextureIndex = -1;
|
||||
|
||||
for (const std::unordered_map<int, PlaneAggregate>::reference pAMapItem : _planesMap)
|
||||
for (std::unordered_map<int, PlaneAggregate>::reference pAMapItem : _planesMap)
|
||||
{
|
||||
// For planes with undefined textures references
|
||||
if (pAMapItem.first == 30) {
|
||||
|
||||
@@ -248,7 +248,13 @@ Fragment getFragment() {
|
||||
// because all calculation for light interactions are done in Object
|
||||
// Space, we avoid a new computation saving the normals in Object Space.
|
||||
frag.gNormal.xyz = normalModelSpace;
|
||||
frag.gPosition = vec4(positionCameraSpace, 1.0); // in Camera Rig Space
|
||||
|
||||
if (dot(positionCameraSpace, vec3(1.0)) != 0.0) {
|
||||
frag.gPosition = vec4(positionCameraSpace, 1.0); // in Camera Rig Space
|
||||
}
|
||||
else {
|
||||
frag.gPosition = vec4(1.0); // in Camera Rig Space
|
||||
}
|
||||
|
||||
frag.depth = fs_position.w;
|
||||
|
||||
|
||||
@@ -244,9 +244,6 @@ bool isInside(const PixelRegion& lhs, const PixelRegion& rhs) {
|
||||
}
|
||||
|
||||
IODescription cutIODescription(IODescription& io, Side side, int pos) {
|
||||
const PixelRegion readPreCut = io.read.region;
|
||||
const PixelRegion writePreCut = io.write.region;
|
||||
|
||||
glm::dvec2 ratio = {
|
||||
io.write.region.numPixels.x / static_cast<double>(io.read.region.numPixels.x),
|
||||
io.write.region.numPixels.y / static_cast<double>(io.read.region.numPixels.y)
|
||||
@@ -368,9 +365,9 @@ RawTile::ReadError postProcessErrorCheck(const RawTile& rawTile, size_t nRasters
|
||||
RawTileDataReader::RawTileDataReader(std::string filePath,
|
||||
TileTextureInitData initData,
|
||||
PerformPreprocessing preprocess)
|
||||
: _initData(std::move(initData))
|
||||
: _datasetFilePath(std::move(filePath))
|
||||
, _initData(std::move(initData))
|
||||
, _preprocess(preprocess)
|
||||
, _datasetFilePath(std::move(filePath))
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
@@ -399,9 +399,9 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
|
||||
FloatProperty(OrenNayarRoughnessInfo, 0.f, 0.f, 1.f)
|
||||
})
|
||||
, _debugPropertyOwner({ "Debug" })
|
||||
, _grid(DefaultSkirtedGridSegments, DefaultSkirtedGridSegments)
|
||||
, _leftRoot(Chunk(LeftHemisphereIndex))
|
||||
, _rightRoot(Chunk(RightHemisphereIndex))
|
||||
, _grid(DefaultSkirtedGridSegments, DefaultSkirtedGridSegments)
|
||||
{
|
||||
// Read the radii in to its own dictionary
|
||||
if (dictionary.hasKeyAndValue<glm::dvec3>(KeyRadii)) {
|
||||
@@ -1229,7 +1229,6 @@ void RenderableGlobe::recompileShaders() {
|
||||
|
||||
// Different layer types can be height layers or color layers for example.
|
||||
// These are used differently within the shaders.
|
||||
preprocessingData.layeredTextureInfo;
|
||||
|
||||
for (size_t i = 0; i < preprocessingData.layeredTextureInfo.size(); i++) {
|
||||
// lastLayerIndex must be at least 0 for the shader to compile,
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
SurfacePositionHandle calculateSurfacePositionHandle(
|
||||
const glm::dvec3& targetModelSpace) const;
|
||||
const glm::dvec3& targetModelSpace) const override;
|
||||
|
||||
const Ellipsoid& ellipsoid() const;
|
||||
const LayerManager& layerManager() const;
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "SkirtedGrid";
|
||||
|
||||
size_t numElements(int xSegments, int ySegments) {
|
||||
return 3 * 2 * xSegments * ySegments;
|
||||
}
|
||||
@@ -162,7 +160,7 @@ void SkirtedGrid::initializeGL() {
|
||||
glBindVertexArray(0);
|
||||
|
||||
ghoul_assert(
|
||||
elementData.size() == _elementSize,
|
||||
static_cast<int>(elementData.size()) == _elementSize,
|
||||
"Wrong element size. The correct number is assumed in the render method"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ TileLoadJob::~TileLoadJob() {
|
||||
}
|
||||
|
||||
void TileLoadJob::execute() {
|
||||
_rawTile = std::move(_rawTileDataReader.readTileData(_chunkIndex));
|
||||
_rawTile = _rawTileDataReader.readTileData(_chunkIndex);
|
||||
_hasTile = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,8 +131,6 @@ namespace bylevelprovider {
|
||||
|
||||
namespace temporal {
|
||||
constexpr const char* KeyBasePath = "BasePath";
|
||||
constexpr const char* KeyPreCacheStartTime = "PreCacheStartTime";
|
||||
constexpr const char* KeyPreCacheEndTime = "PreCacheEndTime";
|
||||
|
||||
constexpr const char* UrlTimePlaceholder = "${OpenSpaceTimeId}";
|
||||
constexpr const char* TimeStart = "OpenSpaceTimeStart";
|
||||
@@ -148,20 +146,6 @@ namespace temporal {
|
||||
};
|
||||
} // namespace temporal
|
||||
|
||||
Type toType(const layergroupid::TypeID& id) {
|
||||
using T = layergroupid::TypeID;
|
||||
switch (id) {
|
||||
case T::Unknown: throw ghoul::MissingCaseException();
|
||||
case T::DefaultTileLayer: return Type::DefaultTileProvider;
|
||||
case T::SingleImageTileLayer: return Type::SingleImageTileProvider;
|
||||
case T::SizeReferenceTileLayer: return Type::SizeReferenceTileProvider;
|
||||
case T::TemporalTileLayer: return Type::TemporalTileProvider;
|
||||
case T::TileIndexTileLayer: return Type::TileIndexTileProvider;
|
||||
case T::ByIndexTileLayer: return Type::ByIndexTileProvider;
|
||||
case T::ByLevelTileLayer: return Type::ByLevelTileProvider;
|
||||
default: throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// DefaultTileProvider
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
#include <modules/server/servermodule.h>
|
||||
#include <openspace/openspace.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "VersionTopic";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
bool VersionTopic::isDone() const {
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef __OPENSPACE_MODULE_WEBBROWSER__WEB_RENDER_HANDLER_H
|
||||
#define __OPENSPACE_MODULE_WEBBROWSER__WEB_RENDER_HANDLER_H
|
||||
|
||||
#include <vector>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable : 4100)
|
||||
@@ -42,6 +45,8 @@ namespace openspace {
|
||||
|
||||
class WebRenderHandler : public CefRenderHandler {
|
||||
public:
|
||||
using Pixel = glm::tvec4<char>;
|
||||
|
||||
virtual void draw(void) = 0;
|
||||
virtual void render() = 0;
|
||||
|
||||
@@ -52,23 +57,25 @@ public:
|
||||
const RectList &dirtyRects, const void* buffer, int width, int height) override;
|
||||
bool hasContent(int x, int y);
|
||||
|
||||
bool isTextureReady() const;
|
||||
void updateTexture();
|
||||
|
||||
protected:
|
||||
int _width = 0;
|
||||
int _height = 0;
|
||||
GLuint _texture;
|
||||
|
||||
private:
|
||||
glm::ivec2 _windowSize;
|
||||
glm::ivec2 _browserBufferSize;
|
||||
|
||||
/**
|
||||
* Alpha mask showing whether or not a pixel is filled with content
|
||||
*
|
||||
* Depending on what config you're running (Debug/Release), use different types here.
|
||||
* This is to increase performance on Debug, since VS is performing lots of extra
|
||||
* checks on vector<bool>.
|
||||
* RGBA buffer from browser
|
||||
*/
|
||||
#if !(defined(NDEBUG) || defined(DEBUG))
|
||||
std::vector<char> _alphaMask;
|
||||
#else
|
||||
std::vector<bool> _alphaMask;
|
||||
#endif
|
||||
std::vector<Pixel> _browserBuffer;
|
||||
bool _needsRepaint = true;
|
||||
bool _textureSizeIsDirty = true;
|
||||
bool _textureIsDirty = true;
|
||||
glm::ivec2 _lowerDirtyRectBound;
|
||||
glm::ivec2 _upperDirtyRectBound;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(WebRenderHandler);
|
||||
};
|
||||
|
||||
@@ -133,6 +133,10 @@ bool ScreenSpaceBrowser::deinitialize() {
|
||||
}
|
||||
|
||||
void ScreenSpaceBrowser::render() {
|
||||
if (!_renderHandler->isTextureReady()) {
|
||||
return;
|
||||
}
|
||||
_renderHandler->updateTexture();
|
||||
draw(rotationMatrix() * translationMatrix() * scaleMatrix());
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,21 @@
|
||||
#include <modules/webbrowser/include/webrenderhandler.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <fmt/format.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void WebRenderHandler::reshape(int w, int h) {
|
||||
_width = w;
|
||||
_height = h;
|
||||
_alphaMask.clear();
|
||||
_alphaMask.resize(w * h);
|
||||
if (w == _windowSize.x && h == _windowSize.y) {
|
||||
return;
|
||||
}
|
||||
_windowSize = glm::ivec2(w, h);
|
||||
_needsRepaint = true;
|
||||
}
|
||||
|
||||
bool WebRenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) {
|
||||
rect = CefRect(0, 0, _width, _height);
|
||||
rect = CefRect(0, 0, _windowSize.x, _windowSize.y);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,38 +48,116 @@ void WebRenderHandler::OnPaint(CefRefPtr<CefBrowser> browser,
|
||||
const CefRenderHandler::RectList& dirtyRects,
|
||||
const void* buffer, int w, int h)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, _texture);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
w,
|
||||
h,
|
||||
0,
|
||||
GL_BGRA_EXT,
|
||||
GL_UNSIGNED_BYTE,
|
||||
buffer
|
||||
);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
const size_t bufferSize = static_cast<size_t>(w * h);
|
||||
|
||||
// copy alpha channel from buffer into the alpha mask
|
||||
const unsigned char* bf = reinterpret_cast<const unsigned char*>(buffer);
|
||||
for (int maskIndex = 0, bufferIndex = 3;
|
||||
maskIndex < w * h;
|
||||
bufferIndex += 4, ++maskIndex)
|
||||
{
|
||||
_alphaMask[maskIndex] = bf[bufferIndex] > 0;
|
||||
glm::ivec2 upperUpdatingRectBound = glm::ivec2(0, 0);
|
||||
glm::ivec2 lowerUpdatingRectBound = glm::ivec2(w, h);
|
||||
|
||||
if (_needsRepaint || _browserBuffer.size() != bufferSize) {
|
||||
_browserBufferSize = glm::ivec2(w, h);
|
||||
_browserBuffer.resize(w * h, Pixel(0));
|
||||
_textureSizeIsDirty = true;
|
||||
_upperDirtyRectBound = upperUpdatingRectBound = glm::ivec2(w, h);
|
||||
_lowerDirtyRectBound = lowerUpdatingRectBound = glm::ivec2(0, 0);
|
||||
}
|
||||
|
||||
for (auto it = dirtyRects.begin(); it != dirtyRects.end(); ++it) {
|
||||
lowerUpdatingRectBound = glm::min(
|
||||
lowerUpdatingRectBound,
|
||||
glm::ivec2(it->x, it->y)
|
||||
);
|
||||
upperUpdatingRectBound = glm::max(
|
||||
upperUpdatingRectBound,
|
||||
glm::ivec2(it->x + it->width, it->y + it->height)
|
||||
);
|
||||
}
|
||||
const glm::ivec2 rectSize = upperUpdatingRectBound - lowerUpdatingRectBound;
|
||||
if (rectSize.x > 0 && rectSize.y > 0) {
|
||||
_textureIsDirty = true;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the updated rectangle line by line.
|
||||
for (int y = lowerUpdatingRectBound.y; y < upperUpdatingRectBound.y; ++y) {
|
||||
int lineOffset = y * w + lowerUpdatingRectBound.x;
|
||||
int rectWidth = upperUpdatingRectBound.x - lowerUpdatingRectBound.x;
|
||||
std::copy(
|
||||
reinterpret_cast<const Pixel*>(buffer) + lineOffset,
|
||||
reinterpret_cast<const Pixel*>(buffer) + lineOffset + rectWidth,
|
||||
_browserBuffer.data() + lineOffset
|
||||
);
|
||||
}
|
||||
|
||||
// Add the dirty rect bounds to the GPU texture dirty rect.
|
||||
_lowerDirtyRectBound = glm::min(lowerUpdatingRectBound, _lowerDirtyRectBound);
|
||||
_upperDirtyRectBound = glm::max(upperUpdatingRectBound, _upperDirtyRectBound);
|
||||
_needsRepaint = false;
|
||||
}
|
||||
|
||||
void WebRenderHandler::updateTexture() {
|
||||
if (_needsRepaint) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_textureSizeIsDirty) {
|
||||
glBindTexture(GL_TEXTURE_2D, _texture);
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
_browserBufferSize.x,
|
||||
_browserBufferSize.y,
|
||||
0,
|
||||
GL_BGRA_EXT,
|
||||
GL_UNSIGNED_BYTE,
|
||||
reinterpret_cast<char*>(_browserBuffer.data())
|
||||
);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
} else if (_textureIsDirty) {
|
||||
glBindTexture(GL_TEXTURE_2D, _texture);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, _browserBufferSize.x);
|
||||
|
||||
glTexSubImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
_lowerDirtyRectBound.x,
|
||||
_lowerDirtyRectBound.y,
|
||||
_upperDirtyRectBound.x - _lowerDirtyRectBound.x,
|
||||
_upperDirtyRectBound.y - _lowerDirtyRectBound.y,
|
||||
GL_BGRA_EXT,
|
||||
GL_UNSIGNED_BYTE,
|
||||
reinterpret_cast<char*>(
|
||||
_browserBuffer.data() +
|
||||
_lowerDirtyRectBound.y * _browserBufferSize.x + _lowerDirtyRectBound.x
|
||||
)
|
||||
);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
_upperDirtyRectBound = glm::ivec2(0, 0);
|
||||
_lowerDirtyRectBound = glm::ivec2(_browserBufferSize.x, _browserBufferSize.y);
|
||||
_textureSizeIsDirty = false;
|
||||
_textureIsDirty = false;
|
||||
}
|
||||
|
||||
bool WebRenderHandler::hasContent(int x, int y) {
|
||||
int index = x + (_width * y);
|
||||
index = glm::clamp(index, 0, static_cast<int>(_alphaMask.size() - 1));
|
||||
return _alphaMask[index];
|
||||
if (_browserBuffer.empty()) {
|
||||
return false;
|
||||
}
|
||||
int index = x + (_browserBufferSize.x * y);
|
||||
index = glm::clamp(index, 0, static_cast<int>(_browserBuffer.size() - 1));
|
||||
return _browserBuffer[index].a;
|
||||
}
|
||||
|
||||
bool WebRenderHandler::isTextureReady() const {
|
||||
return !_needsRepaint;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -309,7 +309,7 @@ void parseLuaState(Configuration& configuration) {
|
||||
std::string findConfiguration(const std::string& filename) {
|
||||
using ghoul::filesystem::Directory;
|
||||
|
||||
Directory directory = FileSys.currentDirectory();
|
||||
Directory directory = FileSys.absolutePath("${BIN}");
|
||||
|
||||
while (true) {
|
||||
std::string fullPath = FileSys.pathByAppendingComponent(
|
||||
|
||||
@@ -1344,9 +1344,8 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
|
||||
};
|
||||
}
|
||||
|
||||
LoadingScreen& OpenSpaceEngine::loadingScreen() {
|
||||
ghoul_assert(_loadingScreen, "Loading Screen must not be nullptr");
|
||||
return *_loadingScreen;
|
||||
LoadingScreen* OpenSpaceEngine::loadingScreen() {
|
||||
return _loadingScreen.get();
|
||||
}
|
||||
|
||||
AssetManager& OpenSpaceEngine::assetManager() {
|
||||
|
||||
@@ -360,7 +360,7 @@ void SessionRecording::saveStringToFile(const std::string s) {
|
||||
_bufferIndex = 0;
|
||||
unsigned char const *p = reinterpret_cast<unsigned char const*>(&strLen);
|
||||
memcpy((_keyframeBuffer + _bufferIndex), p, writeSize_bytes);
|
||||
_bufferIndex += (unsigned int)writeSize_bytes;
|
||||
_bufferIndex += static_cast<unsigned int>(writeSize_bytes);
|
||||
saveKeyframeToFileBinary(_keyframeBuffer, _bufferIndex);
|
||||
|
||||
_recordFile.write(s.c_str(), s.size());
|
||||
@@ -1065,7 +1065,6 @@ bool SessionRecording::findNextFutureCameraIndex(double currTime) {
|
||||
{
|
||||
_idxTimeline_cameraPtrPrev = _idxTimeline_cameraPtrNext;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (seekAheadIndex == (_timeline.size() - 1)) {
|
||||
|
||||
@@ -226,9 +226,9 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
|
||||
|
||||
SceneGraphNode::SceneGraphNode()
|
||||
: properties::PropertyOwner({ "" })
|
||||
, _guiHidden(GuiHiddenInfo)
|
||||
, _guiPath(GuiPathInfo)
|
||||
, _guiDisplayName(GuiNameInfo)
|
||||
, _guiHidden(GuiHiddenInfo)
|
||||
, _transform {
|
||||
std::make_unique<StaticTranslation>(),
|
||||
std::make_unique<StaticRotation>(),
|
||||
|
||||
@@ -52,41 +52,47 @@ MultiThreadedSceneInitializer::MultiThreadedSceneInitializer(unsigned int nThrea
|
||||
|
||||
void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
|
||||
auto initFunction = [this, node]() {
|
||||
LoadingScreen& loadingScreen = global::openSpaceEngine.loadingScreen();
|
||||
LoadingScreen* loadingScreen = global::openSpaceEngine.loadingScreen();
|
||||
|
||||
LoadingScreen::ProgressInfo progressInfo;
|
||||
progressInfo.progress = 1.f;
|
||||
loadingScreen.updateItem(
|
||||
node->identifier(),
|
||||
node->guiName(),
|
||||
LoadingScreen::ItemStatus::Initializing,
|
||||
progressInfo
|
||||
);
|
||||
if (loadingScreen) {
|
||||
loadingScreen->updateItem(
|
||||
node->identifier(),
|
||||
node->guiName(),
|
||||
LoadingScreen::ItemStatus::Initializing,
|
||||
progressInfo
|
||||
);
|
||||
}
|
||||
|
||||
node->initialize();
|
||||
std::lock_guard<std::mutex> g(_mutex);
|
||||
_initializedNodes.push_back(node);
|
||||
_initializingNodes.erase(node);
|
||||
|
||||
loadingScreen.updateItem(
|
||||
node->identifier(),
|
||||
node->guiName(),
|
||||
LoadingScreen::ItemStatus::Finished,
|
||||
progressInfo
|
||||
);
|
||||
if (loadingScreen) {
|
||||
loadingScreen->updateItem(
|
||||
node->identifier(),
|
||||
node->guiName(),
|
||||
LoadingScreen::ItemStatus::Finished,
|
||||
progressInfo
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
LoadingScreen::ProgressInfo progressInfo;
|
||||
progressInfo.progress = 0.f;
|
||||
|
||||
LoadingScreen& loadingScreen = global::openSpaceEngine.loadingScreen();
|
||||
loadingScreen.setItemNumber(loadingScreen.itemNumber() + 1);
|
||||
loadingScreen.updateItem(
|
||||
node->identifier(),
|
||||
node->guiName(),
|
||||
LoadingScreen::ItemStatus::Started,
|
||||
progressInfo
|
||||
);
|
||||
LoadingScreen* loadingScreen = global::openSpaceEngine.loadingScreen();
|
||||
if (loadingScreen) {
|
||||
loadingScreen->setItemNumber(loadingScreen->itemNumber() + 1);
|
||||
loadingScreen->updateItem(
|
||||
node->identifier(),
|
||||
node->guiName(),
|
||||
LoadingScreen::ItemStatus::Started,
|
||||
progressInfo
|
||||
);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> g(_mutex);
|
||||
_initializingNodes.insert(node);
|
||||
|
||||
@@ -365,9 +365,7 @@ int unzipFile(lua_State* L) {
|
||||
deleteSource = ghoul::lua::value<bool>(L, 3, ghoul::lua::PopValue::No);
|
||||
}
|
||||
|
||||
auto onExtractEntry = [](const char *filename, void *arg) {
|
||||
return 0;
|
||||
};
|
||||
auto onExtractEntry = [](const char*, void*) { return 0; };
|
||||
int arg = 2;
|
||||
zip_extract(source.c_str(), dest.c_str(), onExtractEntry, &arg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user