Ejemplo n.º 1
0
StDiagnostics::StDiagnostics(const StHandle<StResourceManager>& theResMgr,
                             const StNativeWin_t                theParentWin,
                             const StHandle<StOpenInfo>&        theOpenInfo)
: StApplication(theResMgr, theParentWin, theOpenInfo) {
    myTitle = "sView - Stereoscopic Device Diagnostics";
    params.IsFullscreen = new StBoolParam(false);
    params.IsFullscreen->signals.onChanged.connect(this, &StDiagnostics::doFullscreen);

    myGUI = new StDiagnosticsGUI(this);

#if defined(__ANDROID__)
    addRenderer(new StOutInterlace  (myResMgr, theParentWin));
    addRenderer(new StOutAnaglyph   (myResMgr, theParentWin));
    addRenderer(new StOutDistorted  (myResMgr, theParentWin));
#else
    addRenderer(new StOutAnaglyph   (myResMgr, theParentWin));
    addRenderer(new StOutDual       (myResMgr, theParentWin));
    addRenderer(new StOutIZ3D       (myResMgr, theParentWin));
    addRenderer(new StOutInterlace  (myResMgr, theParentWin));
    addRenderer(new StOutDistorted  (myResMgr, theParentWin));
    addRenderer(new StOutPageFlipExt(myResMgr, theParentWin));
#endif

    // create actions
    StHandle<StAction> anAction;
    anAction = new StActionBool(stCString("DoFullscreen"), params.IsFullscreen);
    addAction(Action_Fullscreen, anAction, ST_VK_F, ST_VK_RETURN);

    anAction = new StActionIntSlot(stCString("DoStereoModeOn"),  stSlot(this, &StDiagnostics::doStereoMode), 1);
    addAction(Action_StereoModeOn,  anAction, ST_VK_S);

    anAction = new StActionIntSlot(stCString("DoStereoModeOff"), stSlot(this, &StDiagnostics::doStereoMode), 0);
    addAction(Action_StereoModeOff, anAction, ST_VK_M);
}
Ejemplo n.º 2
0
StGLRangeFieldFloat32::StGLRangeFieldFloat32(StGLWidget* theParent,
                                             const StHandle<StFloat32Param>& theTrackedValue,
                                             const int theLeft, const int theTop,
                                             const StGLCorner theCorner)
: StGLWidget(theParent, theLeft, theTop, theCorner),
  myTrackValue(theTrackedValue),
  myValueText(NULL),
  myFormat(stCString("%+01.3f")) {
    myTrackValue->signals.onChanged   += stSlot(this, &StGLRangeFieldFloat32::onValueChange);
    StGLWidget::signals.onMouseUnclick = stSlot(this, &StGLRangeFieldFloat32::doMouseUnclick);
}
Ejemplo n.º 3
0
// function create GUI window
bool StWindowImpl::create() {
    myKeysState.reset();
    myInitState     = STWIN_INITNOTSTART;
    myToResetDevice = false;
    if(myParentWin == NULL) {
        return false;
    }

    // retrieve fixed information
    myHasOrientSensor = myParentWin->hasOrientationSensor();
    myIsPoorOrient    = myParentWin->isPoorOrientationSensor();

    myParentWin->signals.onInputEvent += stSlot(this, &StWindowImpl::onAndroidInput);
    myParentWin->signals.onAppCmd     += stSlot(this, &StWindowImpl::onAndroidCommand);

    /*if(myParentWin->getSavedState() != NULL) {
        // we are starting with a previous saved state; restore from it
        myState = *(StSavedState* )myParentWin->getSavedState();
    }*/

    myIsUpdated = true;
    if(myParentWin->getWindow() != NULL) {
        // re-starting output for existing window
        return onAndroidInitWindow();
    }

    // first start - wait for CommandId_WindowInit...
    int aPollRes  = 0;
    int aNbEvents = 0;
    StAndroidPollSource* aSource = NULL;
    while((aPollRes = ALooper_pollAll(-1, NULL, &aNbEvents, (void** )&aSource)) >= 0) {
        if(aSource != NULL) {
            aSource->process(myParentWin, aSource);
        }

        if(myToResetDevice || myParentWin->ToDestroy()) {
            //myToResetDevice = true;
            myStEvent.Type       = stEvent_Close;
            myStEvent.Close.Time = getEventTime();
            signals.onClose->emit(myStEvent.Close);
            return false;
        } else if(myInitState != STWIN_INITNOTSTART) {
            break;
        }
    }

    return myInitState == STWIN_INIT_SUCCESS;
}
Ejemplo n.º 4
0
bool StGLRangeFieldFloat32::stglInit() {
    if(myValueText != NULL) {
        return true;
    }

    myValueText = new StGLTextArea(this, 0, 0, StGLCorner(ST_VCORNER_CENTER, ST_HCORNER_LEFT), -myRoot->scale(1), myRoot->scale(10));
    onValueChange(0.0f);
    myValueText->setTextColor(StGLVec3(1.0f, 1.0f, 1.0f));
    myValueText->setVisibility(true, true);
    if(!myValueText->stglInitAutoHeightWidth()) {
        delete myValueText; myValueText = NULL;
        return false;
    }

    myValueText->changeRectPx().right() += myRoot->scale(10);
    myValueText->setTextWidth(myValueText->getRectPx().width());
    myValueText->setupAlignment(StGLTextFormatter::ST_ALIGN_X_RIGHT, StGLTextFormatter::ST_ALIGN_Y_TOP);
    onValueChange(myTrackValue->getValue());
    const GLint aHeight = myValueText->getRectPx().height();

    StGLButton* aButDec = new StGLButton(this, 0, 0, "-");
    aButDec->setCorner(StGLCorner(ST_VCORNER_CENTER, ST_HCORNER_LEFT));
    aButDec->setHeight(aHeight);
    aButDec->setWidth(myRoot->scale(15));
    aButDec->setVisibility(true, true);
    aButDec->signals.onBtnClick += stSlot(this, &StGLRangeFieldFloat32::doDecrement);

    myValueText->changeRectPx().moveLeftTo(aButDec->getRectPx().right() - myRoot->scale(5));

    StGLButton* aButInc = new StGLButton(this, myValueText->getRectPx().right() + myRoot->scale(5), 0, "+");
    aButInc->setCorner(StGLCorner(ST_VCORNER_CENTER, ST_HCORNER_LEFT));
    aButInc->setHeight(aHeight);
    aButInc->setWidth(myRoot->scale(15));
    aButInc->setVisibility(true, true);
    aButInc->signals.onBtnClick += stSlot(this, &StGLRangeFieldFloat32::doIncrement);

    changeRectPx().right()  = getRectPx().left() + aButInc->getRectPx().right();
    changeRectPx().bottom() = getRectPx().top()  + aHeight;

    return StGLWidget::stglInit();
}
Ejemplo n.º 5
0
bool StOutAnaglyph::create() {
    StWindow::show();
    if(!StWindow::create()) {
        return false;
    }

    // initialize GL context
    myContext = StWindow::getContext();
    myContext->setMessagesQueue(myMsgQueue);
    if(!myContext->isGlGreaterEqual(2, 0)) {
        myMsgQueue->pushError(stCString("OpenGL 2.0 is required by Anaglyph Output"));
        myIsBroken = true;
        return true;
    }

    myContext->stglSetVSync((StGLContext::VSync_Mode )StWindow::params.VSyncMode->getValue());
    StWindow::params.VSyncMode->signals.onChanged += stSlot(this, &StOutAnaglyph::doSwitchVSync);

    // INIT shaders
    const StString aShadersRoot = StProcess::getStShareFolder() + "shaders" + SYS_FS_SPLITTER
                                + ST_OUT_PLUGIN_NAME + SYS_FS_SPLITTER;
    StGLVertexShader aVertShader("Anaglyph"); // common vertex shader
    if(!aVertShader.initFile(*myContext, aShadersRoot + VSHADER)
    || !initProgram(*myContext, mySimpleAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_SIMPLE)
    || !initProgram(*myContext, myGrayAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_GRAY)
    || !initProgram(*myContext, myTrueAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_TRUE)
    || !initProgram(*myContext, myOptimAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_OPTIM)
    || !initProgram(*myContext, myYellowAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_YELLOW)
    || !initProgram(*myContext, myYellowDubiosAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_YELLOWD)
    || !initProgram(*myContext, myGreenAnaglyph, aVertShader,
                    aShadersRoot + FSHADER_GREEN)) {
        aVertShader.release(*myContext);
        myMsgQueue->pushError(stCString("Anaglyph output - critical error:\nShaders initialization failed!"));
        myIsBroken = true;
        return true;
    }

    aVertShader.release(*myContext);
    myIsBroken = false;
    return true;
}
Ejemplo n.º 6
0
StGLRangeFieldFloat32::~StGLRangeFieldFloat32() {
    myTrackValue->signals.onChanged -= stSlot(this, &StGLRangeFieldFloat32::onValueChange);
}
Ejemplo n.º 7
0
void StOutAnaglyph::close() {
    StWindow::params.VSyncMode->signals.onChanged -= stSlot(this, &StOutAnaglyph::doSwitchVSync);
    releaseResources();
    StWindow::close();
}
Ejemplo n.º 8
0
bool StApplication::open() {
    if(!myWindow.isNull()) {
        return true;
    }

    StSettings aGlobalSettings(myResMgr, "sview");
    if(!mySwitchTo.isNull()) {
        myRendId = mySwitchTo->getRendererId();
        myWindow = mySwitchTo;
        mySwitchTo.nullify();
        aGlobalSettings.saveString(ST_SETTING_RENDERER,      myRendId);
        aGlobalSettings.saveBool  (ST_SETTING_RENDERER_AUTO, false);
    } else {
        if(myRenderers.isEmpty()) {
            myWindow = new StWindow(myResMgr, myWinParent);
            myWindow->setMessagesQueue(myMsgQueue);
            myWindow->params.VSyncMode = params.VSyncMode;
        } else {
            bool isAuto = myRendId.isEqualsIgnoreCase(ST_SETTING_AUTO_VALUE);
            if(!isAuto) {
                for(size_t anIter = 0; anIter < myRenderers.size(); ++anIter) {
                    StHandle<StWindow> aWin = myRenderers[anIter];
                    if(myRendId == aWin->getRendererId()) {
                        myWindow = aWin;
                        aGlobalSettings.saveString(ST_SETTING_RENDERER,      myRendId);
                        aGlobalSettings.saveBool  (ST_SETTING_RENDERER_AUTO, isAuto);
                        break;
                    }
                }

                if(myWindow.isNull()) {
                    stError(StString("Output with id '" + myRendId + "' is not found."));
                    isAuto = true;
                }
            }

            if(isAuto) {
                // autodetection
                aGlobalSettings.saveString(ST_SETTING_RENDERER,      ST_SETTING_AUTO_VALUE);
                aGlobalSettings.saveBool  (ST_SETTING_RENDERER_AUTO, isAuto);
                myWindow = myRenderers[0];
                if(!myDevices.isEmpty()) {
                    StHandle<StOutDevice> aBestDev = myDevices[0];
                    for(size_t aDevIter = 0; aDevIter < myDevices.size(); ++aDevIter) {
                        const StHandle<StOutDevice>& aDev = myDevices[aDevIter];
                        if(aDev->Priority > aBestDev->Priority) {
                            aBestDev = aDev;
                        }
                    }
                    for(size_t anIter = 0; anIter < myRenderers.size(); ++anIter) {
                        const StHandle<StWindow>& aWin = myRenderers[anIter];
                        if(aBestDev->PluginId == aWin->getRendererId()) {
                            myWindow = aWin;
                            myWindow->setDevice(aBestDev->DeviceId);
                            break;
                        }
                    }
                }
            }
        }
        myWindow->setTitle(myTitle);
    }

    // synchronize devices enumeration
    const StString aPluginId = myWindow->getRendererId();
    const StString aDeviceId = myWindow->getDeviceId();
    for(size_t aDevIter = 0; aDevIter < myDevices.size(); ++aDevIter) {
        const StHandle<StOutDevice>& aDev = myDevices[aDevIter];
        if(aPluginId == aDev->PluginId
        && aDeviceId == aDev->DeviceId) {
            params.ActiveDevice->setValue((int32_t )aDevIter);
            break;
        }
    }

    // setup GL options before window creation
    const StWinAttr anAttribs[] = {
        StWinAttr_GlDebug, (StWinAttr )myGlDebug,
        StWinAttr_NULL
    };
    myWindow->setAttributes(anAttribs);

    myIsOpened = myWindow->create();
    if(myIsOpened) {
        // connect slots
        myWindow->signals.onRedraw    = stSlot(this, &StApplication::doDrawProxy);
        myWindow->signals.onClose     = stSlot(this, &StApplication::doClose);
        myWindow->signals.onPause     = stSlot(this, &StApplication::doPause);
        myWindow->signals.onResize    = stSlot(this, &StApplication::doResize);
        myWindow->signals.onAction    = stSlot(this, &StApplication::doAction);
        myWindow->signals.onKeyDown   = stSlot(this, &StApplication::doKeyDown);
        myWindow->signals.onKeyUp     = stSlot(this, &StApplication::doKeyUp);
        myWindow->signals.onKeyHold   = stSlot(this, &StApplication::doKeyHold);
        myWindow->signals.onMouseDown = stSlot(this, &StApplication::doMouseDown);
        myWindow->signals.onMouseUp   = stSlot(this, &StApplication::doMouseUp);
        myWindow->signals.onTouch     = stSlot(this, &StApplication::doTouch);
        myWindow->signals.onGesture   = stSlot(this, &StApplication::doGesture);
        myWindow->signals.onScroll    = stSlot(this, &StApplication::doScroll);
        myWindow->signals.onFileDrop  = stSlot(this, &StApplication::doFileDrop);
        myWindow->signals.onNavigate  = stSlot(this, &StApplication::doNavigate);
    }

    return myIsOpened;
}
Ejemplo n.º 9
0
bool StOutIZ3D::create() {
    StWindow::show();
    if(!StWindow::create()) {
        return false;
    }

    // initialize GL context
    myContext = StWindow::getContext();
    myContext->setMessagesQueue(myMsgQueue);
    const StHandle<StResourceManager>& aResMgr = getResourceManager();
    if(!myContext->isGlGreaterEqual(2, 0)) {
        myMsgQueue->pushError(stCString("OpenGL 2.0 is required by iZ3D Output"));
        myIsBroken = true;
        return true;
    }

    StWindow::stglMakeCurrent(ST_WIN_MASTER);
    myContext->stglSetVSync((StGLContext::VSync_Mode )StWindow::params.VSyncMode->getValue());
    StWindow::params.VSyncMode->signals.onChanged += stSlot(this, &StOutIZ3D::doSwitchVSync);

    // INIT iZ3D tables textures
    StAVImage aTableImg;
    StHandle<StResource> aTableOld = aResMgr->getResource(StString("textures") + SYS_FS_SPLITTER + "iz3dTableOld.png");
    uint8_t* aData     = NULL;
    int      aDataSize = 0;
    if(!aTableOld.isNull()
    && !aTableOld->isFile()
    &&  aTableOld->read()) {
        aData     = (uint8_t* )aTableOld->getData();
        aDataSize = aTableOld->getSize();
    }
    if(!aTableImg.load(!aTableOld.isNull() ? aTableOld->getPath() : StString(), StImageFile::ST_TYPE_PNG, aData, aDataSize)) {
        myMsgQueue->pushError(StString("iZ3D output - critical error:\n") + aTableImg.getState());
        myIsBroken = true;
        return true;
    }
    myTexTableOld.setMinMagFilter(*myContext, GL_NEAREST); // we need not linear filtrating for lookup-table!
    if(!myTexTableOld.init(*myContext, aTableImg.getPlane())) {
        myMsgQueue->pushError(stCString("iZ3D output - critical error:\nLookup-table initalization failed!"));
        myIsBroken = true;
        return true;
    }

    StHandle<StResource> aTableNew = aResMgr->getResource(StString("textures") + SYS_FS_SPLITTER + "iz3dTableNew.png");
    aData     = NULL;
    aDataSize = 0;
    if(!aTableNew.isNull()
    && !aTableNew->isFile()
    &&  aTableNew->read()) {
        aData     = (uint8_t* )aTableNew->getData();
        aDataSize = aTableNew->getSize();
    }
    if(!aTableImg.load(!aTableNew.isNull() ? aTableNew->getPath() : StString(), StImageFile::ST_TYPE_PNG, aData, aDataSize)) {
        myMsgQueue->pushError(StString("iZ3D output - critical error:\n") + aTableImg.getState());
        myIsBroken = true;
        return true;
    }
    myTexTableNew.setMinMagFilter(*myContext, GL_NEAREST); // we need not linear filtrating for lookup-table!
    if(!myTexTableNew.init(*myContext, aTableImg.getPlane())) {
        myMsgQueue->pushError(stCString("iZ3D output - critical error:\nLookup-table initalization failed!"));
        myIsBroken = true;
        return true;
    }

    // INIT shaders
    if(!myShaders.init(*myContext)) {
        myMsgQueue->pushError(stCString("iZ3D output - critical error:\nShaders initialization failed!"));
        myIsBroken = true;
        return true;
    }

    myIsBroken = false;
    return true;
}