コード例 #1
0
ファイル: OSGStagedViewport.cpp プロジェクト: vossg/VCoRE
void StagedViewport::stretchTargetToFrameBuffer(RenderActionBase *action, FrameBufferObject *target)
{

    Window  *pWin = action->getWindow();

    if((pWin->getDrawMode() & Window::PartitionDrawMask) ==
        Window::SequentialPartitionDraw)
    {
        DrawEnv  oEnv;

        oEnv.setWindow(action->getWindow());

        //oEnv.setTileFullSize(getCamera()->tileGetFullSize());
        //oEnv.setTileRegion  (getCamera()->tileGetRegion  ());

        // THINKABOUTME KS:
        //oEnv.setDrawerId  (action->getDrawerId  ());
        //oEnv.setDrawableId(action->getDrawableId());

        glClearColor(0.0, 1.0, 0.0, 0.0);
        glClear(GL_COLOR_BUFFER_BIT);

        FrameBufferAttachment* fba = target->getColorAttachments(0);
        TextureObjChunk* texObj = dynamic_cast<TextureBuffer*>(fba)->getTexture();
        if( texObj )
        {
            texObj->activate(&oEnv,0);
            glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

            glMatrixMode(GL_PROJECTION);
            glPushMatrix();
            glLoadIdentity();
            glOrtho(0, 1, 0, 1, -1, 1 );
            glMatrixMode(GL_MODELVIEW);
            glPushMatrix();
            glLoadIdentity();

            float u = 0.0f;
            float v = 0.0f;

            //            glColor3f(1,1,1);
            glBegin(GL_QUADS);
#if 0
            RTsize w,h;
            buffer->getSize(w,h);
            float view[4];
            view[0] = _optixViewport._viewport.x/(float)w;
            view[1] = _optixViewport._viewport.y/(float)h;
            view[2] = view[0] + _optixViewport._viewport.z/(float)w;
            view[3] = view[1] + _optixViewport._viewport.w/(float)h;

            glTexCoord2f(view[0], view[1]);
            glVertex2f(0.0f, 0.0f);

            glTexCoord2f(view[2], view[1]);
            glVertex2f(1.0f, 0.0f);

            glTexCoord2f(view[2], view[3]);
            glVertex2f(1.0f, 1.0f);

            glTexCoord2f(view[0], view[3]);
            glVertex2f(0.0f, 1.0f);
#else
            glTexCoord2f(u, v);
            glVertex2f(0.1f, 0.1f);
            glTexCoord2f(1.0f, v);
            glVertex2f(.9f, 0.1f);
            glTexCoord2f(1.0f - u, 1.0f - v);
            glVertex2f(.9f, .9f);
            glTexCoord2f(u, 1.0f - v);
            glVertex2f(0.1f, .9f);
#endif
            glEnd();

            glMatrixMode(GL_PROJECTION);
            glPopMatrix();
            glMatrixMode(GL_MODELVIEW);
            glPopMatrix();

            texObj->deactivate(&oEnv,0);
        }
    }
    else
    {
        // TODO: ???
        OSG_ASSERT(false);
    }

}