views:

292

answers:

2

Hello,

How can I use Opengl in PictureBox toolbox in Visual C++.I didn't come across any document on internet.Do you know any document,tutorial,code example etc. about this topic?

Could you help me please?

+1  A: 

Hello,

I think yo can render to any window context.
Simple get the HWND and use it for context creation.

void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
{
    PIXELFORMATDESCRIPTOR pfd;
    int iFormat;

    // get the device context (DC)
    *hDC = GetDC( hWnd );

    // set the pixel format for the DC
    ZeroMemory( &pfd, sizeof( pfd ) );
    pfd.nSize = sizeof( pfd );
    pfd.nVersion = 1;
    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
                  PFD_DOUBLEBUFFER;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    pfd.cDepthBits = 16;
    pfd.iLayerType = PFD_MAIN_PLANE;
    iFormat = ChoosePixelFormat( *hDC, &pfd );
    SetPixelFormat( *hDC, iFormat, &pfd );

    // create and enable the render context (RC)
    *hRC = wglCreateContext( *hDC );
    wglMakeCurrent( *hDC, *hRC );
}
SuperPro
A: 

I've manage to put it in pictureBox, using this example with modification, you'll have only to change the COpenGL Constructor to PictureBox (previously Form). But, only the last picturebox is rendered anyway. Still working on it...

swdev