OpenGL has been searching for images on the Internet for a long time in a single MFC Document, but he has been dissatisfied with what he found, finally, I found a satisfactory answer in the book OpenGL advanced programming and visual system development, but this code has not been found on the internet yet, so I sent it to my blog.
This blog post focuses on the basic framework in the next blog will give the specific function code: http://www.5dkx.com/arch/164.html
Theoretical Basis:
1) set the display pixel format during the creation of a single document window, and set the properties and style of the window as required by OpenGL.
2) first obtain the description table of the Windows device, and then connect it with the preset OpenGL Drawing description table.
3) Call OpenGL to draw images.
4) When you exit the OpenGL Graphic window, release the RC and DC descriptions tables drawn by OpenGL.
The specific programming steps in the MFC single document are as follows:
Eg. Create a project 5dkx.com
1) Add the wm_create, wm_destroy, wm_size, and wm_timer response functions for the 4dkx. comview class.
2) Add the source code to 5dkx. comview. h.
//////////////////////////////////////// ////////////
// Add member functions and member variables
Bool renderscene ();
Bool setuppixelformat (void );
Void setlogicalpalette (void );
Bool initializeopengl (CDC * PDC );
Hglrc m_hrc; // OpenGL plotting description table
HPALETTE m_hPalette; // OpenGL palette
CDC * m_pDC; // OpenGL device description table
3) modify and add the following functions in the 5dkc. comview. cpp file.
5dkx. comVeiw: preCreateWindow ()
5dkx. comVeiw: OnDraw ()
5dkx. comVeiw: OnCreate ()
5dkx. comVeiw: OnDestroy
5dkx. comVeiw: OnSize ()
5dkx. comVeiw: OnTimer (UINT nIDEvent)
Functions to be added
Void 5dkx. comVeiw: SetLogiclPalette (void)
BOOL 5dkx. comVeiw: InitializeOpenGL (CDC * pDC)
BOOL 5dkx. comVeiw: SetupPixelFormat ()
BOOL 5dkx. comVeiw: RenderScene ()
Initial: http://www.5dkx.com/arch/163.html
Non-special instructions are original articles such as reprint, please note: reprint from 5D happy blog [http://www.5DKX.com/]