Problem with EBO data (using glBufferSubData)

Hi, tldr Texture (uv) indices are not used, same with every other EBO data after indices of vertices.
From wiki I know that it is possible to use sub data with EBO, but it does not seem work the way I did it, about half of the cube uv is “properly” set (triangles directly connected) and the rest seems twisted in other direction + one triangle seems buggy like if the texture was scretched and not always visible, depends how I rotate the cube.

Bellow there’s a screenshot.

	glBindBuffer(GL_ARRAY_BUFFER, _VBO);

	int vertices_size = this->m_vertices.size() * sizeof(glm::vec3);
	int uv_size = this->m_uv.size() * sizeof(glm::vec2);
	int normals_size = this->m_normals.size() * sizeof(glm::vec3);
	int colors_size = this->m_colors.size() * sizeof(glm::vec4);
	int data_size = vertices_size + uv_size + normals_size + colors_size;

	glBufferData(GL_ARRAY_BUFFER, data_size, NULL, GL_STATIC_DRAW);

	if (!m_vertices.empty()) {
		glBufferSubData(GL_ARRAY_BUFFER, 0, vertices_size, &m_vertices[0]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)(0));
		if (!m_uv.empty()) {
			glBufferSubData(GL_ARRAY_BUFFER, vertices_size, uv_size, &m_uv[0]);
			glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), (void*)(vertices_size));
		if (!m_normals.empty()){
			glBufferSubData(GL_ARRAY_BUFFER, vertices_size + uv_size, normals_size, &m_normals[0]);
			glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)(vertices_size + uv_size));

		if (!m_colors.empty()) {
			glBufferSubData(GL_ARRAY_BUFFER, vertices_size + uv_size + normals_size, colors_size, &m_colors[0]);
			glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(vertices_size + uv_size + normals_size));
int indices_vertex_size  = this->m_indices.size() * sizeof(unsigned int);
	int indices_uv_size      = this->m_uv_indices.size() * sizeof(unsigned int);
	int indices_normals_size = this->m_normals_indices.size() * sizeof(unsigned int);
	int indices_data_size    = indices_vertex_size + indices_uv_size + indices_normals_size;

	if (!m_indices.empty()) {
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_data_size, NULL, GL_STATIC_DRAW);
		glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, indices_vertex_size, &this->m_indices[0]);
		if (!m_uv_indices.empty()) {
			glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, indices_vertex_size, indices_uv_size, &this->m_uv_indices[0]);

		if (!m_normals_indices.empty()) {
			glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, indices_vertex_size + indices_uv_size, indices_normals_size, &this->m_normals_indices[0]);

	glBindBuffer(GL_ARRAY_BUFFER, 0);

Screenshot of what I see:

Let me guess: you are loading a .OBJ format file? That format has one unfortunate characteristic in that it can use separate indices for the various attributes of a vertex (position, normal, uv, etc.). Graphics APIs only support a single index that is used for all vertex attributes (this limitation is not unique to OpenGL).
If two vertices only share some attributes (e.g. same position) but differ in others (e.g. different UV) they are really two separate vertices and it may be necessary to duplicate certain attribute values.
If you search for how to load .OBJ files (even if that was not your goal) you’ll find descriptions how to perform the necessary conversion to something that is suitable for rendering.