public void StartDrawMeshToImage(int width, int height) { //create texture textureForDrawMesh = new OpenGLTexture(); textureForDrawMesh.LoadImage(new Rgba32[width * height], width, height); //create frame buffer GL.GenFramebuffers(1, frameBuffersForDrawMesh); frameBufferForDrawMesh = frameBuffersForDrawMesh[0]; GL.BindFramebuffer(GL.GL_FRAMEBUFFER_EXT, frameBufferForDrawMesh); GL.BindTexture(GL.GL_TEXTURE_2D, framebufferColorTexture); GL.FramebufferTexture2D(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, (uint) textureForDrawMesh.GetNativeTextureId(), 0); if (GL.CheckFramebufferStatus(GL.GL_FRAMEBUFFER_EXT) != GL.GL_FRAMEBUFFER_COMPLETE_EXT) { throw new Exception("Framebuffer is not complete."); } }