mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 04:31:08 -06:00
Move libmpv render function to update function
This commit is contained in:
@@ -56,8 +56,8 @@ public:
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
void update(const UpdateData& data) override;
|
||||
virtual void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
virtual void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
|
||||
bool deinitializeGL() override;
|
||||
void update() override;
|
||||
void render() override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
|
||||
void reset();
|
||||
void destroy();
|
||||
void update();
|
||||
|
||||
virtual void preSync(bool isMaster) override;
|
||||
virtual void encode(SyncBuffer* syncBuffer) override;
|
||||
|
||||
@@ -368,6 +368,8 @@ void RenderableVideoSphere::render(const RenderData& data, RendererTasks&) {
|
||||
}
|
||||
|
||||
void RenderableVideoSphere::update(const UpdateData&) {
|
||||
_videoPlayer.update();
|
||||
|
||||
if (_shader->isDirty()) {
|
||||
_shader->rebuildFromFile();
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
|
||||
@@ -70,6 +70,8 @@ ScreenSpaceVideo::ScreenSpaceVideo(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
void ScreenSpaceVideo::update() {
|
||||
_videoPlayer.update();
|
||||
|
||||
if (!_videoPlayer.isInitialized()) {
|
||||
return;
|
||||
}
|
||||
@@ -79,6 +81,13 @@ void ScreenSpaceVideo::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSpaceVideo::render() {
|
||||
if (!_videoPlayer.isInitialized()) {
|
||||
return;
|
||||
}
|
||||
ScreenSpaceRenderable::render();
|
||||
}
|
||||
|
||||
bool ScreenSpaceVideo::deinitializeGL() {
|
||||
_videoPlayer.destroy();
|
||||
|
||||
|
||||
@@ -281,17 +281,7 @@ VideoPlayer::VideoPlayer(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
global::callback::postSyncPreDraw->emplace_back([this]() {
|
||||
if (_isDestroying) {
|
||||
return;
|
||||
}
|
||||
// Initialize mpv here to ensure that the opengl context is the same as in for
|
||||
// the rendering
|
||||
if (!_isInitialized) {
|
||||
initializeMpv();
|
||||
}
|
||||
else if(_mpvRenderContext && _mpvHandle) {
|
||||
renderMpv();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
global::callback::postDraw->emplace_back([this]() {
|
||||
@@ -491,6 +481,20 @@ void VideoPlayer::toggleMute() {
|
||||
setPropertyAsyncMpv(mute, MpvKey::Mute);
|
||||
}
|
||||
|
||||
void VideoPlayer::update() {
|
||||
if (_isDestroying) {
|
||||
return;
|
||||
}
|
||||
// Initialize mpv here to ensure that the opengl context is the same as in for
|
||||
// the rendering
|
||||
if (!_isInitialized) {
|
||||
initializeMpv();
|
||||
}
|
||||
else if (_mpvRenderContext && _mpvHandle) {
|
||||
renderMpv();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoPlayer::renderMpv() {
|
||||
handleMpvEvents();
|
||||
|
||||
@@ -519,8 +523,8 @@ 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);
|
||||
glm::ivec2 window = global::windowDelegate->currentDrawBufferResolution();
|
||||
glViewport(0, 0, window.x, window.y);
|
||||
_didRender = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,9 @@ TileDepthTransform VideoTileProvider::depthTransform() {
|
||||
return { 0.f, 1.f };
|
||||
}
|
||||
|
||||
void VideoTileProvider::update() {}
|
||||
void VideoTileProvider::update() {
|
||||
_videoPlayer.update();
|
||||
}
|
||||
|
||||
void VideoTileProvider::reset() {
|
||||
_videoPlayer.reset();
|
||||
|
||||
Reference in New Issue
Block a user