Normal OpenGL cleanup operation WITHOUT context destruction

Recently, I have been doing accelerated GPU acceleration for my real-time program .

I want to create a context and reuse it several times (100+). And I use OpenGL 2.1 and GLSL version 1.20.

Every time I reuse a context, I am going to do the following:

  • Compilation shaders, link program, then glUsePrograme(question 1: should I re-link programor recreate programeach time?)
  • Generate FBOand Texturethen snap them so that I can render on the screen. (Question2: should I destroy those FBOand Texture)
  • Create GL_Array_BUFFERand put some vertex data in it. (Question3: do I even need to clear this?)
  • glDrawArray bluh bluh ...
  • Call glFinish(), then copy the data from the GPU to the CPU by calling glReadPixels.

And is there any other necessary cleanup operation that I should consider?

+4
source share
1 answer

If you can somehow cache or otherwise store OpenGL object identifiers, you should not delete them and instead just reuse them the next time you start. If you do not purchase new identifiers that reuse the old ones, they will either replace existing objects (releasing their distributions correctly), or simply change their data.

glFinish glReadPixels , glReadPixels .

0

All Articles