Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: OpenGL drawElement by changing index

  1. #1
    Newbie Newbie
    Join Date
    Jun 2017
    Posts
    3

    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 : https://github.com/ParkSeungwon/NewbieGL/tree/cubemap/
    src/test.cpp is the main() file.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,124
    Quote Originally Posted by zezeon View Post
    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.
    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.

  3. #3
    Newbie Newbie
    Join Date
    Jun 2017
    Posts
    3

    ....

    Quote Originally Posted by Dark Photon View Post
    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.
    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.

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,124
    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.

  5. #5
    Newbie Newbie
    Join Date
    Jun 2017
    Posts
    3
    Quote Originally Posted by Dark Photon View Post
    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.
    Last edited by zezeon; 06-03-2017 at 08:26 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •