Memory leak

code is:

//////////////////////
HGLRC bmp_hglrc;
HDC bmp_hdc;

HDC memDC = CreateCompatibleDC(NULL);
int bpp = GetDeviceCaps(memDC,BITSPIXEL);
HBITMAP bmp = CreateBitmap(w,h,1,bpp,0);
SelectObject(memDC,(HBITMAP)bmp);
bmp_hdc = memDC;

BITMAP bmInfo;

GetObject(bmp,sizeof(BITMAP),&bmInfo);

PIXELFORMATDESCRIPTOR pfd;
memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1; // Version number
pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_TYPE_RGBA;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = (BYTE)bmInfo.bmBitsPixel;
pfd.cDepthBits = 32; // 32-bit depth buffer
pfd.iLayerType = PFD_MAIN_PLANE ; // Layer type

int pixelFormat = ChoosePixelFormat(bmp_hdc,&pfd);
BOOL success = SetPixelFormat(bmp_hdc,pixelFormat,&pfd);

bmp_hglrc=wglCreateContext(bmp_hdc);

wglMakeCurrent(bmp_hdc,bmp_hglrc);

Draw(); <---- take memory and never free
wglMakeCurrent(bmp_hdc,NULL);

wglMakeCurrent(NULL,NULL);
wglDeleteContext(bmp_hglrc);
//////////////////////

code from http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/001072.html

[This message has been edited by Hance (edited 02-27-2001).]

So, so code of the Draw() function would be of some interest :wink:

oop’s i forget to delete DC:
DeleteDC(bmp_hdc)