Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it necessary to delete a rendering context and destroy a device context?

Tags:

c++

winapi

opengl

Is it necessary to delete the HDC and HRC when using the win32 api for OpenGL? I would think the Win32API would destroy them upon the window's closing?

Clarification: The HRC is a HGLRC object.

like image 277
Darkenor Avatar asked Apr 01 '13 18:04

Darkenor


1 Answers

Is it "necessary"? If your process terminates itself after closing the window, no. Windows will clean up outstanding handles of these type.

Should you do it? Absolutely. You should always clean up objects you use in your application. Dropping things on the floor for the OS to clean up is not good practice. If for no other reason than the fact that you might want to create a new window after closing the old one. In which case, you have this garbage HGLRC lying around taking up precious resources.

like image 173
Nicol Bolas Avatar answered Oct 16 '22 05:10

Nicol Bolas