Reputation: 909
I'm programming combining the yuv data which were got by libvpx(WebM decode library) and OpenGL ES 2.0 shader(for Android).
These are the same byte array, but it's not drawn correctly in this case.
Success:
// ex) unsigned char *p = yuv.y, yuv.u or yuv.v;
for(int dy = 0; dy < hh; dy++){
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, dy, ww, 1, GL_LUMINANCE, GL_UNSIGNED_BYTE, p);
p += ww;
}
Fail :
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ww, hh, GL_LUMINANCE, GL_UNSIGNED_BYTE, p);
Because I'm not knowledgeable about OpenGL, I don't understand this reason. I think that if glTexSubImage2D is called for each line, performance will get worse. Isn't it improvable any more?
Upvotes: 1
Views: 1087
Reputation: 3221
My best guess is that the data you are passing to glTexSubImage2D is not correctly aligned.
From the glTexSubImage2D Reference page for OpenGL ES 2.0:
Storage parameter GL_UNPACK_ALIGNMENT, set by glPixelStorei, affects the way that data is read out of client memory. See glPixelStorei for a description.
Passing a single line at a time from your data probably hides the fact that each line is not correctly aligned, and therefore the call succeeds.
Upvotes: 1