java - LWJGL - not all display lists rendering -


i'm working on minecraft game. create display list each 16x16x16 chunk. works fine. when i'm trying add block selection it's invisible. appears when i'm @ random positions(i render selection @ 0, 0, 0) . have no idea wrong.

my render loop:

while (isrunning) {     glclear(gl_color_buffer_bit | gl_depth_buffer_bit);      timer.nextframe();     input(timer.getdelta());      tex.bind();     glloadidentity();      renderchunks();      rendertext();     renderselection();      display.update();     errorcheck();     if (display.iscloserequested()) {         isrunning = false;     } } 

renderchunks:

glrotated(player.getry(), 1, 0, 0); glrotated(player.getrx(), 0, 1, 0); gltranslatef(-player.getx(), -player.gety(), -player.getz()); //--------- (int x = minworldchunkx; x < maxworldchunkx; ++x) {     (int y = minworldchunky; y < maxworldchunky; ++y) {         (int z = minworldchunkz; z < maxworldchunkz; ++z) {         glpushmatrix();         gltranslatef(x << 4, y << 4, z << 4);         glcalllist(chunkdisplaylists.get(new chunkposition(x, y, z)));         glpopmatrix();         }     } } 

renderselection:

glpushmatrix(); glcalllist(selectiondisplaylist); glpopmatrix(); 

selection display list:

selectiondisplaylist = glgenlists(1); glnewlist(selectiondisplaylist, gl_compile); glbegin(gl_lines); glcolor3f(0, 0, 0); gllinewidth(3);  glvertex3f(1, 1, 1); glvertex3f(1, 0, 1);  glvertex3f(1, 0, 1); glvertex3f(1, 0, 0);  glvertex3f(1, 0, 0); glvertex3f(1, 1, 0);  glvertex3f(1, 1, 0); glvertex3f(1, 1, 1);    glvertex3f(0, 1, 0); glvertex3f(0, 0, 0);  glvertex3f(0, 0, 0); glvertex3f(0, 0, 1);  glvertex3f(0, 0, 1); glvertex3f(0, 1, 1);  glvertex3f(0, 1, 1); glvertex3f(0, 1, 0);   glvertex3f(0, 1, 0); glvertex3f(1, 1, 0);  glvertex3f(0, 0, 0); glvertex3f(1, 0, 0);  glvertex3f(0, 0, 1); glvertex3f(1, 0, 1);  glvertex3f(0, 1, 1); glvertex3f(1, 1, 1); glend(); glendlist(); 

source code avaible on github

edit: when moved renderselection() render loop renderchunks() before rendering chunks worked. when change renderselection() to:

glpushmatrix(); gldisable(gl_depth_test); glcalllist(selectiondisplaylist); glenable(gl_depth_test); glpopmatrix(); 

it disappears completely.

edit 2: disabling blending while rendering selection fixed it.

screenshos

disabling blending while rendering block selection fixed it.

new renderselection code:

glpushmatrix(); gldisable(gl_depth_test); gldisable(gl_blend); glcalllist(selectiondisplaylist); glenable(gl_depth_test); glenable(gl_blend); glpopmatrix(); 

update: wan caused else:

selectiondisplaylist = glgenlists(1); glnewlist(selectiondisplaylist, gl_compile); glbegin(gl_lines); ... gllinewidth(3);//this caused issue ... 

normally setting line width between glbegin() , glend() should cause error, did not on computer (ati graphics card, ubuntu). on other computer glerror() returned non-zero value.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -