コード例 #1
0
ファイル: OpenGLProgram.cpp プロジェクト: Mertank/ToneArm
/*
=============
OpenGLProgram::InitializeProgram

	OpenGLProgram Initialization.
=============
*/
bool OpenGLProgram::InitializeProgram( const char* name, const std::vector<Shader*>& shaderList, const char* outVariable, ProgramFeatures::Value features ) {
	m_programID = glCreateProgram();
	SetProgramName( name );

	for( std::vector<Shader*>::const_iterator iter = shaderList.begin(); iter != shaderList.end(); ++iter ) { 
		if( AttachShader( ( *iter ) ) == 0 ) {
			char buff[256];
			sprintf_s( buff, "Failed to compile %s program", name );
			Log::GetInstance()->WriteToLog( "OpenGLProgram", buff );

			return false;
		}
	}
		
	SetOutVariable( outVariable );
	LinkProgram();
	SetFeatures( features );

	return m_programID > 0;
}
コード例 #2
0
static int __cdecl CGPCmain(int argc, TCHAR** argv)
{
    int            nErrors;
    ICG_IECFront*  pIFront;
    CGlobCtx*      pgc;
    HRESULT        hr;
    FC_CString     jot;
    const TCHAR*          pszGen;
    const CG_POU4CPInfo** pzpProcessed;

    //core init:
    //get a front end:
    hr = CoCreateInstance(CLSID_CG_IECFront,
                          NULL, 
                          CLSCTX_INPROC_SERVER,
                          IID_ICG_IECFront, 
                          (void**)&pIFront);
    if(FAILED(hr))
    {
        _tprintf(CG_FATAL_MSGFMT,__FILE__,__LINE__,_T("failed to create front end COM instance"));
        return 1;
    }

    //new global context:
    pgc = new CGlobCtx(pIFront);



    //check if only command line help wanted:
    if(DumpLogoAndHelp(&pgc->m_dm, argc, argv))
        goto Ende;

    //init front end: loadKAD->loadFeatures->load4CP->load4CL(NULL)->loadCST(NULL)
    //Load the default KAD:
    pIFront->loadKAD(NULL);


    //Parse command line:
    if(pgc->m_dm.hasNoErr())
    {
        ParseCommandLine(&pgc->m_dm, pgc->m_pIF, pgc->getWrtOpts(), argc, argv);
    }


    //load the KAD for this module:
    if(pgc->m_dm.hasNoErr())
    {
        unsigned long ulTrgVer;
        GetVersionDependentKADFileName(&pgc->m_dm, pgc->m_popt, jot, ulTrgVer);
        //ulTrgVer = 21040;
        pgc->m_kad.load(&pgc->m_dm, jot, pgc->m_popt->szCurTrgTyp, ulTrgVer);
    }


    //Load features:
    if(pgc->m_dm.hasNoErr())
    {
        //set the target type name for the not supported diags:
        assert(!pgc->m_popt->szCurTrgTyp.isEmpty());
        pgc->m_dm.setNotSupportedName(pgc->m_popt->szCurTrgTyp);

        //init feature set in front end:
        SetFeatures(pIFront, &pgc->m_kad, pgc->m_popt->szCurTrgTyp);
    }


    //load the 4CP, if no error so far popts->sz4CP is set:
    if(pgc->m_dm.hasNoErr())
        pIFront->load4CP(pgc->m_popt->sz4CP);


    pszGen = pIFront->FCPgetGenPath();
    if(!pszGen || !pszGen[0])
        goto Ende;//no response file!! load4CP is the prerequisite to get 
                  //the gen-path, without gen path info we cannot dump the 
                  //response file!


    //get 4CP options
    if(pgc->m_dm.hasNoErr())
        pgc->getOptionsFrom4CP();

    //load all libs referenced in 4CP:
    if(pgc->m_dm.hasNoErr())
        pIFront->loadLIBs();

    //init lic info (after loadLibs!):
    if(pgc->m_dm.hasNoErr())
        pgc->initLicenseInfo(pIFront->FCPgetAllLIBs(), pgc->m_popt->szCurTrgTyp);

    if(pgc->m_dm.hasNoErr())
        pgc->checkSourceProtection();

    //load all CONST of project and all libs:
    if(pgc->m_dm.hasNoErr())
        pIFront->loadCSTs();

    //Initialisation complete, now check the main processing options:
    if(pgc->m_dm.hasNoErr())
    {
        if(pgc->m_popt->szCheckFile.isEmpty())
        {
            //do a rebuild -i incrementell not supported yet:
            //call a sequence of methods of CGlobCtx: 
            if(pgc->getBPOption()==BP_OPT2)
                pgc->m_dm.userMsg(pgc->m_dm.res1(CG_RES_STR_CMD_MSG));

            pgc->rebuildAll();
        }
        else
        {
            //only check a single source file:
            pgc->checkFile();
        }
    }
 

    if(FC_Exist(pgc->m_popt->sz4CP))
    {
        pzpProcessed = pgc->getProcessed4CPFiles();
        assert(pIFront->FCPgetGenPath() && pIFront->FCPgetGenPath()[0]);
        DumpResponseFile(&pgc->m_dm, pgc->m_popt->szCurTrgTyp, pIFront, pzpProcessed);
        delete(pzpProcessed);
    }//else: do not if no 4cp file, this may happen if you call the backend by hand
     //with a typo in the 4cp file or path, typically this happens if you debug the
     //backend. If called from 4cg the 4cp will always exist
     //TODO:  make a cmdl option if or if not dump a response file, ans also the file name and
     //path should be given on the cmdl by 4cg, this will also give the info in we are called
     //embedded or not, if called embedded and there is a cmdl error we can dump the cmdl 
     //to stdout in order to give the user a hint, if called from dos box the cmdl is visible 
     //anyway...

Ende:
    nErrors = pgc->m_dm.getDisplayedErrors();
    delete(pgc);

    jot.load(pIFront->FCPgetPrjPath())<<"\\"<<pIFront->FCPgetPrjName()<<_T(".4cp");
    hr = pIFront->Release();
    assert(hr==0);
    
    LCT_DumpResult(jot);

    return nErrors;
}