コード例 #1
0
ファイル: ofxShader.cpp プロジェクト: Joe-Z/OF_FractalTerrain
bool ofxShader::compileFile(char const *shaderName, GLhandleARB shader, char const *fileName) {
	char *source;
	source = loadSourceFile(fileName);
	if (source == NULL) {
		printf("%s: Failed to open source file.\n", shaderName);
		return false;
	}
	bool result = compile(shaderName, shader, source);
	free(source);
	return result;
}
コード例 #2
0
//-------------------------------------------------------------------------
bool MainWindow::displaySourceFile(const QString& fileName, bool alwaysLoad)
{
  QPlainTextEdit *tab = getTab(fileName);
  bool result = true;

  if(alwaysLoad || tab->toPlainText().isEmpty())
  {
    result = loadSourceFile(fileName, tab);
  }
  ui.tabWidget->setCurrentWidget(tab);
  return result;
}
コード例 #3
0
ファイル: suiknowbase.cpp プロジェクト: mcdir/sui
void suiKnowBase::loadSourceDirectory(const QDir& path, bool recursively)
{
    // check if path exist
    if (!path.exists())     SuiExcept(SuiExceptionFileNotFound,
                                      QString("Can't find directory '%1'").arg(path.absolutePath()),
                                      "void suiKnowBase::loadSourceDirectory(const QDir& path, bool recursively)");

    QDirIterator dirIt(path, recursively ? QDirIterator::Subdirectories : QDirIterator::NoIteratorFlags);
    while (dirIt.hasNext())
    {
        QFileInfo finfo(dirIt.next());

        if (availableFormats().contains(finfo.suffix(), Qt::CaseInsensitive))
            loadSourceFile(finfo.absoluteFilePath());
    }

}
コード例 #4
0
ファイル: GLSLShader.cpp プロジェクト: abletterer/CGoGN-1
bool GLSLShader::loadGeometryShader(const std::string& filename )
{
	bool	flag;
//	char	*geom_shader_source;

	if (m_geom_shader_source)
		delete [] m_geom_shader_source;

	m_geom_shader_source = loadSourceFile( filename );

	if( !m_geom_shader_source )
	{
		CGoGNerr << "ERROR - GLSLShader::loadGeometryShader() - error occured while loading source file." << CGoGNendl;
		return false;
	}

	flag = loadGeometryShaderSourceString( m_geom_shader_source );
//	delete [] geom_shader_source;

	return flag;
}
コード例 #5
0
ファイル: Bridge.cpp プロジェクト: songzhaochun/x64dbg
void Bridge::emitLoadSourceFile(const QString path, int line, int selection)
{
    emit loadSourceFile(path, line, selection);
}
コード例 #6
0
ファイル: test_symbol_table.c プロジェクト: Hammerkeg/IFJ2015
int main(){

	tSymTablePtr symTable;


	symtableInit(&symTable);


	tData symTableData = symtableInsert(&symTable,"c");

	printf("%s\n",symTable->key);



	symtableInsert(&symTable,"a");
	symtableInsert(&symTable,"e");

	printf("%s\n",symTable->LPtr->key);
	printf("%s\n",symTable->RPtr->key);
	


	//tData symTableData = symtableSearch(symTable,"c");


	symTableData->value->i=0;
	printf("%d\n",symTable->data->value->i);


	symTableData->type=INT;
	printf("%d\n",symTable->data->type);


	symTableData->scope=(char*) malloc(sizeof(5));
	strcpy(symTableData->scope,"main");
	printf("%s\n",symTable->data->scope);




	symTableData = symtableSearch(symTable,"a");

	symTableData->value->f=1.54;
	printf("%f\n",symTableData->value->f);


	symTableData->type=DBL;
	printf("%d\n",symTableData->type);


	symtableScopeInsert(symtableSearch(symTable,"a"),"globalna");
	printf("%s\n",symTable->LPtr->data->scope);



	symtableDispose(&symTable);

	printf("-----------------------------\n");


	loadSourceFile("test.txt");

	Ttoken* token = getNextToken();

	while(!(token->type==END_OF_FILE)){
	
		if ((token->type==1)||(token->type==2)||(token->type==3)||(token->type==4)){
			printf("LINE%d: %s\n",token->lineNum,token->attr->str);
		}
		else{
			printf("LINE%d: %d\n",token->lineNum,token->type);
		}

		destroyToken(token);
		token=getNextToken();
	}
	
	destroyToken(token);
	closeSourceFile();

return 0;
}
コード例 #7
0
ファイル: finalCalc.c プロジェクト: Pitxyoki/Cheetah
void runFJob() {
  int  w, h[NJOBS], n;
  float x1, y1[NJOBS], x2, y2[NJOBS];

  float diff = ((1.0*jobHeight) / HEIGHT) * 0.01;
  x1 = 0.40; //left

  y1[0] = 0.20; //up
  for (int i = 1; i < NJOBS; i++)
    y1[i] = y1[i-1]+diff;//0.20828125;


  x2 = 0.41; //right


  y2[0] = 0.20 + diff;//down
  for (int i = 1; i < NJOBS; i++)
    y2[i] = y2[i-1]+diff;



  w  = WIDTH;  //  -
  for (int i = 0; i < NJOBS; i++)
    h[i] = jobHeight;//-   +




  n  = MAXITER;//  +


  init_rgb();

  printf ("x1=%f y1=%f x2=%f y2=%f w=%d h=%d n=%d file=%s\n",
      x1, y1[0], x2, y2[1], w, h[0], n, "file.ppm");



  nGlobItems[0] = 512;
  nGlobItems[1] = jobHeight < 512 ? jobHeight : 512;
  int nGlobItemsProfile[2] = {512,512};
  nItemsGroup[0] = 8;
  nItemsGroup[1] = (jobHeight % 8) == 0 ? 8 : (jobHeight % 4 == 0) ? 4 : (jobHeight % 2 == 0) ? 2 : 1;
  int nItemsGroupGPU[2];
  nItemsGroupGPU[0] = nItemsGroupGPU[1] = groupSize;

  //jobs for initial profiling
/*  float y1Prof=0.20,  y2Prof=0.21;
  int   wProf =1024,  hProf =1024,  nProf = 1048576;

  for (int i = 0; i < nPUs ; i++) {
    Job *job = createJob();
    setJobID(job, -1-i);
    setAllowPU(job, CL_DEVICE_TYPE_CPU);
    if (GPUs)
      setAllowPU(job, CL_DEVICE_TYPE_GPU);
    setJobCategory(job, 1);
    loadSourceFile(job, "mandel.cl");
    setStartingKernel(job, "calc_tile");

    setArgument(job, INPUT,  1 * sizeof(float), &x1);
    setArgument(job, INPUT,  1 * sizeof(float), &y2Prof);
    setArgument(job, INPUT,  1 * sizeof(float), &x2);
    setArgument(job, INPUT,  1 * sizeof(float), &y1Prof);
    setArgument(job, INPUT,  1 * sizeof(int), &wProf);
    setArgument(job, INPUT,  1 * sizeof(int), &hProf);
    setArgument(job, INPUT,  1 * sizeof(int), &nProf);
    setArgument(job, OUTPUT, wProf*hProf * sizeof(int), NULL);

    setDimensions(job, 2, nGlobItemsProfile, nItemsGroup);
    setResultCollector(job, defaultRCID);
    requestResultNotification(job);

    if (i == 0) {
      sleep(50);
//      printf("Type something to send the first PROFILING job.\n");
//      char asd[100];
//      scanf("%s",asd);
    }
    sendJobToExec(job, defaultSchedID);
  }

  printf("JM  (%i): Sent all PROFILING jobs.\n", myid);
  //jobs for actual work
*/sleep(50);
  for (int i = 0; i < NJOBS; i++) {

    job[i] = createJob();


    setJobID(job[i], i);

    setAllowPU(job[i], CL_DEVICE_TYPE_CPU);
    if (GPUs)
      setAllowPU(job[i], CL_DEVICE_TYPE_GPU);

    setJobCategory(job[i], 1);
    loadSourceFile(job[i], "mandel.cl");
    setStartingKernel(job[i], "calc_tile");


    setArgument(job[i], INPUT,  1 * sizeof(float), &x1);
    setArgument(job[i], INPUT,  1 * sizeof(float), &(y2[(NJOBS-1)-i]));
    setArgument(job[i], INPUT,  1 * sizeof(float), &x2);
    setArgument(job[i], INPUT,  1 * sizeof(float), &(y1[(NJOBS-1)-i]));
    setArgument(job[i], INPUT,  1 * sizeof(int), &w);
    setArgument(job[i], INPUT,  1 * sizeof(int), &(h[i]));
    setArgument(job[i], INPUT,  1 * sizeof(int), &n);
    setArgument(job[i], OUTPUT, w*(h[i]) * sizeof(int), NULL);

    setDimensions(job[i], 2, nGlobItems, nItemsGroup);
    setResultCollector(job[i], defaultRCID);
    requestResultNotification(job[i]);
  }

  pthread_mutex_lock(&end_mutex);
//  while(profilesReceived != nPUs)
//    pthread_cond_wait(&profile_over, &end_mutex);
  pthread_mutex_unlock(&end_mutex);
  //char asd[100];
  sleep(7);
  printf("\n\n\n#####PROFILING OVER#####\n");// Type something to send the first (real) job.\n");
  //      scanf("%s",asd);
  sleep(2);
  if (gettimeofday(&start, NULL)) {
    perror("gettimeofday");
    exit (EXIT_FAILURE);
  }

//  printf("JM: Sending now!\n");
  for (int i = 0; i < NJOBS; i++)
    sendJobToExec(job[i], defaultSchedID);


}
コード例 #8
0
ファイル: Compiler.cpp プロジェクト: SahandMalaei/EagleEngine
bool compileESFile(EagleVirtualMachine::Script *script, char *inputFileAddress, char *outputFileAddress, bool optimize, bool outputEASMAndEVEFiles, bool addComments)
{
    int characterIndex = -1;

    for(int i = strlen(inputFileAddress) - 2; i > -1; --i)
    {
        if(inputFileAddress[i] == '/')
        {
            characterIndex = i;

            break;
        }
    }

    if(characterIndex != -1)
    {
        rootAddress = inputFileAddress;
        rootAddress = rootAddress.substr(0, characterIndex + 1);
    }
    else
    {
        rootAddress = "";
    }

    initializeCompiler();

    if(!loadSourceFile(inputFileAddress))
    {
        shutdownCompiler();

        return 0;
    }

    preprocessSourceFile();

    if(!compileSourceFile())
    {
        shutdownCompiler();

        return 0;
    }

    if(optimize)
    {
        optimizeICode();
    }

    if(outputEASMAndEVEFiles)
    {
        emitCode(outputFileAddress, addComments);
    }

    script->loadCompilerData();

    shutdownCompiler();

    if(outputEASMAndEVEFiles)
    {
        std::string eveAddress = (std::string)outputFileAddress + ".eve";
        EagleAssembler::loadEASMFile(outputFileAddress);
        EagleAssembler::initializeParser();
        EagleAssembler::parseSourceCode();
        //script->loadAssemblerData();
        EagleAssembler::outputAssembledEVE((char *)eveAddress.c_str());
        EagleAssembler::cleanup();
    }

    Debug::outputLogEvent((char *)("Script \"" + (string)inputFileAddress + "\" successfully loaded").c_str());
    Debug::outputLogEvent("");

    return 1;
}
コード例 #9
0
ファイル: Shader.cpp プロジェクト: ElkMonster/gloost-oma
/**
  \brief Class constructur taking vertex- and fragmentshader files

  \param vertexShaderFileName file path to a vertex shader file (ASCII)
  \param fragmentShaderFileName file path to a fragment shader file (ASCII)
  \param geometryShaderFileName file path to a fragment shader file (ASCII)
*/
Shader::Shader(const std::string& vertexShaderFileName,
               const std::string& fragmentShaderFileName,
               const std::string& geometryShaderFileName):
    MultiGlContext(1),
    _vertexShaderFileName(vertexShaderFileName),
    _fragmentShaderFileName(fragmentShaderFileName),
    _geometryShaderFileName(geometryShaderFileName),
    _vertexShaderSource(0),
    _fragmentShaderSource(0),
    _geometryShaderSource(0),
    _nullVertexSource(  "void main (void) { gl_Position  = ftransform(); }"),
    _nullFragmentSource("void main (void) { gl_FragColor = vec4( 0.8, 0.1, 0.1, 1 ); }"),
    _nullGeometrySource("void main (void) { gl_Position = gl_PositionIn[0]; EmitVertex(); EndPrimitiv(); }")


{
  if (_vertexShaderFileName != GLOOST_SHADER_FILE_NONE)
  {

#ifndef GLOOST_SYSTEM_DISABLE_OUTPUT_MESSAGES
    std::cerr << std::endl;
    std::cerr << std::endl << "Message from Shader::Shader() on SharedResource " << getSharedResourceId() << ":";
    std::cerr << std::endl << "             Loading shader files \"" << _vertexShaderFileName << "\", ";
    std::cerr << std::endl << "                                  \"" << _fragmentShaderFileName << "\", ";
    std::cerr << std::endl << "                                  \"" << _geometryShaderFileName << "\"";
    std::cerr << std::endl;
#endif

    /// Read Shaderfiles
    _vertexShaderSource   =  loadSourceFile( _vertexShaderFileName.c_str()   );
    _fragmentShaderSource =  loadSourceFile( _fragmentShaderFileName.c_str() );

    if (geometryShaderFileName != GLOOST_SHADER_FILE_NONE)
    {
      _geometryShaderSource = loadSourceFile( _geometryShaderFileName.c_str()   );
    }


    /// Set nullshader if no source file was loaded
    if (!_vertexShaderSource || !_fragmentShaderSource)
    {

#ifndef GLOOST_SYSTEM_DISABLE_OUTPUT_WARNINGS
      std::cerr << std::endl;
      std::cerr << std::endl << "Warning from Shader::Shader() on SharedResource " << getSharedResourceId() << ":";
      std::cerr << std::endl << "             Applying GLOOST_SHADER_FILE_NONE";
      std::cerr << std::endl;
#endif

      _vertexShaderSource   = _nullVertexSource;
      _fragmentShaderSource = _nullFragmentSource;
    }
    else
    {
      if ((geometryShaderFileName != GLOOST_SHADER_FILE_NONE) && (!_geometryShaderSource))
      {
#ifndef GLOOST_SYSTEM_DISABLE_OUTPUT_WARNINGS
        std::cerr << std::endl;
        std::cerr << std::endl << "Warning from Shader::Shader() on SharedResource " << getSharedResourceId() << ":";
        std::cerr << std::endl << "             Could NOT load geometry shader file \"" << geometryShaderFileName << "\"";
        std::cerr << std::endl;
#endif
        _geometryShaderSource = _nullGeometrySource;

      }
    }
  }
  else
  {

#ifndef GLOOST_SYSTEM_DISABLE_OUTPUT_WARNINGS
    std::cerr << std::endl;
    std::cerr << std::endl << "Warning from Shader::Shader() on SharedResource " << getSharedResourceId() << ":";
    std::cerr << std::endl << "             Applying red GLOOST_SHADER_FILE_NONE";
    std::cerr << std::endl;
#endif

    _vertexShaderSource   = _nullVertexSource;
    _fragmentShaderSource = _nullFragmentSource;
    _geometryShaderSource = NULL;
  }
}
コード例 #10
0
ファイル: shader.cpp プロジェクト: atondwal/Core
void ShaderPart::reload() {
    loadSourceFile();
}
コード例 #11
0
ファイル: shader.cpp プロジェクト: atondwal/Core
void ShaderPart::setSourceFile(const std::string& filename) {
    this->filename = filename;
    loadSourceFile();
}