Exemplo n.º 1
0
void PerVertexColorShader::construct()
{
    QOpenGLFunctions_4_1_Core* f = resourceManager()->functions();

    bool success = create();
    Q_ASSERT(success);

    success = compileFile(ShaderProgram::VertexShader, ":/shaders/pervertexcolor.vert");
    Q_ASSERT(success);

    success = compileFile(ShaderProgram::FragmentShader, ":/shaders/pervertexcolor.frag");
    Q_ASSERT(success);

    link();

    m_iAttributeLocations[Position] = f->glGetAttribLocation(handle(), "vPositionModelSpace");
    m_iAttributeLocations[Normal] = f->glGetAttribLocation(handle(), "vNormal");
    m_iAttributeLocations[Color] = f->glGetAttribLocation(handle(), "vColor");
    m_iAttributeLocations[ColorUniform] = f->glGetUniformLocation(handle(), "fColor");
    m_iAttributeLocations[FogColorUniform] = f->glGetUniformLocation(handle(), "fFogColor");
    m_iAttributeLocations[FogBeginUniform] = f->glGetUniformLocation(handle(), "fFogBegin");
    m_iAttributeLocations[FogEndUniform] = f->glGetUniformLocation(handle(), "fFogEnd");
    m_iAttributeLocations[ModelToWorldMatrix] = f->glGetUniformLocation(handle(), "modelToWorld");
    m_iAttributeLocations[WorldToCameraMatrix] = f->glGetUniformLocation(handle(), "worldToCamera");
    m_iAttributeLocations[CoordinateTransformMatrix] = f->glGetUniformLocation(handle(), "hammerToOpenGL");
    m_iAttributeLocations[CameraProjectionMatrix] = f->glGetUniformLocation(handle(), "projection");
    m_iAttributeLocations[CounterScaleUniform] = f->glGetUniformLocation(handle(), "counterScale");
    m_iAttributeLocations[DirectionalLightUniform] = f->glGetUniformLocation(handle(), "directionalLight");
}
Exemplo n.º 2
0
void
compileObjectFiles()
{ int n;

  for(n=0; n<cfiles.size; n++)
    compileFile(cc, &coptions, cfiles.list[n]);
  for(n=0; n<cppfiles.size; n++)
    compileFile(cxx, &cppoptions, cppfiles.list[n]);
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
	struct ByteStream *data;
	FILE *output;
	--argc;

	if (argc < 1) {
		fprintf(stderr, "\t\x1b[1m\x1b[91mSyntax: %s <path to test file> [<path to executable>]\x1b[0m\n",
		        *argv);
		exit(-1);
	}
	++argv;
	data = compileFile(*argv);
	printf("\n");
	--argc;
	if (argc) {
		++argv;
		output = fopen(*argv, "w");
	} else {
		output = fopen("b.out", "w");
	}
	writeStreamToFile(output, data);
	fclose(output);
	fprintf(stdout, "\x1b[1m\x1b[92mExiting...\x1b[0m\n");
	return 0;

}
Exemplo n.º 4
0
void z::Compiler::compile() {
    for(z::Ast::Config::PathList::const_iterator it = _config.sourceFileList().begin(); it != _config.sourceFileList().end(); ++it) {
        const z::string& filename = *it;
        z::string ext = z::dir::getExtention(filename);
        if(_project.zppExt().find(ext) == z::string::npos) {
            continue;
        }
        std::cout << "Compiling " << filename << std::endl;
        z::Ast::Unit unit;
        initContext(unit, false);

        z::Ast::Module module(unit, filename, 0);
        if(!compileFile(module, filename, "Compiling"))
            throw z::Exception("Compiler", zfmt(Ast::Token(filename, 0, 0, ""), z::string("Cannot open source file: %{s}").arg("s", filename)));

        ZenlangGenerator zgenerator(_project, _config, module);
        zgenerator.run();

        if(_config.olanguage() == "stlcpp") {
            StlcppGenerator generator(_project, _config, module);
            generator.run();
        } else {
            throw z::Exception("Compiler", zfmt(Ast::Token(filename, 0, 0, ""), "Unknown code generator %{s}").arg("s", _config.olanguage()));
        }
    }
}
Exemplo n.º 5
0
	std::pair<PExprNode, FilePath> FileCompiler::loadCode(ExprLocation loc, ConstStrA name)
	{


		FilePath p = loc.getFileName();
		if (p.getPath().empty()) p = FilePath(ConstStrW(L"."), true);
		for (ConstStrA::SplitIterator iter = name.split('/'); iter.hasItems();) {
			ConstStrA part = iter.getNext();
			if (part.empty()) {
				continue;
			}
			else if (part == "..") {
				p = p / parent;
			}
			else {
				p = p / part;
			}			
		}

		const PExprNode *code = codeCache.find(p);
		PExprNode out;
		if (code) out = *code;
		else {
			out = compileFile(p);
			codeCache(p, out);
		}
		return std::make_pair(out, p);

	}
Exemplo n.º 6
0
void IF_LoadCS(void)
{
char * f;
    f = getString();
    if (f != NULL) {
       compileFile(f);
       free((void*)f);
    }
}
Exemplo n.º 7
0
Compiler::Compiler(QWidget *parent) : Page(parent), m_serial(this)
{
    setupUi(this);

    QObject::connect(&m_compiler, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError()));
    QObject::connect(&m_compiler, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput()));
    QObject::connect(&m_compiler, SIGNAL(finished(int, QProcess::ExitStatus)), UserProgram::instance(), SLOT(compileFinished(int, QProcess::ExitStatus)));
    QObject::connect(&m_serial, SIGNAL(downloadFinished(QString)), this, SLOT(compileFile(QString)));
    
    m_serial.start();
}
Exemplo n.º 8
0
void z::Compiler::import(z::Ast::Module& module) {
    z::string ifilename = findImport(module.filename());
    ifilename = z::dir::cleanPath(ifilename);

    // check if file is already imported
    if(module.unit().headerFileList().find(ifilename) != module.unit().headerFileList().end()) {
        return;
    }

    // if not, add it to list of files imported into this unit
    module.unit().addheaderFile(ifilename);
    compileFile(module, ifilename, "Importing");
}
Exemplo n.º 9
0
bool ofxShader::loadShader(char const *vertexFileName, char const *fragmentFileName) {
	loaded = false;

	if (!GLEE_ARB_shader_objects) {
		printf("Extension \"ARB_shader_objects\" not supported.\n");
		return false;
	}

	vertexShader = (GLhandleARB)glCreateShader(GL_VERTEX_SHADER);
	fragmentShader = (GLhandleARB)glCreateShader(GL_FRAGMENT_SHADER);
	shader = glCreateProgramObjectARB();

	if (
		compileFile(vertexFileName, vertexShader, vertexFileName) &&
		compileFile(fragmentFileName, fragmentShader, fragmentFileName) &&
		link(fragmentFileName)
	) {
		return loaded = true;
	} else {
		unload();
		return false;
	}
}
Exemplo n.º 10
0
static inline void compileFolder(const Config *config)
{
	assert(config->handler_dir!=NULL);
	DIR *rep=opendir(config->handler_dir);
	if(rep == NULL)
		die("This is not a folder : %s\n", config->handler_dir);

	Dirent *current=NULL;
	char *ext=NULL;
	while ((current=readdir(rep)) != NULL)
	{
		ext=rindex(current->d_name, '.');
		if (strcmp(current->d_name, ".")!=0 && strcmp(current->d_name, "..")!=0 && ext!=NULL)
			if(strcmp(ext, ".c") == 0)
			{
				size_t size=sizeof(char)*(strlen(config->handler_dir)+strlen(current->d_name)+strlen("/"))+1;

				PRINT("Size1 %d", (int)size);
				char *filename=malloc(size);
				strcpy(filename, config->handler_dir);
				strcat(filename, "/");
				strcat(filename, current->d_name);

				*ext='\0';

				size=sizeof(char)*(strlen(config->tmp_dir)+strlen(current->d_name)+strlen("/"))+1;
				PRINT("Size2 %d", (int)size);
				char *tmp=malloc(size);
				strcpy(tmp, config->tmp_dir);
				strcat(tmp, "/");
				strcat(tmp, current->d_name);


				/*strcpy(tmp, config->tmp_dir);
				strcat(tmp, "/");
				strcat(tmp, current->d_name);*/

				compileFile(config, filename, tmp);

				free(tmp);
				free(filename);
			}
	}
	closedir(rep);
}
Exemplo n.º 11
0
bool CppCompiler::compile()
{
    if (abortChecker && abortChecker->abortRequested())
        return false;

    TIME_SECTION(!verbose ? NULL : onlyCompile ? "compile" : "compile/link");

    Owned<IThreadPool> pool = createThreadPool("CCompilerWorker", this, NULL, maxCompileThreads?maxCompileThreads:1, INFINITE);
    addCompileOption(COMPILE_ONLY[targetCompiler]);

    bool ret = false;
    Semaphore finishedCompiling;
    int numSubmitted = 0;
    numFailed.store(0);

    ForEachItemIn(i0, allSources)
    {
        ret = compileFile(pool, allSources.item(i0), finishedCompiling);
        if (!ret)
            break;
        ++numSubmitted;
    }
Exemplo n.º 12
0
int main(int argc, char **argv)
{
   excmd::parser parser;
   excmd::option_state options;

   // Setup command line options
   parser.global_options()
      .add_option("h,help", excmd::description { "Show the help." })
      .add_option("vsh",
                  excmd::description { "Vertex shader to compile to gsh." },
                  excmd::value<std::string> {})
      .add_option("psh",
                  excmd::description { "Pixel shader to compile to gsh." },
                  excmd::value<std::string> {});

   parser.add_command("help")
      .add_argument("command", excmd::value<std::string> { });

   parser.add_command("compile")
      .add_argument("gsh", excmd::value<std::string> { });

   // Parse command line
   try {
      options = parser.parse(argc, argv);
   } catch (excmd::exception ex) {
      std::cout << "Error parsing command line: " << ex.what() << std::endl;
      return -1;
   }

   // Print help
   if (argc == 1 || options.has("help")) {
      if (options.has("command")) {
         std::cout << parser.format_help("gfdtool", options.get<std::string>("command")) << std::endl;
      } else {
         std::cout << parser.format_help("gfdtool") << std::endl;
      }

      return 0;
   }

   Shader shader;

   try {
      if (options.has("compile")) {
         auto dst = options.get<std::string>("gsh");
         gfd::GFDFile gfd;

         if (options.has("vsh")) {
            auto src = options.get<std::string>("vsh");
            Shader shader;
            shader.path = src;
            shader.type = ShaderType::VertexShader;

            if (!compileFile(shader, src)) {
               return -1;
            }

            if (!gfdAddVertexShader(gfd, shader)) {
               return -1;
            }
         }

         if (options.has("psh")) {
            auto src = options.get<std::string>("psh");
            Shader shader;
            shader.path = src;
            shader.type = ShaderType::PixelShader;

            if (!compileFile(shader, src)) {
               return -1;
            }

            if (!gfdAddPixelShader(gfd, shader)) {
               return -1;
            }
         }

         if (!gfd::writeFile(gfd, dst)) {
            return -1;
         }
      } else {
         return -1;
      }
   } catch (parse_exception e) {
      std::cout << "Parse exception: " << e.what() << std::endl;
      return -1;
   } catch (gfd_header_parse_exception e) {
      std::cout << "GFD header parse exception: " << e.what() << std::endl;
      return -1;
   }

   return 0;
}
Exemplo n.º 13
0
void FSM::VM<X>::init(const std::string &conf, const std::string &luaFile)
{
  readConfFile(conf, luaFile);
  compileFile(luaFile);
}
Exemplo n.º 14
0
inline bool z::Compiler::parseFile(z::Ast::Module& module, const z::string& msg) {
    return compileFile(module, module.filename(), msg);
}