How to use OpenGL mapping below Window - Continued GDI

xiaoxiao2021-03-06  54

How to use OpenGL mapping below Window

1. First set the bitmap format (Pixelformat) property of the display device DC. Method: The structure of the PixelformatDescriptor // This structure determines the physical device properties of the OpenGL mapping

For example, if the PFD_Doublebuffer bit in this structure is not set (set up), it is impossible to use a double buffer to do animation through the OpenGL command of the DC of the device. Note: Some bitmap formats (Pixelformat) It is DC support, and some DCs are not supported. So: The program must first use ChoosepixElFormat to select the closer bitmap format supported with the specified bitmap format supported by DC. Then use the setpixelformat to set the DC bitmap format.

2. Establish a rendering context Rc () using the just's device DC, so that the RC and DC is connected: WGLCReateContext establishes the rendering context RC in the device DC; use WGLmakeCurrent to make RC and DC

3. Call the OpenGL function map. Because the thread is corresponding to the RC one, the parameters in the OpenGL function refers to the handle of this thread RC: It is enough to use the OpenGL function.

4. After the figure is completed, the current thread is disconnected by setting the RC of the current thread (method :: wglmakecurrent (null);) Disconnect the current thread and the rendering context, thereby disconnecting the connection with the device DC.

Note: Since the validity of the RC handle at this time is not clear in Microsoft's own document, it is necessary to judge the effectiveness of the RC (IF (HRC) WGLDeleteContext (HRC) when deleting RC later. Situation Release (ReleaseDC) or deletedc device DC

转载请注明原文地址:https://www.9cbs.com/read-115330.html

New Post(0)