A quick compile and run, and the example works fine.
At a guess you are running from within X. Trying to run it from X does indeed give me the errors you report.
Note the title comment on the example
Trying to get OpenGL ES screen on RPi4 without X
DRM supports a single client at a time. If X is running then it is the one true client, and anything else will be told permission denied. This is expected.
If you wish to run within X then you need to look at composing via EGL, not via GBM/DRM.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.