Hello everybody,

Im desperately trying to embed OpenSG in SystemWindowsForms Application.
I subclassed a UserControl like this:

OpenSGControl::OpenSGControl()
{
        this->Dock = System::Windows::Forms::DockStyle::Fill;
        this->BackColor = System::Drawing::Color::White;
        timer1 = gcnew System::Windows::Forms::Timer();
        timer1->Interval = 500;
        timer1->Enabled = true;
        timer1->Tick += gcnew System::EventHandler(this,
&OpenSGControl::timer1_Tick);

                osg::osgInit(0,NULL);
                osg::WIN32WindowPtr win = osg::WIN32Window::create();
                HWND hwnd = (HWND)this->Handle.ToPointer();
                win->setHwnd(hwnd);
        hdc = GetDC(hwnd);

                int iPixelFormat;
        PIXELFORMATDESCRIPTOR   pfd;
        memset(&pfd, 0, 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.iLayerType = PFD_MAIN_PLANE;
        pfd.cDepthBits = 16;
        iPixelFormat = ChoosePixelFormat(GetDC(hwnd), &pfd);
        SetPixelFormat(GetDC(hwnd), iPixelFormat, &pfd);
                this->mgr = new osg::SimpleSceneManager();
                mgr->setWindow(win);
                win->init();
                //win->deactivate();
                osg::NodePtr scene;
                scene = osg::makeTorus(.5,3,16,16);
                this->mgr->setRoot(scene);
                this->mgr->showAll();

}

In the timer1_tick And the OnPaintMethod, i have overridden I call
mgr->Redraw;
My Form is black if i call redraw. It is white other wise. Thats how it
is expected.
(So I think it must be alreday embedded correctly, because I guess the
screen-blacking is alreday done with opengl-calls coming form opensg)
But theres no torus. Why cant I see the torus?

I tried it also with the PassiveWindow, where I created my own
glcontexts.
(Similar to the PassiveWindow/QT Example)
I could see things painted with normal gl-Functions. But as soon as I
activated my mgr->redraw(); - line the window is only black. :-(

Wheres the error here?


Greetings and thx in advance
        Hagen

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to