In OnlineGDB you only have the standard input and output (the console) and hence you cannot have graphics.
You should use a graphics API, such as OpenGL, DirectX or Vulkan.
You can also use a home brew rendering framework that does not render triangles on the graphics screen, but on the character screen (console). I've got one lying around in Java, I'll turn it into a C++ project and share the project with you if you'd like to play around.
Good luck!