0
Follow
0
View

openGL 3D Rectangle not overlapping properly in C++

dingashuai 注册会员
2023-01-26 01:33

The reason why this was not working is because

  1. You initialized display mode as GLUT_SINGLE (Not including the GLUT_DEPTH).
  2. You did not enabled glEnable(GL_DEPTH_TEST).

Those two are needed to enable the depth test, so, you have to put glEnable(GL_DEPTH_TEST); right after glClear, and change glutInitDisplayMode(GLUT_SINGLE) to glutInitDisplayMode(GLUT_SINGLE|GLUT_DEPTH).

About the Author

Question Info

Publish Time
2023-01-26 01:33
Update Time
2023-01-26 01:33