if i add 
glEnable(GL_DEPTH_TEST);
before 
_window->render(_ID_renderAction);
it seems to work.

Why do I have to do that ?
It's not handled internally by the framework ?
(confused...)

Stephane 

>>> [EMAIL PROTECTED] 27/08/2008 11:17 >>>
Hi,

I'm implementing the IDBuffer technique for rectangle selection of
visible objects.
I have a problem with Z Sorting of the bufffer grabbed from my
PassiveWindow
see screenshots :
http://www.exotk.org/OpenSG/mainview.png 
http://www.exotk.org/OpenSG/idbuffer.png 

even if I use occlusion for the main view and the idbuffer view, it
does not work (in my main view, I don't use occlusion culling)

any idea ?

thanks a lot,

Stephane

the window is created with :
        _hwnd = CreateWindow("STATIC","", WS_OVERLAPPEDWINDOW,0, 0, _w,
_h, HWND_DESKTOP,  0,  GetModuleHandle(NULL), NULL);

the pfd is 
        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;            
the "grab" code is : 

void init()
{
        OSG::SolidBackgroundPtr _solidBkg =
OSG::SolidBackground::create();
        beginEditCP(_solidBkg);
        _solidBkg->setColor(OSG::Color3f(0,0,0));
        endEditCP(_solidBkg);

        _ID_viewport = OSG::Viewport::create();
        beginEditCP(_ID_viewport);
        _ID_viewport->setBackground(_solidBkg);
        _ID_viewport->setSize(0,0,1,1);
        endEditCP(_ID_viewport);

        _window = OSG::PassiveWindow::create();
        _window->init();
        _window->deactivate();
        _window->addPort(_ID_viewport);

        _ID_renderAction = OSG::RenderAction::create();
        _ID_renderAction->setAutoFrustum(true);
}

void grab()
{
        if ( _hwnd )
        {
                RECT r;
                GetWindowRect(_hwnd,&r);
                if ( abs(r.top - r.bottom) != _h || abs(r.right -
r.left) != _w )
                {
                        SetWindowPos(_hwnd, NULL, 0, 0, _w, _h,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
                }
        }
        else
        {
                if ( !_CreateWindow() )
                        return;
        }
        _window->activate();

        wglMakeCurrent(_hdc,_hGLContext);
        // Setup the GrabForeground
        _grabber = OSG::GrabForeground::create();
        beginEditCP(_grabber);
        OSG::ImagePtr img = OSG::Image::create();
        beginEditCP(img);
        img->set(GL_RGBA,_w,_h);
        endEditCP(img);
        _grabber->setImage(img);
        _grabber->setAutoResize(false);
        _grabber->setActive(false);
        endEditCP(_grabber);

        // Putting it to the viewport
        _window->getPort(0)->getMFForegrounds()->push_back(_grabber);

        // We toggle the switch material so as to render identification
colors.
        switchToIDBuffer();

        beginEditCP(_grabber);
        _grabber->setActive(true);
        endEditCP(_grabber);

        // We render to the grabber
        _window->render(_ID_renderAction);
        glFlush();
        SwapBuffers(_hdc);

        beginEditCP(_grabber);
        _grabber->setActive(false);
        endEditCP(_grabber);

        // We get the data back
        if(_grabber->getImage()->getData() != NULL)
        {
//#ifdef _DEBUG
                _grabber->getImage()->write("C:\\idbuffer.png");
//#endif
                _ID_buffer = _grabber->getImage()->getData();
        }

        // We toggle to standard materials
        switchToNormal();

        // we remove the Grabber
        OSG::MFForegroundPtr::iterator i
=_window->getPort(0)->getMFForegrounds()->find(_grabber);
        if( i != _window->getPort(0)->getMFForegrounds()->end() ){
                _window->getPort(0)->getMFForegrounds()->erase(i);
        }
        wglMakeCurrent(NULL,NULL);
        _window->deactivate();
}
______________________________________________________________ 

Reputation Resources Results 

http://www.rwdi.com 

______________________________________________________________ 

This communication is intended for the sole use of the party to whom it

is addressed and may contain information that is privileged and/or 
confidential. Any other distribution, copying or disclosure is
strictly
prohibited. If you have received this e-mail in error, please notify
us
immediately by telephone (1-519-823-1311) and delete the message
without 
retaining any hard or electronic copies of same. 

RWDI scans outgoing emails for viruses, but makes no warranty as to
their
absence in this email or attachments.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/ 
_______________________________________________
Opensg-users mailing list
[email protected] 
https://lists.sourceforge.net/lists/listinfo/opensg-users
______________________________________________________________ 

Reputation Resources Results 

http://www.rwdi.com 

______________________________________________________________ 

This communication is intended for the sole use of the party to whom it 
is addressed and may contain information that is privileged and/or 
confidential. Any other distribution, copying or disclosure is strictly
prohibited. If you have received this e-mail in error, please notify us
immediately by telephone (1-519-823-1311) and delete the message without 
retaining any hard or electronic copies of same. 

RWDI scans outgoing emails for viruses, but makes no warranty as to their
absence in this email or attachments.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to