Esempio n. 1
0
/*----------------------------------------------------------------------------------------------------*/
QVariant configFileValue( QString group, QString key, QString defaultValue )
{
    QVariant result;
    QString fileName  = sandboxPath(SP_APP)+QString("config.ini");
    QSettings settings( fileName, QSettings::IniFormat );
    settings.beginGroup(group);
    result = settings.value( key, defaultValue );
    settings.endGroup();
    /**/
    return result;
}
Esempio n. 2
0
/* @NOTE この関数は近い将来撤去されます */
nlPixelShader nlCreatePixelShader( 
                                  const nlInt8* script, 
                                  unsigned int scriptSize, 
                                  const nlInt8* funcName,
                                  nlEngineContext& cxt )
{
    ID3DBlob* pBlob = NULL;
    ID3DBlob* pErrorBlob = NULL;
    nlPixelShader pixelShader;
    pixelShader.shader_ = NULL;
#ifndef INTROMODE
    const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR;
    HRESULT hr = D3D10CompileShader( script, scriptSize, funcName, shaderMacros, NULL, funcName, "ps_4_0", flag, &pBlob, &pErrorBlob );
    if( FAILED(hr) )
    {
        std::string error = std::string("[")+std::string(funcName)+std::string("]")+std::string(DXGetErrorDescriptionA(hr));
        error.resize(error.size()-1);/* 改行コードを取り除く */
        if(pErrorBlob)
        { 
            error += std::string( (nlInt8*)pErrorBlob->GetBufferPointer() );
            error.resize(error.size()-1);/* 改行コードを取り除く */
        }
        NL_ERR( ERR_018, error.c_str() );
        /* ファイルに書き出す */
        QString fileName;
        QTime now = QDateTime::currentDateTime().time();
        fileName.sprintf("err_%s_%d_%d_d.log",funcName,now.hour(),now.minute(),now.second() );
        QString path = sandboxPath(SP_APP)+fileName;
        QFile dataFile(path);
        dataFile.open(QIODevice::WriteOnly|QIODevice::Text);
        dataFile.write( script );
        /**/
        pixelShader.shader_ = NULL;
        return pixelShader;
    }
#else
    const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR|D3D10_SHADER_OPTIMIZATION_LEVEL3;
    HRESULT hr = D3D10CompileShader( script, scriptSize, funcName, shaderMacros, NULL, funcName, "ps_4_0", flag, &pBlob, &pErrorBlob );
    if( FAILED(hr) )
    {
        MessageBox( NULL, (nlInt8*)pErrorBlob->GetBufferPointer(), "", MB_OK );
    }
#endif
    NL_HR_VALID( cxt.d3dDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &pixelShader.shader_ ) );

    return pixelShader;
}
Esempio n. 3
0
QString sandboxPath( SandboxPath pathType )
{
    switch( pathType )
    {
    case SP_EXE:
        {
            QString tmp = QCoreApplication::applicationFilePath();
            return tmp;
        }
    case SP_APP:
        {
            return QCoreApplication::applicationDirPath()+QString("/");
        }
    case SP_MEDIA:
        {
            QVariant mediaRelPath = configFileValue("config","mediaPath","media");
            QString mediaDir = sandboxPath(SP_APP) + mediaRelPath.toString() + "/";
            /* 最後に本当にそのディレクトリがあるかをチェック */
            QDir dir(mediaDir);
            if( !dir.exists( mediaDir ) )
            {
                //nlPrintf( "media directory is not found\n" );
                return "";
            }
            return mediaDir;
        }
    case SP_MESH:
        return sandboxPath(SP_MEDIA)+QString("mesh/");
    case SP_SHADER:
        return sandboxPath(SP_MEDIA)+QString("shader/");
    case SP_RENDERTARGET:
        return sandboxPath(SP_MEDIA)+QString("rendertarget/");
    case SP_PATH:
        return sandboxPath(SP_MEDIA)+QString("path/");
    case SP_MUSIC:
        return sandboxPath(SP_MEDIA)+QString("music/");
    case SP_SCENE:
        return sandboxPath(SP_MEDIA)+QString("scene/");
    case SP_TMP:
        return sandboxPath(SP_APP)+QString("/tmp/");
    }
    return "";
}
	void start(Poco::OSP::BundleContext::Ptr pContext)
	{		
		// We need to obtain the BundleLoader via the Application's OSPSubsystem.
		Poco::Util::Application& app = Poco::Util::Application::instance();
		Poco::OSP::OSPSubsystem& ospSubsystem = app.getSubsystem<Poco::OSP::OSPSubsystem>();
		Poco::OSP::BundleLoader& bundleLoader = ospSubsystem.bundleLoader();
		
		Poco::Path sandboxPath(pContext->persistentDirectory(), SandboxRequestHandler::SANDBOX_BUNDLE + ".bndl");
		Poco::File sandboxDir(sandboxPath.toString());
		if (!sandboxDir.exists())
		{
			pContext->logger().information("Creating sandbox bundle.");
			sandboxDir.createDirectories();
			Poco::Path metaInfPath(sandboxPath, "META-INF");
			Poco::File metaInfDir(metaInfPath.toString());
			metaInfDir.createDirectory();
			
			Poco::Path manifestPath(metaInfPath, "manifest.mf");
			Poco::SharedPtr<std::istream> pManifestIStream = pContext->thisBundle()->getResource("sandbox/manifest.mf");
			Poco::FileOutputStream manifestOStream(manifestPath.toString());
			Poco::StreamCopier::copyStream(*pManifestIStream, manifestOStream);

			Poco::Path extensionsPath(sandboxPath, "extensions.xml");
			Poco::SharedPtr<std::istream> pExtensionsIStream = pContext->thisBundle()->getResource("sandbox/extensions.xml");
			Poco::FileOutputStream extensionsOStream(extensionsPath.toString());
			Poco::StreamCopier::copyStream(*pExtensionsIStream, extensionsOStream);	

			Poco::Path scriptPath(sandboxPath, SandboxRequestHandler::SANDBOX_SCRIPT);
			Poco::SharedPtr<std::istream> pScriptIStream = pContext->thisBundle()->getResource("sandbox/sandbox.js");
			Poco::FileOutputStream scriptOStream(scriptPath.toString());
			Poco::StreamCopier::copyStream(*pScriptIStream, scriptOStream);	
		}
		pContext->logger().information("Loading sandbox bundle.");
		Poco::OSP::Bundle::Ptr pSandboxBundle = bundleLoader.loadBundle(sandboxPath.toString());
		pSandboxBundle->resolve();
	}
Esempio n. 5
0
/* @NOTE この関数は近い将来撤去されます */
nlVertexShader nlCreateVertexShader(
                                    const nlInt8* script, 
                                    unsigned int scriptSize, 
                                    const nlInt8* funcName,
                                    nlEngineContext& cxt )
{
    struct GOD_VERTEX
    {
        nlVec4    pos_;
        nlVec4    normal_;
        nlVec4    uv_;
        D3DCOLOR  color_;
    };

    ID3DBlob* pBlob = NULL;
    ID3DBlob* pErrorBlob = NULL;
    nlVertexShader vertexShader;
    vertexShader.inputLayout_ = NULL;
    vertexShader.shader_ = NULL;

    
#ifdef INTROMODE
    const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR | D3D10_SHADER_OPTIMIZATION_LEVEL3;
    HRESULT hr = D3D10CompileShader( script, scriptSize, funcName, shaderMacros, NULL, funcName, "vs_4_0", flag, &pBlob, &pErrorBlob );
    if(FAILED( hr ) )
    {
        MessageBoxA(NULL,(nlInt8*)pErrorBlob->GetBufferPointer(),"",MB_OK);
    }
#else 
    const DWORD flag = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR;
    HRESULT hr = D3D10CompileShader( script, scriptSize, funcName, shaderMacros, NULL, funcName, "vs_4_0", flag, &pBlob, &pErrorBlob );
#endif

#ifndef INTROMODE
    if( FAILED(hr) )
    {
        std::string error = std::string("[")+std::string(funcName)+std::string("]")+std::string(DXGetErrorDescriptionA(hr));
        if(pErrorBlob)
        {
            error += std::string( (nlInt8*)pErrorBlob->GetBufferPointer() ); 
            error.resize(error.size()-1);/* 改行コードを取り除く */
        }
        NL_ERR( ERR_005, error.c_str() );
        /* ファイルに書き出す */
        QString fileName;
        QTime now = QDateTime::currentDateTime().time();
        fileName.sprintf("err_%s_%d_%d_d.log",funcName,now.hour(),now.minute(),now.second() );
        QString path = sandboxPath(SP_APP)+fileName;
        QFile dataFile(path);
        dataFile.open(QIODevice::WriteOnly|QIODevice::Text);
        dataFile.write( script );
        /**/
        return vertexShader;
    }
#endif
    /* create shader */
    NL_HR_VALID( cxt.d3dDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), NULL, &vertexShader.shader_ ) );
    /* create inputlayout */
    NL_HR_VALID( cxt.d3dDevice->CreateInputLayout(NLM_INPUT_ELEMENT, _countof(NLM_INPUT_ELEMENT), pBlob->GetBufferPointer(), pBlob->GetBufferSize(), &vertexShader.inputLayout_  ) );
    /**/
    return vertexShader;
}