extract opengl code to graphics.rs