summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Schroeter <mathieu@schroetersa.ch>2017-10-21 21:30:26 +0200
committerMathieu Schroeter <mathieu@schroetersa.ch>2017-10-21 23:31:46 +0200
commitc8cf431e389580fd94e7ce7e4c7bcefb265dd93c (patch)
tree57ee38494f03716ea8fc9c0c8fc714bb5ba3444f
parent37da5b3b0708fd809353b78c258dfd28f78a7805 (diff)
Clear the texture when the movie is starting
Otherwise it's possible to see garbage with the first frame.
-rw-r--r--src/movie.cxx14
-rw-r--r--src/movie.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/src/movie.cxx b/src/movie.cxx
index 7b22e84..a7172bf 100644
--- a/src/movie.cxx
+++ b/src/movie.cxx
@@ -121,7 +121,7 @@ CMovie::fileOpenMovie (const std::string & pFilename)
SDL_PauseAudioDevice (m_audioDev, 0);
m_videoTex = SDL_CreateTexture (
- g_renderer, info.video.format, SDL_TEXTUREACCESS_STATIC, info.video.width,
+ g_renderer, info.video.format, SDL_TEXTUREACCESS_TARGET, info.video.width,
info.video.height);
if (m_videoTex == nullptr)
@@ -146,7 +146,10 @@ CMovie::playMovie ()
// play/pause the AVI movie
if (m_fPlaying)
+ {
+ this->starting = true;
Kit_PlayerPlay (m_player);
+ }
else
Kit_PlayerPause (m_player);
}
@@ -290,6 +293,15 @@ CMovie::Render ()
SDL_SetRenderDrawColor (g_renderer, 0, 0, 0, 255);
SDL_RenderClear (g_renderer);
+ if (this->starting)
+ {
+ SDL_SetRenderTarget (g_renderer, m_videoTex);
+ SDL_SetRenderDrawColor (g_renderer, 0, 0, 0, 255);
+ SDL_RenderClear (g_renderer);
+ SDL_SetRenderTarget (g_renderer, nullptr);
+ this->starting = false;
+ }
+
// Refresh videotexture and render it
Kit_GetVideoData (m_player, m_videoTex);
SDL_RenderCopy (g_renderer, m_videoTex, nullptr, nullptr);
diff --git a/src/movie.h b/src/movie.h
index 9c2f61d..bd9098f 100644
--- a/src/movie.h
+++ b/src/movie.h
@@ -60,6 +60,7 @@ protected:
char m_audiobuf[AUDIOBUFFER_SIZE];
bool m_bEnable;
+ bool starting;
bool m_fPlaying; // Play flag: true == playing, false == paused
bool m_fMovieOpen; // Open flag: true == movie open, false = none
};