c++ - Miscolored picture during multiple video rendering -



c++ - Miscolored picture during multiple video rendering -

i working on rendering 2 different video streams @ same time 2 different opengl textures. utilize implementation of qabstractvideosurface prepare each frame of video , pass opengl draw method. each frame arrives in yuv coding in order rgb values utilize glsl.

the problem following: every time seek draw more 1 of these videos first 1 plays correctly other kinkiness channels.

my vertex shader:

#version 420 attribute vec2 position; attribute vec2 texcoord; uniform mat4 modelviewprojectionmatrix; varying vec2 v_texcoord; void main() { gl_position = modelviewprojectionmatrix * vec4(position, 0, 1); v_texcoord = texcoord.xy; }

my fragment shader:

#version 420 varying vec2 v_texcoord; uniform sampler2d s_texture_y; uniform sampler2d s_texture_u; uniform sampler2d s_texture_v; uniform float s_texture_alpha; void main(void) { highp float y = texture2d(s_texture_y, v_texcoord).r; highp float u = texture2d(s_texture_u, v_texcoord).r - 0.5; highp float v = texture2d(s_texture_v, v_texcoord).r - 0.5; highp float r = y + 1.402 * v; highp float g = y - 0.344 * u - 0.714 * v; highp float b = y + 1.772 * u; gl_fragcolor = vec4(r, g, b, s_texture_alpha); }

the result next picture:

sometimes gets right, it's worse, first video plays correctly time.

after fooling around bit channels found out u variable gets same value v in fragment shader. texture bindig follows:

uniformsamplers[0] = functions.glgetuniformlocation(program, "s_texture_y"); uniformsamplers[1] = functions.glgetuniformlocation(program, "s_texture_u"); uniformsamplers[2] = functions.glgetuniformlocation(program, "s_texture_v"); glactivetexture(gl_texture0 + 0); glbindtexture(gl_texture_2d, textref); glteximage2d(gl_texture_2d, 0, gl_luminance, image_width, image_height, 0, gl_luminance, gl_unsigned_byte, (glvoid*)(image)); 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_edge); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp_to_edge); functions.gluniform1i(uniformsamplers[0], 0); glactivetexture(gl_texture0 + 1); glbindtexture(gl_texture_2d, textrefu); glteximage2d(gl_texture_2d, 0, gl_luminance, image_width / 2, image_height / 2, 0, gl_luminance, gl_unsigned_byte, (glvoid*)(image + image_width * image_height)); 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_edge); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp_to_edge); functions.gluniform1i(uniformsamplers[1], 1); glactivetexture(gl_texture0 + 2); glbindtexture(gl_texture_2d, textrefv); glteximage2d(gl_texture_2d, 0, gl_luminance, image_width / 2, image_height / 2, 0, gl_luminance, gl_unsigned_byte, (glvoid*)(image + image_height * image_width + (image_width / 2) * (image_height / 2))); 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_edge); gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_clamp_to_edge); functions.gluniform1i(uniformsamplers[2], 2);

the problem quite lame, focused on shaders , spent several days trying find out problem there. problem in texture reference intialization. 3 references had same value, overwrote same texture each time. having 3 on different value works perfectly.

c++ linux qt opengl glsl

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -