OpenGL drawElement by changing index

picture share
upper image is what I want, lower image is what I get.

I made 1 million cubes and stacked it. I sent all the vertexes to GPU. I removed some of the cubes and drew those with texture like upper image. But when I do not remove the cube and just change the index array and redraw it, the cubes that were formerly hidden appear as black.

I think I am omitting some procedure. Any help would be appreciated.

Let’s simplify the question… When I draw 100000 full index then I get right image. But if I limit the index size to 50000 like below without changing anything else, when the real index size is 100000, then I get black areas with no texture color.

glDrawElements(GL_QUADS, 50000, GL_UNSIGNED_INT, (void*)(offset+sizeof(unsigned)));

source : GitHub - ParkSeungwon/NewbieGL at cubemap
src/test.cpp is the main() file.

Sounds like the vertices for the cut-out geometry are in the back-half of the that 100,000 index index list. The cut-out are is black like the background, suggesting nothing is drawn there.

To verify that nothing is drawn there, clear the screen to red. Then with backface culling enabled, draw with 50,000 indices. If the cut-out’s still red, nothing was drawn there.

[QUOTE=Dark Photon;1287328]Sounds like the vertices for the cut-out geometry are in the back-half of the that 100,000 index index list. The cut-out are is black like the background, suggesting nothing is drawn there.

To verify that nothing is drawn there, clear the screen to red. Then with backface culling enabled, draw with 50,000 indices. If the cut-out’s still red, nothing was drawn there.[/QUOTE]

Thanks. I tried as you instructed. The background went red, but the missing cube places are still black.
Do I need to redo texture mapping ?
I don’t know what’s going on… Please help.

You might flip to rendering wireframe, change your shaders to render white, and disable backface culling. Just to try and see what you’ve got.

Thanks I found out what went wrong…
My normal calculation was wrong.
If there are 8 cubes around one vertex then the normal would be 0. the outer cubes is exceptional because they only have 2 or 3 cubes.