1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| HDC hdc = wglGetCurrentDC();
HGLRC hglrc = wglGetCurrentContext();
wglGetLastError();
// Query for a suitable pixel format based on the specified mode.
int format;
int pformat[MAX_PFORMATS];
unsigned int nformats; int iattributes[2*MAX_ATTRIBS];
float fattributes[2*MAX_ATTRIBS];
int nfattribs = 0;
int niattribs = 0;
// Attribute arrays must be "0" terminated - for simplicity, first
// just zero-out the array entire, then fill from left to right.
memset(iattributes,0,sizeof(int)*2*MAX_ATTRIBS);
memset(fattributes,0,sizeof(float)*2*MAX_ATTRIBS);
// Since we are trying to create a pbuffer, the pixel format we
// request (and subsequently use) must be "p-buffer capable".
iattributes[niattribs ] = WGL_DRAW_TO_PBUFFER_ARB;
iattributes[++niattribs] = GL_TRUE;
// we are asking for a pbuffer that is meant to be bound
// as an RGBA texture - therefore we need a color plane
iattributes[++niattribs] = WGL_BIND_TO_TEXTURE_RGBA_ARB;
iattributes[++niattribs] = GL_TRUE;
wglChoosePixelFormatARB( hdc, iattributes, fattributes, MAX_PFORMATS, pformat, &nformats ); |