Esempio n. 1
0
/**
 * Genera posiciones para las estrellas de forma aleatoria
 */
void genEstrellas(){
	int cercania = 3;
	estrellas = new rgbint*[ALTO];
	for (int i=0; i<ALTO; i++){
		estrellas[i] = new rgbint[ANCHO];
		for (int j=0; j<ANCHO; j++){
			for (int k=i-cercania; k<i; k++){
				int v = rand()%3000 < 5;
				if (v){
					estrellas[i][j].r = 100+ 25*v;
					estrellas[i][j].g = 100+ 25*v;
					estrellas[i][j].b = 100+ 25*v;
				}else{
					estrellas[i][j].r = 0;
					estrellas[i][j].g = 0;
					estrellas[i][j].b = 0;
				}
			}
		}
	}
	writePPMint("../../estrellas.ppm", estrellas, ALTO);
	dataestrellas = genTextInt(estrellas, 255, ALTO);
	glBindTexture(GL_TEXTURE_2D, texNames[ESTRELLAS]);
	genText(dataestrellas, true, ALTO);
}
Esempio n. 2
0
/*
 * This is the entry point for offline bytecode generation.
 */
void emitAllHHBC(AnalysisResultPtr&& ar) {
  auto ues = ar->getHhasFiles();
  decltype(ues) ues_to_print;
  auto const outputPath = ar->getOutputPath();

  std::thread wp_thread, dispatcherThread;
  auto unexpectedException = [&] (const char* what) {
    if (dispatcherThread.joinable()) {
      Logger::Error("emitAllHHBC exited via an exception "
                    "before dispatcherThread was joined: %s", what);
    }
    if (wp_thread.joinable()) {
      Logger::Error("emitAllHHBC exited via an exception "
                    "before wp_thread was joined: %s", what);
    }
    throw;
  };

  try {
    {
      SCOPE_EXIT {
        genText(ues_to_print, outputPath);
      };

      auto commitSome = [&] (decltype(ues)& emitters) {
        batchCommit(emitters);
        if (Option::GenerateTextHHBC || Option::GenerateHhasHHBC) {
          std::move(emitters.begin(), emitters.end(),
                    std::back_inserter(ues_to_print));
        }
        emitters.clear();
      };

      if (!RuntimeOption::EvalUseHHBBC && ues.size()) {
        commitSome(ues);
      }

      auto commitLoop = [&] {
        folly::Optional<Timer> commitTime;
        // kBatchSize needs to strike a balance between reducing
        // transaction commit overhead (bigger batches are better), and
        // limiting the cost incurred by failed commits due to identical
        // units that require rollback and retry (smaller batches have
        // less to lose).  Empirical results indicate that a value in
        // the 2-10 range is reasonable.
        static const unsigned kBatchSize = 8;

        while (auto ue = s_ueq.pop()) {
          if (!commitTime) {
            commitTime.emplace(Timer::WallTime, "committing units to repo");
          }
          ues.push_back(std::move(ue));
          if (ues.size() == kBatchSize) {
            commitSome(ues);
          }
        }
        if (ues.size()) commitSome(ues);
      };

      LitstrTable::get().setReading();
      ar->finish();
      ar.reset();

      if (!RuntimeOption::EvalUseHHBBC) {
        if (Option::GenerateBinaryHHBC) {
          commitGlobalData(std::unique_ptr<ArrayTypeTable::Builder>{});
        }
        return;
      }

      RuntimeOption::EvalJit = false; // For HHBBC to invoke builtins.
      std::unique_ptr<ArrayTypeTable::Builder> arrTable;
      wp_thread = std::thread([&] {
          Timer timer(Timer::WallTime, "running HHBBC");
          hphp_thread_init();
          hphp_session_init(Treadmill::SessionKind::CompilerEmit);
          SCOPE_EXIT {
            hphp_context_exit();
            hphp_session_exit();
            hphp_thread_exit();
          };

          HHBBC::whole_program(
            std::move(ues), s_ueq, arrTable,
            Option::ParserThreadCount > 0 ? Option::ParserThreadCount : 0);
        });

      commitLoop();
      commitGlobalData(std::move(arrTable));
    }
    wp_thread.join();
  } catch (std::exception& ex) {
Esempio n. 3
0
/**
 * Lee y genera las texturas utilizadas
 */
void genTexturas() {
	paleta = loadPalInt("paletas/landcolor3.ppm", 256);
	paletaf = intPal2Float(paleta, 256);
	paleta_agua = loadPalInt("paletas/watercolor7.ppm", 256);
	paleta_aguaf = intPal2Float(paleta_agua, 256);
	paleta_grass = loadPalInt("paletas/grasscolor2.ppm", 256);
	paleta_grassf = intPal2Float(paleta_grass, 256);
	tree = readPPM("paletas/tree.ppm");
	snowtree = readPPM("paletas/treesnow.ppm");
	treealpha = readPGM("paletas/treealpha.pgm");
	datatree = genTextIntAlpha(tree, treealpha, 256);
	datasnowtree = genTextIntAlpha(snowtree, treealpha, 256);
	paletanubes = loadPalInt("paletas/skyalpha.ppm", 256);
	nubesalpha = skyalpha3D(paletanubes, FRAMES_NUBES, int((nubosidad)*128.0), 256);
	nubes = new rgbint*[256]; // nubes blancas
	for (int i=0; i<256; i++){
		nubes[i] = new rgbint[256];
		for (int j=0; j<256; j++){
			nubes[i][j].r = 255;
			nubes[i][j].g = 255;
			nubes[i][j].b = 255;		
		}
	}
	datanubes = new int*[FRAMES_NUBES];
	for (int i=0; i<FRAMES_NUBES; i++){
		datanubes[i] = genTextIntAlpha(nubes,nubesalpha[i],256);
	}
	//writePGMint("../../nubes3D.pgm", nubesalpha[0], 256);
	
	// Genera los nombres de textura 
	glGenTextures(15, texNames);
	glBindTexture(GL_TEXTURE_2D, texNames[ARBOL]);
	genText(datatree, false, 256);
	
	glBindTexture(GL_TEXTURE_2D, texNames[ARBOLNIEVE]);
	genText(datasnowtree,false, 256);	
	
	for (int i=0; i<FRAMES_NUBES; i++){
		glBindTexture(GL_TEXTURE_2D, texNames[NUBES+i]);
		genText(datanubes[i], true, 256);		
	}
	
	brujula = new rgbint*[128]; // brujula negra
	for (int i=0; i<128; i++){
		brujula[i] = new rgbint[128];
		for (int j=0; j<128; j++){
			brujula[i][j].r = 0;
			brujula[i][j].g = 0;
			brujula[i][j].b = 0;		
		}
	}
	brujulaalpha = readPGM("paletas/brujulaalpha.pgm");
	databrujula = genTextIntAlpha(brujula, brujulaalpha, 128);
	aguja = readPPM("paletas/aguja.ppm");
	agujaalpha = readPGM("paletas/agujaalpha.pgm");
	dataaguja = genTextIntAlpha(aguja, agujaalpha, 128);
	
	glBindTexture(GL_TEXTURE_2D, texNames[BRUJULA]);
	genText(databrujula,false, 128);	
	
	glBindTexture(GL_TEXTURE_2D, texNames[AGUJA]);
	genText(dataaguja,false, 128);	
	
}