aboutsummaryrefslogtreecommitdiff
path: root/src/VideoPlayer.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-04 18:17:43 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-04 18:17:46 +0200
commit8103563530e6e5711f20bfef97141421520341fb (patch)
tree79fd8f1e70df35aa7123d40201c75e6c74ab2aa8 /src/VideoPlayer.cpp
parentf0de15c1939342af2fc702de94e1e6ec81e7ac50 (diff)
Fix scaling issue
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r--src/VideoPlayer.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 6fafedd..96ba6ef 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -17,14 +17,14 @@ namespace QuickMedia {
VideoPlayer::VideoPlayer(unsigned int width, unsigned int height, const char *file, bool loop) :
redrawCounter(0),
- context(sf::ContextSettings(), width, height),
onPlaybackEndedCallback(nullptr),
mpv(nullptr),
mpvGl(nullptr),
+ context(std::make_unique<sf::Context>(sf::ContextSettings(), width, height)),
textureBuffer(nullptr),
desired_size(width, height)
{
- context.setActive(true);
+ context->setActive(true);
texture.setSmooth(true);
// mpv_create requires LC_NUMERIC to be set to "C" for some reason, see mpv_create documentation
@@ -53,7 +53,7 @@ namespace QuickMedia {
if(mpv_opengl_cb_init_gl(mpvGl, nullptr, getProcAddressMpv, nullptr) < 0)
throw VideoInitializationException("Failed to initialize mpv gl callback func");
- context.setActive(false);
+ context->setActive(false);
seekbar.setFillColor(sf::Color::White);
seekbar_background.setFillColor(sf::Color(0, 0, 0, 150));
@@ -116,9 +116,10 @@ namespace QuickMedia {
if(newTextureBuf)
textureBuffer = (sf::Uint8*)newTextureBuf;
}
- context.setActive(true);
+ context.reset(new sf::Context(sf::ContextSettings(), w, h));
+ context->setActive(true);
glViewport(0, 0, w, h);
- context.setActive(false);
+ context->setActive(false);
resize(desired_size);
}
} else if(mpvEvent->event_id == MPV_EVENT_END_FILE) {
@@ -132,7 +133,7 @@ namespace QuickMedia {
if(redrawCounter > 0 && textureBuffer) {
--redrawCounter;
auto textureSize = texture.getSize();
- context.setActive(true);
+ context->setActive(true);
//mpv_render_context_render(mpvGl, params);
mpv_opengl_cb_draw(mpvGl, 0, textureSize.x, textureSize.y);
// TODO: Instead of copying video to cpu buffer and then to texture, copy directly from video buffer to texture buffer
@@ -140,7 +141,7 @@ namespace QuickMedia {
texture.update(textureBuffer);
sprite.setTexture(texture, true);
mpv_opengl_cb_report_flip(mpvGl, 0);
- context.setActive(false);
+ context->setActive(false);
}
window.draw(sprite);