私は単純なボクセル エンジン (Minecraft を考えてください) を作成しており、現在、遮蔽された顔を取り除いて貴重な fps を得る段階にあります。私は OpenGL であまり経験がなく、glColorMask マジックがどのように機能するかをよく理解していません。
これは私が持っているものです:
// new and shiny
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// this one goes without saying
glEnable(GL_DEPTH_TEST);
// I want to see my code working, so fill the mask
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// fill the z-buffer, or whatever
glDepthFunc(GL_LESS);
glColorMask(0,0,0,0);
glDepthMask(GL_TRUE);
// do a first draw pass
world_display();
// now only show lines, so I can see the occluded lines do not display
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// I guess the error is somewhere here
glDepthFunc(GL_LEQUAL);
glColorMask(1,1,1,1);
glDepthMask(GL_FALSE);
// do a second draw pass for the real rendering
world_display();
これはある程度機能しますが、カメラの位置を変更すると、世界が消え始め、線が少なくなり、まったく見えなくなります。