Merge branch 'feature/video-module' of https://github.com/OpenSpace/OpenSpace into feature/video-module

This commit is contained in:
Ylva Selling
2023-03-21 10:50:47 -04:00
7 changed files with 28 additions and 6 deletions

View File

@@ -48,6 +48,7 @@
#include <ghoul/misc/profiling.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/systemcapabilities/openglcapabilitiescomponent.h>
#include <numeric>
@@ -807,6 +808,10 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask
}
_lastChangedLayer = nullptr;
// Reset
global::renderEngine->openglStateCache().resetBlendState();
global::renderEngine->openglStateCache().resetDepthState();
}
void RenderableGlobe::renderSecondary(const RenderData& data, RendererTasks&) {

View File

@@ -40,6 +40,7 @@ class ScreenSpaceVideo : public ScreenSpaceRenderable {
public:
ScreenSpaceVideo(const ghoul::Dictionary& dictionary);
bool initializeGL() override;
bool deinitializeGL() override;
void update() override;
void render() override;

View File

@@ -51,11 +51,13 @@ public:
VideoPlayer(const ghoul::Dictionary& dictionary);
~VideoPlayer();
void initialize();
// Video interaction
void pause();
void play();
void goToStart();
void seekToTime(double time, bool pauseAfter = false);
void toggleMute();
@@ -124,7 +126,7 @@ private:
// Video properties. Try to read all these values from the video
std::string _videoFile;
double _currentVideoTime = 0.0;
double _fps = 24.0; // If when we read it it is 0, use 24 fps
double _fps = 24.0; // If when we read it it is 0, use 24 fps
double _videoDuration = 0.0;
glm::ivec2 _videoResolution = glm::ivec2(2048, 1024); // Used for the fbos
bool _isPaused = false;

View File

@@ -224,6 +224,8 @@ void RenderableVideoSphere::initializeGL() {
);
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
_videoPlayer.initialize();
}
void RenderableVideoSphere::deinitializeGL() {

View File

@@ -88,6 +88,12 @@ void ScreenSpaceVideo::render() {
ScreenSpaceRenderable::render();
}
bool ScreenSpaceVideo::initializeGL() {
_videoPlayer.initialize();
return ScreenSpaceRenderable::initializeGL();
}
bool ScreenSpaceVideo::deinitializeGL() {
_videoPlayer.destroy();

View File

@@ -29,10 +29,12 @@
#include <openspace/engine/syncengine.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/time.h>
#include <openspace/util/timemanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/framebufferobject.h>
#include <ghoul/opengl/openglstatecache.h>
namespace {
constexpr std::string_view _loggerCat = "VideoPlayer";
@@ -358,6 +360,9 @@ void VideoPlayer::stepFrameBackward() {
commandAsyncMpv(cmd);
}
void VideoPlayer::initialize() {
initializeMpv();
}
void VideoPlayer::initializeMpv() {
_mpvHandle = mpv_create();
@@ -530,8 +535,7 @@ void VideoPlayer::renderMpv() {
/* TODO: remove this comment in case we never encounter this issue again */
// We have to set the Viewport on every cycle because
// mpv_render_context_render internally rescales the fb of the context(?!)...
glm::ivec2 window = global::windowDelegate->currentDrawBufferResolution();
glViewport(0, 0, window.x, window.y);
global::renderEngine->openglStateCache().resetViewportState();
// We also need to reset the render target
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);

View File

@@ -138,7 +138,7 @@ int VideoTileProvider::minLevel() {
}
int VideoTileProvider::maxLevel() {
// This is the level where above the tile is marked as unavailable and is no longer
// This is the level where above the tile is marked as unavailable and is no longer
// displayed. Since we want to display the tiles at all times we set the max level
return 1337;
}
@@ -147,7 +147,9 @@ float VideoTileProvider::noDataValueAsFloat() {
return std::numeric_limits<float>::min();
}
void VideoTileProvider::internalInitialize() {}
void VideoTileProvider::internalInitialize() {
_videoPlayer.initialize();
}
VideoTileProvider::~VideoTileProvider() {}