先上代码:
BITMAPINFO    bmi;
   memset(&bmi, 0, sizeof(BITMAPINFO));
   bmi.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
   bmi.bmiHeader.biWidth         = 150;
   bmi.bmiHeader.biHeight        = 150;
   bmi.bmiHeader.biPlanes        = 1;
   bmi.bmiHeader.biBitCount      = 32;
   bmi.bmiHeader.biCompression   = BI_RGB;   HBITMAP hDIB = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, NULL, NULL, (DWORD)0);
   HDC hMem = CreateCompatibleDC(NULL);
   SelectObject(hMem, hDIB);
   BITMAP bm;
   ::GetObject(hDIB, sizeof(bm), &bm);
   unsigned int* m_pBitmap = static_cast<unsigned int*>(bm.bmBits);
   memset(m_pBitmap,255,150*150*4);   PIXELFORMATDESCRIPTOR pfd;
   /* set the pixel format for the DC */
   ZeroMemory(&pfd, sizeof(pfd));   pfd.nSize = sizeof(pfd);
   pfd.nVersion = 1;
   pfd.dwFlags = PFD_DRAW_TO_BITMAP |PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
   pfd.iPixelType = PFD_TYPE_RGBA;
   pfd.iLayerType = PFD_MAIN_PLANE;   int iFormat = ChoosePixelFormat(hMem, &pfd);   SetPixelFormat(hMem, iFormat, &pfd);   /* create and enable the render context (RC) */
   HGLRC hRC = wglCreateContext(hMem);
   if (hRC == 0) std::cout<<"OpenGL resource context creation failed";
   wglMakeCurrent(hMem, hRC);   glClearColor( 1.0f, 0.0f, 0.0f, 1.0f );
   glClear(GL_COLOR_BUFFER_BIT);   glFinish();请教大家,小弟我刚接触OPENGL,我想在内存中绘制含有Alpha通道的HBITMAP,但是我设置glClearColor( 1.0f, 0.0f, 0.0f, 1.0f );然后清空图区的时候(glClear(GL_COLOR_BUFFER_BIT)),m_pBitmap中的Alpha通道却为0,不知道这是为什么?无论我在glClearColor中alpha设置成多少,glClear之后,alpha通道都为0,请问怎样才能保留Alpha的值?