MFC opengl 记录
https://www.songho.ca/opengl/gl_mvc.html
https://www.opengldn.com/codes
glWin.exe
这个地球 可以转动
代码是 vs2015 win32 写的,不是MFC工程,有main.cpp文件
而且代码有错误,编译不出来,有错误
INT_PTR CALLBACK DialogProc ( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void ControllerGL::runThread()
{
// set the current RC in this thread
::wglMakeCurrent(view->getDC(), view->getRC());
// initialize OpenGL states
model->init();
Win::log(L"Initialized OpenGL states.");
// load bmp and create texture
HBITMAP hBitmap = (HBITMAP)LoadImage(::GetModuleHandle(0), MAKEINTRESOURCE(IDB_BITMAP_EARTH),
IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
if(hBitmap)
{
// get bitmap info
BITMAPINFO bitmap;
bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
::GetDIBits(view->getDC(), hBitmap, 0, 0, 0, &bitmap, DIB_RGB_COLORS);
int width = bitmap.bmiHeader.biWidth;
int height = bitmap.bmiHeader.biHeight; // negative means top-to-bottom orientation
int bitCount = bitmap.bmiHeader.biBitCount; // bits per pixel
int byteCount = bitmap.bmiHeader.biSizeImage; // # of bytes of bitmap
// get bitmap data as BGR
unsigned char* buffer = new unsigned char[byteCount];
int result = ::GetDIBits(view->getDC(), hBitmap, 0, height, buffer, &bitmap, DIB_RGB_COLORS);
glWinSimple
OrbitCamera
OrbitCamera