diff --git a/openglosd.cpp b/openglosd.cpp index dfea37e..06a1675 100644 --- a/openglosd.cpp +++ b/openglosd.cpp @@ -909,6 +909,7 @@ bool cOglCmdCopyBufferToOutputFb::Execute(void) { #endif ActivateOsd(oFb->texture,x, y, fb->Width() ,fb->Height()); oFb->Unbind(); + glFlush(); pthread_mutex_unlock(&OSDMutex); return true; diff --git a/video.c b/video.c index 907612e..fbfe319 100644 --- a/video.c +++ b/video.c @@ -2855,27 +2855,28 @@ int get_RGB(CuvidDecoder * decoder) glActiveTexture(GL_TEXTURE0); if (OsdShown && decoder->grab == 2) { - int x,y,h,w; + int x,y,h,w; GLint texLoc; - if (OsdShown == 1) { - if (OSDtexture) - glDeleteTextures(1,&OSDtexture); + if (OsdShown == 1) { + if (OSDtexture) + glDeleteTextures(1,&OSDtexture); + pthread_mutex_lock(&OSDMutex); + glGenTextures(1, &OSDtexture); + glBindTexture(GL_TEXTURE_2D, OSDtexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, OSDxsize, OSDysize, 0, GL_RGBA, GL_UNSIGNED_BYTE, posd); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + pthread_mutex_unlock(&OSDMutex); + OsdShown = 2; + } - glGenTextures(1, &OSDtexture); - glBindTexture(GL_TEXTURE_2D, OSDtexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, OSDxsize, OSDysize, 0, GL_RGBA, GL_UNSIGNED_BYTE, posd); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - OsdShown = 2; - } - - y = OSDy*height/VideoWindowHeight; - x = OSDx*width/VideoWindowWidth; - h = OSDysize*height/VideoWindowHeight; - w = OSDxsize*width/VideoWindowWidth; - glViewport(x,(height - h - y) , w, h); + y = OSDy*height/VideoWindowHeight; + x = OSDx*width/VideoWindowWidth; + h = OSDysize*height/VideoWindowHeight; + w = OSDxsize*width/VideoWindowWidth; + glViewport(x,(height - h - y) , w, h); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2888,11 +2889,11 @@ int get_RGB(CuvidDecoder * decoder) glActiveTexture(GL_TEXTURE0); - pthread_mutex_lock(&OSDMutex); +// pthread_mutex_lock(&OSDMutex); glBindTexture(GL_TEXTURE_2D, OSDtexture); glBindFramebuffer(GL_FRAMEBUFFER, fb); render_pass_quad(0, 0.0, 0.0); - pthread_mutex_unlock(&OSDMutex); +// pthread_mutex_unlock(&OSDMutex); glUseProgram(0); glActiveTexture(GL_TEXTURE0); @@ -3877,27 +3878,34 @@ static void CuvidDisplayFrame(void) if (OsdShown && valid_frame) { GLint texLoc; + int x,y,w,h; glBindTexture(GL_TEXTURE_2D, 0); - if (OsdShown == 1) { - if (OSDtexture) - glDeleteTextures(1,&OSDtexture); - - glGenTextures(1, &OSDtexture); - glBindTexture(GL_TEXTURE_2D, OSDtexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, OSDxsize, OSDysize, 0, GL_RGBA, GL_UNSIGNED_BYTE, posd); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + if (OsdShown == 1) { + if (OSDtexture) + glDeleteTextures(1,&OSDtexture); + pthread_mutex_lock(&OSDMutex); + glGenTextures(1, &OSDtexture); + glBindTexture(GL_TEXTURE_2D, OSDtexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, OSDxsize, OSDysize, 0, GL_RGBA, GL_UNSIGNED_BYTE, posd); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glFlush(); + pthread_mutex_unlock(&OSDMutex); OsdShown = 2; - } + } glBindTexture(GL_TEXTURE_2D, 0); glEnable(GL_BLEND); GlxCheck(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GlxCheck(); - glViewport(OSDx,(VideoWindowHeight - OSDysize - OSDy) , OSDxsize, OSDysize); + y = OSDy*VideoWindowHeight/OsdHeight; + x = OSDx*VideoWindowWidth/OsdWidth; + h = OSDysize*VideoWindowHeight/OsdHeight; + w = OSDxsize*VideoWindowWidth/OsdWidth; + glViewport(x,(VideoWindowHeight - h - y) , w, h); if (gl_prog_osd == 0) gl_prog_osd = sc_generate_osd(gl_prog_osd); // generate shader programm @@ -3908,10 +3916,10 @@ static void CuvidDisplayFrame(void) glActiveTexture(GL_TEXTURE0); - pthread_mutex_lock(&OSDMutex); +// pthread_mutex_lock(&OSDMutex); glBindTexture(GL_TEXTURE_2D, OSDtexture); render_pass_quad(1, 0, 0); - pthread_mutex_unlock(&OSDMutex); +// pthread_mutex_unlock(&OSDMutex); glUseProgram(0); glActiveTexture(GL_TEXTURE0);