Archived

This topic is now archived and is closed to further replies.

garrat

OpenGL in a MFC-Window - Depth Buffer problem

Recommended Posts

garrat    122
Hi all, i am a beginner and have some problems with OpenGL Programming. I want to program a small Maze-Program. Therfore i have some fields with walls, doors etc. My Problem is, that when i draw all fields, then there is a z-buffer failure. That means i could see doors that are behind walls. I have find out, that it depends on the order i draw the walls and doors. For example when i draw first the floor and then the walls then i could see first the floor and only where no floor is I see walls. And that is the same with walls and doors. When I draw secondly the wall and a door is behind that wall but where first drawn on my scene i can see it ...... (Sorry for my bad english, but I hope you understand it...) The problem is, that i don''t know, which to draw first, second and so on, because i can also rotate and move throu my map. I have put some screenshot online so you can see what i mean (hopfully).... http://www.wsc.privat.t-online.de/wrong.jpg http://www.wsc.privat.t-online.de/right.jpg Sources: my init: -------- PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 24, // 24-bit color depth 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored 32, // 32-bit z-buffer 0, // no stencil buffer 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); my deleteScene (next frame) Method: ----- glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ----- Thx a lot. cu, Werner

Share this post


Link to post
Share on other sites