OpenGL 深度测试在某些计算机上不起作用

OpenGL depth test doesn't work on some computers

这是我的第一个问题。在我的程序中,深度测试在某些计算机上工作正常,但在其他计算机上不起作用,距离较远的对象会覆盖距离较近的对象。我调用了 glEnable(GL_DEPTH_TEST); 并尝试调用 glDepthFunc(GL_LESS);,正如我所说,在某些计算机上一切正常,但同一程序在其他计算机上无法正常运行。如何修复?

编辑:问题已解决。在调用之前添加了这些行 al_create_display(); 一切正常

  al_set_new_display_option(  ALLEGRO_COLOR_SIZE,  32,  ALLEGRO_REQUIRE);
  al_set_new_display_option(  ALLEGRO_DEPTH_SIZE,  24,  ALLEGRO_REQUIRE);
  al_set_new_display_option(  ALLEGRO_STENCIL_SIZE,  8,  ALLEGRO_REQUIRE);
  al_set_new_display_option(  ALLEGRO_AUX_BUFFERS,  0,  ALLEGRO_REQUIRE);  
  al_set_new_display_option(  ALLEGRO_SAMPLES,  4,  ALLEGRO_SUGGEST);

除了激活Depth Test (glEnable(GL_DEPTH_TEST)), it is important that the current framebuffer has a depth buffer
default framebuffer is created at the time the OpenGL Context is constructed. The creation of the OpenGL context depends on the OS and windowing library (e.g. GLFW, SDL, SFML)。默认情况下是否创建深度缓冲区通常取决于系统。通常,window 库提供额外的选项,用于在生成 OpenGL window:

时显式指定深度缓冲区

例如: