java - Quads appear in front of others while they're not -


i trying write simple doom style game, , matter i've decided write block-type engine (much simmilar minecraft), have ran problem: blocks render oddly, parts of blocks passing through nothing there.

this happens when @ quad left:left however, when @ right, looks fine: right

let's code, shall we? how initialise opengl:

    glmatrixmode(gl_projection);     glloadidentity();      gluperspective(fov, (float) display.getwidth() / (float) display.getheight(), 0, -2);      glmatrixmode(gl_modelview);     glloadidentity();     glenable(gl_texture_2d);     glenable(gl_blend);     glenable(gl_cull_face);     glcullface(gl_back); 

i render block's faces using display lists. tried using vbo's, changed display lists, thought caused problem. every display list looks same:

        glnewlist(listtop, gl_compile);         glbegin(gl_quads);         tex.bind();             gltexcoord2f(0, 0);         glvertex3f(x+0.0f, y+1.0f, z-1.0f);              gltexcoord2f(0, 1);         glvertex3f(x+0.0f, y+1.0f, z+0.0f);              gltexcoord2f(1, 1);         glvertex3f(x+1.0f, y+1.0f, z+0.0f);              gltexcoord2f(1, 0);         glvertex3f(x+1.0f, y+1.0f, z-1.0f);          glend();     glendlist(); 

and there's rendering:

glclearcolor(0, .5f, 0, 1);     glclear(gl_color_buffer_bit);              glpushmatrix();            if(rto)glcalllist(listtop);           if(rbt)glcalllist(listbot);           if(rfr)glcalllist(listfront);           if(rbk)glcalllist(listback);           if(rle)glcalllist(listleft);           if(rri)glcalllist(listright);              glpopmatrix();      glloadidentity();     //display.update() etc here 

so, might causing bug? had simillar problems?

i don't see enabling depth test,

glenable(gl_depth_test); 

also, have clear depth buffer on every frame.

try before rendering scene, since looks objects being incorrectly overlayed. also, think shouldn't set near value in projection matrix zero, since may cause troubles later.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -