I do not know if this is happening because of Optifine (Version HD U E5) or because of Minecraft itself.
EDIT: Tried on the same singleplayer world without OptiFine, the errors stopped appearing. Looks like it's a OptiFine issue.
Your OpenGL version is not recent enough for Optifine, can you check your version and tell Optifine what OpenGL version + Optifine version you are using, and give them latest.log from your logs file in the Minecraft folder.
Thanks for the help but I found a better solution. Instead of messing around with the settings, I just went to Options -> Video Settings -> Other and disabled "Show OpenGL errors". As I said, the game worked fine even with the error. Although this is just a workaround to ignore the errors, I will still consider this ad the solution and I will mark it as resolved.