Updating texture is failed

Hi,

I’m trying to update an 800x480 texture on a BeagleBone Black.
My code only updates the whole screen for the first few seconds, then only the middle part of the screen (which is just 400x240 in size) gets updated.

I will show you the flow, and if there is anything wrong, could you please let me know?

/*** setup texture function ***/
glGenTextures(1, &window->gl.texture_id);
glBindTexture(GL_TEXTURE_2D, window->gl.texture_id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 800 , 480, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

/*** redraw function ***/
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

// something to update pixels

glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 800, 480, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
glViewport(0, 0, window->geometry.width, window->geometry.height);

glClearColor(1.0, 0.0, 0.0, 0.5);
glClear(GL_COLOR_BUFFER_BIT);

glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
glVertexAttribPointer(window->gl.attr_uv, 2, GL_FLOAT, GL_FALSE, 0, uv);
glEnableVertexAttribArray(window->gl.pos);
glEnableVertexAttribArray(window->gl.attr_uv);
glUniform1i(window->gl.unif_texture, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

//something to swap buffer