PDA

View Full Version : Windowless OpenGL



squarewithin
12-07-2002, 07:16 PM
Is there any way to access OpenGL functionality without having to create a window? For example, I would want to send data to a graphics card, perform computations and read back the results. If I were to make this a library, I would not want to have a window pop up.

Humus
12-07-2002, 07:18 PM
Make a hidden window and render to a pBuffer.

Nakoruru
12-09-2002, 07:16 AM
Pbuffers are for offscreen accelerated rendering. However, You need a DC to set a pixel format and everything, so how do you get it?

You do not have to create a window to get one.

Something like this may work:

HDC hDeskDC = GetDC(GetDesktopWindow());
HPBUFFER hPB = wglCreatePBufferARB(hDeskDC, pixelformat, x, y, NULL);
ReleaseDC(hDeskDC);
HDC hDC = wglGetPBufferDCARB(hPB);
HGLRC hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);

...

wglMakeCurrent(NULL, NULL);
wglDeleteContext(hRC);
wglReleasePBufferDCARB(hDC);
wglDestroyPBufferARB(hPB);

My knowledge of GDI and the pixel buffer extention is not perfect, so I may be leaving something obvious out.

The value of the pixelformat variable will have to be selected using the WGL_ARB_pixel_format extension.


[This message has been edited by Nakoruru (edited 12-09-2002).]